diff options
author | Matt Caswell <matt@openssl.org> | 2016-11-08 11:48:33 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-11-09 10:36:54 +0000 |
commit | ddd2c38917976da07ce0dfcd0bf3f3826c94051c (patch) | |
tree | 5a900b523987dfcbad58828f18615de43f12ff96 /crypto/kdf | |
parent | d2139cf8dffcfe4a936ef55d25f769b162a8c603 (diff) |
Following the changes to HKDF to accept a mode, add some tests for this
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/kdf')
-rw-r--r-- | crypto/kdf/hkdf.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crypto/kdf/hkdf.c b/crypto/kdf/hkdf.c index 0bcb1c2f05..8b6eeb3bde 100644 --- a/crypto/kdf/hkdf.c +++ b/crypto/kdf/hkdf.c @@ -133,6 +133,21 @@ static int pkey_hkdf_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) static int pkey_hkdf_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { + if (strcmp(type, "mode") == 0) { + int mode; + + if (strcmp(value, "EXTRACT_AND_EXPAND") == 0) + mode = EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND; + else if (strcmp(value, "EXTRACT_ONLY") == 0) + mode = EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY; + else if (strcmp(value, "EXPAND_ONLY") == 0) + mode = EVP_PKEY_HKDEF_MODE_EXPAND_ONLY; + else + return 0; + + return EVP_PKEY_CTX_hkdf_mode(ctx, mode); + } + if (strcmp(type, "md") == 0) return EVP_PKEY_CTX_set_hkdf_md(ctx, EVP_get_digestbyname(value)); |