/src/openssl30/crypto/ec/ecdh_kdf.c
| Line | Count | Source (jump to first uncovered line) | 
| 1 |  | /* | 
| 2 |  |  * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. | 
| 3 |  |  * | 
| 4 |  |  * Licensed under the Apache License 2.0 (the "License").  You may not use | 
| 5 |  |  * this file except in compliance with the License.  You can obtain a copy | 
| 6 |  |  * in the file LICENSE in the source distribution or at | 
| 7 |  |  * https://www.openssl.org/source/license.html | 
| 8 |  |  */ | 
| 9 |  |  | 
| 10 |  | /* | 
| 11 |  |  * ECDH low level APIs are deprecated for public use, but still ok for | 
| 12 |  |  * internal use. | 
| 13 |  |  */ | 
| 14 |  | #include "internal/deprecated.h" | 
| 15 |  |  | 
| 16 |  | #include <string.h> | 
| 17 |  | #include <openssl/core_names.h> | 
| 18 |  | #include <openssl/ec.h> | 
| 19 |  | #include <openssl/evp.h> | 
| 20 |  | #include <openssl/kdf.h> | 
| 21 |  | #include "ec_local.h" | 
| 22 |  |  | 
| 23 |  | /* Key derivation function from X9.63/SECG */ | 
| 24 |  | int ossl_ecdh_kdf_X9_63(unsigned char *out, size_t outlen, | 
| 25 |  |                         const unsigned char *Z, size_t Zlen, | 
| 26 |  |                         const unsigned char *sinfo, size_t sinfolen, | 
| 27 |  |                         const EVP_MD *md, | 
| 28 |  |                         OSSL_LIB_CTX *libctx, const char *propq) | 
| 29 | 0 | { | 
| 30 | 0 |     int ret = 0; | 
| 31 | 0 |     EVP_KDF_CTX *kctx = NULL; | 
| 32 | 0 |     OSSL_PARAM params[4], *p = params; | 
| 33 | 0 |     const char *mdname = EVP_MD_get0_name(md); | 
| 34 | 0 |     EVP_KDF *kdf = EVP_KDF_fetch(libctx, OSSL_KDF_NAME_X963KDF, propq); | 
| 35 |  | 
 | 
| 36 | 0 |     if ((kctx = EVP_KDF_CTX_new(kdf)) != NULL) { | 
| 37 | 0 |         *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST, | 
| 38 | 0 |                                                 (char *)mdname, 0); | 
| 39 | 0 |         *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY, | 
| 40 | 0 |                                                  (void *)Z, Zlen); | 
| 41 | 0 |         *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO, | 
| 42 | 0 |                                                  (void *)sinfo, sinfolen); | 
| 43 | 0 |         *p = OSSL_PARAM_construct_end(); | 
| 44 |  | 
 | 
| 45 | 0 |         ret = EVP_KDF_derive(kctx, out, outlen, params) > 0; | 
| 46 | 0 |         EVP_KDF_CTX_free(kctx); | 
| 47 | 0 |     } | 
| 48 | 0 |     EVP_KDF_free(kdf); | 
| 49 | 0 |     return ret; | 
| 50 | 0 | } | 
| 51 |  |  | 
| 52 |  | /*- | 
| 53 |  |  * The old name for ecdh_KDF_X9_63 | 
| 54 |  |  * Retained for ABI compatibility | 
| 55 |  |  */ | 
| 56 |  | #ifndef OPENSSL_NO_DEPRECATED_3_0 | 
| 57 |  | int ECDH_KDF_X9_62(unsigned char *out, size_t outlen, | 
| 58 |  |                    const unsigned char *Z, size_t Zlen, | 
| 59 |  |                    const unsigned char *sinfo, size_t sinfolen, | 
| 60 |  |                    const EVP_MD *md) | 
| 61 | 0 | { | 
| 62 | 0 |     return ossl_ecdh_kdf_X9_63(out, outlen, Z, Zlen, sinfo, sinfolen, md, NULL, | 
| 63 | 0 |                                NULL); | 
| 64 | 0 | } | 
| 65 |  | #endif |