MagickCore 7.0.10
sha2256.c
Go to the documentation of this file.
1/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% SSSSS H H AAA %
6% SS H H A A %
7% SSS HHHHH AAAAA %
8% SS H H A A %
9% SSSSS H H A A %
10% %
11% %
12% Wizard's Toolkit Secure Hash Algorithm 2-256 Methods %
13% %
14% Software Design %
15% Cristy %
16% March 2003 %
17% %
18% %
19% Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization %
20% dedicated to making software imaging solutions freely available. %
21% %
22% You may not use this file except in compliance with the License. You may %
23% obtain a copy of the License at %
24% %
25% https://imagemagick.org/script/license.php %
26% %
27% Unless required by applicable law or agreed to in writing, software %
28% distributed under the License is distributed on an "AS IS" BASIS, %
29% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
30% See the License for the specific language governing permissions and %
31% limitations under the License. %
32% %
33%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34%
35% See http://csrc.nist.gov/groups/ST/toolkit/index.html.
36%
37*/
38
39/*
40 Include declarations.
41*/
42#include "wizard/studio.h"
43#include "wizard/exception.h"
45#include "wizard/memory_.h"
46#include "wizard/sha2256.h"
47/*
48 Define declarations.
49*/
50#define SHA2256Blocksize 64
51#define SHA2256Digestsize 32
52
53/*
54 Typedef declarations.
55*/
57{
58 unsigned int
61
65
66 unsigned int
70
71 size_t
73
76
77 time_t
79
80 size_t
82};
83
84/*
85 Forward declarations.
86*/
87static void
89
90/*
91%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92% %
93% %
94% %
95% A c q u i r e S H A I n f o %
96% %
97% %
98% %
99%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100%
101% AcquireSHA2256Info() allocate the SHA2256Info structure.
102%
103% The format of the AcquireSHA2256Info method is:
104%
105% SHA2256Info *AcquireSHA2256Info(void)
106%
107*/
109{
111 *sha_info;
112
113 unsigned int
114 lsb_first;
115
116 sha_info=(SHA2256Info *) AcquireWizardMemory(sizeof(*sha_info));
117 if (sha_info == (SHA2256Info *) NULL)
119 (void) memset(sha_info,0,sizeof(*sha_info));
121 sha_info->blocksize=SHA2256Blocksize;
124 sha_info->accumulator=(unsigned int *) AcquireQuantumMemory(SHA2256Blocksize,
125 sizeof(*sha_info->accumulator));
126 if (sha_info->accumulator == (unsigned int *) NULL)
128 lsb_first=1;
129 sha_info->lsb_first=(int) (*(char *) &lsb_first) == 1 ? WizardTrue :
131 sha_info->timestamp=time((time_t *) NULL);
132 sha_info->signature=WizardSignature;
133 (void) InitializeSHA2256(sha_info);
134 return(sha_info);
135}
136
137/*
138%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
139% %
140% %
141% %
142% D e s t r o y S H A I n f o %
143% %
144% %
145% %
146%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147%
148% DestroySHA2256Info() zeros memory associated with the SHA2256Info structure.
149%
150% The format of the DestroySHA2256Info method is:
151%
152% SHA2256Info *DestroySHA2256Info(SHA2256Info *sha_info)
153%
154% A description of each parameter follows:
155%
156% o sha_info: The cipher sha_info.
157%
158*/
160{
162 assert(sha_info != (SHA2256Info *) NULL);
163 assert(sha_info->signature == WizardSignature);
164 if (sha_info->accumulator != (unsigned int *) NULL)
165 sha_info->accumulator=(unsigned int *) RelinquishWizardMemory(
166 sha_info->accumulator);
167 if (sha_info->message != (StringInfo *) NULL)
168 sha_info->message=DestroyStringInfo(sha_info->message);
169 if (sha_info->digest != (StringInfo *) NULL)
170 sha_info->digest=DestroyStringInfo(sha_info->digest);
171 sha_info->signature=(~WizardSignature);
172 sha_info=(SHA2256Info *) RelinquishWizardMemory(sha_info);
173 return(sha_info);
174}
175
176/*
177%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
178% %
179% %
180% %
181% F i n a l i z e S H A %
182% %
183% %
184% %
185%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
186%
187% FinalizeSHA2256() finalizes the SHA2256 message accumulator computation.
188%
189% The format of the FinalizeSHA2256 method is:
190%
191% WizardBooleanType FinalizeSHA2256(SHA2256Info *sha_info)
192%
193% A description of each parameter follows:
194%
195% o sha_info: The address of a structure of type SHA2256Info.
196%
197*/
199{
200 ssize_t
201 i;
202
203 unsigned char
204 *q;
205
206 unsigned int
207 *p;
208
209 ssize_t
210 count;
211
212 unsigned char
213 *datum;
214
215 unsigned int
216 high_order,
217 low_order;
218
219 /*
220 Add padding and return the message accumulator.
221 */
223 assert(sha_info != (SHA2256Info *) NULL);
224 assert(sha_info->signature == WizardSignature);
225 low_order=sha_info->low_order;
226 high_order=sha_info->high_order;
227 count=(ssize_t) ((low_order >> 3) & 0x3f);
228 datum=GetStringInfoDatum(sha_info->message);
229 datum[count++]=(unsigned char) 0x80;
230 if (count <= (ssize_t) (GetStringInfoLength(sha_info->message)-8))
231 (void) memset(datum+count,0,GetStringInfoLength(
232 sha_info->message)-8-count);
233 else
234 {
235 (void) memset(datum+count,0,GetStringInfoLength(
236 sha_info->message)-count);
237 TransformSHA2256(sha_info);
238 (void) memset(datum,0,GetStringInfoLength(sha_info->message)-
239 8);
240 }
241 datum[56]=(unsigned char) (high_order >> 24);
242 datum[57]=(unsigned char) (high_order >> 16);
243 datum[58]=(unsigned char) (high_order >> 8);
244 datum[59]=(unsigned char) high_order;
245 datum[60]=(unsigned char) (low_order >> 24);
246 datum[61]=(unsigned char) (low_order >> 16);
247 datum[62]=(unsigned char) (low_order >> 8);
248 datum[63]=(unsigned char) low_order;
249 TransformSHA2256(sha_info);
250 p=sha_info->accumulator;
251 q=GetStringInfoDatum(sha_info->digest);
252 for (i=0; i < (SHA2256Digestsize/4); i++)
253 {
254 *q++=(unsigned char) ((*p >> 24) & 0xff);
255 *q++=(unsigned char) ((*p >> 16) & 0xff);
256 *q++=(unsigned char) ((*p >> 8) & 0xff);
257 *q++=(unsigned char) (*p & 0xff);
258 p++;
259 }
260 /*
261 Reset working registers.
262 */
263 count=0;
264 high_order=0;
265 low_order=0;
266 return(WizardTrue);
267}
268
269/*
270%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271% %
272% %
273% %
274% G e t S H A 2 5 6 B l o c k s i z e %
275% %
276% %
277% %
278%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
279%
280% GetSHA2256Blocksize() returns the SHA2256 blocksize.
281%
282% The format of the GetSHA2256Blocksize method is:
283%
284% unsigned int *GetSHA2256Blocksize(const SHA2256Info *sha2256_info)
285%
286% A description of each parameter follows:
287%
288% o sha2256_info: The sha2256 info.
289%
290*/
291WizardExport unsigned int GetSHA2256Blocksize(const SHA2256Info *sha2256_info)
292{
294 WizardAssert(CipherDomain,sha2256_info != (SHA2256Info *) NULL);
296 return(sha2256_info->blocksize);
297}
298
299/*
300%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301% %
302% %
303% %
304% G e t S H A 2 5 6 D i g e s t %
305% %
306% %
307% %
308%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309%
310% GetSHA2256Digest() returns the SHA2256 digest.
311%
312% The format of the GetSHA2256Digest method is:
313%
314% const StringInfo *GetSHA2256Digest(const SHA2256Info *sha2256_info)
315%
316% A description of each parameter follows:
317%
318% o sha2256_info: The sha2256 info.
319%
320*/
322{
324 WizardAssert(HashDomain,sha2256_info != (SHA2256Info *) NULL);
326 return(sha2256_info->digest);
327}
328
329/*
330%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
331% %
332% %
333% %
334% G e t S H A 2 5 6 D i g e s t s i z e %
335% %
336% %
337% %
338%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
339%
340% GetSHA2256Digestsize() returns the SHA2256 digest size.
341%
342% The format of the GetSHA2256Digestsize method is:
343%
344% unsigned int *GetSHA2256Digestsize(const SHA2256Info *sha2256_info)
345%
346% A description of each parameter follows:
347%
348% o sha2256_info: The sha2256 info.
349%
350*/
351WizardExport unsigned int GetSHA2256Digestsize(const SHA2256Info *sha2256_info)
352{
354 WizardAssert(CipherDomain,sha2256_info != (SHA2256Info *) NULL);
356 return(sha2256_info->digestsize);
357}
358
359/*
360%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
361% %
362% %
363% %
364% I n i t i a l i z e S H A %
365% %
366% %
367% %
368%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
369%
370% IntializeSHA2256() intializes the SHA2256 accumulator.
371%
372% The format of the DestroySHA2256Info method is:
373%
374% WizardBooleanType InitializeSHA2256Info(SHA2256Info *sha_info)
375%
376% A description of each parameter follows:
377%
378% o sha_info: The cipher sha_info.
379%
380*/
382{
384 assert(sha_info != (SHA2256Info *) NULL);
385 assert(sha_info->signature == WizardSignature);
386 sha_info->accumulator[0]=0x6a09e667U;
387 sha_info->accumulator[1]=0xbb67ae85U;
388 sha_info->accumulator[2]=0x3c6ef372U;
389 sha_info->accumulator[3]=0xa54ff53aU;
390 sha_info->accumulator[4]=0x510e527fU;
391 sha_info->accumulator[5]=0x9b05688cU;
392 sha_info->accumulator[6]=0x1f83d9abU;
393 sha_info->accumulator[7]=0x5be0cd19U;
394 sha_info->low_order=0;
395 sha_info->high_order=0;
396 sha_info->offset=0;
397 return(WizardTrue);
398}
399
400/*
401%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
402% %
403% %
404% %
405% T r a n s f o r m S H A %
406% %
407% %
408% %
409%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
410%
411% TransformSHA2256() transforms the SHA2256 message accumulator.
412%
413% The format of the TransformSHA2256 method is:
414%
415% TransformSHA2256(SHA2256Info *sha_info)
416%
417% A description of each parameter follows:
418%
419% o sha_info: The address of a structure of type SHA2256Info.
420%
421*/
422
423static inline unsigned int Ch(const unsigned int x,const unsigned int y,
424 const unsigned int z)
425{
426 return((x & y) ^ (~x & z));
427}
428
429static inline unsigned int Maj(const unsigned int x,const unsigned int y,
430 const unsigned int z)
431{
432 return((x & y) ^ (x & z) ^ (y & z));
433}
434
435static inline unsigned int Trunc32(const unsigned int x)
436{
437 return((unsigned int) (x & 0xffffffffU));
438}
439
440static unsigned int RotateRight(const unsigned int x,const unsigned int n)
441{
442 return(Trunc32((x >> n) | (x << (32-n))));
443}
444
445static void TransformSHA2256(SHA2256Info *sha_info)
446{
447#define Sigma0(x) (RotateRight(x,7) ^ RotateRight(x,18) ^ Trunc32((x) >> 3))
448#define Sigma1(x) (RotateRight(x,17) ^ RotateRight(x,19) ^ Trunc32((x) >> 10))
449#define Suma0(x) (RotateRight(x,2) ^ RotateRight(x,13) ^ RotateRight(x,22))
450#define Suma1(x) (RotateRight(x,6) ^ RotateRight(x,11) ^ RotateRight(x,25))
451
452 ssize_t
453 j;
454
455 ssize_t
456 i;
457
458 unsigned char
459 *p;
460
461 static unsigned int
462 K[64] =
463 {
464 0x428a2f98U, 0x71374491U, 0xb5c0fbcfU, 0xe9b5dba5U, 0x3956c25bU,
465 0x59f111f1U, 0x923f82a4U, 0xab1c5ed5U, 0xd807aa98U, 0x12835b01U,
466 0x243185beU, 0x550c7dc3U, 0x72be5d74U, 0x80deb1feU, 0x9bdc06a7U,
467 0xc19bf174U, 0xe49b69c1U, 0xefbe4786U, 0x0fc19dc6U, 0x240ca1ccU,
468 0x2de92c6fU, 0x4a7484aaU, 0x5cb0a9dcU, 0x76f988daU, 0x983e5152U,
469 0xa831c66dU, 0xb00327c8U, 0xbf597fc7U, 0xc6e00bf3U, 0xd5a79147U,
470 0x06ca6351U, 0x14292967U, 0x27b70a85U, 0x2e1b2138U, 0x4d2c6dfcU,
471 0x53380d13U, 0x650a7354U, 0x766a0abbU, 0x81c2c92eU, 0x92722c85U,
472 0xa2bfe8a1U, 0xa81a664bU, 0xc24b8b70U, 0xc76c51a3U, 0xd192e819U,
473 0xd6990624U, 0xf40e3585U, 0x106aa070U, 0x19a4c116U, 0x1e376c08U,
474 0x2748774cU, 0x34b0bcb5U, 0x391c0cb3U, 0x4ed8aa4aU, 0x5b9cca4fU,
475 0x682e6ff3U, 0x748f82eeU, 0x78a5636fU, 0x84c87814U, 0x8cc70208U,
476 0x90befffaU, 0xa4506cebU, 0xbef9a3f7U, 0xc67178f2U
477 }; /* 32-bit fractional part of the cube root of the first 64 primes */
478
479 unsigned int
480 A,
481 B,
482 C,
483 D,
484 E,
485 F,
486 G,
487 H,
488 shift,
489 T,
490 T1,
491 T2,
492 W[64];
493
494 shift=32;
495 p=GetStringInfoDatum(sha_info->message);
496 if (sha_info->lsb_first == WizardFalse)
497 {
498 if (sizeof(unsigned int) <= 4)
499 for (i=0; i < 16; i++)
500 {
501 T=(*((unsigned int *) p));
502 p+=4;
503 W[i]=Trunc32(T);
504 }
505 else
506 for (i=0; i < 16; i+=2)
507 {
508 T=(*((unsigned int *) p));
509 p+=8;
510 W[i]=Trunc32(T >> shift);
511 W[i+1]=Trunc32(T);
512 }
513 }
514 else
515 if (sizeof(unsigned int) <= 4)
516 for (i=0; i < 16; i++)
517 {
518 T=(*((unsigned int *) p));
519 p+=4;
520 W[i]=((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) |
521 ((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff);
522 }
523 else
524 for (i=0; i < 16; i+=2)
525 {
526 T=(*((unsigned int *) p));
527 p+=8;
528 W[i]=((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) |
529 ((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff);
530 T>>=shift;
531 W[i+1]=((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) |
532 ((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff);
533 }
534 /*
535 Copy accumulator to registers.
536 */
537 A=sha_info->accumulator[0];
538 B=sha_info->accumulator[1];
539 C=sha_info->accumulator[2];
540 D=sha_info->accumulator[3];
541 E=sha_info->accumulator[4];
542 F=sha_info->accumulator[5];
543 G=sha_info->accumulator[6];
544 H=sha_info->accumulator[7];
545 for (i=16; i < 64; i++)
546 W[i]=Trunc32(Sigma1(W[i-2])+W[i-7]+Sigma0(W[i-15])+W[i-16]);
547 for (j=0; j < 64; j++)
548 {
549 T1=Trunc32(H+Suma1(E)+Ch(E,F,G)+K[j]+W[j]);
550 T2=Trunc32(Suma0(A)+Maj(A,B,C));
551 H=G;
552 G=F;
553 F=E;
554 E=Trunc32(D+T1);
555 D=C;
556 C=B;
557 B=A;
558 A=Trunc32(T1+T2);
559 }
560 /*
561 Add registers back to accumulator.
562 */
563 sha_info->accumulator[0]=Trunc32(sha_info->accumulator[0]+A);
564 sha_info->accumulator[1]=Trunc32(sha_info->accumulator[1]+B);
565 sha_info->accumulator[2]=Trunc32(sha_info->accumulator[2]+C);
566 sha_info->accumulator[3]=Trunc32(sha_info->accumulator[3]+D);
567 sha_info->accumulator[4]=Trunc32(sha_info->accumulator[4]+E);
568 sha_info->accumulator[5]=Trunc32(sha_info->accumulator[5]+F);
569 sha_info->accumulator[6]=Trunc32(sha_info->accumulator[6]+G);
570 sha_info->accumulator[7]=Trunc32(sha_info->accumulator[7]+H);
571 /*
572 Reset working registers.
573 */
574 A=0;
575 B=0;
576 C=0;
577 D=0;
578 E=0;
579 F=0;
580 G=0;
581 H=0;
582 T=0;
583 T1=0;
584 T2=0;
585 (void) memset(W,0,sizeof(W));
586}
587
588/*
589%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
590% %
591% %
592% %
593% U p d a t e S H A %
594% %
595% %
596% %
597%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598%
599% UpdateSHA2256() updates the SHA2256 message accumulator.
600%
601% The format of the UpdateSHA2256 method is:
602%
603% WizardBooleanType UpdateSHA2256(SHA2256Info *sha_info,
604% const StringInfo *message)
605%
606% A description of each parameter follows:
607%
608% o sha_info: The address of a structure of type SHA2256Info.
609%
610% o message: The message.
611%
612*/
614 const StringInfo *message)
615{
616 size_t
617 i;
618
619 unsigned char
620 *p;
621
622 size_t
623 n;
624
625 unsigned int
626 length;
627
628 /*
629 Update the SHA2256 accumulator.
630 */
631 assert(sha_info != (SHA2256Info *) NULL);
632 assert(sha_info->signature == WizardSignature);
633 n=GetStringInfoLength(message);
634 length=Trunc32((unsigned int) (sha_info->low_order+(n << 3)));
635 if (length < sha_info->low_order)
636 sha_info->high_order++;
637 sha_info->low_order=length;
638 sha_info->high_order+=(unsigned int) n >> 29;
639 p=GetStringInfoDatum(message);
640 if (sha_info->offset != 0)
641 {
642 i=GetStringInfoLength(sha_info->message)-sha_info->offset;
643 if (i > n)
644 i=n;
646 sha_info->offset,p,i);
647 n-=i;
648 p+=i;
649 sha_info->offset+=i;
650 if (sha_info->offset != GetStringInfoLength(sha_info->message))
651 return(WizardTrue);
652 TransformSHA2256(sha_info);
653 }
654 while (n >= GetStringInfoLength(sha_info->message))
655 {
656 SetStringInfoDatum(sha_info->message,p);
657 p+=GetStringInfoLength(sha_info->message);
658 n-=GetStringInfoLength(sha_info->message);
659 TransformSHA2256(sha_info);
660 }
661 (void) CopyWizardMemory(GetStringInfoDatum(sha_info->message),p,n);
662 sha_info->offset=n;
663 /*
664 Reset working registers.
665 */
666 i=0;
667 n=0;
668 length=0;
669 return(WizardTrue);
670}
#define WizardAssert(domain, predicate)
#define ThrowWizardFatalError(domain, error)
@ HashDomain
Definition exception.h:30
@ CipherDomain
Definition exception.h:34
@ HashError
Definition exception.h:85
@ MemoryError
Definition exception.h:49
WizardBooleanType LogWizardEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition log.c:1390
@ TraceEvent
Definition log.h:39
#define GetWizardModule()
Definition log.h:30
static unsigned int H(const unsigned int x, const unsigned int y, const unsigned int z)
Definition md5.c:424
static unsigned int F(const unsigned int x, const unsigned int y, const unsigned int z)
Definition md5.c:412
static unsigned int G(const unsigned int x, const unsigned int y, const unsigned int z)
Definition md5.c:418
WizardExport void * AcquireWizardMemory(const size_t size)
Definition memory.c:586
WizardExport void * CopyWizardMemory(void *destination, const void *source, const size_t size)
Definition memory.c:700
WizardExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition memory.c:657
WizardExport void * RelinquishWizardMemory(void *memory)
Definition memory.c:1039
#define WizardExport
#define WizardSignature
WizardExport SHA2256Info * DestroySHA2256Info(SHA2256Info *sha_info)
Definition sha2256.c:159
WizardExport unsigned int GetSHA2256Blocksize(const SHA2256Info *sha2256_info)
Definition sha2256.c:291
WizardExport WizardBooleanType InitializeSHA2256(SHA2256Info *sha_info)
Definition sha2256.c:381
#define Suma1(x)
WizardExport const StringInfo * GetSHA2256Digest(const SHA2256Info *sha2256_info)
Definition sha2256.c:321
#define Sigma0(x)
#define Sigma1(x)
WizardExport WizardBooleanType UpdateSHA2256(SHA2256Info *sha_info, const StringInfo *message)
Definition sha2256.c:613
#define SHA2256Digestsize
Definition sha2256.c:51
#define Suma0(x)
WizardExport SHA2256Info * AcquireSHA2256Info(void)
Definition sha2256.c:108
WizardExport unsigned int GetSHA2256Digestsize(const SHA2256Info *sha2256_info)
Definition sha2256.c:351
#define SHA2256Blocksize
Definition sha2256.c:50
WizardExport WizardBooleanType FinalizeSHA2256(SHA2256Info *sha_info)
Definition sha2256.c:198
static void TransformSHA2256(SHA2256Info *)
Definition sha2256.c:445
#define Trunc32(x)
Definition signature.c:52
#define RotateRight(x, n)
#define Maj(x, y, z)
#define Ch(x, y, z)
WizardExport size_t GetStringInfoLength(const StringInfo *string_info)
Definition string.c:1280
WizardExport StringInfo * AcquireStringInfo(const size_t length)
Definition string.c:179
WizardExport void SetStringInfoDatum(StringInfo *string_info, const unsigned char *source)
Definition string.c:1832
WizardExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
Definition string.c:1251
WizardExport StringInfo * DestroyStringInfo(StringInfo *string_info)
Definition string.c:857
unsigned int blocksize
Definition sha2256.c:60
size_t signature
Definition sha2256.c:81
StringInfo * digest
Definition sha2256.c:63
unsigned int high_order
Definition sha2256.c:69
unsigned int digestsize
Definition sha2256.c:59
StringInfo * message
Definition sha2256.c:64
unsigned int low_order
Definition sha2256.c:68
time_t timestamp
Definition sha2256.c:78
unsigned int * accumulator
Definition sha2256.c:67
WizardBooleanType lsb_first
Definition sha2256.c:75
size_t offset
Definition sha2256.c:72
WizardBooleanType
Definition wizard-type.h:26
@ WizardTrue
Definition wizard-type.h:28
@ WizardFalse
Definition wizard-type.h:27