1 /* 2 * Copyright 2014-2022 The GmSSL Project. All Rights Reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the License); you may 5 * not use this file except in compliance with the License. 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 */ 9 10 // RFC 5869 11 12 #ifndef GMSSL_HKDF_H 13 #define GMSSL_HKDF_H 14 15 #include <string.h> 16 #include <gmssl/digest.h> 17 #include <gmssl/hmac.h> 18 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 25 int hkdf_extract(const DIGEST *digest, const uint8_t *salt, size_t saltlen, 26 const uint8_t *ikm, size_t ikmlen, 27 uint8_t *prk, size_t *prklen); 28 29 int hkdf_expand(const DIGEST *digest, const uint8_t *prk, size_t prklen, 30 const uint8_t *opt_info, size_t opt_infolen, 31 size_t L, uint8_t *okm); 32 33 int sm3_hkdf_extract(const uint8_t *salt, size_t saltlen, 34 const uint8_t *ikm, size_t ikmlen, 35 uint8_t *prk, size_t *prklen); 36 37 int sm3_hkdf_expand(const uint8_t *prk, size_t prklen, 38 const uint8_t *opt_info, size_t opt_infolen, 39 size_t L, uint8_t *okm); 40 41 42 #ifdef __cplusplus 43 } 44 #endif 45 #endif 46