MagickCore 7.0.10
hash.c
Go to the documentation of this file.
1/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% H H AAA SSSSS H H %
6% H H A A SS H H %
7% HHHHH AAAAA SSS HHHHH %
8% H H A A SS H H %
9% H H A A SSSSS H H %
10% %
11% %
12% Wizard's Toolkit Secure Hash Algorithm 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/crc64.h"
44#include "wizard/exception.h"
46#include "wizard/hash.h"
47#include "wizard/memory_.h"
48#include "wizard/md5.h"
49#include "wizard/sha1.h"
50#include "wizard/sha2224.h"
51#include "wizard/sha2256.h"
52#include "wizard/sha2384.h"
53#include "wizard/sha2512.h"
54#include "wizard/sha3.h"
55
56/*
57 Typedef declarations.
58*/
60{
63
66
67 void
69
70 time_t
72
73 size_t
75};
76
77/*
78%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79% %
80% %
81% %
82% A c q u i r e H a s h I n f o %
83% %
84% %
85% %
86%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
87%
88% AcquireHashInfo() allocates the HashInfo structure.
89%
90% The format of the AcquireHashInfo method is:
91%
92% HashInfo *AcquireHashInfo(const HashType hash)
93%
94% A description of each parameter follows:
95%
96% o hash: The hash type.
97%
98*/
100{
102 *hash_info;
103
104 size_t
105 digestsize;
106
107 hash_info=(HashInfo *) AcquireWizardMemory(sizeof(*hash_info));
108 if (hash_info == (HashInfo *) NULL)
110 (void) memset(hash_info,0,sizeof(*hash_info));
111 hash_info->hash=hash;
112 switch (hash_info->hash)
113 {
114 case CRC64Hash:
115 {
117 *crc_info;
118
119 crc_info=AcquireCRC64Info();
120 hash_info->handle=(HashInfo *) crc_info;
121 digestsize=GetCRC64Digestsize(crc_info);
122 break;
123 }
124 case MD5Hash:
125 {
126 MD5Info
127 *md5_info;
128
129 md5_info=AcquireMD5Info();
130 hash_info->handle=(HashInfo *) md5_info;
131 digestsize=GetMD5Digestsize(md5_info);
132 break;
133 }
134 case SHA1Hash:
135 {
137 *sha_info;
138
139 sha_info=AcquireSHA1Info();
140 hash_info->handle=(HashInfo *) sha_info;
141 digestsize=GetSHA1Digestsize(sha_info);
142 break;
143 }
144 case SHA2224Hash:
145 {
147 *sha_info;
148
149 sha_info=AcquireSHA2224Info();
150 hash_info->handle=(HashInfo *) sha_info;
151 digestsize=GetSHA2224Digestsize(sha_info);
152 break;
153 }
154 case SHA2256Hash:
155 case SHA2Hash:
156 {
158 *sha_info;
159
160 sha_info=AcquireSHA2256Info();
161 hash_info->handle=(HashInfo *) sha_info;
162 digestsize=GetSHA2256Digestsize(sha_info);
163 break;
164 }
165 case SHA2384Hash:
166 {
168 *sha_info;
169
170 sha_info=AcquireSHA2384Info();
171 hash_info->handle=(HashInfo *) sha_info;
172 digestsize=GetSHA2384Digestsize(sha_info);
173 break;
174 }
175 case SHA2512Hash:
176 {
178 *sha_info;
179
180 sha_info=AcquireSHA2512Info();
181 hash_info->handle=(HashInfo *) sha_info;
182 digestsize=GetSHA2512Digestsize(sha_info);
183 break;
184 }
185 case SHA3Hash:
186 case SHA3224Hash:
187 case SHA3256Hash:
188 case SHA3384Hash:
189 case SHA3512Hash:
190 {
192 *sha_info;
193
194 sha_info=AcquireSHA3Info(hash);
195 hash_info->handle=(HashInfo *) sha_info;
196 digestsize=GetSHA3Digestsize(sha_info);
197 break;
198 }
199 default:
201 }
202 hash_info->digest=AcquireStringInfo((size_t) digestsize);
203 ResetStringInfo(hash_info->digest);
204 hash_info->timestamp=time((time_t *) NULL);
205 hash_info->signature=WizardSignature;
206 return(hash_info);
207}
208
209/*
210%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
211% %
212% %
213% %
214% D e s t r o y H a s h I n f o %
215% %
216% %
217% %
218%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
219%
220% DestroyHashInfo() zeros memory associated with the HashInfo structure.
221%
222% The format of the DestroyHashInfo method is:
223%
224% HashInfo *DestroyHashInfo(HashInfo *hash_info)
225%
226% A description of each parameter follows:
227%
228% o hash_info: The hash info.
229%
230*/
232{
234 assert(hash_info != (HashInfo *) NULL);
235 assert(hash_info->signature == WizardSignature);
236 if (hash_info->handle != (HashInfo *) NULL)
237 switch (hash_info->hash)
238 {
239 case CRC64Hash:
240 {
241 hash_info->handle=(void *) DestroyCRC64Info((CRC64Info *)
242 hash_info->handle);
243 break;
244 }
245 case MD5Hash:
246 {
247 hash_info->handle=(void *) DestroyMD5Info((MD5Info *)
248 hash_info->handle);
249 break;
250 }
251 case SHA1Hash:
252 {
253 hash_info->handle=(void *) DestroySHA1Info((SHA1Info *)
254 hash_info->handle);
255 break;
256 }
257 case SHA2224Hash:
258 {
259 hash_info->handle=(void *) DestroySHA2224Info((SHA2224Info *)
260 hash_info->handle);
261 break;
262 }
263 case SHA2256Hash:
264 case SHA2Hash:
265 {
266 hash_info->handle=(void *) DestroySHA2256Info((SHA2256Info *)
267 hash_info->handle);
268 break;
269 }
270 case SHA2384Hash:
271 {
272 hash_info->handle=(void *) DestroySHA2384Info((SHA2384Info *)
273 hash_info->handle);
274 break;
275 }
276 case SHA2512Hash:
277 {
278 hash_info->handle=(void *) DestroySHA2512Info((SHA2512Info *)
279 hash_info->handle);
280 break;
281 }
282 case SHA3Hash:
283 case SHA3224Hash:
284 case SHA3256Hash:
285 case SHA3384Hash:
286 case SHA3512Hash:
287 {
288 hash_info->handle=(void *) DestroySHA3Info((SHA3Info *)
289 hash_info->handle);
290 break;
291 }
292 default:
294 }
295 if (hash_info->digest != (StringInfo *) NULL)
296 hash_info->digest=DestroyStringInfo(hash_info->digest);
297 hash_info->signature=(~WizardSignature);
298 hash_info=(HashInfo *) RelinquishWizardMemory(hash_info);
299 return(hash_info);
300}
301
302/*
303%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
304% %
305% %
306% %
307% F i n a l i z e H a s h %
308% %
309% %
310% %
311%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
312%
313% FinalizeHash() finalizes the Hash message accumulator computation.
314%
315% The format of the FinalizeHash method is:
316%
317% WizardBooleanType FinalizeHash(HashInfo *hash_info)
318%
319% A description of each parameter follows:
320%
321% o hash_info: The address of a structure of type HashInfo.
322%
323*/
325{
327 status;
328
329 /*
330 Add padding and return the message accumulator.
331 */
333 assert(hash_info != (HashInfo *) NULL);
334 assert(hash_info->signature == WizardSignature);
335 switch (hash_info->hash)
336 {
337 case CRC64Hash:
338 {
340 *crc_info;
341
342 crc_info=(CRC64Info *) hash_info->handle;
343 status=FinalizeCRC64(crc_info);
344 SetStringInfo(hash_info->digest,GetCRC64Digest(crc_info));
345 break;
346 }
347 case MD5Hash:
348 {
349 MD5Info
350 *md5_info;
351
352 md5_info=(MD5Info *) hash_info->handle;
353 status=FinalizeMD5(md5_info);
354 SetStringInfo(hash_info->digest,GetMD5Digest(md5_info));
355 break;
356 }
357 case SHA1Hash:
358 {
360 *sha_info;
361
362 sha_info=(SHA1Info *) hash_info->handle;
363 status=FinalizeSHA1(sha_info);
364 SetStringInfo(hash_info->digest,GetSHA1Digest(sha_info));
365 break;
366 }
367 case SHA2224Hash:
368 {
370 *sha_info;
371
372 sha_info=(SHA2224Info *) hash_info->handle;
373 status=FinalizeSHA2224(sha_info);
374 SetStringInfo(hash_info->digest,GetSHA2224Digest(sha_info));
375 break;
376 }
377 case SHA2256Hash:
378 case SHA2Hash:
379 {
381 *sha_info;
382
383 sha_info=(SHA2256Info *) hash_info->handle;
384 status=FinalizeSHA2256(sha_info);
385 SetStringInfo(hash_info->digest,GetSHA2256Digest(sha_info));
386 break;
387 }
388 case SHA2384Hash:
389 {
391 *sha_info;
392
393 sha_info=(SHA2384Info *) hash_info->handle;
394 status=FinalizeSHA2384(sha_info);
395 SetStringInfo(hash_info->digest,GetSHA2384Digest(sha_info));
396 break;
397 }
398 case SHA2512Hash:
399 {
401 *sha_info;
402
403 sha_info=(SHA2512Info *) hash_info->handle;
404 status=FinalizeSHA2512(sha_info);
405 SetStringInfo(hash_info->digest,GetSHA2512Digest(sha_info));
406 break;
407 }
408 case SHA3Hash:
409 case SHA3224Hash:
410 case SHA3256Hash:
411 case SHA3384Hash:
412 case SHA3512Hash:
413 {
415 *sha_info;
416
417 sha_info=(SHA3Info *) hash_info->handle;
418 status=FinalizeSHA3(sha_info);
419 SetStringInfo(hash_info->digest,GetSHA3Digest(sha_info));
420 break;
421 }
422 default:
423 {
424 status=WizardFalse;
425 break;
426 }
427 }
428 return(status);
429}
430
431/*
432%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
433% %
434% %
435% %
436% G e t H a s h B l o c k s i z e %
437% %
438% %
439% %
440%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
441%
442% GetHashBlocksize() returns the Hash blocksize.
443%
444% The format of the GetHashBlocksize method is:
445%
446% size_t *GetHashBlocksize(const HashInfo *hash_info)
447%
448% A description of each parameter follows:
449%
450% o hash_info: The hash info.
451%
452*/
453WizardExport size_t GetHashBlocksize(const HashInfo *hash_info)
454{
455 size_t
456 blocksize;
457
459 WizardAssert(CipherDomain,hash_info != (HashInfo *) NULL);
461 switch (hash_info->hash)
462 {
463 case CRC64Hash:
464 {
466 *crc_info;
467
468 crc_info=(CRC64Info *) hash_info->handle;
469 blocksize=GetCRC64Blocksize(crc_info);
470 break;
471 }
472 case MD5Hash:
473 {
474 MD5Info
475 *md5_info;
476
477 md5_info=(MD5Info *) hash_info->handle;
478 blocksize=GetMD5Blocksize(md5_info);
479 break;
480 }
481 case SHA1Hash:
482 {
484 *sha_info;
485
486 sha_info=(SHA1Info *) hash_info->handle;
487 blocksize=GetSHA1Blocksize(sha_info);
488 break;
489 }
490 case SHA2224Hash:
491 {
493 *sha_info;
494
495 sha_info=(SHA2224Info *) hash_info->handle;
496 blocksize=GetSHA2224Blocksize(sha_info);
497 break;
498 }
499 case SHA2256Hash:
500 case SHA2Hash:
501 {
503 *sha_info;
504
505 sha_info=(SHA2256Info *) hash_info->handle;
506 blocksize=GetSHA2256Blocksize(sha_info);
507 break;
508 }
509 case SHA2384Hash:
510 {
512 *sha_info;
513
514 sha_info=(SHA2384Info *) hash_info->handle;
515 blocksize=GetSHA2384Blocksize(sha_info);
516 break;
517 }
518 case SHA2512Hash:
519 {
521 *sha_info;
522
523 sha_info=(SHA2512Info *) hash_info->handle;
524 blocksize=GetSHA2512Blocksize(sha_info);
525 break;
526 }
527 case SHA3Hash:
528 case SHA3224Hash:
529 case SHA3256Hash:
530 case SHA3384Hash:
531 case SHA3512Hash:
532 {
534 *sha_info;
535
536 sha_info=(SHA3Info *) hash_info->handle;
537 blocksize=GetSHA3Blocksize(sha_info);
538 break;
539 }
540 default:
542 }
543 return(blocksize);
544}
545
546/*
547%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
548% %
549% %
550% %
551% G e t H a s h D i g e s t %
552% %
553% %
554% %
555%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
556%
557% GetHashDigest() returns the Hash digest.
558%
559% The format of the GetHashDigest method is:
560%
561% const StringInfo *GetHashDigest(const HashInfo *hash_info)
562%
563% A description of each parameter follows:
564%
565% o hash_info: The hash info.
566%
567*/
569{
571 WizardAssert(HashDomain,hash_info != (HashInfo *) NULL);
573 return(hash_info->digest);
574}
575
576/*
577%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578% %
579% %
580% %
581% G e t H a s h D i g e s t s i z e %
582% %
583% %
584% %
585%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
586%
587% GetHashDigestsize() returns the Hash digest size.
588%
589% The format of the GetHashDigestsize method is:
590%
591% unsigned int *GetHashDigestsize(const HashInfo *hash_info)
592%
593% A description of each parameter follows:
594%
595% o hash_info: The hash info.
596%
597*/
599{
600 size_t
601 digestsize;
602
604 WizardAssert(CipherDomain,hash_info != (HashInfo *) NULL);
606 switch (hash_info->hash)
607 {
608 case CRC64Hash:
609 {
611 *crc_info;
612
613 crc_info=(CRC64Info *) hash_info->handle;
614 digestsize=GetCRC64Digestsize(crc_info);
615 break;
616 }
617 case MD5Hash:
618 {
619 MD5Info
620 *md5_info;
621
622 md5_info=(MD5Info *) hash_info->handle;
623 digestsize=GetMD5Digestsize(md5_info);
624 break;
625 }
626 case SHA1Hash:
627 {
629 *sha_info;
630
631 sha_info=(SHA1Info *) hash_info->handle;
632 digestsize=GetSHA1Digestsize(sha_info);
633 break;
634 }
635 case SHA2224Hash:
636 {
638 *sha_info;
639
640 sha_info=(SHA2224Info *) hash_info->handle;
641 digestsize=GetSHA2224Digestsize(sha_info);
642 break;
643 }
644 case SHA2256Hash:
645 case SHA2Hash:
646 {
648 *sha_info;
649
650 sha_info=(SHA2256Info *) hash_info->handle;
651 digestsize=GetSHA2256Digestsize(sha_info);
652 break;
653 }
654 case SHA2384Hash:
655 {
657 *sha_info;
658
659 sha_info=(SHA2384Info *) hash_info->handle;
660 digestsize=GetSHA2384Digestsize(sha_info);
661 break;
662 }
663 case SHA2512Hash:
664 {
666 *sha_info;
667
668 sha_info=(SHA2512Info *) hash_info->handle;
669 digestsize=GetSHA2512Digestsize(sha_info);
670 break;
671 }
672 case SHA3Hash:
673 case SHA3224Hash:
674 case SHA3256Hash:
675 case SHA3384Hash:
676 case SHA3512Hash:
677 {
679 *sha_info;
680
681 sha_info=(SHA3Info *) hash_info->handle;
682 digestsize=GetSHA3Digestsize(sha_info);
683 break;
684 }
685 default:
687 }
688 return(digestsize);
689}
690
691/*
692%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
693% %
694% %
695% %
696% G e t H a s h H e x D i g e s t %
697% %
698% %
699% %
700%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
701%
702% GetHashHexDigest() returns the hash digest as a hex string.
703%
704% The format of the GetHashHexDigest method is:
705%
706% char *GetHashHexDigest(const HashInfo *hash_info)
707%
708% A description of each parameter follows:
709%
710% o hash_info: The hash info.
711%
712*/
714{
715 char
716 *digest;
717
718 const unsigned char
719 *p;
720
721 ssize_t
722 i;
723
725 WizardAssert(HashDomain,hash_info != (HashInfo *) NULL);
727 digest=(char *) AcquireQuantumMemory(2UL*GetHashDigestsize(hash_info)+1UL,
728 sizeof(*digest));
729 if (digest == (char *) NULL)
731 p=GetStringInfoDatum(hash_info->digest);
732 for (i=0; i < (ssize_t) GetHashDigestsize(hash_info); i++)
733 (void) FormatLocaleString(digest+2*i,WizardPathExtent,"%02x",*p++);
734 digest[2*i]='\0';
735 return(digest);
736}
737
738/*
739%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
740% %
741% %
742% %
743% I n i t i a l i z e H a s h %
744% %
745% %
746% %
747%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
748%
749% IntializeHash() intializes the Hash accumulator.
750%
751% The format of the IntializeHash method is:
752%
753% WizardBooleanType IntializeHash(HashInfo *hash_info)
754%
755% A description of each parameter follows:
756%
757% o hash_info: The hash info.
758%
759*/
761{
763 status;
764
766 assert(hash_info != (HashInfo *) NULL);
767 assert(hash_info->signature == WizardSignature);
768 switch (hash_info->hash)
769 {
770 case CRC64Hash:
771 {
772 status=InitializeCRC64((CRC64Info *) hash_info->handle);
773 break;
774 }
775 case MD5Hash:
776 {
777 status=InitializeMD5((MD5Info *) hash_info->handle);
778 break;
779 }
780 case SHA1Hash:
781 {
782 status=InitializeSHA1((SHA1Info *) hash_info->handle);
783 break;
784 }
785 case SHA2224Hash:
786 {
787 status=InitializeSHA2224((SHA2224Info *) hash_info->handle);
788 break;
789 }
790 case SHA2256Hash:
791 case SHA2Hash:
792 {
793 status=InitializeSHA2256((SHA2256Info *) hash_info->handle);
794 break;
795 }
796 case SHA2384Hash:
797 {
798 status=InitializeSHA2384((SHA2384Info *) hash_info->handle);
799 break;
800 }
801 case SHA2512Hash:
802 {
803 status=InitializeSHA2512((SHA2512Info *) hash_info->handle);
804 break;
805 }
806 case SHA3Hash:
807 case SHA3224Hash:
808 case SHA3256Hash:
809 case SHA3384Hash:
810 case SHA3512Hash:
811 {
812 status=InitializeSHA3((SHA3Info *) hash_info->handle);
813 break;
814 }
815 default:
816 {
817 status=WizardFalse;
818 break;
819 }
820 }
821 return(status);
822}
823
824/*
825%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
826% %
827% %
828% %
829% U p d a t e H a s h %
830% %
831% %
832% %
833%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
834%
835% UpdateHash() updates the Hash message accumulator.
836%
837% The format of the UpdateHash method is:
838%
839% WizardBooleanType UpdateHash(HashInfo *hash_info,
840% const StringInfo *message)
841%
842% A description of each parameter follows:
843%
844% o hash_info: The address of a structure of type HashInfo.
845%
846% o message: The message.
847%
848*/
850 const StringInfo *message)
851{
853 status;
854
855 /*
856 Update the Hash accumulator.
857 */
859 assert(hash_info != (HashInfo *) NULL);
860 assert(hash_info->signature == WizardSignature);
861 switch (hash_info->hash)
862 {
863 case CRC64Hash:
864 {
865 status=UpdateCRC64((CRC64Info *) hash_info->handle,message);
866 break;
867 }
868 case MD5Hash:
869 {
870 status=UpdateMD5((MD5Info *) hash_info->handle,message);
871 break;
872 }
873 case SHA1Hash:
874 {
875 status=UpdateSHA1((SHA1Info *) hash_info->handle,message);
876 break;
877 }
878 case SHA2224Hash:
879 {
880 status=UpdateSHA2224((SHA2224Info *) hash_info->handle,message);
881 break;
882 }
883 case SHA2256Hash:
884 case SHA2Hash:
885 {
886 status=UpdateSHA2256((SHA2256Info *) hash_info->handle,message);
887 break;
888 }
889 case SHA2384Hash:
890 {
891 status=UpdateSHA2384((SHA2384Info *) hash_info->handle,message);
892 break;
893 }
894 case SHA2512Hash:
895 {
896 status=UpdateSHA2512((SHA2512Info *) hash_info->handle,message);
897 break;
898 }
899 case SHA3Hash:
900 case SHA3224Hash:
901 case SHA3256Hash:
902 case SHA3384Hash:
903 case SHA3512Hash:
904 {
905 status=UpdateSHA3((SHA3Info *) hash_info->handle,message);
906 break;
907 }
908 default:
909 {
910 status=WizardFalse;
911 break;
912 }
913 }
914 return(status);
915}
WizardExport unsigned int GetCRC64Digestsize(const CRC64Info *crc64_info)
Definition crc64.c:308
WizardExport unsigned int GetCRC64Blocksize(const CRC64Info *crc64_info)
Definition crc64.c:216
WizardExport CRC64Info * DestroyCRC64Info(CRC64Info *crc_info)
Definition crc64.c:137
WizardExport WizardBooleanType InitializeCRC64(CRC64Info *crc_info)
Definition crc64.c:338
WizardExport CRC64Info * AcquireCRC64Info(void)
Definition crc64.c:94
WizardExport const StringInfo * GetCRC64Digest(const CRC64Info *crc64_info)
Definition crc64.c:278
WizardExport WizardBooleanType FinalizeCRC64(CRC64Info *crc_info)
Definition crc64.c:174
WizardExport WizardBooleanType UpdateCRC64(CRC64Info *crc_info, const StringInfo *message)
Definition crc64.c:391
#define WizardAssert(domain, predicate)
#define ThrowWizardFatalError(domain, error)
@ HashDomain
Definition exception.h:30
@ CipherDomain
Definition exception.h:34
@ EnumerateError
Definition exception.h:50
@ MemoryError
Definition exception.h:49
WizardExport HashInfo * AcquireHashInfo(const HashType hash)
Definition hash.c:99
WizardExport WizardBooleanType UpdateHash(HashInfo *hash_info, const StringInfo *message)
Definition hash.c:849
WizardExport WizardBooleanType InitializeHash(HashInfo *hash_info)
Definition hash.c:760
WizardExport HashInfo * DestroyHashInfo(HashInfo *hash_info)
Definition hash.c:231
WizardExport size_t GetHashBlocksize(const HashInfo *hash_info)
Definition hash.c:453
WizardExport const StringInfo * GetHashDigest(const HashInfo *hash_info)
Definition hash.c:568
WizardExport size_t GetHashDigestsize(const HashInfo *hash_info)
Definition hash.c:598
WizardExport WizardBooleanType FinalizeHash(HashInfo *hash_info)
Definition hash.c:324
WizardExport char * GetHashHexDigest(const HashInfo *hash_info)
Definition hash.c:713
HashType
Definition hash.h:28
@ SHA3512Hash
Definition hash.h:43
@ SHA3Hash
Definition hash.h:39
@ CRC64Hash
Definition hash.h:31
@ SHA2224Hash
Definition hash.h:35
@ SHA2512Hash
Definition hash.h:38
@ SHA3256Hash
Definition hash.h:41
@ MD5Hash
Definition hash.h:32
@ SHA3384Hash
Definition hash.h:42
@ SHA2256Hash
Definition hash.h:36
@ SHA2Hash
Definition hash.h:34
@ SHA3224Hash
Definition hash.h:40
@ SHA1Hash
Definition hash.h:33
@ SHA2384Hash
Definition hash.h:37
WizardExport ssize_t FormatLocaleString(char *string, const size_t length, const char *format,...)
Definition locale.c:465
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
WizardExport WizardBooleanType InitializeMD5(MD5Info *md5_info)
Definition md5.c:371
WizardExport const StringInfo * GetMD5Digest(const MD5Info *md5_info)
Definition md5.c:311
WizardExport WizardBooleanType FinalizeMD5(MD5Info *md5_info)
Definition md5.c:185
WizardExport WizardBooleanType UpdateMD5(MD5Info *md5_info, const StringInfo *message)
Definition md5.c:604
WizardExport MD5Info * AcquireMD5Info(void)
Definition md5.c:102
WizardExport unsigned int GetMD5Blocksize(const MD5Info *md5_info)
Definition md5.c:281
WizardExport MD5Info * DestroyMD5Info(MD5Info *md5_info)
Definition md5.c:146
WizardExport unsigned int GetMD5Digestsize(const MD5Info *md5_info)
Definition md5.c:341
WizardExport void * AcquireWizardMemory(const size_t size)
Definition memory.c:586
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 WizardPathExtent
#define WizardSignature
WizardExport WizardBooleanType InitializeSHA1(SHA1Info *sha_info)
Definition sha1.c:382
WizardExport unsigned int GetSHA1Blocksize(const SHA1Info *sha1_info)
Definition sha1.c:292
WizardExport SHA1Info * DestroySHA1Info(SHA1Info *sha_info)
Definition sha1.c:160
WizardExport WizardBooleanType UpdateSHA1(SHA1Info *sha_info, const StringInfo *message)
Definition sha1.c:592
WizardExport WizardBooleanType FinalizeSHA1(SHA1Info *sha_info)
Definition sha1.c:199
WizardExport unsigned int GetSHA1Digestsize(const SHA1Info *sha1_info)
Definition sha1.c:352
WizardExport const StringInfo * GetSHA1Digest(const SHA1Info *sha1_info)
Definition sha1.c:322
WizardExport SHA1Info * AcquireSHA1Info(void)
Definition sha1.c:109
WizardExport const StringInfo * GetSHA2224Digest(const SHA2224Info *sha2224_info)
Definition sha2224.c:320
WizardExport SHA2224Info * AcquireSHA2224Info(void)
Definition sha2224.c:108
WizardExport WizardBooleanType FinalizeSHA2224(SHA2224Info *sha_info)
Definition sha2224.c:197
WizardExport unsigned int GetSHA2224Blocksize(const SHA2224Info *sha2224_info)
Definition sha2224.c:290
WizardExport WizardBooleanType InitializeSHA2224(SHA2224Info *sha_info)
Definition sha2224.c:380
WizardExport unsigned int GetSHA2224Digestsize(const SHA2224Info *sha2224_info)
Definition sha2224.c:350
WizardExport WizardBooleanType UpdateSHA2224(SHA2224Info *sha_info, const StringInfo *message)
Definition sha2224.c:611
WizardExport SHA2224Info * DestroySHA2224Info(SHA2224Info *sha_info)
Definition sha2224.c:158
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
WizardExport const StringInfo * GetSHA2256Digest(const SHA2256Info *sha2256_info)
Definition sha2256.c:321
WizardExport WizardBooleanType UpdateSHA2256(SHA2256Info *sha_info, const StringInfo *message)
Definition sha2256.c:613
WizardExport SHA2256Info * AcquireSHA2256Info(void)
Definition sha2256.c:108
WizardExport unsigned int GetSHA2256Digestsize(const SHA2256Info *sha2256_info)
Definition sha2256.c:351
WizardExport WizardBooleanType FinalizeSHA2256(SHA2256Info *sha_info)
Definition sha2256.c:198
WizardExport SHA2384Info * DestroySHA2384Info(SHA2384Info *sha_info)
Definition sha2384.c:159
WizardExport WizardBooleanType UpdateSHA2384(SHA2384Info *sha_info, const StringInfo *message)
Definition sha2384.c:675
WizardExport SHA2384Info * AcquireSHA2384Info(void)
Definition sha2384.c:108
WizardExport unsigned int GetSHA2384Digestsize(const SHA2384Info *sha2384_info)
Definition sha2384.c:363
WizardExport unsigned int GetSHA2384Blocksize(const SHA2384Info *sha2384_info)
Definition sha2384.c:303
WizardExport WizardBooleanType FinalizeSHA2384(SHA2384Info *sha_info)
Definition sha2384.c:198
WizardExport const StringInfo * GetSHA2384Digest(const SHA2384Info *sha2384_info)
Definition sha2384.c:333
WizardExport WizardBooleanType InitializeSHA2384(SHA2384Info *sha_info)
Definition sha2384.c:393
WizardExport WizardBooleanType FinalizeSHA2512(SHA2512Info *sha_info)
Definition sha2512.c:198
WizardExport const StringInfo * GetSHA2512Digest(const SHA2512Info *sha2512_info)
Definition sha2512.c:333
WizardExport WizardBooleanType InitializeSHA2512(SHA2512Info *sha_info)
Definition sha2512.c:393
WizardExport unsigned int GetSHA2512Digestsize(const SHA2512Info *sha2512_info)
Definition sha2512.c:363
WizardExport SHA2512Info * AcquireSHA2512Info(void)
Definition sha2512.c:108
WizardExport WizardBooleanType UpdateSHA2512(SHA2512Info *sha_info, const StringInfo *message)
Definition sha2512.c:675
WizardExport SHA2512Info * DestroySHA2512Info(SHA2512Info *sha_info)
Definition sha2512.c:159
WizardExport unsigned int GetSHA2512Blocksize(const SHA2512Info *sha2512_info)
Definition sha2512.c:303
WizardExport const StringInfo * GetSHA3Digest(const SHA3Info *sha_info)
Definition sha3.c:557
WizardExport WizardBooleanType InitializeSHA3(SHA3Info *sha_info)
Definition sha3.c:706
WizardExport WizardBooleanType UpdateSHA3(SHA3Info *sha_info, const StringInfo *message)
Definition sha3.c:903
WizardExport SHA3Info * DestroySHA3Info(SHA3Info *sha_info)
Definition sha3.c:208
WizardExport unsigned int GetSHA3Blocksize(const SHA3Info *sha_info)
Definition sha3.c:527
WizardExport SHA3Info * AcquireSHA3Info(const HashType hash)
Definition sha3.c:132
WizardExport WizardBooleanType FinalizeSHA3(SHA3Info *sha_info)
Definition sha3.c:469
WizardExport unsigned int GetSHA3Digestsize(const SHA3Info *sha_info)
Definition sha3.c:587
WizardExport void SetStringInfo(StringInfo *string_info, const StringInfo *source)
Definition string.c:1792
WizardExport StringInfo * AcquireStringInfo(const size_t length)
Definition string.c:179
WizardExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
Definition string.c:1251
WizardExport void ResetStringInfo(StringInfo *string_info)
Definition string.c:1761
WizardExport StringInfo * DestroyStringInfo(StringInfo *string_info)
Definition string.c:857
void * handle
Definition hash.c:68
HashType hash
Definition hash.c:62
size_t signature
Definition hash.c:74
time_t timestamp
Definition hash.c:71
StringInfo * digest
Definition hash.c:65
Definition md5.c:57
WizardBooleanType
Definition wizard-type.h:26
@ WizardFalse
Definition wizard-type.h:27