Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-03-01 05:56:12 +0300
committerAdam Langley <agl@google.com>2015-03-03 02:16:12 +0300
commit23721e3705bd92789238cc1753642730111ae9ce (patch)
treeb1e6760df1c2623a0b858fc39d92338e3d036416 /include/openssl/hmac.h
parentcc239d3903f908fff2933f379577cf8f57482a09 (diff)
Forbid reusing HMAC key without reusing the hash function.
There's no good reason to do this, and it doesn't work; HMAC checks the length of the key and runs it through the hash function if too long. The reuse occurs after this check. This allows us to shave 132 bytes off HMAC_CTX as this was the only reason it ever stored the original key. It also slightly simplifies HMAC_Init_ex's logic. Change-Id: Ib56aabc3630b7178f1ee7c38ef6370c9638efbab Reviewed-on: https://boringssl-review.googlesource.com/3733 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'include/openssl/hmac.h')
-rw-r--r--include/openssl/hmac.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/include/openssl/hmac.h b/include/openssl/hmac.h
index 6c34cdc3..89cdf8f0 100644
--- a/include/openssl/hmac.h
+++ b/include/openssl/hmac.h
@@ -94,9 +94,14 @@ OPENSSL_EXPORT void HMAC_CTX_init(HMAC_CTX *ctx);
OPENSSL_EXPORT void HMAC_CTX_cleanup(HMAC_CTX *ctx);
/* HMAC_Init_ex sets up an initialised |HMAC_CTX| to use |md| as the hash
- * function and |key| as the key. Any of |md| or |key| can be NULL, in which
- * case the previous value will be used. It returns one on success or zero
- * otherwise. */
+ * function and |key| as the key. For a non-initial call, |md| may be NULL, in
+ * which case the previous hash function will be used. If the hash function has
+ * not changed and |key| is NULL, |ctx| reuses the previous key. It returns one
+ * on success or zero otherwise.
+ *
+ * WARNING: NULL and empty keys are ambiguous on non-initial calls. Passing NULL
+ * |key| but repeating the previous |md| reuses the previous key rather than the
+ * empty key. */
OPENSSL_EXPORT int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, size_t key_len,
const EVP_MD *md, ENGINE *impl);
@@ -152,8 +157,6 @@ struct hmac_ctx_st {
EVP_MD_CTX md_ctx;
EVP_MD_CTX i_ctx;
EVP_MD_CTX o_ctx;
- unsigned int key_length;
- unsigned char key[HMAC_MAX_MD_CBLOCK];
} /* HMAC_CTX */;