]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
SHA: only renamed hd -> ctx
authorPavel Tvrdík <pawel.tvrdik@gmail.cz>
Tue, 12 May 2015 10:24:28 +0000 (12:24 +0200)
committerPavel Tvrdík <pawel.tvrdik@gmail.cz>
Tue, 12 May 2015 10:24:28 +0000 (12:24 +0200)
lib/sha1.c
lib/sha256.c
lib/sha512.c

index 5589b086fc90218db1f006387f7b20cddf58054b..fff37ff6fa0800a16a3ee71a7284c68b230ff790 100644 (file)
@@ -274,15 +274,15 @@ sha1_final(sha1_context *hd)
 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];
 
@@ -299,34 +299,34 @@ sha1_hmac_init(sha1_hmac_context *hd, const byte *key, uint keylen)
   }
 
   // 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
index f7be5b89f774e7356fccc2407db57d736a90d748..8bf1739529da1de82cfb1035174011774eff04fa 100644 (file)
@@ -393,14 +393,14 @@ void sha256_hmac_update(sha256_hmac_context *ctx, const byte *buf, size_t buflen
   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);
 }
 
 /**
@@ -454,12 +454,12 @@ void sha224_hmac_update(sha224_hmac_context *ctx, const byte *buf, size_t buflen
   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);
 }
index 25066eaff6cb778bbe82f461a822b7c34a718dc5..e3e3582361a107563f5768610e453867d9c36652 100644 (file)
@@ -543,14 +543,14 @@ void sha512_hmac_update(sha512_hmac_context *ctx, const byte *buf, size_t buflen
   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);
 }
 
 /**
@@ -604,12 +604,12 @@ void sha384_hmac_update(sha384_hmac_context *ctx, const byte *buf, size_t buflen
   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);
 }