Changeset View
Changeset View
Standalone View
Standalone View
sys/crypto/sha2/sha512c.c
Show First 20 Lines • Show All 328 Lines • ▼ Show 20 Lines | SHA512_Final(unsigned char digest[static SHA512_DIGEST_LENGTH], SHA512_CTX *ctx) | ||||
/* Write the hash */ | /* Write the hash */ | ||||
be64enc_vect(digest, ctx->state, SHA512_DIGEST_LENGTH); | be64enc_vect(digest, ctx->state, SHA512_DIGEST_LENGTH); | ||||
/* Clear the context state */ | /* Clear the context state */ | ||||
memset(ctx, 0, sizeof(*ctx)); | memset(ctx, 0, sizeof(*ctx)); | ||||
} | } | ||||
#ifndef _STANDALONE | |||||
/*** SHA-512t: *********************************************************/ | /*** SHA-512t: *********************************************************/ | ||||
/* | /* | ||||
* the SHA512t transforms are identical to SHA512 so reuse the existing function | * the SHA512t transforms are identical to SHA512 so reuse the existing function | ||||
*/ | */ | ||||
void | void | ||||
SHA512_224_Init(SHA512_CTX * ctx) | SHA512_224_Init(SHA512_CTX * ctx) | ||||
{ | { | ||||
Show All 26 Lines | SHA512_224_Final(unsigned char digest[static SHA512_224_DIGEST_LENGTH], SHA512_CTX * ctx) | ||||
SHA512_Pad(ctx); | SHA512_Pad(ctx); | ||||
/* Write the hash */ | /* Write the hash */ | ||||
be64enc_vect(digest, ctx->state, SHA512_224_DIGEST_LENGTH); | be64enc_vect(digest, ctx->state, SHA512_224_DIGEST_LENGTH); | ||||
/* Clear the context state */ | /* Clear the context state */ | ||||
memset(ctx, 0, sizeof(*ctx)); | memset(ctx, 0, sizeof(*ctx)); | ||||
} | } | ||||
#endif | |||||
void | void | ||||
SHA512_256_Init(SHA512_CTX * ctx) | SHA512_256_Init(SHA512_CTX * ctx) | ||||
{ | { | ||||
/* Zero bits processed so far */ | /* Zero bits processed so far */ | ||||
ctx->count[0] = ctx->count[1] = 0; | ctx->count[0] = ctx->count[1] = 0; | ||||
Show All 24 Lines | SHA512_256_Final(unsigned char digest[static SHA512_256_DIGEST_LENGTH], SHA512_CTX * ctx) | ||||
/* Write the hash */ | /* Write the hash */ | ||||
be64enc_vect(digest, ctx->state, SHA512_256_DIGEST_LENGTH); | be64enc_vect(digest, ctx->state, SHA512_256_DIGEST_LENGTH); | ||||
/* Clear the context state */ | /* Clear the context state */ | ||||
memset(ctx, 0, sizeof(*ctx)); | memset(ctx, 0, sizeof(*ctx)); | ||||
} | } | ||||
#ifndef _STANDALONE | |||||
/*** SHA-384: *********************************************************/ | /*** SHA-384: *********************************************************/ | ||||
/* | /* | ||||
* the SHA384 and SHA512 transforms are identical, so SHA384 is skipped | * the SHA384 and SHA512 transforms are identical, so SHA384 is skipped | ||||
*/ | */ | ||||
/* SHA-384 initialization. Begins a SHA-384 operation. */ | /* SHA-384 initialization. Begins a SHA-384 operation. */ | ||||
void | void | ||||
SHA384_Init(SHA384_CTX * ctx) | SHA384_Init(SHA384_CTX * ctx) | ||||
Show All 33 Lines | SHA384_Final(unsigned char digest[static SHA384_DIGEST_LENGTH], SHA384_CTX *ctx) | ||||
SHA512_Pad((SHA512_CTX *)ctx); | SHA512_Pad((SHA512_CTX *)ctx); | ||||
/* Write the hash */ | /* Write the hash */ | ||||
be64enc_vect(digest, ctx->state, SHA384_DIGEST_LENGTH); | be64enc_vect(digest, ctx->state, SHA384_DIGEST_LENGTH); | ||||
/* Clear the context state */ | /* Clear the context state */ | ||||
memset(ctx, 0, sizeof(*ctx)); | memset(ctx, 0, sizeof(*ctx)); | ||||
} | } | ||||
#endif | |||||
#ifdef WEAK_REFS | #ifdef WEAK_REFS | ||||
/* When building libmd, provide weak references. Note: this is not | /* When building libmd, provide weak references. Note: this is not | ||||
activated in the context of compiling these sources for internal | activated in the context of compiling these sources for internal | ||||
use in libcrypt. | use in libcrypt. | ||||
*/ | */ | ||||
#undef SHA512_Init | #undef SHA512_Init | ||||
__weak_reference(_libmd_SHA512_Init, SHA512_Init); | __weak_reference(_libmd_SHA512_Init, SHA512_Init); | ||||
Show All 28 Lines |