Lines Matching refs:context
334 void SHA256_Init(SHA256_CTX* context) { in SHA256_Init() argument
335 if (context == (SHA256_CTX*)0) { in SHA256_Init()
338 bcopy(sha256_initial_hash_value, context->state, SHA256_DIGEST_LENGTH); in SHA256_Init()
339 bzero(context->buffer, SHA256_BLOCK_LENGTH); in SHA256_Init()
340 context->bitcount = 0; in SHA256_Init()
380 void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { in SHA256_Transform() argument
385 W256 = (sha2_word32*)context->buffer; in SHA256_Transform()
388 a = context->state[0]; in SHA256_Transform()
389 b = context->state[1]; in SHA256_Transform()
390 c = context->state[2]; in SHA256_Transform()
391 d = context->state[3]; in SHA256_Transform()
392 e = context->state[4]; in SHA256_Transform()
393 f = context->state[5]; in SHA256_Transform()
394 g = context->state[6]; in SHA256_Transform()
395 h = context->state[7]; in SHA256_Transform()
423 context->state[0] += a; in SHA256_Transform()
424 context->state[1] += b; in SHA256_Transform()
425 context->state[2] += c; in SHA256_Transform()
426 context->state[3] += d; in SHA256_Transform()
427 context->state[4] += e; in SHA256_Transform()
428 context->state[5] += f; in SHA256_Transform()
429 context->state[6] += g; in SHA256_Transform()
430 context->state[7] += h; in SHA256_Transform()
438 void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { in SHA256_Transform() argument
443 W256 = (sha2_word32*)context->buffer; in SHA256_Transform()
446 a = context->state[0]; in SHA256_Transform()
447 b = context->state[1]; in SHA256_Transform()
448 c = context->state[2]; in SHA256_Transform()
449 d = context->state[3]; in SHA256_Transform()
450 e = context->state[4]; in SHA256_Transform()
451 f = context->state[5]; in SHA256_Transform()
452 g = context->state[6]; in SHA256_Transform()
453 h = context->state[7]; in SHA256_Transform()
503 context->state[0] += a; in SHA256_Transform()
504 context->state[1] += b; in SHA256_Transform()
505 context->state[2] += c; in SHA256_Transform()
506 context->state[3] += d; in SHA256_Transform()
507 context->state[4] += e; in SHA256_Transform()
508 context->state[5] += f; in SHA256_Transform()
509 context->state[6] += g; in SHA256_Transform()
510 context->state[7] += h; in SHA256_Transform()
518 void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) { in SHA256_Update() argument
527 assert(context != (SHA256_CTX*)0 && data != (sha2_byte*)0); in SHA256_Update()
529 usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; in SHA256_Update()
536 bcopy(data, &context->buffer[usedspace], freespace); in SHA256_Update()
537 context->bitcount += freespace << 3; in SHA256_Update()
540 SHA256_Transform(context, (sha2_word32*)context->buffer); in SHA256_Update()
543 bcopy(data, &context->buffer[usedspace], len); in SHA256_Update()
544 context->bitcount += len << 3; in SHA256_Update()
552 SHA256_Transform(context, (const sha2_word32*)data); in SHA256_Update()
553 context->bitcount += SHA256_BLOCK_LENGTH << 3; in SHA256_Update()
559 bcopy(data, context->buffer, len); in SHA256_Update()
560 context->bitcount += len << 3; in SHA256_Update()
566 void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) { in SHA256_Final() argument
571 assert(context != (SHA256_CTX*)0); in SHA256_Final()
575 usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; in SHA256_Final()
578 REVERSE64(context->bitcount,context->bitcount); in SHA256_Final()
582 context->buffer[usedspace++] = 0x80; in SHA256_Final()
586 bzero(&context->buffer[usedspace], SHA256_SHORT_BLOCK_LENGTH - usedspace); in SHA256_Final()
589 bzero(&context->buffer[usedspace], SHA256_BLOCK_LENGTH - usedspace); in SHA256_Final()
592 SHA256_Transform(context, (sha2_word32*)context->buffer); in SHA256_Final()
595 bzero(context->buffer, SHA256_SHORT_BLOCK_LENGTH); in SHA256_Final()
599 bzero(context->buffer, SHA256_SHORT_BLOCK_LENGTH); in SHA256_Final()
602 *context->buffer = 0x80; in SHA256_Final()
605 *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; in SHA256_Final()
608 SHA256_Transform(context, (sha2_word32*)context->buffer); in SHA256_Final()
615 REVERSE32(context->state[j],context->state[j]); in SHA256_Final()
616 *d++ = context->state[j]; in SHA256_Final()
620 bcopy(context->state, d, SHA256_DIGEST_LENGTH); in SHA256_Final()
625 bzero(context, sizeof(*context)); in SHA256_Final()
629 char *SHA256_End(SHA256_CTX* context, char buffer[]) { in SHA256_End() argument
634 assert(context != (SHA256_CTX*)0); in SHA256_End()
637 SHA256_Final(digest, context); in SHA256_End()
646 bzero(context, sizeof(*context)); in SHA256_End()
653 SHA256_CTX context; in SHA256_Data() local
655 SHA256_Init(&context); in SHA256_Data()
656 SHA256_Update(&context, data, len); in SHA256_Data()
657 return SHA256_End(&context, digest); in SHA256_Data()
662 void SHA512_Init(SHA512_CTX* context) { in SHA512_Init() argument
663 if (context == (SHA512_CTX*)0) { in SHA512_Init()
666 bcopy(sha512_initial_hash_value, context->state, SHA512_DIGEST_LENGTH); in SHA512_Init()
667 bzero(context->buffer, SHA512_BLOCK_LENGTH); in SHA512_Init()
668 context->bitcount[0] = context->bitcount[1] = 0; in SHA512_Init()
707 void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { in SHA512_Transform() argument
709 sha2_word64 T1, *W512 = (sha2_word64*)context->buffer; in SHA512_Transform()
713 a = context->state[0]; in SHA512_Transform()
714 b = context->state[1]; in SHA512_Transform()
715 c = context->state[2]; in SHA512_Transform()
716 d = context->state[3]; in SHA512_Transform()
717 e = context->state[4]; in SHA512_Transform()
718 f = context->state[5]; in SHA512_Transform()
719 g = context->state[6]; in SHA512_Transform()
720 h = context->state[7]; in SHA512_Transform()
747 context->state[0] += a; in SHA512_Transform()
748 context->state[1] += b; in SHA512_Transform()
749 context->state[2] += c; in SHA512_Transform()
750 context->state[3] += d; in SHA512_Transform()
751 context->state[4] += e; in SHA512_Transform()
752 context->state[5] += f; in SHA512_Transform()
753 context->state[6] += g; in SHA512_Transform()
754 context->state[7] += h; in SHA512_Transform()
762 void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) { in SHA512_Transform() argument
764 sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer; in SHA512_Transform()
768 a = context->state[0]; in SHA512_Transform()
769 b = context->state[1]; in SHA512_Transform()
770 c = context->state[2]; in SHA512_Transform()
771 d = context->state[3]; in SHA512_Transform()
772 e = context->state[4]; in SHA512_Transform()
773 f = context->state[5]; in SHA512_Transform()
774 g = context->state[6]; in SHA512_Transform()
775 h = context->state[7]; in SHA512_Transform()
825 context->state[0] += a; in SHA512_Transform()
826 context->state[1] += b; in SHA512_Transform()
827 context->state[2] += c; in SHA512_Transform()
828 context->state[3] += d; in SHA512_Transform()
829 context->state[4] += e; in SHA512_Transform()
830 context->state[5] += f; in SHA512_Transform()
831 context->state[6] += g; in SHA512_Transform()
832 context->state[7] += h; in SHA512_Transform()
840 void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) { in SHA512_Update() argument
849 assert(context != (SHA512_CTX*)0 && data != (sha2_byte*)0); in SHA512_Update()
851 usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; in SHA512_Update()
858 bcopy(data, &context->buffer[usedspace], freespace); in SHA512_Update()
859 ADDINC128(context->bitcount, freespace << 3); in SHA512_Update()
862 SHA512_Transform(context, (sha2_word64*)context->buffer); in SHA512_Update()
865 bcopy(data, &context->buffer[usedspace], len); in SHA512_Update()
866 ADDINC128(context->bitcount, len << 3); in SHA512_Update()
874 SHA512_Transform(context, (const sha2_word64*)data); in SHA512_Update()
875 ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3); in SHA512_Update()
881 bcopy(data, context->buffer, len); in SHA512_Update()
882 ADDINC128(context->bitcount, len << 3); in SHA512_Update()
888 void SHA512_Last(SHA512_CTX* context) { in SHA512_Last() argument
891 usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; in SHA512_Last()
894 REVERSE64(context->bitcount[0],context->bitcount[0]); in SHA512_Last()
895 REVERSE64(context->bitcount[1],context->bitcount[1]); in SHA512_Last()
899 context->buffer[usedspace++] = 0x80; in SHA512_Last()
903 bzero(&context->buffer[usedspace], SHA512_SHORT_BLOCK_LENGTH - usedspace); in SHA512_Last()
906 bzero(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace); in SHA512_Last()
909 SHA512_Transform(context, (sha2_word64*)context->buffer); in SHA512_Last()
912 bzero(context->buffer, SHA512_BLOCK_LENGTH - 2); in SHA512_Last()
916 bzero(context->buffer, SHA512_SHORT_BLOCK_LENGTH); in SHA512_Last()
919 *context->buffer = 0x80; in SHA512_Last()
922 *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1]; in SHA512_Last()
923 *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0]; in SHA512_Last()
926 SHA512_Transform(context, (sha2_word64*)context->buffer); in SHA512_Last()
929 void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) { in SHA512_Final() argument
933 assert(context != (SHA512_CTX*)0); in SHA512_Final()
937 SHA512_Last(context); in SHA512_Final()
945 REVERSE64(context->state[j],context->state[j]); in SHA512_Final()
946 *d++ = context->state[j]; in SHA512_Final()
950 bcopy(context->state, d, SHA512_DIGEST_LENGTH); in SHA512_Final()
955 bzero(context, sizeof(*context)); in SHA512_Final()
958 char *SHA512_End(SHA512_CTX* context, char buffer[]) { in SHA512_End() argument
963 assert(context != (SHA512_CTX*)0); in SHA512_End()
966 SHA512_Final(digest, context); in SHA512_End()
975 bzero(context, sizeof(*context)); in SHA512_End()
982 SHA512_CTX context; in SHA512_Data() local
984 SHA512_Init(&context); in SHA512_Data()
985 SHA512_Update(&context, data, len); in SHA512_Data()
986 return SHA512_End(&context, digest); in SHA512_Data()
991 void SHA384_Init(SHA384_CTX* context) { in SHA384_Init() argument
992 if (context == (SHA384_CTX*)0) { in SHA384_Init()
995 bcopy(sha384_initial_hash_value, context->state, SHA512_DIGEST_LENGTH); in SHA384_Init()
996 bzero(context->buffer, SHA384_BLOCK_LENGTH); in SHA384_Init()
997 context->bitcount[0] = context->bitcount[1] = 0; in SHA384_Init()
1000 void SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) { in SHA384_Update() argument
1001 SHA512_Update((SHA512_CTX*)context, data, len); in SHA384_Update()
1004 void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) { in SHA384_Final() argument
1008 assert(context != (SHA384_CTX*)0); in SHA384_Final()
1012 SHA512_Last((SHA512_CTX*)context); in SHA384_Final()
1020 REVERSE64(context->state[j],context->state[j]); in SHA384_Final()
1021 *d++ = context->state[j]; in SHA384_Final()
1025 bcopy(context->state, d, SHA384_DIGEST_LENGTH); in SHA384_Final()
1030 bzero(context, sizeof(*context)); in SHA384_Final()
1033 char *SHA384_End(SHA384_CTX* context, char buffer[]) { in SHA384_End() argument
1038 assert(context != (SHA384_CTX*)0); in SHA384_End()
1041 SHA384_Final(digest, context); in SHA384_End()
1050 bzero(context, sizeof(*context)); in SHA384_End()
1057 SHA384_CTX context; in SHA384_Data() local
1059 SHA384_Init(&context); in SHA384_Data()
1060 SHA384_Update(&context, data, len); in SHA384_Data()
1061 return SHA384_End(&context, digest); in SHA384_Data()