Adapt HMAC to the EVP_MD_CTX changes

This change required some special treatment, as HMAC is intertwined
with EVP_MD.  For now, all local HMAC_CTX variables MUST be
initialised with HMAC_CTX_EMPTY, or whatever happens to be on the
stack will be mistaken for actual pointers to EVP_MD_CTX.  This will
change as soon as HMAC_CTX becomes opaque.

Also, since HMAC_CTX_init() can fail now, its return type changes from
void to int, and it will return 0 on failure, 1 on success.

Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
Richard Levitte
2015-11-27 14:10:15 +01:00
parent 77a01145be
commit fa0c23de83
10 changed files with 70 additions and 44 deletions

View File

@@ -77,9 +77,10 @@ typedef struct hmac_ctx_st {
unsigned char key[HMAC_MAX_MD_CBLOCK];
} HMAC_CTX;
# define HMAC_CTX_EMPTY { NULL, NULL, NULL, NULL, 0, "" }
# define HMAC_size(e) (EVP_MD_size((e)->md))
void HMAC_CTX_init(HMAC_CTX *ctx);
int HMAC_CTX_init(HMAC_CTX *ctx);
void HMAC_CTX_cleanup(HMAC_CTX *ctx);
#ifdef OPENSSL_USE_DEPRECATED