|
|
9b88be |
diff -up openssl-1.1.1d/crypto/err/openssl.txt.krb5-kdf openssl-1.1.1d/crypto/err/openssl.txt
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/err/openssl.txt.krb5-kdf 2019-11-14 15:07:05.320094521 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/err/openssl.txt 2019-11-14 15:07:05.342094129 +0100
|
|
|
9b88be |
@@ -821,6 +821,11 @@ EVP_F_S390X_AES_GCM_CTRL:201:s390x_aes_g
|
|
|
9b88be |
EVP_F_SCRYPT_ALG:228:scrypt_alg
|
|
|
9b88be |
EVP_F_UPDATE:173:update
|
|
|
9b88be |
KDF_F_HKDF_EXTRACT:112:HKDF_Extract
|
|
|
9b88be |
+KDF_F_KBKDF_CTRL:134:kbkdf_ctrl
|
|
|
9b88be |
+KDF_F_KBKDF_CTRL_STR:135:kbkdf_ctrl_str
|
|
|
9b88be |
+KDF_F_KBKDF_DERIVE:136:kbkdf_derive
|
|
|
9b88be |
+KDF_F_KBKDF_NEW:137:kbkdf_new
|
|
|
9b88be |
+KDF_F_KDF_CIPHER2CTRL:138:kdf_cipher2ctrl
|
|
|
9b88be |
KDF_F_KDF_HKDF_DERIVE:113:kdf_hkdf_derive
|
|
|
9b88be |
KDF_F_KDF_HKDF_NEW:114:kdf_hkdf_new
|
|
|
9b88be |
KDF_F_KDF_HKDF_SIZE:115:kdf_hkdf_size
|
|
|
9b88be |
@@ -840,6 +845,8 @@ KDF_F_KDF_SSHKDF_NEW:133:kdf_sshkdf_new
|
|
|
9b88be |
KDF_F_KDF_TLS1_PRF_CTRL_STR:125:kdf_tls1_prf_ctrl_str
|
|
|
9b88be |
KDF_F_KDF_TLS1_PRF_DERIVE:126:kdf_tls1_prf_derive
|
|
|
9b88be |
KDF_F_KDF_TLS1_PRF_NEW:127:kdf_tls1_prf_new
|
|
|
9b88be |
+KDF_F_KRB5KDF:139:KRB5KDF
|
|
|
9b88be |
+KDF_F_KRB5KDF_DERIVE:140:krb5kdf_derive
|
|
|
9b88be |
KDF_F_PBKDF2_SET_MEMBUF:128:pbkdf2_set_membuf
|
|
|
9b88be |
KDF_F_PKEY_HKDF_CTRL_STR:103:pkey_hkdf_ctrl_str
|
|
|
9b88be |
KDF_F_PKEY_HKDF_DERIVE:102:pkey_hkdf_derive
|
|
|
9b88be |
@@ -853,6 +860,9 @@ KDF_F_PKEY_TLS1_PRF_CTRL_STR:100:pkey_tl
|
|
|
9b88be |
KDF_F_PKEY_TLS1_PRF_DERIVE:101:pkey_tls1_prf_derive
|
|
|
9b88be |
KDF_F_PKEY_TLS1_PRF_INIT:110:pkey_tls1_prf_init
|
|
|
9b88be |
KDF_F_SCRYPT_SET_MEMBUF:129:scrypt_set_membuf
|
|
|
9b88be |
+KDF_F_SSKDF_DERIVE:141:sskdf_derive
|
|
|
9b88be |
+KDF_F_SSKDF_NEW:142:sskdf_new
|
|
|
9b88be |
+KDF_F_SSKDF_SIZE:143:sskdf_size
|
|
|
9b88be |
KDF_F_TLS1_PRF_ALG:111:tls1_prf_alg
|
|
|
9b88be |
OBJ_F_OBJ_ADD_OBJECT:105:OBJ_add_object
|
|
|
9b88be |
OBJ_F_OBJ_ADD_SIGID:107:OBJ_add_sigid
|
|
|
9b88be |
@@ -2325,7 +2335,13 @@ EVP_R_UNSUPPORTED_SALT_TYPE:126:unsuppor
|
|
|
9b88be |
EVP_R_WRAP_MODE_NOT_ALLOWED:170:wrap mode not allowed
|
|
|
9b88be |
EVP_R_WRONG_FINAL_BLOCK_LENGTH:109:wrong final block length
|
|
|
9b88be |
EVP_R_XTS_DUPLICATED_KEYS:183:xts duplicated keys
|
|
|
9b88be |
+KDF_R_FAILED_TO_GENERATE_KEY:118:failed to generate key
|
|
|
9b88be |
+KDF_R_INVALID_CIPHER:116:invalid cipher
|
|
|
9b88be |
+KDF_R_INVALID_CONSTANT_LENGTH:119:invalid constant length
|
|
|
9b88be |
KDF_R_INVALID_DIGEST:100:invalid digest
|
|
|
9b88be |
+KDF_R_INVALID_SEED_LENGTH:117:invalid seed length
|
|
|
9b88be |
+KDF_R_MISSING_CIPHER:120:missing cipher
|
|
|
9b88be |
+KDF_R_MISSING_CONSTANT:121:missing constant
|
|
|
9b88be |
KDF_R_MISSING_ITERATION_COUNT:109:missing iteration count
|
|
|
9b88be |
KDF_R_MISSING_KEY:104:missing key
|
|
|
9b88be |
KDF_R_MISSING_MESSAGE_DIGEST:105:missing message digest
|
|
|
9b88be |
@@ -2340,6 +2356,7 @@ KDF_R_MISSING_XCGHASH:115:missing xcghas
|
|
|
9b88be |
KDF_R_UNKNOWN_PARAMETER_TYPE:103:unknown parameter type
|
|
|
9b88be |
KDF_R_VALUE_ERROR:108:value error
|
|
|
9b88be |
KDF_R_VALUE_MISSING:102:value missing
|
|
|
9b88be |
+KDF_R_WRONG_FINAL_BLOCK_LENGTH:120:wrong final block length
|
|
|
9b88be |
KDF_R_WRONG_OUTPUT_BUFFER_SIZE:112:wrong output buffer size
|
|
|
9b88be |
OBJ_R_OID_EXISTS:102:oid exists
|
|
|
9b88be |
OBJ_R_UNKNOWN_NID:101:unknown nid
|
|
|
9b88be |
diff -up openssl-1.1.1d/crypto/evp/kdf_lib.c.krb5-kdf openssl-1.1.1d/crypto/evp/kdf_lib.c
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/evp/kdf_lib.c.krb5-kdf 2019-11-14 15:07:05.320094521 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/evp/kdf_lib.c 2019-11-14 15:07:05.342094129 +0100
|
|
|
9b88be |
@@ -31,6 +31,9 @@ static const EVP_KDF_METHOD *standard_me
|
|
|
9b88be |
&tls1_prf_kdf_meth,
|
|
|
9b88be |
&hkdf_kdf_meth,
|
|
|
9b88be |
&sshkdf_kdf_meth,
|
|
|
9b88be |
+ &kb_kdf_meth,
|
|
|
9b88be |
+ &krb5kdf_kdf_meth,
|
|
|
9b88be |
+ &ss_kdf_meth
|
|
|
9b88be |
};
|
|
|
9b88be |
|
|
|
9b88be |
DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_KDF_METHOD *, const EVP_KDF_METHOD *,
|
|
|
9b88be |
diff -up openssl-1.1.1d/include/crypto/evp.h.krb5-kdf openssl-1.1.1d/include/crypto/evp.h
|
|
|
9b88be |
--- openssl-1.1.1d/include/crypto/evp.h.krb5-kdf 2019-11-14 15:07:05.320094521 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/include/crypto/evp.h 2019-11-14 15:07:05.342094129 +0100
|
|
|
9b88be |
@@ -130,6 +130,9 @@ extern const EVP_KDF_METHOD scrypt_kdf_m
|
|
|
9b88be |
extern const EVP_KDF_METHOD tls1_prf_kdf_meth;
|
|
|
9b88be |
extern const EVP_KDF_METHOD hkdf_kdf_meth;
|
|
|
9b88be |
extern const EVP_KDF_METHOD sshkdf_kdf_meth;
|
|
|
9b88be |
+extern const EVP_KDF_METHOD kb_kdf_meth;
|
|
|
9b88be |
+extern const EVP_KDF_METHOD krb5kdf_kdf_meth;
|
|
|
9b88be |
+extern const EVP_KDF_METHOD ss_kdf_meth;
|
|
|
9b88be |
|
|
|
9b88be |
struct evp_md_st {
|
|
|
9b88be |
int type;
|
|
|
9b88be |
diff -up openssl-1.1.1d/crypto/kdf/build.info.krb5-kdf openssl-1.1.1d/crypto/kdf/build.info
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/kdf/build.info.krb5-kdf 2019-11-14 15:07:05.320094521 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/kdf/build.info 2019-11-14 15:07:05.342094129 +0100
|
|
|
9b88be |
@@ -1,3 +1,3 @@
|
|
|
9b88be |
LIBS=../../libcrypto
|
|
|
9b88be |
SOURCE[../../libcrypto]=\
|
|
|
9b88be |
- tls1_prf.c kdf_err.c kdf_util.c hkdf.c scrypt.c pbkdf2.c sshkdf.c
|
|
|
9b88be |
+ tls1_prf.c kdf_err.c kdf_util.c hkdf.c scrypt.c pbkdf2.c sshkdf.c kbkdf.c krb5kdf.c sskdf.c
|
|
|
9b88be |
diff -up openssl-1.1.1d/crypto/kdf/kbkdf.c.krb5-kdf openssl-1.1.1d/crypto/kdf/kbkdf.c
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/kdf/kbkdf.c.krb5-kdf 2019-11-14 15:07:05.343094112 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/kdf/kbkdf.c 2019-11-18 17:21:58.326635901 +0100
|
|
|
9b88be |
@@ -0,0 +1,540 @@
|
|
|
9b88be |
+/*
|
|
|
9b88be |
+ * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
|
|
9b88be |
+ * Copyright 2019 Red Hat, Inc.
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
|
9b88be |
+ * this file except in compliance with the License. You can obtain a copy
|
|
|
9b88be |
+ * in the file LICENSE in the source distribution or at
|
|
|
9b88be |
+ * https://www.openssl.org/source/license.html
|
|
|
9b88be |
+ */
|
|
|
9b88be |
+
|
|
|
9b88be |
+/*
|
|
|
9b88be |
+ * This implements https://csrc.nist.gov/publications/detail/sp/800-108/final
|
|
|
9b88be |
+ * section 5.1 ("counter mode") and section 5.2 ("feedback mode") in both HMAC
|
|
|
9b88be |
+ * and CMAC. That document does not name the KDFs it defines; the name is
|
|
|
9b88be |
+ * derived from
|
|
|
9b88be |
+ * https://csrc.nist.gov/Projects/Cryptographic-Algorithm-Validation-Program/Key-Derivation
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * Note that section 5.3 ("double-pipeline mode") is not implemented, though
|
|
|
9b88be |
+ * it would be possible to do so in the future.
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * These versions all assume the counter is used. It would be relatively
|
|
|
9b88be |
+ * straightforward to expose a configuration handle should the need arise.
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * Variable names attempt to match those of SP800-108.
|
|
|
9b88be |
+ */
|
|
|
9b88be |
+
|
|
|
9b88be |
+#include <stdarg.h>
|
|
|
9b88be |
+#include <stdlib.h>
|
|
|
9b88be |
+#include <string.h>
|
|
|
9b88be |
+
|
|
|
9b88be |
+#include <openssl/evp.h>
|
|
|
9b88be |
+#include <openssl/hmac.h>
|
|
|
9b88be |
+#include <openssl/cmac.h>
|
|
|
9b88be |
+#include <openssl/kdf.h>
|
|
|
9b88be |
+
|
|
|
9b88be |
+#include "internal/numbers.h"
|
|
|
9b88be |
+#include "internal/cryptlib.h"
|
|
|
9b88be |
+#include "crypto/evp.h"
|
|
|
9b88be |
+#include "kdf_local.h"
|
|
|
9b88be |
+
|
|
|
9b88be |
+#include "e_os.h"
|
|
|
9b88be |
+
|
|
|
9b88be |
+#ifdef MIN
|
|
|
9b88be |
+# undef MIN
|
|
|
9b88be |
+#endif
|
|
|
9b88be |
+#define MIN(a, b) ((a) < (b)) ? (a) : (b)
|
|
|
9b88be |
+
|
|
|
9b88be |
+typedef struct {
|
|
|
9b88be |
+ int mac_type;
|
|
|
9b88be |
+ union {
|
|
|
9b88be |
+ HMAC_CTX *hmac;
|
|
|
9b88be |
+ CMAC_CTX *cmac;
|
|
|
9b88be |
+ } m;
|
|
|
9b88be |
+} MAC_CTX;
|
|
|
9b88be |
+
|
|
|
9b88be |
+/* Our context structure. */
|
|
|
9b88be |
+struct evp_kdf_impl_st {
|
|
|
9b88be |
+ int mode;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ MAC_CTX *ctx_init;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ const EVP_CIPHER *cipher;
|
|
|
9b88be |
+ const EVP_MD *md;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* Names are lowercased versions of those found in SP800-108. */
|
|
|
9b88be |
+ unsigned char *ki;
|
|
|
9b88be |
+ size_t ki_len;
|
|
|
9b88be |
+ unsigned char *label;
|
|
|
9b88be |
+ size_t label_len;
|
|
|
9b88be |
+ unsigned char *context;
|
|
|
9b88be |
+ size_t context_len;
|
|
|
9b88be |
+ unsigned char *iv;
|
|
|
9b88be |
+ size_t iv_len;
|
|
|
9b88be |
+};
|
|
|
9b88be |
+
|
|
|
9b88be |
+static MAC_CTX *EVP_MAC_CTX_new(int mac_type)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ MAC_CTX *ctx;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ctx = OPENSSL_zalloc(sizeof(*ctx));
|
|
|
9b88be |
+ if (ctx == NULL)
|
|
|
9b88be |
+ return NULL;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ctx->mac_type = mac_type;
|
|
|
9b88be |
+ if (mac_type == EVP_KDF_KB_MAC_TYPE_HMAC) {
|
|
|
9b88be |
+ if ((ctx->m.hmac = HMAC_CTX_new()) == NULL)
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ } else {
|
|
|
9b88be |
+ if ((ctx->m.cmac = CMAC_CTX_new()) == NULL)
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ return ctx;
|
|
|
9b88be |
+
|
|
|
9b88be |
+err:
|
|
|
9b88be |
+ OPENSSL_free(ctx);
|
|
|
9b88be |
+ return NULL;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static void EVP_MAC_CTX_free(MAC_CTX *ctx)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ if (ctx == NULL)
|
|
|
9b88be |
+ return;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (ctx->mac_type == EVP_KDF_KB_MAC_TYPE_HMAC)
|
|
|
9b88be |
+ HMAC_CTX_free(ctx->m.hmac);
|
|
|
9b88be |
+ else
|
|
|
9b88be |
+ CMAC_CTX_free(ctx->m.cmac);
|
|
|
9b88be |
+ OPENSSL_free(ctx);
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static MAC_CTX *EVP_MAC_CTX_dup(MAC_CTX *sctx)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ MAC_CTX *ctx;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ctx = OPENSSL_zalloc(sizeof(*sctx));
|
|
|
9b88be |
+ if (ctx == NULL)
|
|
|
9b88be |
+ return NULL;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ctx->mac_type = sctx->mac_type;
|
|
|
9b88be |
+ if (sctx->mac_type == EVP_KDF_KB_MAC_TYPE_HMAC) {
|
|
|
9b88be |
+ if ((ctx->m.hmac = HMAC_CTX_new()) == NULL
|
|
|
9b88be |
+ || HMAC_CTX_copy(ctx->m.hmac, sctx->m.hmac) <= 0)
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ } else {
|
|
|
9b88be |
+ if ((ctx->m.cmac = CMAC_CTX_new()) == NULL
|
|
|
9b88be |
+ || CMAC_CTX_copy(ctx->m.cmac, sctx->m.cmac) <= 0)
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ return ctx;
|
|
|
9b88be |
+
|
|
|
9b88be |
+err:
|
|
|
9b88be |
+ EVP_MAC_CTX_free(ctx);
|
|
|
9b88be |
+ return NULL;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static size_t EVP_MAC_size(MAC_CTX *ctx)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ if (ctx->mac_type == EVP_KDF_KB_MAC_TYPE_HMAC) {
|
|
|
9b88be |
+ const EVP_MD *md;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (ctx->m.hmac == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ if ((md = HMAC_CTX_get_md(ctx->m.hmac)) == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ return (size_t)EVP_MD_size(md);
|
|
|
9b88be |
+ } else {
|
|
|
9b88be |
+ const EVP_CIPHER_CTX *cctx;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (ctx->m.cmac == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ if ((cctx = CMAC_CTX_get0_cipher_ctx(ctx->m.cmac)) == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ return EVP_CIPHER_CTX_block_size(cctx);
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int EVP_MAC_update(MAC_CTX *ctx, const unsigned char *data,
|
|
|
9b88be |
+ size_t datalen)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ if (ctx->mac_type == EVP_KDF_KB_MAC_TYPE_HMAC)
|
|
|
9b88be |
+ return HMAC_Update(ctx->m.hmac, data, datalen);
|
|
|
9b88be |
+ else
|
|
|
9b88be |
+ return CMAC_Update(ctx->m.cmac, data, datalen);
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int EVP_MAC_final(MAC_CTX *ctx, unsigned char *out,
|
|
|
9b88be |
+ size_t *outl, size_t outsize)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ if (outsize != EVP_MAC_size(ctx))
|
|
|
9b88be |
+ /* we do not cope with anything else */
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (ctx->mac_type == EVP_KDF_KB_MAC_TYPE_HMAC) {
|
|
|
9b88be |
+ unsigned int intsize = (unsigned int)outsize;
|
|
|
9b88be |
+ int ret;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ret = HMAC_Final(ctx->m.hmac, out, &intsize);
|
|
|
9b88be |
+ if (outl != NULL)
|
|
|
9b88be |
+ *outl = intsize;
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+ } else {
|
|
|
9b88be |
+ size_t size = outsize;
|
|
|
9b88be |
+ int ret;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ret = CMAC_Final(ctx->m.cmac, out, &size);
|
|
|
9b88be |
+ if (outl != NULL)
|
|
|
9b88be |
+ *outl = size;
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int evp_mac_init(MAC_CTX *ctx, const EVP_MD *md,
|
|
|
9b88be |
+ const EVP_CIPHER *cipher, unsigned char *key, size_t keylen)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ if (ctx->mac_type == EVP_KDF_KB_MAC_TYPE_HMAC) {
|
|
|
9b88be |
+ if (md == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ return HMAC_Init_ex(ctx->m.hmac, key, (int)keylen, md, NULL);
|
|
|
9b88be |
+ } else {
|
|
|
9b88be |
+ if (cipher == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ return CMAC_Init(ctx->m.cmac, key, keylen, cipher, NULL);
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static void kbkdf_reset(EVP_KDF_IMPL *ctx);
|
|
|
9b88be |
+
|
|
|
9b88be |
+/* Not all platforms have htobe32(). */
|
|
|
9b88be |
+static uint32_t be32(uint32_t host)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ uint32_t big = 0;
|
|
|
9b88be |
+ const union {
|
|
|
9b88be |
+ long one;
|
|
|
9b88be |
+ char little;
|
|
|
9b88be |
+ } is_endian = { 1 };
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (!is_endian.little)
|
|
|
9b88be |
+ return host;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ big |= (host & 0xff000000) >> 24;
|
|
|
9b88be |
+ big |= (host & 0x00ff0000) >> 8;
|
|
|
9b88be |
+ big |= (host & 0x0000ff00) << 8;
|
|
|
9b88be |
+ big |= (host & 0x000000ff) << 24;
|
|
|
9b88be |
+ return big;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static EVP_KDF_IMPL *kbkdf_new(void)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ EVP_KDF_IMPL *ctx;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ctx = OPENSSL_zalloc(sizeof(*ctx));
|
|
|
9b88be |
+ if (ctx == NULL) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KBKDF_NEW, ERR_R_MALLOC_FAILURE);
|
|
|
9b88be |
+ return NULL;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ return ctx;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static void kbkdf_free(EVP_KDF_IMPL *ctx)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ kbkdf_reset(ctx);
|
|
|
9b88be |
+ OPENSSL_free(ctx);
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static void kbkdf_reset(EVP_KDF_IMPL *ctx)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ EVP_MAC_CTX_free(ctx->ctx_init);
|
|
|
9b88be |
+ OPENSSL_clear_free(ctx->context, ctx->context_len);
|
|
|
9b88be |
+ OPENSSL_clear_free(ctx->label, ctx->label_len);
|
|
|
9b88be |
+ OPENSSL_clear_free(ctx->ki, ctx->ki_len);
|
|
|
9b88be |
+ OPENSSL_clear_free(ctx->iv, ctx->iv_len);
|
|
|
9b88be |
+ memset(ctx, 0, sizeof(*ctx));
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+/* SP800-108 section 5.1 or section 5.2 depending on mode. */
|
|
|
9b88be |
+static int derive(MAC_CTX *ctx_init, int mode, unsigned char *iv,
|
|
|
9b88be |
+ size_t iv_len, unsigned char *label, size_t label_len,
|
|
|
9b88be |
+ unsigned char *context, size_t context_len,
|
|
|
9b88be |
+ unsigned char *k_i, size_t h, uint32_t l, unsigned char *ko,
|
|
|
9b88be |
+ size_t ko_len)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ int ret = 0;
|
|
|
9b88be |
+ MAC_CTX *ctx = NULL;
|
|
|
9b88be |
+ size_t written = 0, to_write, k_i_len = iv_len;
|
|
|
9b88be |
+ const unsigned char zero = 0;
|
|
|
9b88be |
+ uint32_t counter, i;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* Setup K(0) for feedback mode. */
|
|
|
9b88be |
+ if (iv_len > 0)
|
|
|
9b88be |
+ memcpy(k_i, iv, iv_len);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ for (counter = 1; written < ko_len; counter++) {
|
|
|
9b88be |
+ i = be32(counter);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ctx = EVP_MAC_CTX_dup(ctx_init);
|
|
|
9b88be |
+ if (ctx == NULL)
|
|
|
9b88be |
+ goto done;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* Perform feedback, if appropriate. */
|
|
|
9b88be |
+ if (mode == EVP_KDF_KB_MODE_FEEDBACK && !EVP_MAC_update(ctx, k_i, k_i_len))
|
|
|
9b88be |
+ goto done;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (!EVP_MAC_update(ctx, (unsigned char *)&i, 4)
|
|
|
9b88be |
+ || !EVP_MAC_update(ctx, label, label_len)
|
|
|
9b88be |
+ || !EVP_MAC_update(ctx, &zero, 1)
|
|
|
9b88be |
+ || !EVP_MAC_update(ctx, context, context_len)
|
|
|
9b88be |
+ || !EVP_MAC_update(ctx, (unsigned char *)&l, 4)
|
|
|
9b88be |
+ || !EVP_MAC_final(ctx, k_i, NULL, h))
|
|
|
9b88be |
+ goto done;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ to_write = ko_len - written;
|
|
|
9b88be |
+ memcpy(ko + written, k_i, MIN(to_write, h));
|
|
|
9b88be |
+ written += h;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ k_i_len = h;
|
|
|
9b88be |
+ EVP_MAC_CTX_free(ctx);
|
|
|
9b88be |
+ ctx = NULL;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ret = 1;
|
|
|
9b88be |
+done:
|
|
|
9b88be |
+ EVP_MAC_CTX_free(ctx);
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int kbkdf_derive(EVP_KDF_IMPL *ctx, unsigned char *key, size_t keylen)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ int ret = 0;
|
|
|
9b88be |
+ unsigned char *k_i = NULL;
|
|
|
9b88be |
+ uint32_t l = be32(keylen * 8);
|
|
|
9b88be |
+ size_t h = 0;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* label, context, and iv are permitted to be empty. Check everything
|
|
|
9b88be |
+ * else. */
|
|
|
9b88be |
+ if (ctx->ctx_init == NULL
|
|
|
9b88be |
+ || evp_mac_init(ctx->ctx_init, ctx->md, ctx->cipher, ctx->ki, ctx->ki_len) <= 0) {
|
|
|
9b88be |
+ if (ctx->ki_len == 0 || ctx->ki == NULL) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KBKDF_DERIVE, KDF_R_MISSING_KEY);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ /* Could either be missing MAC or missing message digest or missing
|
|
|
9b88be |
+ * cipher - arbitrarily, I pick this one. */
|
|
|
9b88be |
+ KDFerr(KDF_F_KBKDF_DERIVE, KDF_R_MISSING_PARAMETER);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ h = EVP_MAC_size(ctx->ctx_init);
|
|
|
9b88be |
+ if (h == 0)
|
|
|
9b88be |
+ goto done;
|
|
|
9b88be |
+ if (ctx->iv_len != 0 && ctx->iv_len != h) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KBKDF_DERIVE, KDF_R_INVALID_SEED_LENGTH);
|
|
|
9b88be |
+ goto done;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ k_i = OPENSSL_zalloc(h);
|
|
|
9b88be |
+ if (k_i == NULL)
|
|
|
9b88be |
+ goto done;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ret = derive(ctx->ctx_init, ctx->mode, ctx->iv, ctx->iv_len, ctx->label,
|
|
|
9b88be |
+ ctx->label_len, ctx->context, ctx->context_len, k_i, h, l,
|
|
|
9b88be |
+ key, keylen);
|
|
|
9b88be |
+done:
|
|
|
9b88be |
+ if (ret != 1)
|
|
|
9b88be |
+ OPENSSL_cleanse(key, keylen);
|
|
|
9b88be |
+ OPENSSL_clear_free(k_i, h);
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static size_t kbkdf_size(EVP_KDF_IMPL *ctx)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ return UINT32_MAX/8;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int kbkdf_parse_buffer_arg(unsigned char **dst, size_t *dst_len,
|
|
|
9b88be |
+ va_list args)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ const unsigned char *p;
|
|
|
9b88be |
+ size_t len;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ p = va_arg(args, const unsigned char *);
|
|
|
9b88be |
+ len = va_arg(args, size_t);
|
|
|
9b88be |
+ OPENSSL_clear_free(*dst, *dst_len);
|
|
|
9b88be |
+ if (len == 0) {
|
|
|
9b88be |
+ *dst = NULL;
|
|
|
9b88be |
+ *dst_len = 0;
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ *dst = OPENSSL_memdup(p, len);
|
|
|
9b88be |
+ if (*dst == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ *dst_len = len;
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int kbkdf_ctrl(EVP_KDF_IMPL *ctx, int cmd, va_list args)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ int t;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ switch (cmd) {
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_MD:
|
|
|
9b88be |
+ ctx->md = va_arg(args, const EVP_MD *);
|
|
|
9b88be |
+ if (ctx->md == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_CIPHER:
|
|
|
9b88be |
+ ctx->cipher = va_arg(args, const EVP_CIPHER *);
|
|
|
9b88be |
+ if (ctx->cipher == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_KEY:
|
|
|
9b88be |
+ return kbkdf_parse_buffer_arg(&ctx->ki,
|
|
|
9b88be |
+ &ctx->ki_len, args);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_SALT:
|
|
|
9b88be |
+ return kbkdf_parse_buffer_arg(&ctx->label,
|
|
|
9b88be |
+ &ctx->label_len, args);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_KB_INFO:
|
|
|
9b88be |
+ return kbkdf_parse_buffer_arg(&ctx->context,
|
|
|
9b88be |
+ &ctx->context_len, args);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_KB_SEED:
|
|
|
9b88be |
+ return kbkdf_parse_buffer_arg(&ctx->iv,
|
|
|
9b88be |
+ &ctx->iv_len, args);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_KB_MODE:
|
|
|
9b88be |
+ t = va_arg(args, int);
|
|
|
9b88be |
+ if (t != EVP_KDF_KB_MODE_COUNTER && t != EVP_KDF_KB_MODE_FEEDBACK ) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KBKDF_CTRL, KDF_R_VALUE_ERROR);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ ctx->mode = t;
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_KB_MAC_TYPE:
|
|
|
9b88be |
+ t = va_arg(args, int);
|
|
|
9b88be |
+ if (t != EVP_KDF_KB_MAC_TYPE_HMAC && t != EVP_KDF_KB_MAC_TYPE_CMAC ) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KBKDF_CTRL, KDF_R_VALUE_ERROR);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (ctx->ctx_init != NULL) {
|
|
|
9b88be |
+ EVP_MAC_CTX_free(ctx->ctx_init);
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ ctx->ctx_init = EVP_MAC_CTX_new(t);
|
|
|
9b88be |
+ if (ctx->ctx_init == NULL) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KBKDF_CTRL, ERR_R_MALLOC_FAILURE);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ default:
|
|
|
9b88be |
+ return -2;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int kbkdf_ctrl_str(EVP_KDF_IMPL *ctx, const char *type,
|
|
|
9b88be |
+ const char *value)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ if (value == NULL) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KDF_SSHKDF_CTRL_STR, KDF_R_VALUE_MISSING);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "digest") == 0)
|
|
|
9b88be |
+ return kdf_md2ctrl(ctx, kbkdf_ctrl, EVP_KDF_CTRL_SET_MD, value);
|
|
|
9b88be |
+ /* alias, for historical reasons */
|
|
|
9b88be |
+ if (strcmp(type, "md") == 0)
|
|
|
9b88be |
+ return kdf_md2ctrl(ctx, kbkdf_ctrl, EVP_KDF_CTRL_SET_MD, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "cipher") == 0)
|
|
|
9b88be |
+ return kdf_cipher2ctrl(ctx, kbkdf_ctrl, EVP_KDF_CTRL_SET_CIPHER, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "key") == 0)
|
|
|
9b88be |
+ return kdf_str2ctrl(ctx, kbkdf_ctrl,
|
|
|
9b88be |
+ EVP_KDF_CTRL_SET_KEY, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "hexkey") == 0)
|
|
|
9b88be |
+ return kdf_hex2ctrl(ctx, kbkdf_ctrl,
|
|
|
9b88be |
+ EVP_KDF_CTRL_SET_KEY, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "salt") == 0)
|
|
|
9b88be |
+ return kdf_str2ctrl(ctx, kbkdf_ctrl,
|
|
|
9b88be |
+ EVP_KDF_CTRL_SET_SALT, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "hexsalt") == 0)
|
|
|
9b88be |
+ return kdf_hex2ctrl(ctx, kbkdf_ctrl,
|
|
|
9b88be |
+ EVP_KDF_CTRL_SET_SALT, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "info") == 0)
|
|
|
9b88be |
+ return kdf_str2ctrl(ctx, kbkdf_ctrl,
|
|
|
9b88be |
+ EVP_KDF_CTRL_SET_KB_INFO, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "hexinfo") == 0)
|
|
|
9b88be |
+ return kdf_hex2ctrl(ctx, kbkdf_ctrl,
|
|
|
9b88be |
+ EVP_KDF_CTRL_SET_KB_INFO, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "seed") == 0)
|
|
|
9b88be |
+ return kdf_str2ctrl(ctx, kbkdf_ctrl,
|
|
|
9b88be |
+ EVP_KDF_CTRL_SET_KB_SEED, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "hexseed") == 0)
|
|
|
9b88be |
+ return kdf_hex2ctrl(ctx, kbkdf_ctrl,
|
|
|
9b88be |
+ EVP_KDF_CTRL_SET_KB_SEED, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "mode") == 0) {
|
|
|
9b88be |
+ int mode;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcasecmp(value, "counter") == 0) {
|
|
|
9b88be |
+ mode = EVP_KDF_KB_MODE_COUNTER;
|
|
|
9b88be |
+ } else if (strcasecmp(value, "feedback") == 0) {
|
|
|
9b88be |
+ mode = EVP_KDF_KB_MODE_FEEDBACK;
|
|
|
9b88be |
+ } else {
|
|
|
9b88be |
+ KDFerr(KDF_F_KBKDF_CTRL_STR, KDF_R_VALUE_ERROR);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ return call_ctrl(kbkdf_ctrl, ctx, EVP_KDF_CTRL_SET_KB_MODE,
|
|
|
9b88be |
+ mode);
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "mac_type") == 0) {
|
|
|
9b88be |
+ int mac_type;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcasecmp(value, "hmac") == 0) {
|
|
|
9b88be |
+ mac_type = EVP_KDF_KB_MAC_TYPE_HMAC;
|
|
|
9b88be |
+ } else if (strcasecmp(value, "cmac") == 0) {
|
|
|
9b88be |
+ mac_type = EVP_KDF_KB_MAC_TYPE_CMAC;
|
|
|
9b88be |
+ } else {
|
|
|
9b88be |
+ KDFerr(KDF_F_KBKDF_CTRL_STR, KDF_R_VALUE_ERROR);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ return call_ctrl(kbkdf_ctrl, ctx, EVP_KDF_CTRL_SET_KB_MAC_TYPE,
|
|
|
9b88be |
+ mac_type);
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ KDFerr(KDF_F_KBKDF_CTRL_STR, KDF_R_UNKNOWN_PARAMETER_TYPE);
|
|
|
9b88be |
+ return -2;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+const EVP_KDF_METHOD kb_kdf_meth = {
|
|
|
9b88be |
+ EVP_KDF_KB,
|
|
|
9b88be |
+ kbkdf_new,
|
|
|
9b88be |
+ kbkdf_free,
|
|
|
9b88be |
+ kbkdf_reset,
|
|
|
9b88be |
+ kbkdf_ctrl,
|
|
|
9b88be |
+ kbkdf_ctrl_str,
|
|
|
9b88be |
+ kbkdf_size,
|
|
|
9b88be |
+ kbkdf_derive,
|
|
|
9b88be |
+};
|
|
|
9b88be |
+
|
|
|
9b88be |
diff -up openssl-1.1.1d/crypto/kdf/kdf_err.c.krb5-kdf openssl-1.1.1d/crypto/kdf/kdf_err.c
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/kdf/kdf_err.c.krb5-kdf 2019-11-14 15:07:05.320094521 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/kdf/kdf_err.c 2019-11-14 15:07:05.343094112 +0100
|
|
|
9b88be |
@@ -15,6 +15,11 @@
|
|
|
9b88be |
|
|
|
9b88be |
static const ERR_STRING_DATA KDF_str_functs[] = {
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, KDF_F_HKDF_EXTRACT, 0), "HKDF_Extract"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, KDF_F_KBKDF_CTRL, 0), "kbkdf_ctrl"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, KDF_F_KBKDF_CTRL_STR, 0), "kbkdf_ctrl_str"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, KDF_F_KBKDF_DERIVE, 0), "kbkdf_derive"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, KDF_F_KBKDF_NEW, 0), "kbkdf_new"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_CIPHER2CTRL, 0), "kdf_cipher2ctrl"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_HKDF_DERIVE, 0), "kdf_hkdf_derive"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_HKDF_NEW, 0), "kdf_hkdf_new"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_HKDF_SIZE, 0), "kdf_hkdf_size"},
|
|
|
9b88be |
@@ -41,6 +46,8 @@ static const ERR_STRING_DATA KDF_str_fun
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_TLS1_PRF_DERIVE, 0),
|
|
|
9b88be |
"kdf_tls1_prf_derive"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_TLS1_PRF_NEW, 0), "kdf_tls1_prf_new"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, KDF_F_KRB5KDF, 0), "KRB5KDF"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, KDF_F_KRB5KDF_DERIVE, 0), "krb5kdf_derive"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, KDF_F_PBKDF2_SET_MEMBUF, 0), "pbkdf2_set_membuf"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_HKDF_CTRL_STR, 0), "pkey_hkdf_ctrl_str"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_HKDF_DERIVE, 0), "pkey_hkdf_derive"},
|
|
|
9b88be |
@@ -59,12 +66,22 @@ static const ERR_STRING_DATA KDF_str_fun
|
|
|
9b88be |
"pkey_tls1_prf_derive"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_TLS1_PRF_INIT, 0), "pkey_tls1_prf_init"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, KDF_F_SCRYPT_SET_MEMBUF, 0), "scrypt_set_membuf"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, KDF_F_SSKDF_DERIVE, 0), "sskdf_derive"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, KDF_F_SSKDF_NEW, 0), "sskdf_new"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, KDF_F_SSKDF_SIZE, 0), "sskdf_size"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, KDF_F_TLS1_PRF_ALG, 0), "tls1_prf_alg"},
|
|
|
9b88be |
{0, NULL}
|
|
|
9b88be |
};
|
|
|
9b88be |
|
|
|
9b88be |
static const ERR_STRING_DATA KDF_str_reasons[] = {
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_FAILED_TO_GENERATE_KEY),
|
|
|
9b88be |
+ "failed to generate key"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_INVALID_CIPHER), "invalid cipher"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_INVALID_CONSTANT_LENGTH), "invalid constant length"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_INVALID_DIGEST), "invalid digest"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_INVALID_SEED_LENGTH), "invalid seed length"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_CIPHER), "missing cipher"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_CONSTANT), "missing constant"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_ITERATION_COUNT),
|
|
|
9b88be |
"missing iteration count"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_KEY), "missing key"},
|
|
|
9b88be |
@@ -82,6 +99,8 @@ static const ERR_STRING_DATA KDF_str_rea
|
|
|
9b88be |
"unknown parameter type"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_VALUE_ERROR), "value error"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_VALUE_MISSING), "value missing"},
|
|
|
9b88be |
+ {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_WRONG_FINAL_BLOCK_LENGTH),
|
|
|
9b88be |
+ "wrong final block length"},
|
|
|
9b88be |
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_WRONG_OUTPUT_BUFFER_SIZE),
|
|
|
9b88be |
"wrong output buffer size"},
|
|
|
9b88be |
{0, NULL}
|
|
|
9b88be |
diff -up openssl-1.1.1d/crypto/kdf/kdf_local.h.krb5-kdf openssl-1.1.1d/crypto/kdf/kdf_local.h
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/kdf/kdf_local.h.krb5-kdf 2019-11-14 15:07:05.313094646 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/kdf/kdf_local.h 2019-11-14 15:07:05.344094093 +0100
|
|
|
9b88be |
@@ -19,4 +19,6 @@ int kdf_hex2ctrl(EVP_KDF_IMPL *impl,
|
|
|
9b88be |
int kdf_md2ctrl(EVP_KDF_IMPL *impl,
|
|
|
9b88be |
int (*ctrl)(EVP_KDF_IMPL *impl, int cmd, va_list args),
|
|
|
9b88be |
int cmd, const char *md_name);
|
|
|
9b88be |
-
|
|
|
9b88be |
+int kdf_cipher2ctrl(EVP_KDF_IMPL *impl,
|
|
|
9b88be |
+ int (*ctrl)(EVP_KDF_IMPL *impl, int cmd, va_list args),
|
|
|
9b88be |
+ int cmd, const char *cipher_name);
|
|
|
9b88be |
diff -up openssl-1.1.1d/crypto/kdf/kdf_util.c.krb5-kdf openssl-1.1.1d/crypto/kdf/kdf_util.c
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/kdf/kdf_util.c.krb5-kdf 2019-11-14 15:07:05.313094646 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/kdf/kdf_util.c 2019-11-14 15:07:05.344094093 +0100
|
|
|
9b88be |
@@ -71,3 +71,16 @@ int kdf_md2ctrl(EVP_KDF_IMPL *impl,
|
|
|
9b88be |
return call_ctrl(ctrl, impl, cmd, md);
|
|
|
9b88be |
}
|
|
|
9b88be |
|
|
|
9b88be |
+/* Pass a cipher to a ctrl */
|
|
|
9b88be |
+int kdf_cipher2ctrl(EVP_KDF_IMPL *impl,
|
|
|
9b88be |
+ int (*ctrl)(EVP_KDF_IMPL *impl, int cmd, va_list args),
|
|
|
9b88be |
+ int cmd, const char *cipher_name)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ const EVP_CIPHER *cipher;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (cipher_name == NULL || (cipher = EVP_get_cipherbyname(cipher_name)) == NULL) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KDF_CIPHER2CTRL, KDF_R_INVALID_CIPHER);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ return call_ctrl(ctrl, impl, cmd, cipher);
|
|
|
9b88be |
+}
|
|
|
9b88be |
diff -up openssl-1.1.1d/crypto/kdf/krb5kdf.c.krb5-kdf openssl-1.1.1d/crypto/kdf/krb5kdf.c
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/kdf/krb5kdf.c.krb5-kdf 2019-11-14 15:07:05.344094093 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/kdf/krb5kdf.c 2019-11-18 17:18:13.056604404 +0100
|
|
|
9b88be |
@@ -0,0 +1,423 @@
|
|
|
9b88be |
+/*
|
|
|
9b88be |
+ * Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved.
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
9b88be |
+ * this file except in compliance with the License. You can obtain a copy
|
|
|
9b88be |
+ * in the file LICENSE in the source distribution or at
|
|
|
9b88be |
+ * https://www.openssl.org/source/license.html
|
|
|
9b88be |
+ */
|
|
|
9b88be |
+
|
|
|
9b88be |
+#include <stdlib.h>
|
|
|
9b88be |
+#include <stdarg.h>
|
|
|
9b88be |
+#include <string.h>
|
|
|
9b88be |
+
|
|
|
9b88be |
+#include <openssl/des.h>
|
|
|
9b88be |
+#include <openssl/evp.h>
|
|
|
9b88be |
+#include <openssl/kdf.h>
|
|
|
9b88be |
+
|
|
|
9b88be |
+#include "internal/cryptlib.h"
|
|
|
9b88be |
+#include "crypto/evp.h"
|
|
|
9b88be |
+#include "kdf_local.h"
|
|
|
9b88be |
+
|
|
|
9b88be |
+/* KRB5 KDF defined in RFC 3961, Section 5.1 */
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int KRB5KDF(const EVP_CIPHER *cipher,
|
|
|
9b88be |
+ const unsigned char *key, size_t key_len,
|
|
|
9b88be |
+ const unsigned char *constant, size_t constant_len,
|
|
|
9b88be |
+ unsigned char *okey, size_t okey_len);
|
|
|
9b88be |
+
|
|
|
9b88be |
+struct evp_kdf_impl_st {
|
|
|
9b88be |
+ const EVP_CIPHER *cipher;
|
|
|
9b88be |
+ unsigned char *key;
|
|
|
9b88be |
+ size_t key_len;
|
|
|
9b88be |
+ unsigned char *constant;
|
|
|
9b88be |
+ size_t constant_len;
|
|
|
9b88be |
+};
|
|
|
9b88be |
+
|
|
|
9b88be |
+static void krb5kdf_reset(EVP_KDF_IMPL *ctx);
|
|
|
9b88be |
+
|
|
|
9b88be |
+static EVP_KDF_IMPL *krb5kdf_new(void)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ EVP_KDF_IMPL *ctx;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) == NULL)
|
|
|
9b88be |
+ KDFerr(KDF_F_KBKDF_NEW, ERR_R_MALLOC_FAILURE);
|
|
|
9b88be |
+ return ctx;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static void krb5kdf_free(EVP_KDF_IMPL *ctx)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ krb5kdf_reset(ctx);
|
|
|
9b88be |
+ OPENSSL_free(ctx);
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static void krb5kdf_reset(EVP_KDF_IMPL *ctx)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ OPENSSL_clear_free(ctx->key, ctx->key_len);
|
|
|
9b88be |
+ OPENSSL_clear_free(ctx->constant, ctx->constant_len);
|
|
|
9b88be |
+ memset(ctx, 0, sizeof(*ctx));
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int krb5kdf_derive(EVP_KDF_IMPL *ctx, unsigned char *key,
|
|
|
9b88be |
+ size_t keylen)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ if (ctx->cipher == NULL) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KRB5KDF_DERIVE, KDF_R_MISSING_CIPHER);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (ctx->key == NULL) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KRB5KDF_DERIVE, KDF_R_MISSING_KEY);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (ctx->constant == NULL) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KRB5KDF_DERIVE, KDF_R_MISSING_CONSTANT);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ return KRB5KDF(ctx->cipher, ctx->key, ctx->key_len,
|
|
|
9b88be |
+ ctx->constant, ctx->constant_len,
|
|
|
9b88be |
+ key, keylen);
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static size_t krb5kdf_size(EVP_KDF_IMPL *ctx)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ if (ctx->cipher != NULL)
|
|
|
9b88be |
+ return EVP_CIPHER_key_length(ctx->cipher);
|
|
|
9b88be |
+ else
|
|
|
9b88be |
+ return EVP_MAX_KEY_LENGTH;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int krb5kdf_parse_buffer_arg(unsigned char **dst, size_t *dst_len,
|
|
|
9b88be |
+ va_list args)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ const unsigned char *p;
|
|
|
9b88be |
+ size_t len;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ p = va_arg(args, const unsigned char *);
|
|
|
9b88be |
+ len = va_arg(args, size_t);
|
|
|
9b88be |
+ OPENSSL_clear_free(*dst, *dst_len);
|
|
|
9b88be |
+ if (len == 0) {
|
|
|
9b88be |
+ *dst = NULL;
|
|
|
9b88be |
+ *dst_len = 0;
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ *dst = OPENSSL_memdup(p, len);
|
|
|
9b88be |
+ if (*dst == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ *dst_len = len;
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int krb5kdf_ctrl(EVP_KDF_IMPL *ctx, int cmd, va_list args)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ switch (cmd) {
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_CIPHER:
|
|
|
9b88be |
+ ctx->cipher = va_arg(args, const EVP_CIPHER *);
|
|
|
9b88be |
+ if (ctx->cipher == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_KEY:
|
|
|
9b88be |
+ return krb5kdf_parse_buffer_arg(&ctx->key,
|
|
|
9b88be |
+ &ctx->key_len, args);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_KRB5KDF_CONSTANT:
|
|
|
9b88be |
+ return krb5kdf_parse_buffer_arg(&ctx->constant,
|
|
|
9b88be |
+ &ctx->constant_len, args);
|
|
|
9b88be |
+ default:
|
|
|
9b88be |
+ return -2;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int krb5kdf_ctrl_str(EVP_KDF_IMPL *ctx, const char *type,
|
|
|
9b88be |
+ const char *value)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ if (value == NULL) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KDF_SSHKDF_CTRL_STR, KDF_R_VALUE_MISSING);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "cipher") == 0)
|
|
|
9b88be |
+ return kdf_cipher2ctrl(ctx, krb5kdf_ctrl, EVP_KDF_CTRL_SET_CIPHER, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "key") == 0)
|
|
|
9b88be |
+ return kdf_str2ctrl(ctx, krb5kdf_ctrl,
|
|
|
9b88be |
+ EVP_KDF_CTRL_SET_KEY, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "hexkey") == 0)
|
|
|
9b88be |
+ return kdf_hex2ctrl(ctx, krb5kdf_ctrl,
|
|
|
9b88be |
+ EVP_KDF_CTRL_SET_KEY, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "constant") == 0)
|
|
|
9b88be |
+ return kdf_str2ctrl(ctx, krb5kdf_ctrl,
|
|
|
9b88be |
+ EVP_KDF_CTRL_SET_KRB5KDF_CONSTANT, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "hexconstant") == 0)
|
|
|
9b88be |
+ return kdf_hex2ctrl(ctx, krb5kdf_ctrl,
|
|
|
9b88be |
+ EVP_KDF_CTRL_SET_KRB5KDF_CONSTANT, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ KDFerr(KDF_F_KBKDF_CTRL_STR, KDF_R_UNKNOWN_PARAMETER_TYPE);
|
|
|
9b88be |
+ return -2;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+
|
|
|
9b88be |
+#ifndef OPENSSL_NO_DES
|
|
|
9b88be |
+/*
|
|
|
9b88be |
+ * DES3 is a special case, it requires a random-to-key function and its
|
|
|
9b88be |
+ * input truncated to 21 bytes of the 24 produced by the cipher.
|
|
|
9b88be |
+ * See RFC3961 6.3.1
|
|
|
9b88be |
+ */
|
|
|
9b88be |
+static int fixup_des3_key(unsigned char *key)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ unsigned char *cblock;
|
|
|
9b88be |
+ int i, j;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ for (i = 2; i >= 0; i--) {
|
|
|
9b88be |
+ cblock = &key[i * 8];
|
|
|
9b88be |
+ memmove(cblock, &key[i * 7], 7);
|
|
|
9b88be |
+ cblock[7] = 0;
|
|
|
9b88be |
+ for (j = 0; j < 7; j++)
|
|
|
9b88be |
+ cblock[7] |= (cblock[j] & 1) << (j + 1);
|
|
|
9b88be |
+ DES_set_odd_parity((DES_cblock *)cblock);
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* fail if keys are such that triple des degrades to single des */
|
|
|
9b88be |
+ if (CRYPTO_memcmp(&key[0], &key[8], 8) == 0 ||
|
|
|
9b88be |
+ CRYPTO_memcmp(&key[8], &key[16], 8) == 0) {
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+#endif
|
|
|
9b88be |
+
|
|
|
9b88be |
+/*
|
|
|
9b88be |
+ * N-fold(K) where blocksize is N, and constant_len is K
|
|
|
9b88be |
+ * Note: Here |= denotes concatenation
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * L = lcm(N,K)
|
|
|
9b88be |
+ * R = L/K
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * for r: 1 -> R
|
|
|
9b88be |
+ * s |= constant rot 13*(r-1))
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * block = 0
|
|
|
9b88be |
+ * for k: 1 -> K
|
|
|
9b88be |
+ * block += s[N(k-1)..(N-1)k] (one's complement addition)
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * Optimizing for space we compute:
|
|
|
9b88be |
+ * for each l in L-1 -> 0:
|
|
|
9b88be |
+ * s[l] = (constant rot 13*(l/K))[l%k]
|
|
|
9b88be |
+ * block[l % N] += s[l] (with carry)
|
|
|
9b88be |
+ * finally add carry if any
|
|
|
9b88be |
+ */
|
|
|
9b88be |
+static void n_fold(unsigned char *block, unsigned int blocksize,
|
|
|
9b88be |
+ const unsigned char *constant, size_t constant_len)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ unsigned int tmp, gcd, remainder, lcm, carry;
|
|
|
9b88be |
+ int b, l;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (constant_len == blocksize) {
|
|
|
9b88be |
+ memcpy(block, constant, constant_len);
|
|
|
9b88be |
+ return;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* Least Common Multiple of lengths: LCM(a,b)*/
|
|
|
9b88be |
+ gcd = blocksize;
|
|
|
9b88be |
+ remainder = constant_len;
|
|
|
9b88be |
+ /* Calculate Great Common Divisor first GCD(a,b) */
|
|
|
9b88be |
+ while (remainder != 0) {
|
|
|
9b88be |
+ tmp = gcd % remainder;
|
|
|
9b88be |
+ gcd = remainder;
|
|
|
9b88be |
+ remainder = tmp;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ /* resulting a is the GCD, LCM(a,b) = |a*b|/GCD(a,b) */
|
|
|
9b88be |
+ lcm = blocksize * constant_len / gcd;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* now spread out the bits */
|
|
|
9b88be |
+ memset(block, 0, blocksize);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* last to first to be able to bring carry forward */
|
|
|
9b88be |
+ carry = 0;
|
|
|
9b88be |
+ for (l = lcm - 1; l >= 0; l--) {
|
|
|
9b88be |
+ unsigned int rotbits, rshift, rbyte;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* destination byte in block is l % N */
|
|
|
9b88be |
+ b = l % blocksize;
|
|
|
9b88be |
+ /* Our virtual s buffer is R = L/K long (K = constant_len) */
|
|
|
9b88be |
+ /* So we rotate backwards from R-1 to 0 (none) rotations */
|
|
|
9b88be |
+ rotbits = 13 * (l / constant_len);
|
|
|
9b88be |
+ /* find the byte on s where rotbits falls onto */
|
|
|
9b88be |
+ rbyte = l - (rotbits / 8);
|
|
|
9b88be |
+ /* calculate how much shift on that byte */
|
|
|
9b88be |
+ rshift = rotbits & 0x07;
|
|
|
9b88be |
+ /* rbyte % constant_len gives us the unrotated byte in the
|
|
|
9b88be |
+ * constant buffer, get also the previous byte then
|
|
|
9b88be |
+ * appropriately shift them to get the rotated byte we need */
|
|
|
9b88be |
+ tmp = (constant[(rbyte-1) % constant_len] << (8 - rshift)
|
|
|
9b88be |
+ | constant[rbyte % constant_len] >> rshift)
|
|
|
9b88be |
+ & 0xff;
|
|
|
9b88be |
+ /* add with carry to any value placed by previous passes */
|
|
|
9b88be |
+ tmp += carry + block[b];
|
|
|
9b88be |
+ block[b] = tmp & 0xff;
|
|
|
9b88be |
+ /* save any carry that may be left */
|
|
|
9b88be |
+ carry = tmp >> 8;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* if any carry is left at the end, add it through the number */
|
|
|
9b88be |
+ for (b = blocksize - 1; b >= 0 && carry != 0; b--) {
|
|
|
9b88be |
+ carry += block[b];
|
|
|
9b88be |
+ block[b] = carry & 0xff;
|
|
|
9b88be |
+ carry >>= 8;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int cipher_init(EVP_CIPHER_CTX *ctx,
|
|
|
9b88be |
+ const EVP_CIPHER *cipher,
|
|
|
9b88be |
+ const unsigned char *key, size_t key_len)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ int klen, ret;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ret = EVP_EncryptInit_ex(ctx, cipher, NULL, key, NULL);
|
|
|
9b88be |
+ if (!ret)
|
|
|
9b88be |
+ goto out;
|
|
|
9b88be |
+ /* set the key len for the odd variable key len cipher */
|
|
|
9b88be |
+ klen = EVP_CIPHER_CTX_key_length(ctx);
|
|
|
9b88be |
+ if (key_len != (size_t)klen) {
|
|
|
9b88be |
+ ret = EVP_CIPHER_CTX_set_key_length(ctx, key_len);
|
|
|
9b88be |
+ if (!ret)
|
|
|
9b88be |
+ goto out;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ /* we never want padding, either the length requested is a multiple of
|
|
|
9b88be |
+ * the cipher block size or we are passed a cipher that can cope with
|
|
|
9b88be |
+ * partial blocks via techniques like cipher text stealing */
|
|
|
9b88be |
+ ret = EVP_CIPHER_CTX_set_padding(ctx, 0);
|
|
|
9b88be |
+ if (!ret)
|
|
|
9b88be |
+ goto out;
|
|
|
9b88be |
+
|
|
|
9b88be |
+out:
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int KRB5KDF(const EVP_CIPHER *cipher,
|
|
|
9b88be |
+ const unsigned char *key, size_t key_len,
|
|
|
9b88be |
+ const unsigned char *constant, size_t constant_len,
|
|
|
9b88be |
+ unsigned char *okey, size_t okey_len)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ EVP_CIPHER_CTX *ctx = NULL;
|
|
|
9b88be |
+ unsigned char block[EVP_MAX_BLOCK_LENGTH * 2];
|
|
|
9b88be |
+ unsigned char *plainblock, *cipherblock;
|
|
|
9b88be |
+ size_t blocksize;
|
|
|
9b88be |
+ size_t cipherlen;
|
|
|
9b88be |
+ size_t osize;
|
|
|
9b88be |
+ int des3_no_fixup = 0;
|
|
|
9b88be |
+ int ret;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (key_len != okey_len) {
|
|
|
9b88be |
+ /* special case for 3des, where the caller may be requesting
|
|
|
9b88be |
+ * the random raw key, instead of the fixed up key */
|
|
|
9b88be |
+ if (EVP_CIPHER_nid(cipher) == NID_des_ede3_cbc &&
|
|
|
9b88be |
+ key_len == 24 && okey_len == 21) {
|
|
|
9b88be |
+ des3_no_fixup = 1;
|
|
|
9b88be |
+ } else {
|
|
|
9b88be |
+ KDFerr(KDF_F_KRB5KDF, KDF_R_WRONG_OUTPUT_BUFFER_SIZE);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ctx = EVP_CIPHER_CTX_new();
|
|
|
9b88be |
+ if (ctx == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ret = cipher_init(ctx, cipher, key, key_len);
|
|
|
9b88be |
+ if (!ret)
|
|
|
9b88be |
+ goto out;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* Initialize input block */
|
|
|
9b88be |
+ blocksize = EVP_CIPHER_CTX_block_size(ctx);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (constant_len == 0 || constant_len > blocksize) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KRB5KDF, KDF_R_INVALID_CONSTANT_LENGTH);
|
|
|
9b88be |
+ ret = 0;
|
|
|
9b88be |
+ goto out;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ n_fold(block, blocksize, constant, constant_len);
|
|
|
9b88be |
+ plainblock = block;
|
|
|
9b88be |
+ cipherblock = block + EVP_MAX_BLOCK_LENGTH;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ for (osize = 0; osize < okey_len; osize += cipherlen) {
|
|
|
9b88be |
+ int olen;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ret = EVP_EncryptUpdate(ctx, cipherblock, &olen,
|
|
|
9b88be |
+ plainblock, blocksize);
|
|
|
9b88be |
+ if (!ret)
|
|
|
9b88be |
+ goto out;
|
|
|
9b88be |
+ cipherlen = olen;
|
|
|
9b88be |
+ ret = EVP_EncryptFinal_ex(ctx, cipherblock, &olen);
|
|
|
9b88be |
+ if (!ret)
|
|
|
9b88be |
+ goto out;
|
|
|
9b88be |
+ if (olen != 0) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KRB5KDF, KDF_R_WRONG_FINAL_BLOCK_LENGTH);
|
|
|
9b88be |
+ ret = 0;
|
|
|
9b88be |
+ goto out;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* write cipherblock out */
|
|
|
9b88be |
+ if (cipherlen > okey_len - osize)
|
|
|
9b88be |
+ cipherlen = okey_len - osize;
|
|
|
9b88be |
+ memcpy(okey + osize, cipherblock, cipherlen);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (okey_len > osize + cipherlen) {
|
|
|
9b88be |
+ /* we need to reinitialize cipher context per spec */
|
|
|
9b88be |
+ ret = EVP_CIPHER_CTX_reset(ctx);
|
|
|
9b88be |
+ if (!ret)
|
|
|
9b88be |
+ goto out;
|
|
|
9b88be |
+ ret = cipher_init(ctx, cipher, key, key_len);
|
|
|
9b88be |
+ if (!ret)
|
|
|
9b88be |
+ goto out;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* also swap block offsets so last ciphertext becomes new
|
|
|
9b88be |
+ * plaintext */
|
|
|
9b88be |
+ plainblock = cipherblock;
|
|
|
9b88be |
+ if (cipherblock == block) {
|
|
|
9b88be |
+ cipherblock += EVP_MAX_BLOCK_LENGTH;
|
|
|
9b88be |
+ } else {
|
|
|
9b88be |
+ cipherblock = block;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+#ifndef OPENSSL_NO_DES
|
|
|
9b88be |
+ if (EVP_CIPHER_nid(cipher) == NID_des_ede3_cbc && !des3_no_fixup) {
|
|
|
9b88be |
+ ret = fixup_des3_key(okey);
|
|
|
9b88be |
+ if (!ret) {
|
|
|
9b88be |
+ KDFerr(KDF_F_KRB5KDF, KDF_R_FAILED_TO_GENERATE_KEY);
|
|
|
9b88be |
+ goto out;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+#endif
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ret = 1;
|
|
|
9b88be |
+
|
|
|
9b88be |
+out:
|
|
|
9b88be |
+ EVP_CIPHER_CTX_free(ctx);
|
|
|
9b88be |
+ OPENSSL_cleanse(block, EVP_MAX_BLOCK_LENGTH * 2);
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+const EVP_KDF_METHOD krb5kdf_kdf_meth = {
|
|
|
9b88be |
+ EVP_KDF_KRB5KDF,
|
|
|
9b88be |
+ krb5kdf_new,
|
|
|
9b88be |
+ krb5kdf_free,
|
|
|
9b88be |
+ krb5kdf_reset,
|
|
|
9b88be |
+ krb5kdf_ctrl,
|
|
|
9b88be |
+ krb5kdf_ctrl_str,
|
|
|
9b88be |
+ krb5kdf_size,
|
|
|
9b88be |
+ krb5kdf_derive,
|
|
|
9b88be |
+};
|
|
|
9b88be |
+
|
|
|
9b88be |
diff -up openssl-1.1.1d/crypto/kdf/sshkdf.c.krb5-kdf openssl-1.1.1d/crypto/kdf/sshkdf.c
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/kdf/sshkdf.c.krb5-kdf 2019-11-14 15:07:05.327094396 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/kdf/sshkdf.c 2019-11-18 17:18:25.343388314 +0100
|
|
|
9b88be |
@@ -12,6 +12,7 @@
|
|
|
9b88be |
#include <string.h>
|
|
|
9b88be |
#include <openssl/evp.h>
|
|
|
9b88be |
#include <openssl/kdf.h>
|
|
|
9b88be |
+#include "internal/numbers.h"
|
|
|
9b88be |
#include "internal/cryptlib.h"
|
|
|
9b88be |
#include "crypto/evp.h"
|
|
|
9b88be |
#include "kdf_local.h"
|
|
|
9b88be |
@@ -68,6 +69,12 @@ static int kdf_sshkdf_parse_buffer_arg(u
|
|
|
9b88be |
p = va_arg(args, const unsigned char *);
|
|
|
9b88be |
len = va_arg(args, size_t);
|
|
|
9b88be |
OPENSSL_clear_free(*dst, *dst_len);
|
|
|
9b88be |
+ if (len == 0) {
|
|
|
9b88be |
+ *dst = NULL;
|
|
|
9b88be |
+ *dst_len = 0;
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
*dst = OPENSSL_memdup(p, len);
|
|
|
9b88be |
if (*dst == NULL)
|
|
|
9b88be |
return 0;
|
|
|
9b88be |
diff -up openssl-1.1.1d/crypto/kdf/sskdf.c.krb5-kdf openssl-1.1.1d/crypto/kdf/sskdf.c
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/kdf/sskdf.c.krb5-kdf 2019-11-14 15:07:05.344094093 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/kdf/sskdf.c 2019-11-18 17:21:40.349952802 +0100
|
|
|
9b88be |
@@ -0,0 +1,255 @@
|
|
|
9b88be |
+/*
|
|
|
9b88be |
+ * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
|
|
9b88be |
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
|
9b88be |
+ * this file except in compliance with the License. You can obtain a copy
|
|
|
9b88be |
+ * in the file LICENSE in the source distribution or at
|
|
|
9b88be |
+ * https://www.openssl.org/source/license.html
|
|
|
9b88be |
+ */
|
|
|
9b88be |
+
|
|
|
9b88be |
+/*
|
|
|
9b88be |
+ * Refer to https://csrc.nist.gov/publications/detail/sp/800-56c/rev-1/final
|
|
|
9b88be |
+ * Section 4.1.
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * The Single Step KDF algorithm is given by:
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * Result(0) = empty bit string (i.e., the null string).
|
|
|
9b88be |
+ * For i = 1 to reps, do the following:
|
|
|
9b88be |
+ * Increment counter by 1.
|
|
|
9b88be |
+ * Result(i) = Result(i – 1) || H(counter || Z || FixedInfo).
|
|
|
9b88be |
+ * DKM = LeftmostBits(Result(reps), L))
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * NOTES:
|
|
|
9b88be |
+ * Z is a shared secret required to produce the derived key material.
|
|
|
9b88be |
+ * counter is a 4 byte buffer.
|
|
|
9b88be |
+ * FixedInfo is a bit string containing context specific data.
|
|
|
9b88be |
+ * DKM is the output derived key material.
|
|
|
9b88be |
+ * L is the required size of the DKM.
|
|
|
9b88be |
+ * reps = [L / H_outputBits]
|
|
|
9b88be |
+ * H(x) is the auxiliary function that can be either a hash, HMAC or KMAC.
|
|
|
9b88be |
+ * This backported version supports only a hash.
|
|
|
9b88be |
+ * H_outputBits is the length of the output of the auxiliary function H(x).
|
|
|
9b88be |
+ *
|
|
|
9b88be |
+ * Currently there is not a comprehensive list of test vectors for this
|
|
|
9b88be |
+ * algorithm, especially for H(x) = HMAC and H(x) = KMAC.
|
|
|
9b88be |
+ * Test vectors for H(x) = Hash are indirectly used by CAVS KAS tests.
|
|
|
9b88be |
+ */
|
|
|
9b88be |
+#include <stdlib.h>
|
|
|
9b88be |
+#include <stdarg.h>
|
|
|
9b88be |
+#include <string.h>
|
|
|
9b88be |
+#include <openssl/hmac.h>
|
|
|
9b88be |
+#include <openssl/evp.h>
|
|
|
9b88be |
+#include <openssl/kdf.h>
|
|
|
9b88be |
+#include "internal/cryptlib.h"
|
|
|
9b88be |
+#include "crypto/evp.h"
|
|
|
9b88be |
+#include "kdf_local.h"
|
|
|
9b88be |
+
|
|
|
9b88be |
+struct evp_kdf_impl_st {
|
|
|
9b88be |
+ const EVP_MD *md; /* H(x) = hash */
|
|
|
9b88be |
+ unsigned char *secret;
|
|
|
9b88be |
+ size_t secret_len;
|
|
|
9b88be |
+ unsigned char *info;
|
|
|
9b88be |
+ size_t info_len;
|
|
|
9b88be |
+};
|
|
|
9b88be |
+
|
|
|
9b88be |
+#define SSKDF_MAX_INLEN (1<<30)
|
|
|
9b88be |
+
|
|
|
9b88be |
+/*
|
|
|
9b88be |
+ * Refer to https://csrc.nist.gov/publications/detail/sp/800-56c/rev-1/final
|
|
|
9b88be |
+ * Section 4. One-Step Key Derivation using H(x) = hash(x)
|
|
|
9b88be |
+ */
|
|
|
9b88be |
+static int SSKDF_hash_kdm(const EVP_MD *kdf_md,
|
|
|
9b88be |
+ const unsigned char *z, size_t z_len,
|
|
|
9b88be |
+ const unsigned char *info, size_t info_len,
|
|
|
9b88be |
+ unsigned char *derived_key, size_t derived_key_len)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ int ret = 0, hlen;
|
|
|
9b88be |
+ size_t counter, out_len, len = derived_key_len;
|
|
|
9b88be |
+ unsigned char c[4];
|
|
|
9b88be |
+ unsigned char mac[EVP_MAX_MD_SIZE];
|
|
|
9b88be |
+ unsigned char *out = derived_key;
|
|
|
9b88be |
+ EVP_MD_CTX *ctx = NULL, *ctx_init = NULL;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (z_len > SSKDF_MAX_INLEN || info_len > SSKDF_MAX_INLEN
|
|
|
9b88be |
+ || derived_key_len > SSKDF_MAX_INLEN
|
|
|
9b88be |
+ || derived_key_len == 0)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ hlen = EVP_MD_size(kdf_md);
|
|
|
9b88be |
+ if (hlen <= 0)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ out_len = (size_t)hlen;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ctx = EVP_MD_CTX_create();
|
|
|
9b88be |
+ ctx_init = EVP_MD_CTX_create();
|
|
|
9b88be |
+ if (ctx == NULL || ctx_init == NULL)
|
|
|
9b88be |
+ goto end;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (!EVP_DigestInit(ctx_init, kdf_md))
|
|
|
9b88be |
+ goto end;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ for (counter = 1;; counter++) {
|
|
|
9b88be |
+ c[0] = (unsigned char)((counter >> 24) & 0xff);
|
|
|
9b88be |
+ c[1] = (unsigned char)((counter >> 16) & 0xff);
|
|
|
9b88be |
+ c[2] = (unsigned char)((counter >> 8) & 0xff);
|
|
|
9b88be |
+ c[3] = (unsigned char)(counter & 0xff);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (!(EVP_MD_CTX_copy_ex(ctx, ctx_init)
|
|
|
9b88be |
+ && EVP_DigestUpdate(ctx, c, sizeof(c))
|
|
|
9b88be |
+ && EVP_DigestUpdate(ctx, z, z_len)
|
|
|
9b88be |
+ && EVP_DigestUpdate(ctx, info, info_len)))
|
|
|
9b88be |
+ goto end;
|
|
|
9b88be |
+ if (len >= out_len) {
|
|
|
9b88be |
+ if (!EVP_DigestFinal_ex(ctx, out, NULL))
|
|
|
9b88be |
+ goto end;
|
|
|
9b88be |
+ out += out_len;
|
|
|
9b88be |
+ len -= out_len;
|
|
|
9b88be |
+ if (len == 0)
|
|
|
9b88be |
+ break;
|
|
|
9b88be |
+ } else {
|
|
|
9b88be |
+ if (!EVP_DigestFinal_ex(ctx, mac, NULL))
|
|
|
9b88be |
+ goto end;
|
|
|
9b88be |
+ memcpy(out, mac, len);
|
|
|
9b88be |
+ break;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ ret = 1;
|
|
|
9b88be |
+end:
|
|
|
9b88be |
+ EVP_MD_CTX_destroy(ctx);
|
|
|
9b88be |
+ EVP_MD_CTX_destroy(ctx_init);
|
|
|
9b88be |
+ OPENSSL_cleanse(mac, sizeof(mac));
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static EVP_KDF_IMPL *sskdf_new(void)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ EVP_KDF_IMPL *impl;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if ((impl = OPENSSL_zalloc(sizeof(*impl))) == NULL)
|
|
|
9b88be |
+ KDFerr(KDF_F_SSKDF_NEW, ERR_R_MALLOC_FAILURE);
|
|
|
9b88be |
+ return impl;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static void sskdf_reset(EVP_KDF_IMPL *impl)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ OPENSSL_clear_free(impl->secret, impl->secret_len);
|
|
|
9b88be |
+ OPENSSL_clear_free(impl->info, impl->info_len);
|
|
|
9b88be |
+ memset(impl, 0, sizeof(*impl));
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static void sskdf_free(EVP_KDF_IMPL *impl)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ sskdf_reset(impl);
|
|
|
9b88be |
+ OPENSSL_free(impl);
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int sskdf_set_buffer(va_list args, unsigned char **out, size_t *out_len)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ const unsigned char *p;
|
|
|
9b88be |
+ size_t len;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ p = va_arg(args, const unsigned char *);
|
|
|
9b88be |
+ len = va_arg(args, size_t);
|
|
|
9b88be |
+ OPENSSL_clear_free(*out, *out_len);
|
|
|
9b88be |
+ if (len == 0) {
|
|
|
9b88be |
+ *out = NULL;
|
|
|
9b88be |
+ *out_len = 0;
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ *out = OPENSSL_memdup(p, len);
|
|
|
9b88be |
+ if (*out == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ *out_len = len;
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int sskdf_ctrl(EVP_KDF_IMPL *impl, int cmd, va_list args)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ const EVP_MD *md;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ switch (cmd) {
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_KEY:
|
|
|
9b88be |
+ return sskdf_set_buffer(args, &impl->secret, &impl->secret_len);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_SSKDF_INFO:
|
|
|
9b88be |
+ return sskdf_set_buffer(args, &impl->info, &impl->info_len);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ case EVP_KDF_CTRL_SET_MD:
|
|
|
9b88be |
+ md = va_arg(args, const EVP_MD *);
|
|
|
9b88be |
+ if (md == NULL)
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ impl->md = md;
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ default:
|
|
|
9b88be |
+ return -2;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int sskdf_ctrl_str(EVP_KDF_IMPL *impl, const char *type,
|
|
|
9b88be |
+ const char *value)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ if (strcmp(type, "secret") == 0 || strcmp(type, "key") == 0)
|
|
|
9b88be |
+ return kdf_str2ctrl(impl, sskdf_ctrl, EVP_KDF_CTRL_SET_KEY,
|
|
|
9b88be |
+ value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "hexsecret") == 0 || strcmp(type, "hexkey") == 0)
|
|
|
9b88be |
+ return kdf_hex2ctrl(impl, sskdf_ctrl, EVP_KDF_CTRL_SET_KEY,
|
|
|
9b88be |
+ value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "info") == 0)
|
|
|
9b88be |
+ return kdf_str2ctrl(impl, sskdf_ctrl, EVP_KDF_CTRL_SET_SSKDF_INFO,
|
|
|
9b88be |
+ value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "hexinfo") == 0)
|
|
|
9b88be |
+ return kdf_hex2ctrl(impl, sskdf_ctrl, EVP_KDF_CTRL_SET_SSKDF_INFO,
|
|
|
9b88be |
+ value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (strcmp(type, "digest") == 0)
|
|
|
9b88be |
+ return kdf_md2ctrl(impl, sskdf_ctrl, EVP_KDF_CTRL_SET_MD, value);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ return -2;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static size_t sskdf_size(EVP_KDF_IMPL *impl)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ int len;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (impl->md == NULL) {
|
|
|
9b88be |
+ KDFerr(KDF_F_SSKDF_SIZE, KDF_R_MISSING_MESSAGE_DIGEST);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ len = EVP_MD_size(impl->md);
|
|
|
9b88be |
+ return (len <= 0) ? 0 : (size_t)len;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int sskdf_derive(EVP_KDF_IMPL *impl, unsigned char *key, size_t keylen)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ if (impl->secret == NULL) {
|
|
|
9b88be |
+ KDFerr(KDF_F_SSKDF_DERIVE, KDF_R_MISSING_SECRET);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ /* H(x) = hash */
|
|
|
9b88be |
+ if (impl->md == NULL) {
|
|
|
9b88be |
+ KDFerr(KDF_F_SSKDF_DERIVE, KDF_R_MISSING_MESSAGE_DIGEST);
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ return SSKDF_hash_kdm(impl->md, impl->secret, impl->secret_len,
|
|
|
9b88be |
+ impl->info, impl->info_len, key, keylen);
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+const EVP_KDF_METHOD ss_kdf_meth = {
|
|
|
9b88be |
+ EVP_KDF_SS,
|
|
|
9b88be |
+ sskdf_new,
|
|
|
9b88be |
+ sskdf_free,
|
|
|
9b88be |
+ sskdf_reset,
|
|
|
9b88be |
+ sskdf_ctrl,
|
|
|
9b88be |
+ sskdf_ctrl_str,
|
|
|
9b88be |
+ sskdf_size,
|
|
|
9b88be |
+ sskdf_derive
|
|
|
9b88be |
+};
|
|
|
9b88be |
diff -up openssl-1.1.1d/crypto/objects/obj_dat.h.krb5-kdf openssl-1.1.1d/crypto/objects/obj_dat.h
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/objects/obj_dat.h.krb5-kdf 2019-11-14 15:07:05.322094485 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/objects/obj_dat.h 2019-11-14 15:07:05.345094076 +0100
|
|
|
9b88be |
@@ -1078,7 +1078,7 @@ static const unsigned char so[7762] = {
|
|
|
9b88be |
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x0D, /* [ 7753] OBJ_hmacWithSHA512_256 */
|
|
|
9b88be |
};
|
|
|
9b88be |
|
|
|
9b88be |
-#define NUM_NID 1196
|
|
|
9b88be |
+#define NUM_NID 1199
|
|
|
9b88be |
static const ASN1_OBJECT nid_objs[NUM_NID] = {
|
|
|
9b88be |
{"UNDEF", "undefined", NID_undef},
|
|
|
9b88be |
{"rsadsi", "RSA Data Security, Inc.", NID_rsadsi, 6, &so[0]},
|
|
|
9b88be |
@@ -2276,9 +2276,12 @@ static const ASN1_OBJECT nid_objs[NUM_NI
|
|
|
9b88be |
{"hmacWithSHA512-224", "hmacWithSHA512-224", NID_hmacWithSHA512_224, 8, &so[7745]},
|
|
|
9b88be |
{"hmacWithSHA512-256", "hmacWithSHA512-256", NID_hmacWithSHA512_256, 8, &so[7753]},
|
|
|
9b88be |
{"SSHKDF", "sshkdf", NID_sshkdf},
|
|
|
9b88be |
+ {"KBKDF", "kbkdf", NID_kbkdf},
|
|
|
9b88be |
+ {"KRB5KDF", "krb5kdf", NID_krb5kdf},
|
|
|
9b88be |
+ {"SSKDF", "sskdf", NID_sskdf},
|
|
|
9b88be |
};
|
|
|
9b88be |
|
|
|
9b88be |
-#define NUM_SN 1187
|
|
|
9b88be |
+#define NUM_SN 1190
|
|
|
9b88be |
static const unsigned int sn_objs[NUM_SN] = {
|
|
|
9b88be |
364, /* "AD_DVCS" */
|
|
|
9b88be |
419, /* "AES-128-CBC" */
|
|
|
9b88be |
@@ -2442,7 +2445,9 @@ static const unsigned int sn_objs[NUM_SN
|
|
|
9b88be |
183, /* "ISO-US" */
|
|
|
9b88be |
645, /* "ITU-T" */
|
|
|
9b88be |
646, /* "JOINT-ISO-ITU-T" */
|
|
|
9b88be |
+ 1196, /* "KBKDF" */
|
|
|
9b88be |
773, /* "KISA" */
|
|
|
9b88be |
+ 1197, /* "KRB5KDF" */
|
|
|
9b88be |
1063, /* "KxANY" */
|
|
|
9b88be |
1039, /* "KxDHE" */
|
|
|
9b88be |
1041, /* "KxDHE-PSK" */
|
|
|
9b88be |
@@ -2557,6 +2562,7 @@ static const unsigned int sn_objs[NUM_SN
|
|
|
9b88be |
100, /* "SN" */
|
|
|
9b88be |
1006, /* "SNILS" */
|
|
|
9b88be |
1195, /* "SSHKDF" */
|
|
|
9b88be |
+ 1198, /* "SSKDF" */
|
|
|
9b88be |
16, /* "ST" */
|
|
|
9b88be |
143, /* "SXNetID" */
|
|
|
9b88be |
1062, /* "SipHash" */
|
|
|
9b88be |
@@ -3469,7 +3475,7 @@ static const unsigned int sn_objs[NUM_SN
|
|
|
9b88be |
1093, /* "x509ExtAdmission" */
|
|
|
9b88be |
};
|
|
|
9b88be |
|
|
|
9b88be |
-#define NUM_LN 1187
|
|
|
9b88be |
+#define NUM_LN 1190
|
|
|
9b88be |
static const unsigned int ln_objs[NUM_LN] = {
|
|
|
9b88be |
363, /* "AD Time Stamping" */
|
|
|
9b88be |
405, /* "ANSI X9.62" */
|
|
|
9b88be |
@@ -4262,8 +4268,10 @@ static const unsigned int ln_objs[NUM_LN
|
|
|
9b88be |
957, /* "jurisdictionCountryName" */
|
|
|
9b88be |
955, /* "jurisdictionLocalityName" */
|
|
|
9b88be |
956, /* "jurisdictionStateOrProvinceName" */
|
|
|
9b88be |
+ 1196, /* "kbkdf" */
|
|
|
9b88be |
150, /* "keyBag" */
|
|
|
9b88be |
773, /* "kisa" */
|
|
|
9b88be |
+ 1197, /* "krb5kdf" */
|
|
|
9b88be |
1063, /* "kx-any" */
|
|
|
9b88be |
1039, /* "kx-dhe" */
|
|
|
9b88be |
1041, /* "kx-dhe-psk" */
|
|
|
9b88be |
@@ -4612,6 +4620,7 @@ static const unsigned int ln_objs[NUM_LN
|
|
|
9b88be |
1133, /* "sm4-ecb" */
|
|
|
9b88be |
1135, /* "sm4-ofb" */
|
|
|
9b88be |
1195, /* "sshkdf" */
|
|
|
9b88be |
+ 1198, /* "sskdf" */
|
|
|
9b88be |
16, /* "stateOrProvinceName" */
|
|
|
9b88be |
660, /* "streetAddress" */
|
|
|
9b88be |
498, /* "subtreeMaximumQuality" */
|
|
|
9b88be |
diff -up openssl-1.1.1d/crypto/objects/objects.txt.krb5-kdf openssl-1.1.1d/crypto/objects/objects.txt
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/objects/objects.txt.krb5-kdf 2019-11-14 15:07:05.322094485 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/objects/objects.txt 2019-11-14 15:07:05.345094076 +0100
|
|
|
9b88be |
@@ -1603,6 +1603,15 @@ secg-scheme 14 3 : dhSinglePass-cofactor
|
|
|
9b88be |
# NID for SSHKDF
|
|
|
9b88be |
: SSHKDF : sshkdf
|
|
|
9b88be |
|
|
|
9b88be |
+# NID for KBKDF
|
|
|
9b88be |
+ : KBKDF : kbkdf
|
|
|
9b88be |
+
|
|
|
9b88be |
+# NID for KRB5KDF
|
|
|
9b88be |
+ : KRB5KDF : krb5kdf
|
|
|
9b88be |
+
|
|
|
9b88be |
+# NID for SSKDF
|
|
|
9b88be |
+ : SSKDF : sskdf
|
|
|
9b88be |
+
|
|
|
9b88be |
# RFC 4556
|
|
|
9b88be |
1 3 6 1 5 2 3 : id-pkinit
|
|
|
9b88be |
id-pkinit 4 : pkInitClientAuth : PKINIT Client Auth
|
|
|
9b88be |
diff -up openssl-1.1.1d/crypto/objects/obj_mac.num.krb5-kdf openssl-1.1.1d/crypto/objects/obj_mac.num
|
|
|
9b88be |
--- openssl-1.1.1d/crypto/objects/obj_mac.num.krb5-kdf 2019-11-14 15:07:05.322094485 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/crypto/objects/obj_mac.num 2019-11-14 15:07:05.346094058 +0100
|
|
|
9b88be |
@@ -1193,3 +1193,6 @@ magma_mac 1192
|
|
|
9b88be |
hmacWithSHA512_224 1193
|
|
|
9b88be |
hmacWithSHA512_256 1194
|
|
|
9b88be |
sshkdf 1195
|
|
|
9b88be |
+kbkdf 1196
|
|
|
9b88be |
+krb5kdf 1197
|
|
|
9b88be |
+sskdf 1198
|
|
|
9b88be |
diff -up openssl-1.1.1d/doc/man3/EVP_KDF_CTX.pod.krb5-kdf openssl-1.1.1d/doc/man3/EVP_KDF_CTX.pod
|
|
|
9b88be |
--- openssl-1.1.1d/doc/man3/EVP_KDF_CTX.pod.krb5-kdf 2019-11-14 15:07:05.314094628 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/doc/man3/EVP_KDF_CTX.pod 2019-11-14 15:07:05.346094058 +0100
|
|
|
9b88be |
@@ -140,7 +140,14 @@ The value string is expected to be a dec
|
|
|
9b88be |
This control expects one argument: C<EVP_MD *md>
|
|
|
9b88be |
|
|
|
9b88be |
For MAC implementations that use a message digest as an underlying computation
|
|
|
9b88be |
-algorithm, this control set what the digest algorithm should be.
|
|
|
9b88be |
+algorithm, this control sets what the digest algorithm should be.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_CIPHER>
|
|
|
9b88be |
+
|
|
|
9b88be |
+This control expects one argument: C<EVP_CIPHER *cipher>
|
|
|
9b88be |
+
|
|
|
9b88be |
+For MAC implementations that use a cipher as an underlying computation
|
|
|
9b88be |
+algorithm, this control sets what the cipher algorithm should be.
|
|
|
9b88be |
|
|
|
9b88be |
EVP_KDF_ctrl_str() type string: "md"
|
|
|
9b88be |
|
|
|
9b88be |
diff -up openssl-1.1.1d/doc/man7/EVP_KDF_KB.pod.krb5-kdf openssl-1.1.1d/doc/man7/EVP_KDF_KB.pod
|
|
|
9b88be |
--- openssl-1.1.1d/doc/man7/EVP_KDF_KB.pod.krb5-kdf 2019-11-14 15:07:05.346094058 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/doc/man7/EVP_KDF_KB.pod 2019-11-14 15:07:05.346094058 +0100
|
|
|
9b88be |
@@ -0,0 +1,173 @@
|
|
|
9b88be |
+=pod
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 NAME
|
|
|
9b88be |
+
|
|
|
9b88be |
+EVP_KDF_KB - The Key-Based EVP_KDF implementation
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 DESCRIPTION
|
|
|
9b88be |
+
|
|
|
9b88be |
+The EVP_KDF_KB algorithm implements the Key-Based key derivation function
|
|
|
9b88be |
+(KBKDF). KBKDF derives a key from repeated application of a keyed MAC to an
|
|
|
9b88be |
+input secret (and other optional values).
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head2 Numeric identity
|
|
|
9b88be |
+
|
|
|
9b88be |
+B<EVP_KDF_KB> is the numeric identity for this implementation; it can be used with the
|
|
|
9b88be |
+EVP_KDF_CTX_new_id() function.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head2 Supported controls
|
|
|
9b88be |
+
|
|
|
9b88be |
+The supported controls are:
|
|
|
9b88be |
+
|
|
|
9b88be |
+=over 4
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_KB_MODE>
|
|
|
9b88be |
+
|
|
|
9b88be |
+This control expects one argument: C<int mode>
|
|
|
9b88be |
+
|
|
|
9b88be |
+Sets the mode for the KBKDF operation. There are two supported modes:
|
|
|
9b88be |
+
|
|
|
9b88be |
+=over 4
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_KB_MODE_COUNTER>
|
|
|
9b88be |
+
|
|
|
9b88be |
+The counter mode of KBKDF should be used. This is the default.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_KB_MODE_FEEDBACK>
|
|
|
9b88be |
+
|
|
|
9b88be |
+The feedback mode of KBKDF should be used.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=back
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_KB_MAC_TYPE>
|
|
|
9b88be |
+
|
|
|
9b88be |
+This control expects one argument: C<int mac_type>
|
|
|
9b88be |
+
|
|
|
9b88be |
+Sets the mac type for the KBKDF operation. There are two supported mac types:
|
|
|
9b88be |
+
|
|
|
9b88be |
+=over 4
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_KB_MAC_TYPE_HMAC>
|
|
|
9b88be |
+
|
|
|
9b88be |
+The HMAC with the digest set by B<EVP_KDF_CTRL_SET_MD> should be used as the mac.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_KB_MAC_TYPE_CMAC>
|
|
|
9b88be |
+
|
|
|
9b88be |
+The CMAC with the cipher set by B<EVP_KDF_CTRL_SET_CIPHER> should be used as the mac.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=back
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_MD>
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_CIPHER>
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_KEY>
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_SALT>
|
|
|
9b88be |
+
|
|
|
9b88be |
+These controls work as described in L<EVP_KDF_CTX(3)/CONTROLS>.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_KB_INFO>
|
|
|
9b88be |
+
|
|
|
9b88be |
+This control expects two arguments: C<unsigned char *info>, C<size_t infolen>
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_KB_SEED>
|
|
|
9b88be |
+
|
|
|
9b88be |
+This control expects two arguments: C<unsigned char *seed>, C<size_t seedlen>
|
|
|
9b88be |
+
|
|
|
9b88be |
+It is used only in the feedback mode and the length must be the same
|
|
|
9b88be |
+as the block length of the cipher in CMAC or the size of the digest in HMAC.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=back
|
|
|
9b88be |
+
|
|
|
9b88be |
+The controls B<EVP_KDF_CTRL_SET_KEY>, B<EVP_KDF_CTRL_SET_SALT>,
|
|
|
9b88be |
+B<EVP_KDF_CTRL_SET_KB_INFO>, and B<EVP_KDF_CTRL_SET_KB_SEED>
|
|
|
9b88be |
+correspond to KI, Label, Context, and IV (respectively) in SP800-108.
|
|
|
9b88be |
+As in that document, salt, info, and seed are optional and may be
|
|
|
9b88be |
+omitted.
|
|
|
9b88be |
+
|
|
|
9b88be |
+Depending on whether mac is CMAC or HMAC, either digest or cipher is
|
|
|
9b88be |
+required (respectively) and the other is unused.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 NOTES
|
|
|
9b88be |
+
|
|
|
9b88be |
+A context for KBKDF can be obtained by calling:
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_CTX *kctx = EVP_KDF_CTX_new_id(EVP_KDF_KB);
|
|
|
9b88be |
+
|
|
|
9b88be |
+The output length of an KBKDF is specified via the C<keylen>
|
|
|
9b88be |
+parameter to the L<EVP_KDF_derive(3)> function.
|
|
|
9b88be |
+
|
|
|
9b88be |
+Note that currently OpenSSL only implements counter and feedback modes. Other
|
|
|
9b88be |
+variants may be supported in the future.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 EXAMPLES
|
|
|
9b88be |
+
|
|
|
9b88be |
+This example derives 10 bytes using COUNTER-HMAC-SHA256, with KI "secret",
|
|
|
9b88be |
+Label "label", and Context "context".
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_CTX *kctx;
|
|
|
9b88be |
+ unsigned char out[10];
|
|
|
9b88be |
+
|
|
|
9b88be |
+ kctx = EVP_KDF_CTX_new_id(EVP_KDF_KB);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256());
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_MAC_TYPE, EVP_KDF_KB_MAC_TYPE_HMAC);
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, "secret", strlen("secret"));
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, "label", strlen("label"));
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_INFO, "context", strlen("context"));
|
|
|
9b88be |
+ if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0)
|
|
|
9b88be |
+ error("EVP_KDF_derive");
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_CTX_free(kctx);
|
|
|
9b88be |
+
|
|
|
9b88be |
+This example derives 10 bytes using FEEDBACK-CMAC-AES256, with KI "secret",
|
|
|
9b88be |
+Label "label", Context "context", and IV "sixteen bytes iv".
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_CTX *kctx;
|
|
|
9b88be |
+ unsigned char out[10];
|
|
|
9b88be |
+ unsigned char *iv = "sixteen bytes iv";
|
|
|
9b88be |
+
|
|
|
9b88be |
+ kctx = EVP_KDF_CTX_new_id(EVP_KDF_KB);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_CIPHER, EVP_aes_256_cbc());
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_MAC_TYPE, EVP_KDF_KB_MAC_TYPE_CMAC);
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_MODE, EVP_KDF_KB_MODE_FEEDBACK);
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, "secret", strlen("secret"));
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, "label", strlen("label"));
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_INFO, "context", strlen("context"));
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_SEED, iv, strlen(iv));
|
|
|
9b88be |
+ if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0)
|
|
|
9b88be |
+ error("EVP_KDF_derive");
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_CTX_free(kctx);
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 CONFORMING TO
|
|
|
9b88be |
+
|
|
|
9b88be |
+NIST SP800-108, IETF RFC 6803, IETF RFC 8009.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 SEE ALSO
|
|
|
9b88be |
+
|
|
|
9b88be |
+L<EVP_KDF_CTX(3)>,
|
|
|
9b88be |
+L<EVP_KDF_CTX_new_id(3)>,
|
|
|
9b88be |
+L<EVP_KDF_CTX_free(3)>,
|
|
|
9b88be |
+L<EVP_KDF_ctrl(3)>,
|
|
|
9b88be |
+L<EVP_KDF_size(3)>,
|
|
|
9b88be |
+L<EVP_KDF_derive(3)>,
|
|
|
9b88be |
+L<EVP_KDF_CTX(3)/CONTROLS>
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 HISTORY
|
|
|
9b88be |
+
|
|
|
9b88be |
+This functionality was added to OpenSSL 3.0.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 COPYRIGHT
|
|
|
9b88be |
+
|
|
|
9b88be |
+Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
|
|
9b88be |
+Copyright 2019 Red Hat, Inc.
|
|
|
9b88be |
+
|
|
|
9b88be |
+Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
|
9b88be |
+this file except in compliance with the License. You can obtain a copy
|
|
|
9b88be |
+in the file LICENSE in the source distribution or at
|
|
|
9b88be |
+L<https://www.openssl.org/source/license.html>.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=cut
|
|
|
9b88be |
diff -up openssl-1.1.1d/doc/man7/EVP_KDF_KRB5KDF.pod.krb5-kdf openssl-1.1.1d/doc/man7/EVP_KDF_KRB5KDF.pod
|
|
|
9b88be |
--- openssl-1.1.1d/doc/man7/EVP_KDF_KRB5KDF.pod.krb5-kdf 2019-11-14 15:07:05.346094058 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/doc/man7/EVP_KDF_KRB5KDF.pod 2019-11-14 15:07:05.346094058 +0100
|
|
|
9b88be |
@@ -0,0 +1,107 @@
|
|
|
9b88be |
+=pod
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 NAME
|
|
|
9b88be |
+
|
|
|
9b88be |
+EVP_KDF_KRB5KDF - The RFC3961 Krb5 KDF EVP_KDF implementation
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 DESCRIPTION
|
|
|
9b88be |
+
|
|
|
9b88be |
+Support for computing the B<KRB5KDF> KDF through the B<EVP_KDF> API.
|
|
|
9b88be |
+
|
|
|
9b88be |
+The B<EVP_KDF_KRB5KDF> algorithm implements the key derivation function defined
|
|
|
9b88be |
+in RFC 3961, section 5.1 and is used by Krb5 to derive session keys.
|
|
|
9b88be |
+Three inputs are required to perform key derivation: a cipher, (for example
|
|
|
9b88be |
+AES-128-CBC), the initial key, and a constant.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head2 Numeric identity
|
|
|
9b88be |
+
|
|
|
9b88be |
+B<EVP_KDF_KRB5KDF> is the numeric identity for this implementation; it can be used with the
|
|
|
9b88be |
+EVP_KDF_CTX_new_id() function.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head2 Supported controls
|
|
|
9b88be |
+
|
|
|
9b88be |
+The supported controls are:
|
|
|
9b88be |
+
|
|
|
9b88be |
+=over 4
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_CIPHER>
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_KEY>
|
|
|
9b88be |
+
|
|
|
9b88be |
+These controls work as described in L<EVP_KDF_CTX(3)/CONTROLS>.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_KRB5KDF_CONSTANT>
|
|
|
9b88be |
+
|
|
|
9b88be |
+This control expects two arguments: C<unsigned char *constant>, C<size_t constantlen>
|
|
|
9b88be |
+
|
|
|
9b88be |
+This control sets the I<constant> value for the KDF.
|
|
|
9b88be |
+If a value is already set, the contents are replaced.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=back
|
|
|
9b88be |
+
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 NOTES
|
|
|
9b88be |
+
|
|
|
9b88be |
+A context for KRB5KDF can be obtained by calling:
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_CTX *kctx = EVP_KDF_CTX_new_id(EVP_KDF_KRB5KDF);
|
|
|
9b88be |
+
|
|
|
9b88be |
+The output length of the KRB5KDF derivation is specified via the I<keylen>
|
|
|
9b88be |
+parameter to the L<EVP_KDF_derive(3)> function, and MUST match the key
|
|
|
9b88be |
+length for the chosen cipher or an error is returned. Moreover the
|
|
|
9b88be |
+I<constant>'s length must not exceed the block size of the cipher.
|
|
|
9b88be |
+Since the KRB5KDF output length depends on the chosen cipher, calling
|
|
|
9b88be |
+L<EVP_KDF_size()> to obtain the requisite length returns the correct length
|
|
|
9b88be |
+only after the cipher is set. Prior to that B<EVP_MAX_KEY_LENGTH> is returned.
|
|
|
9b88be |
+The caller must allocate a buffer of the correct length for the chosen
|
|
|
9b88be |
+cipher, and pass that buffer to the L<EVP_KDF_derive(3)> function along
|
|
|
9b88be |
+with that length.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 EXAMPLES
|
|
|
9b88be |
+
|
|
|
9b88be |
+This example derives a key using the AES-128-CBC cipher:
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_CTX *kctx;
|
|
|
9b88be |
+ unsigned char key[16] = "01234...";
|
|
|
9b88be |
+ unsigned char constant[] = "I'm a constant";
|
|
|
9b88be |
+ unsigned char out[16];
|
|
|
9b88be |
+ size_t outlen = sizeof(out);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ kctx = EVP_KDF_CTX_new_id(EVP_KDF_KRB5KDF);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_CIPHER, EVP_aes_128_cbc());
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, key, (size_t)16);
|
|
|
9b88be |
+ EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KRB5KDF_CONSTANT, constant, strlen(constant));
|
|
|
9b88be |
+ if (EVP_KDF_derive(kctx, out, outlen) <= 0)
|
|
|
9b88be |
+ /* Error */
|
|
|
9b88be |
+ EVP_KDF_CTX_free(kctx);
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 CONFORMING TO
|
|
|
9b88be |
+
|
|
|
9b88be |
+RFC 3961
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 SEE ALSO
|
|
|
9b88be |
+
|
|
|
9b88be |
+L<EVP_KDF_CTX(3)>,
|
|
|
9b88be |
+L<EVP_KDF_CTX_new_id(3)>,
|
|
|
9b88be |
+L<EVP_KDF_CTX_free(3)>,
|
|
|
9b88be |
+L<EVP_KDF_ctrl(3)>,
|
|
|
9b88be |
+L<EVP_KDF_size(3)>,
|
|
|
9b88be |
+L<EVP_KDF_derive(3)>,
|
|
|
9b88be |
+L<EVP_KDF_CTX(3)/CONTROLS>
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 HISTORY
|
|
|
9b88be |
+
|
|
|
9b88be |
+This functionality was added to OpenSSL 3.0.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 COPYRIGHT
|
|
|
9b88be |
+
|
|
|
9b88be |
+Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
|
|
|
9b88be |
+
|
|
|
9b88be |
+Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
9b88be |
+this file except in compliance with the License. You can obtain a copy
|
|
|
9b88be |
+in the file LICENSE in the source distribution or at
|
|
|
9b88be |
+L<https://www.openssl.org/source/license.html>.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=cut
|
|
|
9b88be |
+
|
|
|
9b88be |
diff -up openssl-1.1.1d/doc/man7/EVP_KDF_SS.pod.krb5-kdf openssl-1.1.1d/doc/man7/EVP_KDF_SS.pod
|
|
|
9b88be |
--- openssl-1.1.1d/doc/man7/EVP_KDF_SS.pod.krb5-kdf 2019-11-14 15:07:05.346094058 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/doc/man7/EVP_KDF_SS.pod 2019-11-14 15:07:05.346094058 +0100
|
|
|
9b88be |
@@ -0,0 +1,146 @@
|
|
|
9b88be |
+=pod
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 NAME
|
|
|
9b88be |
+
|
|
|
9b88be |
+EVP_KDF_SS - The Single Step / One Step EVP_KDF implementation
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 DESCRIPTION
|
|
|
9b88be |
+
|
|
|
9b88be |
+The EVP_KDF_SS algorithm implements the Single Step key derivation function (SSKDF).
|
|
|
9b88be |
+SSKDF derives a key using input such as a shared secret key (that was generated
|
|
|
9b88be |
+during the execution of a key establishment scheme) and fixedinfo.
|
|
|
9b88be |
+SSKDF is also informally referred to as 'Concat KDF'.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head2 Auxilary function
|
|
|
9b88be |
+
|
|
|
9b88be |
+The implementation uses a selectable auxiliary function H, which can be in the
|
|
|
9b88be |
+backported version only a:
|
|
|
9b88be |
+
|
|
|
9b88be |
+=over 4
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<H(x) = hash(x, digest=md)>
|
|
|
9b88be |
+
|
|
|
9b88be |
+=back
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head2 Numeric identity
|
|
|
9b88be |
+
|
|
|
9b88be |
+B<EVP_KDF_SS> is the numeric identity for this implementation; it
|
|
|
9b88be |
+can be used with the EVP_KDF_CTX_new_id() function.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head2 Supported controls
|
|
|
9b88be |
+
|
|
|
9b88be |
+The supported controls are:
|
|
|
9b88be |
+
|
|
|
9b88be |
+=over 4
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_MD>
|
|
|
9b88be |
+
|
|
|
9b88be |
+This control works as described in L<EVP_KDF_CTX(3)/CONTROLS>.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_KEY>
|
|
|
9b88be |
+
|
|
|
9b88be |
+This control expects two arguments: C<unsigned char *secret>, C<size_t secretlen>
|
|
|
9b88be |
+
|
|
|
9b88be |
+The shared secret used for key derivation. This control sets the secret.
|
|
|
9b88be |
+
|
|
|
9b88be |
+EVP_KDF_ctrl_str() takes two type strings for this control:
|
|
|
9b88be |
+
|
|
|
9b88be |
+=over 4
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item "secret"
|
|
|
9b88be |
+
|
|
|
9b88be |
+The value string is used as is.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item "hexsecret"
|
|
|
9b88be |
+
|
|
|
9b88be |
+The value string is expected to be a hexadecimal number, which will be
|
|
|
9b88be |
+decoded before being passed on as the control value.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=back
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item B<EVP_KDF_CTRL_SET_SSKDF_INFO>
|
|
|
9b88be |
+
|
|
|
9b88be |
+This control expects two arguments: C<unsigned char *info>, C<size_t infolen>
|
|
|
9b88be |
+
|
|
|
9b88be |
+An optional value for fixedinfo, also known as otherinfo. This control sets the fixedinfo.
|
|
|
9b88be |
+
|
|
|
9b88be |
+EVP_KDF_ctrl_str() takes two type strings for this control:
|
|
|
9b88be |
+
|
|
|
9b88be |
+=over 4
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item "info"
|
|
|
9b88be |
+
|
|
|
9b88be |
+The value string is used as is.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=item "hexinfo"
|
|
|
9b88be |
+
|
|
|
9b88be |
+The value string is expected to be a hexadecimal number, which will be
|
|
|
9b88be |
+decoded before being passed on as the control value.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=back
|
|
|
9b88be |
+
|
|
|
9b88be |
+=back
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 NOTES
|
|
|
9b88be |
+
|
|
|
9b88be |
+A context for SSKDF can be obtained by calling:
|
|
|
9b88be |
+
|
|
|
9b88be |
+EVP_KDF_CTX *kctx = EVP_KDF_CTX_new_id(EVP_KDF_SS);
|
|
|
9b88be |
+
|
|
|
9b88be |
+The output length of an SSKDF is specified via the C<keylen>
|
|
|
9b88be |
+parameter to the L<EVP_KDF_derive(3)> function.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 EXAMPLE
|
|
|
9b88be |
+
|
|
|
9b88be |
+This example derives 10 bytes using H(x) = SHA-256, with the secret key "secret"
|
|
|
9b88be |
+and fixedinfo value "label":
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_CTX *kctx;
|
|
|
9b88be |
+ unsigned char out[10];
|
|
|
9b88be |
+
|
|
|
9b88be |
+ kctx = EVP_KDF_CTX_new_id(EVP_KDF_SS);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()) <= 0) {
|
|
|
9b88be |
+ error("EVP_KDF_CTRL_SET_MD");
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, "secret", (size_t)6) <= 0) {
|
|
|
9b88be |
+ error("EVP_KDF_CTRL_SET_KEY");
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SSKDF_INFO, "label", (size_t)5) <= 0) {
|
|
|
9b88be |
+ error("EVP_KDF_CTRL_SET_SSKDF_INFO");
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
|
|
|
9b88be |
+ error("EVP_KDF_derive");
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_CTX_free(kctx);
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 CONFORMING TO
|
|
|
9b88be |
+
|
|
|
9b88be |
+NIST SP800-56Cr1.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 SEE ALSO
|
|
|
9b88be |
+
|
|
|
9b88be |
+L<EVP_KDF_CTX>,
|
|
|
9b88be |
+L<EVP_KDF_CTX_new_id(3)>,
|
|
|
9b88be |
+L<EVP_KDF_CTX_free(3)>,
|
|
|
9b88be |
+L<EVP_KDF_ctrl(3)>,
|
|
|
9b88be |
+L<EVP_KDF_size(3)>,
|
|
|
9b88be |
+L<EVP_KDF_derive(3)>,
|
|
|
9b88be |
+L<EVP_KDF_CTX(3)/CONTROLS>
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 HISTORY
|
|
|
9b88be |
+
|
|
|
9b88be |
+This functionality was added to OpenSSL 3.0.0.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=head1 COPYRIGHT
|
|
|
9b88be |
+
|
|
|
9b88be |
+Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. Copyright
|
|
|
9b88be |
+(c) 2019, Oracle and/or its affiliates. All rights reserved.
|
|
|
9b88be |
+
|
|
|
9b88be |
+Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
|
9b88be |
+this file except in compliance with the License. You can obtain a copy
|
|
|
9b88be |
+in the file LICENSE in the source distribution or at
|
|
|
9b88be |
+L<https://www.openssl.org/source/license.html>.
|
|
|
9b88be |
+
|
|
|
9b88be |
+=cut
|
|
|
9b88be |
diff -up openssl-1.1.1d/include/openssl/kdferr.h.krb5-kdf openssl-1.1.1d/include/openssl/kdferr.h
|
|
|
9b88be |
--- openssl-1.1.1d/include/openssl/kdferr.h.krb5-kdf 2019-11-14 15:07:05.323094468 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/include/openssl/kdferr.h 2019-11-14 15:07:05.347094040 +0100
|
|
|
9b88be |
@@ -24,6 +24,11 @@ int ERR_load_KDF_strings(void);
|
|
|
9b88be |
* KDF function codes.
|
|
|
9b88be |
*/
|
|
|
9b88be |
# define KDF_F_HKDF_EXTRACT 112
|
|
|
9b88be |
+# define KDF_F_KBKDF_CTRL 134
|
|
|
9b88be |
+# define KDF_F_KBKDF_CTRL_STR 135
|
|
|
9b88be |
+# define KDF_F_KBKDF_DERIVE 136
|
|
|
9b88be |
+# define KDF_F_KBKDF_NEW 137
|
|
|
9b88be |
+# define KDF_F_KDF_CIPHER2CTRL 138
|
|
|
9b88be |
# define KDF_F_KDF_HKDF_DERIVE 113
|
|
|
9b88be |
# define KDF_F_KDF_HKDF_NEW 114
|
|
|
9b88be |
# define KDF_F_KDF_HKDF_SIZE 115
|
|
|
9b88be |
@@ -43,6 +48,8 @@ int ERR_load_KDF_strings(void);
|
|
|
9b88be |
# define KDF_F_KDF_TLS1_PRF_CTRL_STR 125
|
|
|
9b88be |
# define KDF_F_KDF_TLS1_PRF_DERIVE 126
|
|
|
9b88be |
# define KDF_F_KDF_TLS1_PRF_NEW 127
|
|
|
9b88be |
+# define KDF_F_KRB5KDF 139
|
|
|
9b88be |
+# define KDF_F_KRB5KDF_DERIVE 140
|
|
|
9b88be |
# define KDF_F_PBKDF2_SET_MEMBUF 128
|
|
|
9b88be |
# define KDF_F_PKEY_HKDF_CTRL_STR 103
|
|
|
9b88be |
# define KDF_F_PKEY_HKDF_DERIVE 102
|
|
|
9b88be |
@@ -56,12 +63,21 @@ int ERR_load_KDF_strings(void);
|
|
|
9b88be |
# define KDF_F_PKEY_TLS1_PRF_DERIVE 101
|
|
|
9b88be |
# define KDF_F_PKEY_TLS1_PRF_INIT 110
|
|
|
9b88be |
# define KDF_F_SCRYPT_SET_MEMBUF 129
|
|
|
9b88be |
+# define KDF_F_SSKDF_DERIVE 141
|
|
|
9b88be |
+# define KDF_F_SSKDF_NEW 142
|
|
|
9b88be |
+# define KDF_F_SSKDF_SIZE 143
|
|
|
9b88be |
# define KDF_F_TLS1_PRF_ALG 111
|
|
|
9b88be |
|
|
|
9b88be |
/*
|
|
|
9b88be |
* KDF reason codes.
|
|
|
9b88be |
*/
|
|
|
9b88be |
+# define KDF_R_FAILED_TO_GENERATE_KEY 118
|
|
|
9b88be |
+# define KDF_R_INVALID_CIPHER 116
|
|
|
9b88be |
+# define KDF_R_INVALID_CONSTANT_LENGTH 119
|
|
|
9b88be |
# define KDF_R_INVALID_DIGEST 100
|
|
|
9b88be |
+# define KDF_R_INVALID_SEED_LENGTH 117
|
|
|
9b88be |
+# define KDF_R_MISSING_CIPHER 120
|
|
|
9b88be |
+# define KDF_R_MISSING_CONSTANT 121
|
|
|
9b88be |
# define KDF_R_MISSING_ITERATION_COUNT 109
|
|
|
9b88be |
# define KDF_R_MISSING_KEY 104
|
|
|
9b88be |
# define KDF_R_MISSING_MESSAGE_DIGEST 105
|
|
|
9b88be |
@@ -76,6 +92,7 @@ int ERR_load_KDF_strings(void);
|
|
|
9b88be |
# define KDF_R_UNKNOWN_PARAMETER_TYPE 103
|
|
|
9b88be |
# define KDF_R_VALUE_ERROR 108
|
|
|
9b88be |
# define KDF_R_VALUE_MISSING 102
|
|
|
9b88be |
+# define KDF_R_WRONG_FINAL_BLOCK_LENGTH 122
|
|
|
9b88be |
# define KDF_R_WRONG_OUTPUT_BUFFER_SIZE 112
|
|
|
9b88be |
|
|
|
9b88be |
#endif
|
|
|
9b88be |
diff -up openssl-1.1.1d/include/openssl/kdf.h.krb5-kdf openssl-1.1.1d/include/openssl/kdf.h
|
|
|
9b88be |
--- openssl-1.1.1d/include/openssl/kdf.h.krb5-kdf 2019-11-14 15:07:05.323094468 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/include/openssl/kdf.h 2019-11-14 15:07:05.347094040 +0100
|
|
|
9b88be |
@@ -21,6 +21,9 @@ extern "C" {
|
|
|
9b88be |
# define EVP_KDF_TLS1_PRF NID_tls1_prf
|
|
|
9b88be |
# define EVP_KDF_HKDF NID_hkdf
|
|
|
9b88be |
# define EVP_KDF_SSHKDF NID_sshkdf
|
|
|
9b88be |
+# define EVP_KDF_KB NID_kbkdf
|
|
|
9b88be |
+# define EVP_KDF_KRB5KDF NID_krb5kdf
|
|
|
9b88be |
+# define EVP_KDF_SS NID_sskdf
|
|
|
9b88be |
|
|
|
9b88be |
EVP_KDF_CTX *EVP_KDF_CTX_new_id(int id);
|
|
|
9b88be |
void EVP_KDF_CTX_free(EVP_KDF_CTX *ctx);
|
|
|
9b88be |
@@ -51,6 +54,13 @@ int EVP_KDF_derive(EVP_KDF_CTX *ctx, uns
|
|
|
9b88be |
# define EVP_KDF_CTRL_SET_SSHKDF_XCGHASH 0x10 /* unsigned char *, size_t */
|
|
|
9b88be |
# define EVP_KDF_CTRL_SET_SSHKDF_SESSION_ID 0x11 /* unsigned char *, size_t */
|
|
|
9b88be |
# define EVP_KDF_CTRL_SET_SSHKDF_TYPE 0x12 /* int */
|
|
|
9b88be |
+# define EVP_KDF_CTRL_SET_KB_MODE 0x13 /* int */
|
|
|
9b88be |
+# define EVP_KDF_CTRL_SET_KB_MAC_TYPE 0x14 /* int */
|
|
|
9b88be |
+# define EVP_KDF_CTRL_SET_CIPHER 0x15 /* EVP_CIPHER * */
|
|
|
9b88be |
+# define EVP_KDF_CTRL_SET_KB_INFO 0x16 /* unsigned char *, size_t */
|
|
|
9b88be |
+# define EVP_KDF_CTRL_SET_KB_SEED 0x17 /* unsigned char *, size_t */
|
|
|
9b88be |
+# define EVP_KDF_CTRL_SET_KRB5KDF_CONSTANT 0x18 /* unsigned char *, size_t */
|
|
|
9b88be |
+# define EVP_KDF_CTRL_SET_SSKDF_INFO 0x19 /* unsigned char *, size_t */
|
|
|
9b88be |
|
|
|
9b88be |
# define EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND 0
|
|
|
9b88be |
# define EVP_KDF_HKDF_MODE_EXTRACT_ONLY 1
|
|
|
9b88be |
@@ -63,6 +73,12 @@ int EVP_KDF_derive(EVP_KDF_CTX *ctx, uns
|
|
|
9b88be |
#define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV 69
|
|
|
9b88be |
#define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI 70
|
|
|
9b88be |
|
|
|
9b88be |
+#define EVP_KDF_KB_MODE_COUNTER 0
|
|
|
9b88be |
+#define EVP_KDF_KB_MODE_FEEDBACK 1
|
|
|
9b88be |
+
|
|
|
9b88be |
+#define EVP_KDF_KB_MAC_TYPE_HMAC 0
|
|
|
9b88be |
+#define EVP_KDF_KB_MAC_TYPE_CMAC 1
|
|
|
9b88be |
+
|
|
|
9b88be |
/**** The legacy PKEY-based KDF API follows. ****/
|
|
|
9b88be |
|
|
|
9b88be |
# define EVP_PKEY_CTRL_TLS_MD (EVP_PKEY_ALG_CTRL)
|
|
|
9b88be |
diff -up openssl-1.1.1d/include/openssl/obj_mac.h.krb5-kdf openssl-1.1.1d/include/openssl/obj_mac.h
|
|
|
9b88be |
--- openssl-1.1.1d/include/openssl/obj_mac.h.krb5-kdf 2019-11-14 15:07:05.323094468 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/include/openssl/obj_mac.h 2019-11-14 15:07:05.347094040 +0100
|
|
|
9b88be |
@@ -4974,6 +4974,18 @@
|
|
|
9b88be |
#define LN_sshkdf "sshkdf"
|
|
|
9b88be |
#define NID_sshkdf 1203
|
|
|
9b88be |
|
|
|
9b88be |
+#define SN_kbkdf "KBKDF"
|
|
|
9b88be |
+#define LN_kbkdf "kbkdf"
|
|
|
9b88be |
+#define NID_kbkdf 1204
|
|
|
9b88be |
+
|
|
|
9b88be |
+#define SN_krb5kdf "KRB5KDF"
|
|
|
9b88be |
+#define LN_krb5kdf "krb5kdf"
|
|
|
9b88be |
+#define NID_krb5kdf 1205
|
|
|
9b88be |
+
|
|
|
9b88be |
+#define SN_sskdf "SSKDF"
|
|
|
9b88be |
+#define LN_sskdf "sskdf"
|
|
|
9b88be |
+#define NID_sskdf 1206
|
|
|
9b88be |
+
|
|
|
9b88be |
#define SN_id_pkinit "id-pkinit"
|
|
|
9b88be |
#define NID_id_pkinit 1031
|
|
|
9b88be |
#define OBJ_id_pkinit 1L,3L,6L,1L,5L,2L,3L
|
|
|
9b88be |
diff -up openssl-1.1.1d/test/evp_kdf_test.c.krb5-kdf openssl-1.1.1d/test/evp_kdf_test.c
|
|
|
9b88be |
--- openssl-1.1.1d/test/evp_kdf_test.c.krb5-kdf 2019-11-14 15:07:05.315094610 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/test/evp_kdf_test.c 2019-11-14 15:07:05.348094022 +0100
|
|
|
9b88be |
@@ -225,13 +225,358 @@ err:
|
|
|
9b88be |
}
|
|
|
9b88be |
#endif
|
|
|
9b88be |
|
|
|
9b88be |
+/*
|
|
|
9b88be |
+ * KBKDF test vectors from RFC 6803 (Camellia Encryption for Kerberos 5)
|
|
|
9b88be |
+ * section 10.
|
|
|
9b88be |
+ */
|
|
|
9b88be |
+static int test_kdf_kbkdf_6803_128(void)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ int ret = 0, i;
|
|
|
9b88be |
+ EVP_KDF_CTX *kctx;
|
|
|
9b88be |
+ static unsigned char input_key[] = {
|
|
|
9b88be |
+ 0x57, 0xD0, 0x29, 0x72, 0x98, 0xFF, 0xD9, 0xD3,
|
|
|
9b88be |
+ 0x5D, 0xE5, 0xA4, 0x7F, 0xB4, 0xBD, 0xE2, 0x4B,
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ static unsigned char constants[][5] = {
|
|
|
9b88be |
+ { 0x00, 0x00, 0x00, 0x02, 0x99 },
|
|
|
9b88be |
+ { 0x00, 0x00, 0x00, 0x02, 0xaa },
|
|
|
9b88be |
+ { 0x00, 0x00, 0x00, 0x02, 0x55 },
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ static unsigned char outputs[][16] = {
|
|
|
9b88be |
+ {0xD1, 0x55, 0x77, 0x5A, 0x20, 0x9D, 0x05, 0xF0,
|
|
|
9b88be |
+ 0x2B, 0x38, 0xD4, 0x2A, 0x38, 0x9E, 0x5A, 0x56},
|
|
|
9b88be |
+ {0x64, 0xDF, 0x83, 0xF8, 0x5A, 0x53, 0x2F, 0x17,
|
|
|
9b88be |
+ 0x57, 0x7D, 0x8C, 0x37, 0x03, 0x57, 0x96, 0xAB},
|
|
|
9b88be |
+ {0x3E, 0x4F, 0xBD, 0xF3, 0x0F, 0xB8, 0x25, 0x9C,
|
|
|
9b88be |
+ 0x42, 0x5C, 0xB6, 0xC9, 0x6F, 0x1F, 0x46, 0x35}
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ static unsigned char iv[16] = { 0 };
|
|
|
9b88be |
+ unsigned char result[16] = { 0 };
|
|
|
9b88be |
+
|
|
|
9b88be |
+ for (i = 0; i < 3; i++) {
|
|
|
9b88be |
+ ret = 0;
|
|
|
9b88be |
+ if ((kctx = EVP_KDF_CTX_new_id(EVP_KDF_KB)) == NULL) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_KB");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_MAC_TYPE, EVP_KDF_KB_MAC_TYPE_CMAC) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KB_MAC_TYPE");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_MODE, EVP_KDF_KB_MODE_FEEDBACK) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KB_MODE");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_CIPHER, EVP_camellia_128_cbc()) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_CIPHER");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, input_key, sizeof(input_key)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KEY");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, constants[i], sizeof(constants[i])) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_SALT");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_SEED, iv, sizeof(iv)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KB_SEED");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ ret = TEST_int_gt(EVP_KDF_derive(kctx, result, sizeof(result)), 0)
|
|
|
9b88be |
+ && TEST_mem_eq(result, sizeof(result), outputs[i],
|
|
|
9b88be |
+ sizeof(outputs[i]));
|
|
|
9b88be |
+err:
|
|
|
9b88be |
+ EVP_KDF_CTX_free(kctx);
|
|
|
9b88be |
+ if (ret != 1)
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int test_kdf_kbkdf_6803_256(void)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ int ret = 0, i;
|
|
|
9b88be |
+ EVP_KDF_CTX *kctx;
|
|
|
9b88be |
+ static unsigned char input_key[] = {
|
|
|
9b88be |
+ 0xB9, 0xD6, 0x82, 0x8B, 0x20, 0x56, 0xB7, 0xBE,
|
|
|
9b88be |
+ 0x65, 0x6D, 0x88, 0xA1, 0x23, 0xB1, 0xFA, 0xC6,
|
|
|
9b88be |
+ 0x82, 0x14, 0xAC, 0x2B, 0x72, 0x7E, 0xCF, 0x5F,
|
|
|
9b88be |
+ 0x69, 0xAF, 0xE0, 0xC4, 0xDF, 0x2A, 0x6D, 0x2C,
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ static unsigned char constants[][5] = {
|
|
|
9b88be |
+ { 0x00, 0x00, 0x00, 0x02, 0x99 },
|
|
|
9b88be |
+ { 0x00, 0x00, 0x00, 0x02, 0xaa },
|
|
|
9b88be |
+ { 0x00, 0x00, 0x00, 0x02, 0x55 },
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ static unsigned char outputs[][32] = {
|
|
|
9b88be |
+ {0xE4, 0x67, 0xF9, 0xA9, 0x55, 0x2B, 0xC7, 0xD3,
|
|
|
9b88be |
+ 0x15, 0x5A, 0x62, 0x20, 0xAF, 0x9C, 0x19, 0x22,
|
|
|
9b88be |
+ 0x0E, 0xEE, 0xD4, 0xFF, 0x78, 0xB0, 0xD1, 0xE6,
|
|
|
9b88be |
+ 0xA1, 0x54, 0x49, 0x91, 0x46, 0x1A, 0x9E, 0x50,
|
|
|
9b88be |
+ },
|
|
|
9b88be |
+ {0x41, 0x2A, 0xEF, 0xC3, 0x62, 0xA7, 0x28, 0x5F,
|
|
|
9b88be |
+ 0xC3, 0x96, 0x6C, 0x6A, 0x51, 0x81, 0xE7, 0x60,
|
|
|
9b88be |
+ 0x5A, 0xE6, 0x75, 0x23, 0x5B, 0x6D, 0x54, 0x9F,
|
|
|
9b88be |
+ 0xBF, 0xC9, 0xAB, 0x66, 0x30, 0xA4, 0xC6, 0x04,
|
|
|
9b88be |
+ },
|
|
|
9b88be |
+ {0xFA, 0x62, 0x4F, 0xA0, 0xE5, 0x23, 0x99, 0x3F,
|
|
|
9b88be |
+ 0xA3, 0x88, 0xAE, 0xFD, 0xC6, 0x7E, 0x67, 0xEB,
|
|
|
9b88be |
+ 0xCD, 0x8C, 0x08, 0xE8, 0xA0, 0x24, 0x6B, 0x1D,
|
|
|
9b88be |
+ 0x73, 0xB0, 0xD1, 0xDD, 0x9F, 0xC5, 0x82, 0xB0,
|
|
|
9b88be |
+ },
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ static unsigned char iv[16] = { 0 };
|
|
|
9b88be |
+ unsigned char result[32] = { 0 };
|
|
|
9b88be |
+
|
|
|
9b88be |
+ for (i = 0; i < 3; i++) {
|
|
|
9b88be |
+ ret = 0;
|
|
|
9b88be |
+ if ((kctx = EVP_KDF_CTX_new_id(EVP_KDF_KB)) == NULL) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_KB");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_MAC_TYPE, EVP_KDF_KB_MAC_TYPE_CMAC) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KB_MAC_TYPE");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_MODE, EVP_KDF_KB_MODE_FEEDBACK) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KB_MODE");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_CIPHER, EVP_camellia_256_cbc()) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_CIPHER");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, input_key, sizeof(input_key)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KEY");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, constants[i], sizeof(constants[i])) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_SALT");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_SEED, iv, sizeof(iv)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KB_SEED");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ ret = TEST_int_gt(EVP_KDF_derive(kctx, result, sizeof(result)), 0)
|
|
|
9b88be |
+ && TEST_mem_eq(result, sizeof(result), outputs[i],
|
|
|
9b88be |
+ sizeof(outputs[i]));
|
|
|
9b88be |
+err:
|
|
|
9b88be |
+ EVP_KDF_CTX_free(kctx);
|
|
|
9b88be |
+ if (ret != 1)
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+/* Two test vectors from RFC 8009 (AES Encryption with HMAC-SHA2 for Kerberos
|
|
|
9b88be |
+ * 5) appendix A. */
|
|
|
9b88be |
+static int test_kdf_kbkdf_8009_prf1(void)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ int ret = 0;
|
|
|
9b88be |
+ EVP_KDF_CTX *kctx;
|
|
|
9b88be |
+ char *label = "prf", *prf_input = "test";
|
|
|
9b88be |
+ static unsigned char input_key[] = {
|
|
|
9b88be |
+ 0x37, 0x05, 0xD9, 0x60, 0x80, 0xC1, 0x77, 0x28,
|
|
|
9b88be |
+ 0xA0, 0xE8, 0x00, 0xEA, 0xB6, 0xE0, 0xD2, 0x3C,
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ static unsigned char output[] = {
|
|
|
9b88be |
+ 0x9D, 0x18, 0x86, 0x16, 0xF6, 0x38, 0x52, 0xFE,
|
|
|
9b88be |
+ 0x86, 0x91, 0x5B, 0xB8, 0x40, 0xB4, 0xA8, 0x86,
|
|
|
9b88be |
+ 0xFF, 0x3E, 0x6B, 0xB0, 0xF8, 0x19, 0xB4, 0x9B,
|
|
|
9b88be |
+ 0x89, 0x33, 0x93, 0xD3, 0x93, 0x85, 0x42, 0x95,
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ unsigned char result[sizeof(output)] = { 0 };
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if ((kctx = EVP_KDF_CTX_new_id(EVP_KDF_KB)) == NULL) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_KB");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_MAC_TYPE, EVP_KDF_KB_MAC_TYPE_HMAC) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KB_MAC_TYPE");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_MD");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, input_key, sizeof(input_key)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KEY");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, label, strlen(label)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_SALT");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_INFO, prf_input, strlen(prf_input)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KB_INFO");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ ret = TEST_int_gt(EVP_KDF_derive(kctx, result, sizeof(result)), 0)
|
|
|
9b88be |
+ && TEST_mem_eq(result, sizeof(result), output,
|
|
|
9b88be |
+ sizeof(output));
|
|
|
9b88be |
+err:
|
|
|
9b88be |
+ EVP_KDF_CTX_free(kctx);
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int test_kdf_kbkdf_8009_prf2(void)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ int ret = 0;
|
|
|
9b88be |
+ EVP_KDF_CTX *kctx;
|
|
|
9b88be |
+ char *label = "prf", *prf_input = "test";
|
|
|
9b88be |
+ static unsigned char input_key[] = {
|
|
|
9b88be |
+ 0x6D, 0x40, 0x4D, 0x37, 0xFA, 0xF7, 0x9F, 0x9D,
|
|
|
9b88be |
+ 0xF0, 0xD3, 0x35, 0x68, 0xD3, 0x20, 0x66, 0x98,
|
|
|
9b88be |
+ 0x00, 0xEB, 0x48, 0x36, 0x47, 0x2E, 0xA8, 0xA0,
|
|
|
9b88be |
+ 0x26, 0xD1, 0x6B, 0x71, 0x82, 0x46, 0x0C, 0x52,
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ static unsigned char output[] = {
|
|
|
9b88be |
+ 0x98, 0x01, 0xF6, 0x9A, 0x36, 0x8C, 0x2B, 0xF6,
|
|
|
9b88be |
+ 0x75, 0xE5, 0x95, 0x21, 0xE1, 0x77, 0xD9, 0xA0,
|
|
|
9b88be |
+ 0x7F, 0x67, 0xEF, 0xE1, 0xCF, 0xDE, 0x8D, 0x3C,
|
|
|
9b88be |
+ 0x8D, 0x6F, 0x6A, 0x02, 0x56, 0xE3, 0xB1, 0x7D,
|
|
|
9b88be |
+ 0xB3, 0xC1, 0xB6, 0x2A, 0xD1, 0xB8, 0x55, 0x33,
|
|
|
9b88be |
+ 0x60, 0xD1, 0x73, 0x67, 0xEB, 0x15, 0x14, 0xD2,
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ unsigned char result[sizeof(output)] = { 0 };
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if ((kctx = EVP_KDF_CTX_new_id(EVP_KDF_KB)) == NULL) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_KB");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_MAC_TYPE, EVP_KDF_KB_MAC_TYPE_HMAC) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KB_MAC_TYPE");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha384()) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_MD");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, input_key, sizeof(input_key)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KEY");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, label, strlen(label)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_SALT");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KB_INFO, prf_input, strlen(prf_input)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KB_INFO");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ ret = TEST_int_gt(EVP_KDF_derive(kctx, result, sizeof(result)), 0)
|
|
|
9b88be |
+ && TEST_mem_eq(result, sizeof(result), output,
|
|
|
9b88be |
+ sizeof(output));
|
|
|
9b88be |
+err:
|
|
|
9b88be |
+ EVP_KDF_CTX_free(kctx);
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int test_kdf_krb5kdf(void)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ int ret = 0;
|
|
|
9b88be |
+ EVP_KDF_CTX *kctx;
|
|
|
9b88be |
+ unsigned char out[16];
|
|
|
9b88be |
+ static unsigned char key[] = {
|
|
|
9b88be |
+ 0x42, 0x26, 0x3C, 0x6E, 0x89, 0xF4, 0xFC, 0x28,
|
|
|
9b88be |
+ 0xB8, 0xDF, 0x68, 0xEE, 0x09, 0x79, 0x9F, 0x15
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ static unsigned char constant[] = {
|
|
|
9b88be |
+ 0x00, 0x00, 0x00, 0x02, 0x99
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ static const unsigned char expected[sizeof(out)] = {
|
|
|
9b88be |
+ 0x34, 0x28, 0x0A, 0x38, 0x2B, 0xC9, 0x27, 0x69,
|
|
|
9b88be |
+ 0xB2, 0xDA, 0x2F, 0x9E, 0xF0, 0x66, 0x85, 0x4B
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if ((kctx = EVP_KDF_CTX_new_id(EVP_KDF_KRB5KDF)) == NULL) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_KRB5KDF");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_CIPHER, EVP_aes_128_cbc()) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_CIPHER");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, key, sizeof(key)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KEY");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KRB5KDF_CONSTANT, constant, sizeof(constant)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KRB5KDF_CONSTANT");
|
|
|
9b88be |
+ goto err;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ ret =
|
|
|
9b88be |
+ TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out)), 0)
|
|
|
9b88be |
+ && TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
|
|
|
9b88be |
+
|
|
|
9b88be |
+err:
|
|
|
9b88be |
+ EVP_KDF_CTX_free(kctx);
|
|
|
9b88be |
+ return ret;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
+static int test_kdf_ss_hash(void)
|
|
|
9b88be |
+{
|
|
|
9b88be |
+ EVP_KDF_CTX *kctx;
|
|
|
9b88be |
+ const unsigned char z[] = {
|
|
|
9b88be |
+ 0x6d,0xbd,0xc2,0x3f,0x04,0x54,0x88,0xe4,0x06,0x27,0x57,0xb0,0x6b,0x9e,
|
|
|
9b88be |
+ 0xba,0xe1,0x83,0xfc,0x5a,0x59,0x46,0xd8,0x0d,0xb9,0x3f,0xec,0x6f,0x62,
|
|
|
9b88be |
+ 0xec,0x07,0xe3,0x72,0x7f,0x01,0x26,0xae,0xd1,0x2c,0xe4,0xb2,0x62,0xf4,
|
|
|
9b88be |
+ 0x7d,0x48,0xd5,0x42,0x87,0xf8,0x1d,0x47,0x4c,0x7c,0x3b,0x18,0x50,0xe9
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ const unsigned char other[] = {
|
|
|
9b88be |
+ 0xa1,0xb2,0xc3,0xd4,0xe5,0x43,0x41,0x56,0x53,0x69,0x64,0x3c,0x83,0x2e,
|
|
|
9b88be |
+ 0x98,0x49,0xdc,0xdb,0xa7,0x1e,0x9a,0x31,0x39,0xe6,0x06,0xe0,0x95,0xde,
|
|
|
9b88be |
+ 0x3c,0x26,0x4a,0x66,0xe9,0x8a,0x16,0x58,0x54,0xcd,0x07,0x98,0x9b,0x1e,
|
|
|
9b88be |
+ 0xe0,0xec,0x3f,0x8d,0xbe
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ const unsigned char expected[] = {
|
|
|
9b88be |
+ 0xa4,0x62,0xde,0x16,0xa8,0x9d,0xe8,0x46,0x6e,0xf5,0x46,0x0b,0x47,0xb8
|
|
|
9b88be |
+ };
|
|
|
9b88be |
+ unsigned char out[14];
|
|
|
9b88be |
+
|
|
|
9b88be |
+ kctx = EVP_KDF_CTX_new_id(EVP_KDF_SS);
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha224()) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_MD");
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, z, sizeof(z)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_KEY");
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SSKDF_INFO, other,
|
|
|
9b88be |
+ sizeof(other)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_CTRL_SET_SSKDF_INFO");
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+ if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
|
|
|
9b88be |
+ TEST_error("EVP_KDF_derive");
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+ }
|
|
|
9b88be |
+
|
|
|
9b88be |
+ if (!TEST_mem_eq(out, sizeof(out), expected, sizeof(expected)))
|
|
|
9b88be |
+ return 0;
|
|
|
9b88be |
+
|
|
|
9b88be |
+ EVP_KDF_CTX_free(kctx);
|
|
|
9b88be |
+ return 1;
|
|
|
9b88be |
+}
|
|
|
9b88be |
+
|
|
|
9b88be |
int setup_tests(void)
|
|
|
9b88be |
{
|
|
|
9b88be |
+ ADD_TEST(test_kdf_kbkdf_6803_128);
|
|
|
9b88be |
+ ADD_TEST(test_kdf_kbkdf_6803_256);
|
|
|
9b88be |
+ ADD_TEST(test_kdf_kbkdf_8009_prf1);
|
|
|
9b88be |
+ ADD_TEST(test_kdf_kbkdf_8009_prf2);
|
|
|
9b88be |
ADD_TEST(test_kdf_tls1_prf);
|
|
|
9b88be |
ADD_TEST(test_kdf_hkdf);
|
|
|
9b88be |
ADD_TEST(test_kdf_pbkdf2);
|
|
|
9b88be |
#ifndef OPENSSL_NO_SCRYPT
|
|
|
9b88be |
ADD_TEST(test_kdf_scrypt);
|
|
|
9b88be |
#endif
|
|
|
9b88be |
+ ADD_TEST(test_kdf_krb5kdf);
|
|
|
9b88be |
+ ADD_TEST(test_kdf_ss_hash);
|
|
|
9b88be |
return 1;
|
|
|
9b88be |
}
|
|
|
9b88be |
diff -up openssl-1.1.1d/test/recipes/30-test_evp_data/evpkdf.txt.krb5-kdf openssl-1.1.1d/test/recipes/30-test_evp_data/evpkdf.txt
|
|
|
9b88be |
--- openssl-1.1.1d/test/recipes/30-test_evp_data/evpkdf.txt.krb5-kdf 2019-11-14 15:07:05.327094396 +0100
|
|
|
9b88be |
+++ openssl-1.1.1d/test/recipes/30-test_evp_data/evpkdf.txt 2019-11-14 15:07:05.349094005 +0100
|
|
|
9b88be |
@@ -5286,3 +5286,559 @@ Ctrl.hexsession_id = hexsession_id:a4ebd
|
|
|
9b88be |
Ctrl.type = type:A
|
|
|
9b88be |
Output = FF
|
|
|
9b88be |
Result = KDF_MISMATCH
|
|
|
9b88be |
+
|
|
|
9b88be |
+Title = KRB5KDF tests (from RFC 3961 test vectors and krb5 sources)
|
|
|
9b88be |
+
|
|
|
9b88be |
+#RFC3961
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:dce06b1f64c857a11c3db57c51899b2cc1791008ce973b92
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:0000000155
|
|
|
9b88be |
+Output = 925179d04591a79b5d3192c4a7e9c289b049c71f6ee604cd
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:5e13d31c70ef765746578531cb51c15bf11ca82c97cee9f2
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:00000001aa
|
|
|
9b88be |
+Output = 9e58e5a146d9942a101c469845d67a20e3c4259ed913f207
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:98e6fd8a04a4b6859b75a176540b9752bad3ecd610a252bc
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:0000000155
|
|
|
9b88be |
+Output = 13fef80d763e94ec6d13fd2ca1d085070249dad39808eabf
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:622aec25a2fe2cad7094680b7c64940280084c1a7cec92b5
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:00000001aa
|
|
|
9b88be |
+Output = f8dfbf04b097e6d9dc0702686bcb3489d91fd9a4516b703e
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:d3f8298ccb166438dcb9b93ee5a7629286a491f838f802fb
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:6b65726265726f73
|
|
|
9b88be |
+Output = 2370da575d2a3da864cebfdc5204d56df779a7df43d9da43
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:c1081649ada74362e6a1459d01dfd30d67c2234c940704da
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:0000000155
|
|
|
9b88be |
+Output = 348057ec98fdc48016161c2a4c7a943e92ae492c989175f7
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:5d154af238f46713155719d55e2f1f790dd661f279a7917c
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:00000001aa
|
|
|
9b88be |
+Output = a8808ac267dada3dcbe9a7c84626fbc761c294b01315e5c1
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:798562e049852f57dc8c343ba17f2ca1d97394efc8adc443
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:0000000155
|
|
|
9b88be |
+Output = c813f88a3be3b334f75425ce9175fbe3c8493b89c8703b49
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:26dce334b545292f2feab9a8701a89a4b99eb9942cecd016
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:00000001aa
|
|
|
9b88be |
+Output = f48ffd6e83f83e7354e694fd252cf83bfe58f7d5ba37ec5d
|
|
|
9b88be |
+
|
|
|
9b88be |
+#Krb5 sources
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:850BB51358548CD05E86768C313E3BFEF7511937DCF72C3E
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:0000000299
|
|
|
9b88be |
+Output = F78C496D16E6C2DAE0E0B6C24057A84C0426AEEF26FD6DCE
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:850BB51358548CD05E86768C313E3BFEF7511937DCF72C3E
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:00000002AA
|
|
|
9b88be |
+Output = 5B5723D0B634CB684C3EBA5264E9A70D52E683231AD3C4CE
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:850BB51358548CD05E86768C313E3BFEF7511937DCF72C3E
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:0000000255
|
|
|
9b88be |
+Output = A77C94980E9B7345A81525C423A737CE67F4CD91B6B3DA45
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:AES-128-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:42263C6E89F4FC28B8DF68EE09799F15
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:0000000299
|
|
|
9b88be |
+Output = 34280A382BC92769B2DA2F9EF066854B
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:AES-128-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:42263C6E89F4FC28B8DF68EE09799F15
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:00000002AA
|
|
|
9b88be |
+Output = 5B14FC4E250E14DDF9DCCF1AF6674F53
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:AES-128-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:42263C6E89F4FC28B8DF68EE09799F15
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:0000000255
|
|
|
9b88be |
+Output = 4ED31063621684F09AE8D89991AF3E8F
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:AES-256-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:FE697B52BC0D3CE14432BA036A92E65BBB52280990A2FA27883998D72AF30161
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:0000000299
|
|
|
9b88be |
+Output = BFAB388BDCB238E9F9C98D6A878304F04D30C82556375AC507A7A852790F4674
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:AES-256-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:FE697B52BC0D3CE14432BA036A92E65BBB52280990A2FA27883998D72AF30161
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:00000002AA
|
|
|
9b88be |
+Output = C7CFD9CD75FE793A586A542D87E0D1396F1134A104BB1A9190B8C90ADA3DDF37
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:AES-256-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:FE697B52BC0D3CE14432BA036A92E65BBB52280990A2FA27883998D72AF30161
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:0000000255
|
|
|
9b88be |
+Output = 97151B4C76945063E2EB0529DC067D97D7BBA90776D8126D91F34F3101AEA8BA
|
|
|
9b88be |
+
|
|
|
9b88be |
+#Same as the first but with no "fixup"
|
|
|
9b88be |
+KDF = KRB5KDF
|
|
|
9b88be |
+Ctrl.cipher = cipher:DES-EDE3-CBC
|
|
|
9b88be |
+Ctrl.hexkey = hexkey:dce06b1f64c857a11c3db57c51899b2cc1791008ce973b92
|
|
|
9b88be |
+Ctrl.hexconstant = hexconstant:0000000155
|
|
|
9b88be |
+Output = 935079d14490a75c3093c4a6e8c3b049c71e6ee705
|
|
|
9b88be |
+
|
|
|
9b88be |
+#There are currently no official test vectors for Single Step KDF
|
|
|
9b88be |
+#https://github.com/patrickfav/singlestep-kdf/wiki/NIST-SP-800-56C-Rev1:-Non-Official-Test-Vectors
|
|
|
9b88be |
+Title = Single Step KDF tests
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:d09a6b1a472f930db4f5e6b967900744
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:b117255ab5f1b6b96fc434b0
|
|
|
9b88be |
+Output = b5a3c52e97ae6e8c5069954354eab3c7
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:343666c0dd34b756e70f759f14c304f5
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:722b28448d7eab85491bce09
|
|
|
9b88be |
+Output = 1003b650ddd3f0891a15166db5ec881d
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:b84acf03ab08652dd7f82fa956933261
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:3d8773ec068c86053a918565
|
|
|
9b88be |
+Output = 1635dcd1ce698f736831b4badb68ab2b
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:8cc24ca3f1d1a8b34783780b79890430
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:f08d4f2d9a8e6d7105c0bc16
|
|
|
9b88be |
+Output = b8e716fb84a420aed4812cd76d9700ee
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:b616905a6f7562cd2689142ce21e42a3
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:ead310159a909da87e7b4b40
|
|
|
9b88be |
+Output = 1b9201358c50fe5d5d42907c4a9fce78
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:3f57fd3fd56199b3eb33890f7ee28180
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:7a5056ba4fdb034c7cb6c4fe
|
|
|
9b88be |
+Output = e51ebd30a8c4b8449b0fb29d9adc11af
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:fb9fb108d104e9f662d6593fc84cde69
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:5faf29211c1bdbf1b2696a7c
|
|
|
9b88be |
+Output = 7a3a7e670656e48c390cdd7c51e167e0
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:237a39981794f4516dccffc3dda28396
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:62ed9528d104c241e0f66275
|
|
|
9b88be |
+Output = 0c26fc9e90e1c5c5f943428301682045
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:b9b6c45f7279218fa09894e06366a3a1
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:0f384339670aaed4b89ecb7e
|
|
|
9b88be |
+Output = ee5fad414e32fad5d52a2bf61a7f6c72
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:08b7140e2cd0a4abd79171e4d5a71cad
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:099211f0d8a2e02dbb5958c0
|
|
|
9b88be |
+Output = 6162f5142e057efafd2c4f2bad5985a1
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a2
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f4853
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493d
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759a
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac704
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbe
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf1050
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f3
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5d2b4
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5d2b4cb11
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5d2b4cb11ba8b
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5d2b4cb11ba8bf4ba
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5d2b4cb11ba8bf4ba3f22
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5d2b4cb11ba8bf4ba3f227688
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5d2b4cb11ba8bf4ba3f2276885abf
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5d2b4cb11ba8bf4ba3f2276885abfbc3e
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5d2b4cb11ba8bf4ba3f2276885abfbc3e811a
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5d2b4cb11ba8bf4ba3f2276885abfbc3e811a568d
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5d2b4cb11ba8bf4ba3f2276885abfbc3e811a568d480d
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:ebe28edbae5a410b87a479243db3f690
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:e60dd8b28228ce5b9be74d3b
|
|
|
9b88be |
+Output = b4a23963e07f485382cb358a493daec1759ac7043dbeac37152c6ddf105031f0f239f270b7f30616166f10e5d2b4cb11ba8bf4ba3f2276885abfbc3e811a568d480d9192
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:d7e6
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:0bbe1fa8722023d7c3da4fff
|
|
|
9b88be |
+Output = 31e798e9931b612a3ad1b9b1008faa8c
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:4646779d
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:0bbe1fa8722023d7c3da4fff
|
|
|
9b88be |
+Output = 139f68bcca879b490e268e569087d04d
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:d9811c81d4c6
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:0bbe1fa8722023d7c3da4fff
|
|
|
9b88be |
+Output = 914dc4f09cb633a76e6c389e04c64485
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:8838f9d99ec46f09
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:0bbe1fa8722023d7c3da4fff
|
|
|
9b88be |
+Output = 4f07dfb6f7a5bf348689e08b2e29c948
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:3e0939b33f34e779f30e
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:0bbe1fa8722023d7c3da4fff
|
|
|
9b88be |
+Output = b42c7a98c23be19d1187ff960e87557f
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:f36230cacca4d245d303058c
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:0bbe1fa8722023d7c3da4fff
|
|
|
9b88be |
+Output = 50f2068d8010d355d56c5e34aaffbc67
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:7005d32c3d4284c73c3aefc70438
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:0bbe1fa8722023d7c3da4fff
|
|
|
9b88be |
+Output = 66fd712ccf5462bbd41e89041ea7ea26
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:c01c83150b7734f8dbd6efd6f54d7365
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:0bbe1fa8722023d7c3da4fff
|
|
|
9b88be |
+Output = 5c5edb0ceda9cd0c7f1f3d9e239c67d5
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:da69f1dbbebc837480af692e7e9ee6b9
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:9949
|
|
|
9b88be |
+Output = 33c83f54ed00fb1bccd2113e88550941
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:da69f1dbbebc837480af692e7e9ee6b9
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:17144da6
|
|
|
9b88be |
+Output = a999c28961424cab35ec06015e8c376a
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:da69f1dbbebc837480af692e7e9ee6b9
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:dffdee1062eb
|
|
|
9b88be |
+Output = 4101ad50e626ed6f957bff926dfbb7db
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:da69f1dbbebc837480af692e7e9ee6b9
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:9f365043e23b4648
|
|
|
9b88be |
+Output = 4d3e4b971b88771f229df9f564984832
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:da69f1dbbebc837480af692e7e9ee6b9
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:a885a0c4567ddc4f96da
|
|
|
9b88be |
+Output = bebbc30f5a83df5e9c9b57db33c0c879
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:da69f1dbbebc837480af692e7e9ee6b9
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:c9d86183295bfe4c3d85f0fd
|
|
|
9b88be |
+Output = 87c947e45407db63eb94cbaa02d14e94
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:da69f1dbbebc837480af692e7e9ee6b9
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:825fadce46964236a486732c5dad
|
|
|
9b88be |
+Output = 192370a85ff78e3c0245129d9b398558
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:da69f1dbbebc837480af692e7e9ee6b9
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:5c0b5eb3ac9f342347d73d7a521723aa
|
|
|
9b88be |
+Output = c7b7634fd809383e87c4b1b3e728be56
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:8d7a4e7d5cf34b3f74873b862aeb33b7
|
|
|
9b88be |
+Output = 6a5594f402f74f69
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:9b208e7ee1e641fac1dff48fc1beb2d2
|
|
|
9b88be |
+Output = 556ed67e24ac0c7c46cc432da8bdb23c
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:4d2572539fed433211da28c8a0eebac3
|
|
|
9b88be |
+Output = 5a4054c59c5b92814025578f43c1b79fe84968fc284e240b
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:4e1e70c9886819a31bc29a537911add9
|
|
|
9b88be |
+Output = ddbfc440449aab4131c6d8aec08ce1496f2702241d0e27cc155c5c7c3cda75b5
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:68f144c952528e540c686dc353b766f2
|
|
|
9b88be |
+Output = 59ed66bb6f54a9688a0b891d0b2ea6743621d9e1b5cc098cf3a55e6f864f9af8a95e4d945d2f987f
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:b66c9d507c9f837fbe60b6675fdbf38b
|
|
|
9b88be |
+Output = c282787ddf421a72fc88811be81b08d0d6ab66c92d1011974aa58335a6bbbd62e9e982bfae5929865ea1d517247089d2
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:34e730b49e46c7ed2fb25975a4cccd2d
|
|
|
9b88be |
+Output = 39e76e6571cb00740260b9070accbdcc4a492c295cbef33d9e37dac21e5e9d07e0f12dc7063d2172641475d4e08b8e3712fb26a10c8376b8
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:e340d87e2d7adbc1b95ec2dbdc3b82be
|
|
|
9b88be |
+Output = a660c0037a53f76f1e7667043f5869348ad07ac0e272e615ce31f16d4ab90d4b35fe5c370c0010ce79aff45682c6fb8b97f9a05b7d40b5af3c62999a10df9c6d
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA256
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:afc4e154498d4770aa8365f6903dc83b
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:662af20379b29d5ef813e655
|
|
|
9b88be |
+Output = f0b80d6ae4c1e19e2105a37024e35dc6
|
|
|
9b88be |
+
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA512
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:108cf63318555c787fa578731dd4f037
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:53191b1dd3f94d83084d61d6
|
|
|
9b88be |
+Output = 0ad475c1826da3007637970c8b92b993
|
|
|
9b88be |
+
|
|
|
9b88be |
+Title = SSKDF Test vectors from RFC 8636 Section 8 (With precoumputed ASN.1 info)
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA1
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:307e300a06082b06010502030601a01f041d301ba0071b0553552e5345a110300ea003020101a10730051b036c6861a12904273025a0071b0553552e5345a11a3018a003020101a111300f1b066b72627467741b0553552e5345a22404223020a003020112a10c040aaaaaaaaaaaaaaaaaaaaaa20b0409bbbbbbbbbbbbbbbbbb
|
|
|
9b88be |
+Output = e6ab38c9413e035bb079201ed0b6b73d8d49a814a737c04ee6649614206f73ad
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA256
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:307e300a06082b06010502030602a01f041d301ba0071b0553552e5345a110300ea003020101a10730051b036c6861a12904273025a0071b0553552e5345a11a3018a003020101a111300f1b066b72627467741b0553552e5345a22404223020a003020112a10c040aaaaaaaaaaaaaaaaaaaaaa20b0409bbbbbbbbbbbbbbbbbb
|
|
|
9b88be |
+Output = 77ef4e48c420ae3fec75109d7981697eed5d295c90c62564f7bfd101fa9bc1d5
|
|
|
9b88be |
+
|
|
|
9b88be |
+KDF = SSKDF
|
|
|
9b88be |
+Ctrl.digest = digest:SHA512
|
|
|
9b88be |
+Ctrl.hexsecret = hexsecret:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
9b88be |
+Ctrl.hexinfo = hexinfo:307e300a06082b06010502030603a01f041d301ba0071b0553552e5345a110300ea003020101a10730051b036c6861a12904273025a0071b0553552e5345a11a3018a003020101a111300f1b066b72627467741b0553552e5345a22404223020a003020110a10c040aaaaaaaaaaaaaaaaaaaaaa20b0409bbbbbbbbbbbbbbbbbb
|
|
|
9b88be |
+Output = d3c78b78d75313e9a926f75dfb012363fa17fa01db
|