minor variable rename LENGTH -> LEN, STRING_LENGTH -> STR_LEN
This commit is contained in:
parent
a9cbd60327
commit
fd30a3491d
@ -874,7 +874,7 @@ get_keys(fko_ctx_t ctx, fko_cli_options_t *options,
|
||||
{
|
||||
*hmac_key_len = fko_base64_decode(options->hmac_key_base64,
|
||||
(unsigned char *) options->hmac_key);
|
||||
memcpy(hmac_key, options->hmac_key, SHA256_BLOCK_LENGTH);
|
||||
memcpy(hmac_key, options->hmac_key, SHA256_BLOCK_LEN);
|
||||
use_hmac = 1;
|
||||
}
|
||||
else if (options->use_hmac)
|
||||
|
||||
40
lib/digest.c
40
lib/digest.c
@ -62,10 +62,10 @@ md5(unsigned char *out, unsigned char *in, size_t size)
|
||||
void
|
||||
md5_hex(char *out, unsigned char *in, size_t size)
|
||||
{
|
||||
uint8_t md[MD5_DIGEST_LENGTH];
|
||||
uint8_t md[MD5_DIGEST_LEN];
|
||||
|
||||
md5(md, in, size);
|
||||
digest_to_hex(out, md, MD5_DIGEST_LENGTH);
|
||||
digest_to_hex(out, md, MD5_DIGEST_LEN);
|
||||
}
|
||||
|
||||
/* Compute MD5 hash on in and store the base64 string result in out.
|
||||
@ -73,10 +73,10 @@ md5_hex(char *out, unsigned char *in, size_t size)
|
||||
void
|
||||
md5_base64(char *out, unsigned char *in, size_t size)
|
||||
{
|
||||
uint8_t md[MD5_DIGEST_LENGTH];
|
||||
uint8_t md[MD5_DIGEST_LEN];
|
||||
|
||||
md5(md, in, size);
|
||||
b64_encode(md, out, MD5_DIGEST_LENGTH);
|
||||
b64_encode(md, out, MD5_DIGEST_LEN);
|
||||
|
||||
strip_b64_eq(out);
|
||||
}
|
||||
@ -98,10 +98,10 @@ sha1(unsigned char *out, unsigned char *in, size_t size)
|
||||
void
|
||||
sha1_hex(char *out, unsigned char *in, size_t size)
|
||||
{
|
||||
uint8_t md[SHA1_DIGEST_LENGTH];
|
||||
uint8_t md[SHA1_DIGEST_LEN];
|
||||
|
||||
sha1(md, in, size);
|
||||
digest_to_hex(out, md, SHA1_DIGEST_LENGTH);
|
||||
digest_to_hex(out, md, SHA1_DIGEST_LEN);
|
||||
}
|
||||
|
||||
/* Compute SHA1 hash on in and store the base64 string result in out.
|
||||
@ -109,10 +109,10 @@ sha1_hex(char *out, unsigned char *in, size_t size)
|
||||
void
|
||||
sha1_base64(char *out, unsigned char *in, size_t size)
|
||||
{
|
||||
uint8_t md[SHA1_DIGEST_LENGTH];
|
||||
uint8_t md[SHA1_DIGEST_LEN];
|
||||
|
||||
sha1(md, in, size);
|
||||
b64_encode(md, out, SHA1_DIGEST_LENGTH);
|
||||
b64_encode(md, out, SHA1_DIGEST_LEN);
|
||||
|
||||
strip_b64_eq(out);
|
||||
}
|
||||
@ -134,10 +134,10 @@ sha256(unsigned char *out, unsigned char *in, size_t size)
|
||||
void
|
||||
sha256_hex(char *out, unsigned char *in, size_t size)
|
||||
{
|
||||
uint8_t md[SHA256_DIGEST_LENGTH];
|
||||
uint8_t md[SHA256_DIGEST_LEN];
|
||||
|
||||
sha256(md, in, size);
|
||||
digest_to_hex(out, md, SHA256_DIGEST_LENGTH);
|
||||
digest_to_hex(out, md, SHA256_DIGEST_LEN);
|
||||
}
|
||||
|
||||
/* Compute SHA256 hash on in and store the base64 string result in out.
|
||||
@ -145,10 +145,10 @@ sha256_hex(char *out, unsigned char *in, size_t size)
|
||||
void
|
||||
sha256_base64(char *out, unsigned char *in, size_t size)
|
||||
{
|
||||
uint8_t md[SHA256_DIGEST_LENGTH];
|
||||
uint8_t md[SHA256_DIGEST_LEN];
|
||||
|
||||
sha256(md, in, size);
|
||||
b64_encode(md, out, SHA256_DIGEST_LENGTH);
|
||||
b64_encode(md, out, SHA256_DIGEST_LEN);
|
||||
|
||||
strip_b64_eq(out);
|
||||
}
|
||||
@ -170,10 +170,10 @@ sha384(unsigned char *out, unsigned char *in, size_t size)
|
||||
void
|
||||
sha384_hex(char *out, unsigned char *in, size_t size)
|
||||
{
|
||||
uint8_t md[SHA384_DIGEST_LENGTH];
|
||||
uint8_t md[SHA384_DIGEST_LEN];
|
||||
|
||||
sha384(md, in, size);
|
||||
digest_to_hex(out, md, SHA384_DIGEST_LENGTH);
|
||||
digest_to_hex(out, md, SHA384_DIGEST_LEN);
|
||||
}
|
||||
|
||||
/* Compute SHA384 hash on in and store the base64 string result in out.
|
||||
@ -181,10 +181,10 @@ sha384_hex(char *out, unsigned char *in, size_t size)
|
||||
void
|
||||
sha384_base64(char *out, unsigned char *in, size_t size)
|
||||
{
|
||||
uint8_t md[SHA384_DIGEST_LENGTH];
|
||||
uint8_t md[SHA384_DIGEST_LEN];
|
||||
|
||||
sha384(md, in, size);
|
||||
b64_encode(md, out, SHA384_DIGEST_LENGTH);
|
||||
b64_encode(md, out, SHA384_DIGEST_LEN);
|
||||
|
||||
strip_b64_eq(out);
|
||||
}
|
||||
@ -206,10 +206,10 @@ sha512(unsigned char *out, unsigned char *in, size_t size)
|
||||
void
|
||||
sha512_hex(char *out, unsigned char *in, size_t size)
|
||||
{
|
||||
uint8_t md[SHA512_DIGEST_LENGTH];
|
||||
uint8_t md[SHA512_DIGEST_LEN];
|
||||
|
||||
sha512(md, in, size);
|
||||
digest_to_hex(out, md, SHA512_DIGEST_LENGTH);
|
||||
digest_to_hex(out, md, SHA512_DIGEST_LEN);
|
||||
}
|
||||
|
||||
/* Compute SHA512 hash on in and store the base64 string result in out.
|
||||
@ -217,10 +217,10 @@ sha512_hex(char *out, unsigned char *in, size_t size)
|
||||
void
|
||||
sha512_base64(char *out, unsigned char *in, size_t size)
|
||||
{
|
||||
uint8_t md[SHA512_DIGEST_LENGTH];
|
||||
uint8_t md[SHA512_DIGEST_LEN];
|
||||
|
||||
sha512(md, in, size);
|
||||
b64_encode(md, out, SHA512_DIGEST_LENGTH);
|
||||
b64_encode(md, out, SHA512_DIGEST_LEN);
|
||||
|
||||
strip_b64_eq(out);
|
||||
}
|
||||
|
||||
10
lib/digest.h
10
lib/digest.h
@ -43,11 +43,11 @@
|
||||
|
||||
/* Predefined base64 encoded digest sizes.
|
||||
*/
|
||||
#define MD5_B64_LENGTH 22
|
||||
#define SHA1_B64_LENGTH 27
|
||||
#define SHA256_B64_LENGTH 43
|
||||
#define SHA384_B64_LENGTH 64
|
||||
#define SHA512_B64_LENGTH 86
|
||||
#define MD5_B64_LEN 22
|
||||
#define SHA1_B64_LEN 27
|
||||
#define SHA256_B64_LEN 43
|
||||
#define SHA384_B64_LEN 64
|
||||
#define SHA512_B64_LEN 86
|
||||
|
||||
void md5(unsigned char* out, unsigned char* in, size_t size);
|
||||
void md5_hex(char* out, unsigned char* in, size_t size);
|
||||
|
||||
@ -61,27 +61,27 @@ fko_decode_spa_data(fko_ctx_t ctx)
|
||||
if (i < MIN_SPA_FIELDS)
|
||||
return(FKO_ERROR_INVALID_DATA);
|
||||
|
||||
t_size = strnlen(ndx, SHA512_B64_LENGTH+1);
|
||||
t_size = strnlen(ndx, SHA512_B64_LEN+1);
|
||||
|
||||
switch(t_size)
|
||||
{
|
||||
case MD5_B64_LENGTH:
|
||||
case MD5_B64_LEN:
|
||||
ctx->digest_type = FKO_DIGEST_MD5;
|
||||
break;
|
||||
|
||||
case SHA1_B64_LENGTH:
|
||||
case SHA1_B64_LEN:
|
||||
ctx->digest_type = FKO_DIGEST_SHA1;
|
||||
break;
|
||||
|
||||
case SHA256_B64_LENGTH:
|
||||
case SHA256_B64_LEN:
|
||||
ctx->digest_type = FKO_DIGEST_SHA256;
|
||||
break;
|
||||
|
||||
case SHA384_B64_LENGTH:
|
||||
case SHA384_B64_LEN:
|
||||
ctx->digest_type = FKO_DIGEST_SHA384;
|
||||
break;
|
||||
|
||||
case SHA512_B64_LENGTH:
|
||||
case SHA512_B64_LEN:
|
||||
ctx->digest_type = FKO_DIGEST_SHA512;
|
||||
break;
|
||||
|
||||
|
||||
@ -111,53 +111,53 @@ set_digest(char *data, char **digest, short digest_type, int *digest_len)
|
||||
switch(digest_type)
|
||||
{
|
||||
case FKO_DIGEST_MD5:
|
||||
md = malloc(MD_HEX_SIZE(MD5_DIGEST_LENGTH)+1);
|
||||
md = malloc(MD_HEX_SIZE(MD5_DIGEST_LEN)+1);
|
||||
if(md == NULL)
|
||||
return(FKO_ERROR_MEMORY_ALLOCATION);
|
||||
|
||||
md5_base64(md,
|
||||
(unsigned char*)data, data_len);
|
||||
*digest_len = MD5_B64_LENGTH;
|
||||
*digest_len = MD5_B64_LEN;
|
||||
break;
|
||||
|
||||
case FKO_DIGEST_SHA1:
|
||||
md = malloc(MD_HEX_SIZE(SHA1_DIGEST_LENGTH)+1);
|
||||
md = malloc(MD_HEX_SIZE(SHA1_DIGEST_LEN)+1);
|
||||
if(md == NULL)
|
||||
return(FKO_ERROR_MEMORY_ALLOCATION);
|
||||
|
||||
sha1_base64(md,
|
||||
(unsigned char*)data, data_len);
|
||||
*digest_len = SHA1_B64_LENGTH;
|
||||
*digest_len = SHA1_B64_LEN;
|
||||
break;
|
||||
|
||||
case FKO_DIGEST_SHA256:
|
||||
md = malloc(MD_HEX_SIZE(SHA256_DIGEST_LENGTH)+1);
|
||||
md = malloc(MD_HEX_SIZE(SHA256_DIGEST_LEN)+1);
|
||||
if(md == NULL)
|
||||
return(FKO_ERROR_MEMORY_ALLOCATION);
|
||||
|
||||
sha256_base64(md,
|
||||
(unsigned char*)data, data_len);
|
||||
*digest_len = SHA256_B64_LENGTH;
|
||||
*digest_len = SHA256_B64_LEN;
|
||||
break;
|
||||
|
||||
case FKO_DIGEST_SHA384:
|
||||
md = malloc(MD_HEX_SIZE(SHA384_DIGEST_LENGTH)+1);
|
||||
md = malloc(MD_HEX_SIZE(SHA384_DIGEST_LEN)+1);
|
||||
if(md == NULL)
|
||||
return(FKO_ERROR_MEMORY_ALLOCATION);
|
||||
|
||||
sha384_base64(md,
|
||||
(unsigned char*)data, data_len);
|
||||
*digest_len = SHA384_B64_LENGTH;
|
||||
*digest_len = SHA384_B64_LEN;
|
||||
break;
|
||||
|
||||
case FKO_DIGEST_SHA512:
|
||||
md = malloc(MD_HEX_SIZE(SHA512_DIGEST_LENGTH)+1);
|
||||
md = malloc(MD_HEX_SIZE(SHA512_DIGEST_LEN)+1);
|
||||
if(md == NULL)
|
||||
return(FKO_ERROR_MEMORY_ALLOCATION);
|
||||
|
||||
sha512_base64(md,
|
||||
(unsigned char*)data, data_len);
|
||||
*digest_len = SHA512_B64_LENGTH;
|
||||
*digest_len = SHA512_B64_LEN;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@ -353,13 +353,13 @@ int
|
||||
fko_key_gen(char *key_base64, char *hmac_key_base64)
|
||||
{
|
||||
unsigned char key[RIJNDAEL_MAX_KEYSIZE];
|
||||
unsigned char hmac_key[SHA256_BLOCK_LENGTH];
|
||||
unsigned char hmac_key[SHA256_BLOCK_LEN];
|
||||
|
||||
get_random_data(key, RIJNDAEL_MAX_KEYSIZE);
|
||||
get_random_data(hmac_key, SHA256_BLOCK_LENGTH);
|
||||
get_random_data(hmac_key, SHA256_BLOCK_LEN);
|
||||
|
||||
b64_encode(key, key_base64, RIJNDAEL_MAX_KEYSIZE);
|
||||
b64_encode(hmac_key, hmac_key_base64, SHA256_BLOCK_LENGTH);
|
||||
b64_encode(hmac_key, hmac_key_base64, SHA256_BLOCK_LEN);
|
||||
|
||||
return(FKO_SUCCESS);
|
||||
}
|
||||
|
||||
@ -52,21 +52,21 @@ int fko_verify_hmac(fko_ctx_t ctx,
|
||||
/* Get digest value
|
||||
*/
|
||||
hmac_digest_from_data = strndup((ctx->encrypted_msg
|
||||
+ ctx->encrypted_msg_len - SHA256_B64_LENGTH), SHA256_B64_LENGTH);
|
||||
+ ctx->encrypted_msg_len - SHA256_B64_LEN), SHA256_B64_LEN);
|
||||
|
||||
if(hmac_digest_from_data == NULL)
|
||||
return(FKO_ERROR_MEMORY_ALLOCATION);
|
||||
|
||||
/* Now we chop the HMAC digest off of the encrypted msg
|
||||
*/
|
||||
tbuf = strndup(ctx->encrypted_msg, ctx->encrypted_msg_len - SHA256_B64_LENGTH);
|
||||
tbuf = strndup(ctx->encrypted_msg, ctx->encrypted_msg_len - SHA256_B64_LEN);
|
||||
if(tbuf == NULL)
|
||||
return(FKO_ERROR_MEMORY_ALLOCATION);
|
||||
|
||||
free(ctx->encrypted_msg);
|
||||
|
||||
ctx->encrypted_msg = tbuf;
|
||||
ctx->encrypted_msg_len -= SHA256_B64_LENGTH;
|
||||
ctx->encrypted_msg_len -= SHA256_B64_LEN;
|
||||
|
||||
/* See if we need to add the "Salted__" string to the front of the
|
||||
* encrypted data.
|
||||
@ -88,7 +88,7 @@ int fko_verify_hmac(fko_ctx_t ctx,
|
||||
if(res == FKO_SUCCESS)
|
||||
{
|
||||
if(strncmp(hmac_digest_from_data,
|
||||
ctx->msg_hmac, SHA256_B64_LENGTH) != 0)
|
||||
ctx->msg_hmac, SHA256_B64_LEN) != 0)
|
||||
{
|
||||
res = FKO_ERROR_INVALID_DATA;
|
||||
}
|
||||
@ -136,7 +136,7 @@ fko_set_hmac_mode(fko_ctx_t ctx, const short hmac_mode)
|
||||
int fko_calculate_hmac(fko_ctx_t ctx,
|
||||
const char *hmac_key, const int hmac_key_len)
|
||||
{
|
||||
unsigned char hmac[SHA256_DIGEST_STRING_LENGTH] = {0};
|
||||
unsigned char hmac[SHA256_DIGEST_STR_LEN] = {0};
|
||||
char *hmac_base64 = NULL;
|
||||
|
||||
/* Must be initialized
|
||||
@ -149,18 +149,18 @@ int fko_calculate_hmac(fko_ctx_t ctx,
|
||||
if(ctx->hmac_mode != FKO_HMAC_SHA256)
|
||||
return(FKO_ERROR_UNSUPPORTED_HMAC_MODE);
|
||||
|
||||
hmac_base64 = calloc(1, MD_HEX_SIZE(SHA256_DIGEST_LENGTH)+1);
|
||||
hmac_base64 = calloc(1, MD_HEX_SIZE(SHA256_DIGEST_LEN)+1);
|
||||
if (hmac_base64 == NULL)
|
||||
return(FKO_ERROR_MEMORY_ALLOCATION);
|
||||
|
||||
hmac_sha256(ctx->encrypted_msg,
|
||||
ctx->encrypted_msg_len, hmac, hmac_key);
|
||||
|
||||
b64_encode(hmac, hmac_base64, SHA256_DIGEST_LENGTH);
|
||||
b64_encode(hmac, hmac_base64, SHA256_DIGEST_LEN);
|
||||
strip_b64_eq(hmac_base64);
|
||||
|
||||
ctx->msg_hmac = strdup(hmac_base64);
|
||||
ctx->msg_hmac_len = strnlen(ctx->msg_hmac, SHA512_DIGEST_STRING_LENGTH);
|
||||
ctx->msg_hmac_len = strnlen(ctx->msg_hmac, SHA512_DIGEST_STR_LEN);
|
||||
|
||||
free(hmac_base64);
|
||||
|
||||
|
||||
@ -60,15 +60,15 @@ is_valid_digest_len(const int len)
|
||||
{
|
||||
switch(len)
|
||||
{
|
||||
case MD5_B64_LENGTH:
|
||||
case MD5_B64_LEN:
|
||||
break;
|
||||
case SHA1_B64_LENGTH:
|
||||
case SHA1_B64_LEN:
|
||||
break;
|
||||
case SHA256_B64_LENGTH:
|
||||
case SHA256_B64_LEN:
|
||||
break;
|
||||
case SHA384_B64_LENGTH:
|
||||
case SHA384_B64_LEN:
|
||||
break;
|
||||
case SHA512_B64_LENGTH:
|
||||
case SHA512_B64_LEN:
|
||||
break;
|
||||
default:
|
||||
return(0);
|
||||
|
||||
10
lib/hmac.c
10
lib/hmac.c
@ -47,16 +47,16 @@ void hmac_sha256_init(hmac_sha256_ctx *ctx, const char *key)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i=0; i < (int) SHA256_BLOCK_LENGTH; i++) {
|
||||
for (i=0; i < (int) SHA256_BLOCK_LEN; i++) {
|
||||
ctx->block_inner_pad[i] = key[i] ^ 0x36;
|
||||
ctx->block_outer_pad[i] = key[i] ^ 0x5c;
|
||||
}
|
||||
|
||||
SHA256_Init(&ctx->ctx_inside);
|
||||
SHA256_Update(&ctx->ctx_inside, ctx->block_inner_pad, SHA256_BLOCK_LENGTH);
|
||||
SHA256_Update(&ctx->ctx_inside, ctx->block_inner_pad, SHA256_BLOCK_LEN);
|
||||
|
||||
SHA256_Init(&ctx->ctx_outside);
|
||||
SHA256_Update(&ctx->ctx_outside, ctx->block_outer_pad, SHA256_BLOCK_LENGTH);
|
||||
SHA256_Update(&ctx->ctx_outside, ctx->block_outer_pad, SHA256_BLOCK_LEN);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -70,10 +70,10 @@ void hmac_sha256_update(hmac_sha256_ctx *ctx, const char *msg,
|
||||
|
||||
void hmac_sha256_final(hmac_sha256_ctx *ctx, unsigned char *hmac)
|
||||
{
|
||||
unsigned char digest_inside[SHA256_DIGEST_LENGTH];
|
||||
unsigned char digest_inside[SHA256_DIGEST_LEN];
|
||||
|
||||
SHA256_Final(digest_inside, &ctx->ctx_inside);
|
||||
SHA256_Update(&ctx->ctx_outside, digest_inside, SHA256_DIGEST_LENGTH);
|
||||
SHA256_Update(&ctx->ctx_outside, digest_inside, SHA256_DIGEST_LEN);
|
||||
SHA256_Final(hmac, &ctx->ctx_outside);
|
||||
|
||||
return;
|
||||
|
||||
@ -37,8 +37,8 @@ typedef struct {
|
||||
SHA256_CTX ctx_inside;
|
||||
SHA256_CTX ctx_outside;
|
||||
|
||||
unsigned char block_inner_pad[SHA256_BLOCK_LENGTH];
|
||||
unsigned char block_outer_pad[SHA256_BLOCK_LENGTH];
|
||||
unsigned char block_inner_pad[SHA256_BLOCK_LEN];
|
||||
unsigned char block_outer_pad[SHA256_BLOCK_LEN];
|
||||
} hmac_sha256_ctx;
|
||||
|
||||
void hmac_sha256(const char *msg, const unsigned int msg_len,
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
#include "fko_common.h"
|
||||
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
#define MD5_DIGEST_LEN 16
|
||||
|
||||
typedef struct _MD5Context {
|
||||
uint32_t buf[4];
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
#endif
|
||||
|
||||
#define SHA1_BLOCKSIZE 64
|
||||
#define SHA1_DIGEST_LENGTH 20
|
||||
#define SHA1_DIGEST_LEN 20
|
||||
|
||||
typedef struct {
|
||||
uint32_t digest[8];
|
||||
@ -58,6 +58,6 @@ typedef struct {
|
||||
*/
|
||||
void sha1_init(SHA1_INFO *sha1_info);
|
||||
void sha1_update(SHA1_INFO *sha1_info, uint8_t *buffer, int count);
|
||||
void sha1_final(uint8_t digest[SHA1_DIGEST_LENGTH], SHA1_INFO *sha1_info);
|
||||
void sha1_final(uint8_t digest[SHA1_DIGEST_LEN], SHA1_INFO *sha1_info);
|
||||
|
||||
#endif /* SHA1_H */
|
||||
|
||||
106
lib/sha2.c
106
lib/sha2.c
@ -140,9 +140,9 @@ typedef u_int64_t sha2_word64; /* Exactly 8 bytes */
|
||||
|
||||
/*** SHA-256/384/512 Various Length Definitions ***********************/
|
||||
/* NOTE: Most of these are in sha2.h */
|
||||
#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8)
|
||||
#define SHA384_SHORT_BLOCK_LENGTH (SHA384_BLOCK_LENGTH - 16)
|
||||
#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16)
|
||||
#define SHA256_SHORT_BLOCK_LEN (SHA256_BLOCK_LEN - 8)
|
||||
#define SHA384_SHORT_BLOCK_LEN (SHA384_BLOCK_LEN - 16)
|
||||
#define SHA512_SHORT_BLOCK_LEN (SHA512_BLOCK_LEN - 16)
|
||||
|
||||
|
||||
/*** ENDIAN REVERSAL MACROS *******************************************/
|
||||
@ -357,8 +357,8 @@ void SHA256_Init(SHA256_CTX* context) {
|
||||
if (context == (SHA256_CTX*)0) {
|
||||
return;
|
||||
}
|
||||
MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA256_DIGEST_LENGTH);
|
||||
MEMSET_BZERO(context->buffer, SHA256_BLOCK_LENGTH);
|
||||
MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA256_DIGEST_LEN);
|
||||
MEMSET_BZERO(context->buffer, SHA256_BLOCK_LEN);
|
||||
context->bitcount = 0;
|
||||
}
|
||||
|
||||
@ -548,10 +548,10 @@ void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
|
||||
/* Sanity check: */
|
||||
assert(context != (SHA256_CTX*)0 && data != (sha2_byte*)0);
|
||||
|
||||
usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH;
|
||||
usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LEN;
|
||||
if (usedspace > 0) {
|
||||
/* Calculate how much free space is available in the buffer */
|
||||
freespace = SHA256_BLOCK_LENGTH - usedspace;
|
||||
freespace = SHA256_BLOCK_LEN - usedspace;
|
||||
|
||||
if (len >= freespace) {
|
||||
/* Fill the buffer completely and process it */
|
||||
@ -569,12 +569,12 @@ void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (len >= SHA256_BLOCK_LENGTH) {
|
||||
while (len >= SHA256_BLOCK_LEN) {
|
||||
/* Process as many complete blocks as we can */
|
||||
SHA256_Transform(context, (sha2_word32*)data);
|
||||
context->bitcount += SHA256_BLOCK_LENGTH << 3;
|
||||
len -= SHA256_BLOCK_LENGTH;
|
||||
data += SHA256_BLOCK_LENGTH;
|
||||
context->bitcount += SHA256_BLOCK_LEN << 3;
|
||||
len -= SHA256_BLOCK_LEN;
|
||||
data += SHA256_BLOCK_LEN;
|
||||
}
|
||||
if (len > 0) {
|
||||
/* There's left-overs, so save 'em */
|
||||
@ -594,7 +594,7 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
|
||||
|
||||
/* If no digest buffer is passed, we don't bother doing this: */
|
||||
if (digest != (sha2_byte*)0) {
|
||||
usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH;
|
||||
usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LEN;
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
/* Convert FROM host byte order */
|
||||
REVERSE64(context->bitcount,context->bitcount);
|
||||
@ -603,28 +603,28 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
|
||||
/* Begin padding with a 1 bit: */
|
||||
context->buffer[usedspace++] = 0x80;
|
||||
|
||||
if (usedspace <= SHA256_SHORT_BLOCK_LENGTH) {
|
||||
if (usedspace <= SHA256_SHORT_BLOCK_LEN) {
|
||||
/* Set-up for the last transform: */
|
||||
MEMSET_BZERO(&context->buffer[usedspace], SHA256_SHORT_BLOCK_LENGTH - usedspace);
|
||||
MEMSET_BZERO(&context->buffer[usedspace], SHA256_SHORT_BLOCK_LEN - usedspace);
|
||||
} else {
|
||||
if (usedspace < SHA256_BLOCK_LENGTH) {
|
||||
MEMSET_BZERO(&context->buffer[usedspace], SHA256_BLOCK_LENGTH - usedspace);
|
||||
if (usedspace < SHA256_BLOCK_LEN) {
|
||||
MEMSET_BZERO(&context->buffer[usedspace], SHA256_BLOCK_LEN - usedspace);
|
||||
}
|
||||
/* Do second-to-last transform: */
|
||||
SHA256_Transform(context, (sha2_word32*)context->buffer);
|
||||
|
||||
/* And set-up for the last transform: */
|
||||
MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH);
|
||||
MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LEN);
|
||||
}
|
||||
} else {
|
||||
/* Set-up for the last transform: */
|
||||
MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH);
|
||||
MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LEN);
|
||||
|
||||
/* Begin padding with a 1 bit: */
|
||||
*context->buffer = 0x80;
|
||||
}
|
||||
/* Set the bit count: */
|
||||
*(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
|
||||
*(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LEN] = context->bitcount;
|
||||
|
||||
/* Final transform: */
|
||||
SHA256_Transform(context, (sha2_word32*)context->buffer);
|
||||
@ -639,7 +639,7 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
|
||||
}
|
||||
}
|
||||
#else
|
||||
MEMCPY_BCOPY(d, context->state, SHA256_DIGEST_LENGTH);
|
||||
MEMCPY_BCOPY(d, context->state, SHA256_DIGEST_LEN);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -649,7 +649,7 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
|
||||
}
|
||||
|
||||
char *SHA256_End(SHA256_CTX* context, char buffer[]) {
|
||||
sha2_byte digest[SHA256_DIGEST_LENGTH], *d = digest;
|
||||
sha2_byte digest[SHA256_DIGEST_LEN], *d = digest;
|
||||
int i;
|
||||
|
||||
/* Sanity check: */
|
||||
@ -658,7 +658,7 @@ char *SHA256_End(SHA256_CTX* context, char buffer[]) {
|
||||
if (buffer != (char*)0) {
|
||||
SHA256_Final(digest, context);
|
||||
|
||||
for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
|
||||
for (i = 0; i < SHA256_DIGEST_LEN; i++) {
|
||||
*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
|
||||
*buffer++ = sha2_hex_digits[*d & 0x0f];
|
||||
d++;
|
||||
@ -667,11 +667,11 @@ char *SHA256_End(SHA256_CTX* context, char buffer[]) {
|
||||
} else {
|
||||
MEMSET_BZERO(context, sizeof(context));
|
||||
}
|
||||
MEMSET_BZERO(digest, SHA256_DIGEST_LENGTH);
|
||||
MEMSET_BZERO(digest, SHA256_DIGEST_LEN);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char* SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) {
|
||||
char* SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STR_LEN]) {
|
||||
SHA256_CTX context;
|
||||
|
||||
SHA256_Init(&context);
|
||||
@ -685,8 +685,8 @@ void SHA512_Init(SHA512_CTX* context) {
|
||||
if (context == (SHA512_CTX*)0) {
|
||||
return;
|
||||
}
|
||||
MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH);
|
||||
MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH);
|
||||
MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LEN);
|
||||
MEMSET_BZERO(context->buffer, SHA512_BLOCK_LEN);
|
||||
context->bitcount[0] = context->bitcount[1] = 0;
|
||||
}
|
||||
|
||||
@ -870,10 +870,10 @@ void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
|
||||
/* Sanity check: */
|
||||
assert(context != (SHA512_CTX*)0 && data != (sha2_byte*)0);
|
||||
|
||||
usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH;
|
||||
usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LEN;
|
||||
if (usedspace > 0) {
|
||||
/* Calculate how much free space is available in the buffer */
|
||||
freespace = SHA512_BLOCK_LENGTH - usedspace;
|
||||
freespace = SHA512_BLOCK_LEN - usedspace;
|
||||
|
||||
if (len >= freespace) {
|
||||
/* Fill the buffer completely and process it */
|
||||
@ -891,12 +891,12 @@ void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (len >= SHA512_BLOCK_LENGTH) {
|
||||
while (len >= SHA512_BLOCK_LEN) {
|
||||
/* Process as many complete blocks as we can */
|
||||
SHA512_Transform(context, (sha2_word64*)data);
|
||||
ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3);
|
||||
len -= SHA512_BLOCK_LENGTH;
|
||||
data += SHA512_BLOCK_LENGTH;
|
||||
ADDINC128(context->bitcount, SHA512_BLOCK_LEN << 3);
|
||||
len -= SHA512_BLOCK_LEN;
|
||||
data += SHA512_BLOCK_LEN;
|
||||
}
|
||||
if (len > 0) {
|
||||
/* There's left-overs, so save 'em */
|
||||
@ -910,7 +910,7 @@ void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
|
||||
void SHA512_Last(SHA512_CTX* context) {
|
||||
unsigned int usedspace;
|
||||
|
||||
usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH;
|
||||
usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LEN;
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
/* Convert FROM host byte order */
|
||||
REVERSE64(context->bitcount[0],context->bitcount[0]);
|
||||
@ -920,29 +920,29 @@ void SHA512_Last(SHA512_CTX* context) {
|
||||
/* Begin padding with a 1 bit: */
|
||||
context->buffer[usedspace++] = 0x80;
|
||||
|
||||
if (usedspace <= SHA512_SHORT_BLOCK_LENGTH) {
|
||||
if (usedspace <= SHA512_SHORT_BLOCK_LEN) {
|
||||
/* Set-up for the last transform: */
|
||||
MEMSET_BZERO(&context->buffer[usedspace], SHA512_SHORT_BLOCK_LENGTH - usedspace);
|
||||
MEMSET_BZERO(&context->buffer[usedspace], SHA512_SHORT_BLOCK_LEN - usedspace);
|
||||
} else {
|
||||
if (usedspace < SHA512_BLOCK_LENGTH) {
|
||||
MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace);
|
||||
if (usedspace < SHA512_BLOCK_LEN) {
|
||||
MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LEN - usedspace);
|
||||
}
|
||||
/* Do second-to-last transform: */
|
||||
SHA512_Transform(context, (sha2_word64*)context->buffer);
|
||||
|
||||
/* And set-up for the last transform: */
|
||||
MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH - 2);
|
||||
MEMSET_BZERO(context->buffer, SHA512_BLOCK_LEN - 2);
|
||||
}
|
||||
} else {
|
||||
/* Prepare for final transform: */
|
||||
MEMSET_BZERO(context->buffer, SHA512_SHORT_BLOCK_LENGTH);
|
||||
MEMSET_BZERO(context->buffer, SHA512_SHORT_BLOCK_LEN);
|
||||
|
||||
/* Begin padding with a 1 bit: */
|
||||
*context->buffer = 0x80;
|
||||
}
|
||||
/* Store the length of input data (in bits): */
|
||||
*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
|
||||
*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];
|
||||
*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LEN] = context->bitcount[1];
|
||||
*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LEN+8] = context->bitcount[0];
|
||||
|
||||
/* Final transform: */
|
||||
SHA512_Transform(context, (sha2_word64*)context->buffer);
|
||||
@ -969,7 +969,7 @@ void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
|
||||
}
|
||||
}
|
||||
#else
|
||||
MEMCPY_BCOPY(d, context->state, SHA512_DIGEST_LENGTH);
|
||||
MEMCPY_BCOPY(d, context->state, SHA512_DIGEST_LEN);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -978,7 +978,7 @@ void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
|
||||
}
|
||||
|
||||
char *SHA512_End(SHA512_CTX* context, char buffer[]) {
|
||||
sha2_byte digest[SHA512_DIGEST_LENGTH], *d = digest;
|
||||
sha2_byte digest[SHA512_DIGEST_LEN], *d = digest;
|
||||
int i;
|
||||
|
||||
/* Sanity check: */
|
||||
@ -987,7 +987,7 @@ char *SHA512_End(SHA512_CTX* context, char buffer[]) {
|
||||
if (buffer != (char*)0) {
|
||||
SHA512_Final(digest, context);
|
||||
|
||||
for (i = 0; i < SHA512_DIGEST_LENGTH; i++) {
|
||||
for (i = 0; i < SHA512_DIGEST_LEN; i++) {
|
||||
*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
|
||||
*buffer++ = sha2_hex_digits[*d & 0x0f];
|
||||
d++;
|
||||
@ -996,11 +996,11 @@ char *SHA512_End(SHA512_CTX* context, char buffer[]) {
|
||||
} else {
|
||||
MEMSET_BZERO(context, sizeof(context));
|
||||
}
|
||||
MEMSET_BZERO(digest, SHA512_DIGEST_LENGTH);
|
||||
MEMSET_BZERO(digest, SHA512_DIGEST_LEN);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char* SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) {
|
||||
char* SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STR_LEN]) {
|
||||
SHA512_CTX context;
|
||||
|
||||
SHA512_Init(&context);
|
||||
@ -1014,8 +1014,8 @@ void SHA384_Init(SHA384_CTX* context) {
|
||||
if (context == (SHA384_CTX*)0) {
|
||||
return;
|
||||
}
|
||||
MEMCPY_BCOPY(context->state, sha384_initial_hash_value, SHA512_DIGEST_LENGTH);
|
||||
MEMSET_BZERO(context->buffer, SHA384_BLOCK_LENGTH);
|
||||
MEMCPY_BCOPY(context->state, sha384_initial_hash_value, SHA512_DIGEST_LEN);
|
||||
MEMSET_BZERO(context->buffer, SHA384_BLOCK_LEN);
|
||||
context->bitcount[0] = context->bitcount[1] = 0;
|
||||
}
|
||||
|
||||
@ -1044,7 +1044,7 @@ void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
|
||||
}
|
||||
}
|
||||
#else
|
||||
MEMCPY_BCOPY(d, context->state, SHA384_DIGEST_LENGTH);
|
||||
MEMCPY_BCOPY(d, context->state, SHA384_DIGEST_LEN);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1053,7 +1053,7 @@ void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
|
||||
}
|
||||
|
||||
char *SHA384_End(SHA384_CTX* context, char buffer[]) {
|
||||
sha2_byte digest[SHA384_DIGEST_LENGTH], *d = digest;
|
||||
sha2_byte digest[SHA384_DIGEST_LEN], *d = digest;
|
||||
int i;
|
||||
|
||||
/* Sanity check: */
|
||||
@ -1062,7 +1062,7 @@ char *SHA384_End(SHA384_CTX* context, char buffer[]) {
|
||||
if (buffer != (char*)0) {
|
||||
SHA384_Final(digest, context);
|
||||
|
||||
for (i = 0; i < SHA384_DIGEST_LENGTH; i++) {
|
||||
for (i = 0; i < SHA384_DIGEST_LEN; i++) {
|
||||
*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
|
||||
*buffer++ = sha2_hex_digits[*d & 0x0f];
|
||||
d++;
|
||||
@ -1071,11 +1071,11 @@ char *SHA384_End(SHA384_CTX* context, char buffer[]) {
|
||||
} else {
|
||||
MEMSET_BZERO(context, sizeof(context));
|
||||
}
|
||||
MEMSET_BZERO(digest, SHA384_DIGEST_LENGTH);
|
||||
MEMSET_BZERO(digest, SHA384_DIGEST_LEN);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char* SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) {
|
||||
char* SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STR_LEN]) {
|
||||
SHA384_CTX context;
|
||||
|
||||
SHA384_Init(&context);
|
||||
|
||||
62
lib/sha2.h
62
lib/sha2.h
@ -67,15 +67,15 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/*** SHA-256/384/512 Various Length Definitions ***********************/
|
||||
#define SHA256_BLOCK_LENGTH 64
|
||||
#define SHA256_DIGEST_LENGTH 32
|
||||
#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
|
||||
#define SHA384_BLOCK_LENGTH 128
|
||||
#define SHA384_DIGEST_LENGTH 48
|
||||
#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
|
||||
#define SHA512_BLOCK_LENGTH 128
|
||||
#define SHA512_DIGEST_LENGTH 64
|
||||
#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
|
||||
#define SHA256_BLOCK_LEN 64
|
||||
#define SHA256_DIGEST_LEN 32
|
||||
#define SHA256_DIGEST_STR_LEN (SHA256_DIGEST_LEN * 2 + 1)
|
||||
#define SHA384_BLOCK_LEN 128
|
||||
#define SHA384_DIGEST_LEN 48
|
||||
#define SHA384_DIGEST_STR_LEN (SHA384_DIGEST_LEN * 2 + 1)
|
||||
#define SHA512_BLOCK_LEN 128
|
||||
#define SHA512_DIGEST_LEN 64
|
||||
#define SHA512_DIGEST_STR_LEN (SHA512_DIGEST_LEN * 2 + 1)
|
||||
|
||||
|
||||
/*** SHA-256/384/512 Context Structures *******************************/
|
||||
@ -109,12 +109,12 @@ typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */
|
||||
typedef struct _SHA256_CTX {
|
||||
uint32_t state[8];
|
||||
uint64_t bitcount;
|
||||
uint8_t buffer[SHA256_BLOCK_LENGTH];
|
||||
uint8_t buffer[SHA256_BLOCK_LEN];
|
||||
} SHA256_CTX;
|
||||
typedef struct _SHA512_CTX {
|
||||
uint64_t state[8];
|
||||
uint64_t bitcount[2];
|
||||
uint8_t buffer[SHA512_BLOCK_LENGTH];
|
||||
uint8_t buffer[SHA512_BLOCK_LEN];
|
||||
} SHA512_CTX;
|
||||
|
||||
#else /* SHA2_USE_INTTYPES_H */
|
||||
@ -122,12 +122,12 @@ typedef struct _SHA512_CTX {
|
||||
typedef struct _SHA256_CTX {
|
||||
u_int32_t state[8];
|
||||
u_int64_t bitcount;
|
||||
u_int8_t buffer[SHA256_BLOCK_LENGTH];
|
||||
u_int8_t buffer[SHA256_BLOCK_LEN];
|
||||
} SHA256_CTX;
|
||||
typedef struct _SHA512_CTX {
|
||||
u_int64_t state[8];
|
||||
u_int64_t bitcount[2];
|
||||
u_int8_t buffer[SHA512_BLOCK_LENGTH];
|
||||
u_int8_t buffer[SHA512_BLOCK_LEN];
|
||||
} SHA512_CTX;
|
||||
|
||||
#endif /* SHA2_USE_INTTYPES_H */
|
||||
@ -141,41 +141,41 @@ typedef SHA512_CTX SHA384_CTX;
|
||||
|
||||
void SHA256_Init(SHA256_CTX *);
|
||||
void SHA256_Update(SHA256_CTX*, const uint8_t*, size_t);
|
||||
void SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
|
||||
char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
|
||||
char* SHA256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
|
||||
void SHA256_Final(uint8_t[SHA256_DIGEST_LEN], SHA256_CTX*);
|
||||
char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STR_LEN]);
|
||||
char* SHA256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STR_LEN]);
|
||||
|
||||
void SHA384_Init(SHA384_CTX*);
|
||||
void SHA384_Update(SHA384_CTX*, const uint8_t*, size_t);
|
||||
void SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
|
||||
char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
|
||||
char* SHA384_Data(const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
|
||||
void SHA384_Final(uint8_t[SHA384_DIGEST_LEN], SHA384_CTX*);
|
||||
char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STR_LEN]);
|
||||
char* SHA384_Data(const uint8_t*, size_t, char[SHA384_DIGEST_STR_LEN]);
|
||||
|
||||
void SHA512_Init(SHA512_CTX*);
|
||||
void SHA512_Update(SHA512_CTX*, const uint8_t*, size_t);
|
||||
void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
|
||||
char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
|
||||
char* SHA512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
|
||||
void SHA512_Final(uint8_t[SHA512_DIGEST_LEN], SHA512_CTX*);
|
||||
char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STR_LEN]);
|
||||
char* SHA512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STR_LEN]);
|
||||
|
||||
#else /* SHA2_USE_INTTYPES_H */
|
||||
|
||||
void SHA256_Init(SHA256_CTX *);
|
||||
void SHA256_Update(SHA256_CTX*, const u_int8_t*, size_t);
|
||||
void SHA256_Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
|
||||
char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
|
||||
char* SHA256_Data(const u_int8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
|
||||
void SHA256_Final(u_int8_t[SHA256_DIGEST_LEN], SHA256_CTX*);
|
||||
char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STR_LEN]);
|
||||
char* SHA256_Data(const u_int8_t*, size_t, char[SHA256_DIGEST_STR_LEN]);
|
||||
|
||||
void SHA384_Init(SHA384_CTX*);
|
||||
void SHA384_Update(SHA384_CTX*, const u_int8_t*, size_t);
|
||||
void SHA384_Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
|
||||
char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
|
||||
char* SHA384_Data(const u_int8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
|
||||
void SHA384_Final(u_int8_t[SHA384_DIGEST_LEN], SHA384_CTX*);
|
||||
char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STR_LEN]);
|
||||
char* SHA384_Data(const u_int8_t*, size_t, char[SHA384_DIGEST_STR_LEN]);
|
||||
|
||||
void SHA512_Init(SHA512_CTX*);
|
||||
void SHA512_Update(SHA512_CTX*, const u_int8_t*, size_t);
|
||||
void SHA512_Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
|
||||
char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
|
||||
char* SHA512_Data(const u_int8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
|
||||
void SHA512_Final(u_int8_t[SHA512_DIGEST_LEN], SHA512_CTX*);
|
||||
char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STR_LEN]);
|
||||
char* SHA512_Data(const u_int8_t*, size_t, char[SHA512_DIGEST_STR_LEN]);
|
||||
|
||||
#endif /* SHA2_USE_INTTYPES_H */
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user