void
sha1_hash_buffer(byte *outbuf, const byte *buffer, uint length)
{
- sha1_context hd;
+ sha1_context ctx;
- sha1_init(&hd);
- sha1_update(&hd, buffer, length);
- memcpy(outbuf, sha1_final(&hd), SHA1_SIZE);
+ sha1_init(&ctx);
+ sha1_update(&ctx, buffer, length);
+ memcpy(outbuf, sha1_final(&ctx), SHA1_SIZE);
}
void
-sha1_hmac_init(sha1_hmac_context *hd, const byte *key, uint keylen)
+sha1_hmac_init(sha1_hmac_context *ctx, const byte *key, uint keylen)
{
byte keybuf[SHA1_BLOCK_SIZE], buf[SHA1_BLOCK_SIZE];
}
// Initialize the inner digest
- sha1_init(&hd->ictx);
+ sha1_init(&ctx->ictx);
int i;
for (i = 0; i < SHA1_BLOCK_SIZE; i++)
buf[i] = keybuf[i] ^ 0x36;
- sha1_update(&hd->ictx, buf, SHA1_BLOCK_SIZE);
+ sha1_update(&ctx->ictx, buf, SHA1_BLOCK_SIZE);
// Initialize the outer digest
- sha1_init(&hd->octx);
+ sha1_init(&ctx->octx);
for (i = 0; i < SHA1_BLOCK_SIZE; i++)
buf[i] = keybuf[i] ^ 0x5c;
- sha1_update(&hd->octx, buf, SHA1_BLOCK_SIZE);
+ sha1_update(&ctx->octx, buf, SHA1_BLOCK_SIZE);
}
void
-sha1_hmac_update(sha1_hmac_context *hd, const byte *data, uint datalen)
+sha1_hmac_update(sha1_hmac_context *ctx, const byte *data, uint datalen)
{
// Just update the inner digest
- sha1_update(&hd->ictx, data, datalen);
+ sha1_update(&ctx->ictx, data, datalen);
}
-byte *sha1_hmac_final(sha1_hmac_context *hd)
+byte *sha1_hmac_final(sha1_hmac_context *ctx)
{
// Finish the inner digest
- byte *isha = sha1_final(&hd->ictx);
+ byte *isha = sha1_final(&ctx->ictx);
// Finish the outer digest
- sha1_update(&hd->octx, isha, SHA1_SIZE);
- return sha1_final(&hd->octx);
+ sha1_update(&ctx->octx, isha, SHA1_SIZE);
+ return sha1_final(&ctx->octx);
}
void
sha256_update(&ctx->ictx, buf, buflen);
}
-byte *sha256_hmac_final(sha256_hmac_context *hd)
+byte *sha256_hmac_final(sha256_hmac_context *ctx)
{
// Finish the inner digest
- byte *isha = sha256_final(&hd->ictx);
+ byte *isha = sha256_final(&ctx->ictx);
// Finish the outer digest
- sha256_update(&hd->octx, isha, SHA256_SIZE);
- return sha256_final(&hd->octx);
+ sha256_update(&ctx->octx, isha, SHA256_SIZE);
+ return sha256_final(&ctx->octx);
}
/**
sha256_update(&ctx->ictx, buf, buflen);
}
-byte *sha224_hmac_final(sha224_hmac_context *hd)
+byte *sha224_hmac_final(sha224_hmac_context *ctx)
{
// Finish the inner digest
- byte *isha = sha224_final(&hd->ictx);
+ byte *isha = sha224_final(&ctx->ictx);
// Finish the outer digest
- sha224_update(&hd->octx, isha, SHA224_SIZE);
- return sha224_final(&hd->octx);
+ sha224_update(&ctx->octx, isha, SHA224_SIZE);
+ return sha224_final(&ctx->octx);
}
sha512_update(&ctx->ictx, buf, buflen);
}
-byte *sha512_hmac_final(sha512_hmac_context *hd)
+byte *sha512_hmac_final(sha512_hmac_context *ctx)
{
// Finish the inner digest
- byte *isha = sha512_final(&hd->ictx);
+ byte *isha = sha512_final(&ctx->ictx);
// Finish the outer digest
- sha512_update(&hd->octx, isha, SHA512_SIZE);
- return sha512_final(&hd->octx);
+ sha512_update(&ctx->octx, isha, SHA512_SIZE);
+ return sha512_final(&ctx->octx);
}
/**
sha384_update(&ctx->ictx, buf, buflen);
}
-byte *sha384_hmac_final(sha384_hmac_context *hd)
+byte *sha384_hmac_final(sha384_hmac_context *ctx)
{
// Finish the inner digest
- byte *isha = sha384_final(&hd->ictx);
+ byte *isha = sha384_final(&ctx->ictx);
// Finish the outer digest
- sha384_update(&hd->octx, isha, SHA384_SIZE);
- return sha384_final(&hd->octx);
+ sha384_update(&ctx->octx, isha, SHA384_SIZE);
+ return sha384_final(&ctx->octx);
}