| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374 |
- /* hmac.c
- *
- * Copyright (C) 2006-2023 wolfSSL Inc.
- *
- * This file is part of wolfSSL.
- *
- * wolfSSL is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * wolfSSL is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
- */
- #ifdef HAVE_CONFIG_H
- #include <config.h>
- #endif
- #include <wolfssl/wolfcrypt/wc_port.h>
- #include <wolfssl/wolfcrypt/error-crypt.h>
- #include <wolfssl/wolfcrypt/logging.h>
- #ifndef NO_HMAC
- #if defined(HAVE_FIPS) && \
- defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
- /* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */
- #define FIPS_NO_WRAPPERS
- #ifdef USE_WINDOWS_API
- #pragma code_seg(".fipsA$b")
- #pragma const_seg(".fipsB$b")
- #endif
- #endif
- #include <wolfssl/wolfcrypt/hmac.h>
- #ifdef WOLF_CRYPTO_CB
- #include <wolfssl/wolfcrypt/cryptocb.h>
- #endif
- #ifdef NO_INLINE
- #include <wolfssl/wolfcrypt/misc.h>
- #else
- #define WOLFSSL_MISC_INCLUDED
- #include <wolfcrypt/src/misc.c>
- #endif
- #ifdef WOLFSSL_KCAPI_HMAC
- #include <wolfssl/wolfcrypt/port/kcapi/kcapi_hmac.h>
- /* map the _Software calls used by kcapi_hmac.c */
- #define wc_HmacSetKey wc_HmacSetKey_Software
- #define wc_HmacUpdate wc_HmacUpdate_Software
- #define wc_HmacFinal wc_HmacFinal_Software
- #endif
- int wc_HmacSizeByType(int type)
- {
- int ret;
- if (!(type == WC_MD5 || type == WC_SHA ||
- #ifdef WOLFSSL_SM3
- type == WC_SM3 ||
- #endif
- type == WC_SHA224 || type == WC_SHA256 ||
- type == WC_SHA384 || type == WC_SHA512 ||
- type == WC_SHA3_224 || type == WC_SHA3_256 ||
- type == WC_SHA3_384 || type == WC_SHA3_512)) {
- return BAD_FUNC_ARG;
- }
- switch (type) {
- #ifndef NO_MD5
- case WC_MD5:
- ret = WC_MD5_DIGEST_SIZE;
- break;
- #endif /* !NO_MD5 */
- #ifndef NO_SHA
- case WC_SHA:
- ret = WC_SHA_DIGEST_SIZE;
- break;
- #endif /* !NO_SHA */
- #ifdef WOLFSSL_SHA224
- case WC_SHA224:
- ret = WC_SHA224_DIGEST_SIZE;
- break;
- #endif /* WOLFSSL_SHA224 */
- #ifndef NO_SHA256
- case WC_SHA256:
- ret = WC_SHA256_DIGEST_SIZE;
- break;
- #endif /* !NO_SHA256 */
- #ifdef WOLFSSL_SHA384
- case WC_SHA384:
- ret = WC_SHA384_DIGEST_SIZE;
- break;
- #endif /* WOLFSSL_SHA384 */
- #ifdef WOLFSSL_SHA512
- case WC_SHA512:
- ret = WC_SHA512_DIGEST_SIZE;
- break;
- #endif /* WOLFSSL_SHA512 */
- #ifdef WOLFSSL_SHA3
- case WC_SHA3_224:
- ret = WC_SHA3_224_DIGEST_SIZE;
- break;
- case WC_SHA3_256:
- ret = WC_SHA3_256_DIGEST_SIZE;
- break;
- case WC_SHA3_384:
- ret = WC_SHA3_384_DIGEST_SIZE;
- break;
- case WC_SHA3_512:
- ret = WC_SHA3_512_DIGEST_SIZE;
- break;
- #endif /* WOLFSSL_SHA3 */
- #ifdef WOLFSSL_SM3
- case WC_SM3:
- ret = WC_SM3_DIGEST_SIZE;
- break;
- #endif
- default:
- ret = BAD_FUNC_ARG;
- break;
- }
- return ret;
- }
- int _InitHmac(Hmac* hmac, int type, void* heap)
- {
- int ret = 0;
- #ifdef WOLF_CRYPTO_CB
- int devId = hmac->devId;
- #else
- int devId = INVALID_DEVID;
- #endif
- switch (type) {
- #ifndef NO_MD5
- case WC_MD5:
- ret = wc_InitMd5_ex(&hmac->hash.md5, heap, devId);
- break;
- #endif /* !NO_MD5 */
- #ifndef NO_SHA
- case WC_SHA:
- ret = wc_InitSha_ex(&hmac->hash.sha, heap, devId);
- break;
- #endif /* !NO_SHA */
- #ifdef WOLFSSL_SHA224
- case WC_SHA224:
- ret = wc_InitSha224_ex(&hmac->hash.sha224, heap, devId);
- break;
- #endif /* WOLFSSL_SHA224 */
- #ifndef NO_SHA256
- case WC_SHA256:
- ret = wc_InitSha256_ex(&hmac->hash.sha256, heap, devId);
- break;
- #endif /* !NO_SHA256 */
- #ifdef WOLFSSL_SHA384
- case WC_SHA384:
- ret = wc_InitSha384_ex(&hmac->hash.sha384, heap, devId);
- break;
- #endif /* WOLFSSL_SHA384 */
- #ifdef WOLFSSL_SHA512
- case WC_SHA512:
- ret = wc_InitSha512_ex(&hmac->hash.sha512, heap, devId);
- break;
- #endif /* WOLFSSL_SHA512 */
- #ifdef WOLFSSL_SHA3
- #ifndef WOLFSSL_NOSHA3_224
- case WC_SHA3_224:
- ret = wc_InitSha3_224(&hmac->hash.sha3, heap, devId);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_256
- case WC_SHA3_256:
- ret = wc_InitSha3_256(&hmac->hash.sha3, heap, devId);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_384
- case WC_SHA3_384:
- ret = wc_InitSha3_384(&hmac->hash.sha3, heap, devId);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_512
- case WC_SHA3_512:
- ret = wc_InitSha3_512(&hmac->hash.sha3, heap, devId);
- break;
- #endif
- #endif
- #ifdef WOLFSSL_SM3
- case WC_SM3:
- ret = wc_InitSm3(&hmac->hash.sm3, heap, devId);
- break;
- #endif
- default:
- ret = BAD_FUNC_ARG;
- break;
- }
- /* default to NULL heap hint or test value */
- #ifdef WOLFSSL_HEAP_TEST
- hmac->heap = (void*)WOLFSSL_HEAP_TEST;
- #else
- hmac->heap = heap;
- #endif /* WOLFSSL_HEAP_TEST */
- return ret;
- }
- int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
- {
- #ifndef WOLFSSL_MAXQ108X
- byte* ip;
- byte* op;
- word32 hmac_block_size = 0;
- #endif
- int ret = 0;
- void* heap = NULL;
- if (hmac == NULL || (key == NULL && length != 0) ||
- !(type == WC_MD5 || type == WC_SHA ||
- #ifdef WOLFSSL_SM3
- type == WC_SM3 ||
- #endif
- type == WC_SHA224 || type == WC_SHA256 ||
- type == WC_SHA384 || type == WC_SHA512 ||
- type == WC_SHA3_224 || type == WC_SHA3_256 ||
- type == WC_SHA3_384 || type == WC_SHA3_512)) {
- return BAD_FUNC_ARG;
- }
- #ifndef HAVE_FIPS
- /* if set key has already been run then make sure and free existing */
- /* This is for async and PIC32MZ situations, and just normally OK,
- provided the user calls wc_HmacInit() first. That function is not
- available in FIPS builds. In current FIPS builds, the hashes are
- not allocating resources. */
- if (hmac->macType != WC_HASH_TYPE_NONE) {
- wc_HmacFree(hmac);
- }
- #endif
- hmac->innerHashKeyed = 0;
- hmac->macType = (byte)type;
- ret = _InitHmac(hmac, type, heap);
- if (ret != 0)
- return ret;
- #ifdef HAVE_FIPS
- if (length < HMAC_FIPS_MIN_KEY) {
- WOLFSSL_ERROR_VERBOSE(HMAC_MIN_KEYLEN_E);
- return HMAC_MIN_KEYLEN_E;
- }
- #endif
- #ifdef WOLF_CRYPTO_CB
- hmac->keyRaw = key; /* use buffer directly */
- hmac->keyLen = (word16)length;
- #endif
- #ifdef WOLFSSL_MAXQ108X
- /* For MAXQ108x, nothing left to do. */
- return 0;
- #else
- ip = (byte*)hmac->ipad;
- op = (byte*)hmac->opad;
- switch (hmac->macType) {
- #ifndef NO_MD5
- case WC_MD5:
- hmac_block_size = WC_MD5_BLOCK_SIZE;
- if (length <= WC_MD5_BLOCK_SIZE) {
- if (key != NULL) {
- XMEMCPY(ip, key, length);
- }
- }
- else {
- ret = wc_Md5Update(&hmac->hash.md5, key, length);
- if (ret != 0)
- break;
- ret = wc_Md5Final(&hmac->hash.md5, ip);
- if (ret != 0)
- break;
- length = WC_MD5_DIGEST_SIZE;
- }
- break;
- #endif /* !NO_MD5 */
- #ifndef NO_SHA
- case WC_SHA:
- hmac_block_size = WC_SHA_BLOCK_SIZE;
- if (length <= WC_SHA_BLOCK_SIZE) {
- if (key != NULL) {
- XMEMCPY(ip, key, length);
- }
- }
- else {
- ret = wc_ShaUpdate(&hmac->hash.sha, key, length);
- if (ret != 0)
- break;
- ret = wc_ShaFinal(&hmac->hash.sha, ip);
- if (ret != 0)
- break;
- length = WC_SHA_DIGEST_SIZE;
- }
- break;
- #endif /* !NO_SHA */
- #ifdef WOLFSSL_SHA224
- case WC_SHA224:
- hmac_block_size = WC_SHA224_BLOCK_SIZE;
- if (length <= WC_SHA224_BLOCK_SIZE) {
- if (key != NULL) {
- XMEMCPY(ip, key, length);
- }
- }
- else {
- ret = wc_Sha224Update(&hmac->hash.sha224, key, length);
- if (ret != 0)
- break;
- ret = wc_Sha224Final(&hmac->hash.sha224, ip);
- if (ret != 0)
- break;
- length = WC_SHA224_DIGEST_SIZE;
- }
- break;
- #endif /* WOLFSSL_SHA224 */
- #ifndef NO_SHA256
- case WC_SHA256:
- hmac_block_size = WC_SHA256_BLOCK_SIZE;
- if (length <= WC_SHA256_BLOCK_SIZE) {
- if (key != NULL) {
- XMEMCPY(ip, key, length);
- }
- }
- else {
- ret = wc_Sha256Update(&hmac->hash.sha256, key, length);
- if (ret != 0)
- break;
- ret = wc_Sha256Final(&hmac->hash.sha256, ip);
- if (ret != 0)
- break;
- length = WC_SHA256_DIGEST_SIZE;
- }
- break;
- #endif /* !NO_SHA256 */
- #ifdef WOLFSSL_SHA384
- case WC_SHA384:
- hmac_block_size = WC_SHA384_BLOCK_SIZE;
- if (length <= WC_SHA384_BLOCK_SIZE) {
- if (key != NULL) {
- XMEMCPY(ip, key, length);
- }
- }
- else {
- ret = wc_Sha384Update(&hmac->hash.sha384, key, length);
- if (ret != 0)
- break;
- ret = wc_Sha384Final(&hmac->hash.sha384, ip);
- if (ret != 0)
- break;
- length = WC_SHA384_DIGEST_SIZE;
- }
- break;
- #endif /* WOLFSSL_SHA384 */
- #ifdef WOLFSSL_SHA512
- case WC_SHA512:
- hmac_block_size = WC_SHA512_BLOCK_SIZE;
- if (length <= WC_SHA512_BLOCK_SIZE) {
- if (key != NULL) {
- XMEMCPY(ip, key, length);
- }
- }
- else {
- ret = wc_Sha512Update(&hmac->hash.sha512, key, length);
- if (ret != 0)
- break;
- ret = wc_Sha512Final(&hmac->hash.sha512, ip);
- if (ret != 0)
- break;
- length = WC_SHA512_DIGEST_SIZE;
- }
- break;
- #endif /* WOLFSSL_SHA512 */
- #ifdef WOLFSSL_SHA3
- #ifndef WOLFSSL_NOSHA3_224
- case WC_SHA3_224:
- hmac_block_size = WC_SHA3_224_BLOCK_SIZE;
- if (length <= WC_SHA3_224_BLOCK_SIZE) {
- if (key != NULL) {
- XMEMCPY(ip, key, length);
- }
- }
- else {
- ret = wc_Sha3_224_Update(&hmac->hash.sha3, key, length);
- if (ret != 0)
- break;
- ret = wc_Sha3_224_Final(&hmac->hash.sha3, ip);
- if (ret != 0)
- break;
- length = WC_SHA3_224_DIGEST_SIZE;
- }
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_256
- case WC_SHA3_256:
- hmac_block_size = WC_SHA3_256_BLOCK_SIZE;
- if (length <= WC_SHA3_256_BLOCK_SIZE) {
- if (key != NULL) {
- XMEMCPY(ip, key, length);
- }
- }
- else {
- ret = wc_Sha3_256_Update(&hmac->hash.sha3, key, length);
- if (ret != 0)
- break;
- ret = wc_Sha3_256_Final(&hmac->hash.sha3, ip);
- if (ret != 0)
- break;
- length = WC_SHA3_256_DIGEST_SIZE;
- }
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_384
- case WC_SHA3_384:
- hmac_block_size = WC_SHA3_384_BLOCK_SIZE;
- if (length <= WC_SHA3_384_BLOCK_SIZE) {
- if (key != NULL) {
- XMEMCPY(ip, key, length);
- }
- }
- else {
- ret = wc_Sha3_384_Update(&hmac->hash.sha3, key, length);
- if (ret != 0)
- break;
- ret = wc_Sha3_384_Final(&hmac->hash.sha3, ip);
- if (ret != 0)
- break;
- length = WC_SHA3_384_DIGEST_SIZE;
- }
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_512
- case WC_SHA3_512:
- hmac_block_size = WC_SHA3_512_BLOCK_SIZE;
- if (length <= WC_SHA3_512_BLOCK_SIZE) {
- if (key != NULL) {
- XMEMCPY(ip, key, length);
- }
- }
- else {
- ret = wc_Sha3_512_Update(&hmac->hash.sha3, key, length);
- if (ret != 0)
- break;
- ret = wc_Sha3_512_Final(&hmac->hash.sha3, ip);
- if (ret != 0)
- break;
- length = WC_SHA3_512_DIGEST_SIZE;
- }
- break;
- #endif
- #endif /* WOLFSSL_SHA3 */
- #ifdef WOLFSSL_SM3
- case WC_SM3:
- hmac_block_size = WC_SM3_BLOCK_SIZE;
- if (length <= WC_SM3_BLOCK_SIZE) {
- if (key != NULL) {
- XMEMCPY(ip, key, length);
- }
- }
- else {
- ret = wc_Sm3Update(&hmac->hash.sm3, key, length);
- if (ret != 0)
- break;
- ret = wc_Sm3Final(&hmac->hash.sm3, ip);
- if (ret != 0)
- break;
- length = WC_SM3_DIGEST_SIZE;
- }
- break;
- #endif
- default:
- return BAD_FUNC_ARG;
- }
- #if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC)
- if (hmac->asyncDev.marker == WOLFSSL_ASYNC_MARKER_HMAC) {
- #if defined(HAVE_INTEL_QA) || defined(HAVE_CAVIUM)
- #ifdef HAVE_INTEL_QA
- if (IntelQaHmacGetType(hmac->macType, NULL) == 0)
- #endif
- {
- if (length > hmac_block_size)
- length = hmac_block_size;
- /* update key length */
- hmac->keyLen = (word16)length;
- return ret;
- }
- /* no need to pad below */
- #endif
- }
- #endif
- if (ret == 0) {
- word32 i;
- if (length < hmac_block_size)
- XMEMSET(ip + length, 0, hmac_block_size - length);
- for(i = 0; i < hmac_block_size; i++) {
- op[i] = (byte)(ip[i] ^ OPAD);
- ip[i] ^= IPAD;
- }
- }
- return ret;
- #endif /* WOLFSSL_MAXQ108X */
- }
- static int HmacKeyInnerHash(Hmac* hmac)
- {
- int ret = 0;
- switch (hmac->macType) {
- #ifndef NO_MD5
- case WC_MD5:
- ret = wc_Md5Update(&hmac->hash.md5, (byte*)hmac->ipad,
- WC_MD5_BLOCK_SIZE);
- break;
- #endif /* !NO_MD5 */
- #ifndef NO_SHA
- case WC_SHA:
- ret = wc_ShaUpdate(&hmac->hash.sha, (byte*)hmac->ipad,
- WC_SHA_BLOCK_SIZE);
- break;
- #endif /* !NO_SHA */
- #ifdef WOLFSSL_SHA224
- case WC_SHA224:
- ret = wc_Sha224Update(&hmac->hash.sha224, (byte*)hmac->ipad,
- WC_SHA224_BLOCK_SIZE);
- break;
- #endif /* WOLFSSL_SHA224 */
- #ifndef NO_SHA256
- case WC_SHA256:
- ret = wc_Sha256Update(&hmac->hash.sha256, (byte*)hmac->ipad,
- WC_SHA256_BLOCK_SIZE);
- break;
- #endif /* !NO_SHA256 */
- #ifdef WOLFSSL_SHA384
- case WC_SHA384:
- ret = wc_Sha384Update(&hmac->hash.sha384, (byte*)hmac->ipad,
- WC_SHA384_BLOCK_SIZE);
- break;
- #endif /* WOLFSSL_SHA384 */
- #ifdef WOLFSSL_SHA512
- case WC_SHA512:
- ret = wc_Sha512Update(&hmac->hash.sha512, (byte*)hmac->ipad,
- WC_SHA512_BLOCK_SIZE);
- break;
- #endif /* WOLFSSL_SHA512 */
- #ifdef WOLFSSL_SHA3
- #ifndef WOLFSSL_NOSHA3_224
- case WC_SHA3_224:
- ret = wc_Sha3_224_Update(&hmac->hash.sha3, (byte*)hmac->ipad,
- WC_SHA3_224_BLOCK_SIZE);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_256
- case WC_SHA3_256:
- ret = wc_Sha3_256_Update(&hmac->hash.sha3, (byte*)hmac->ipad,
- WC_SHA3_256_BLOCK_SIZE);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_384
- case WC_SHA3_384:
- ret = wc_Sha3_384_Update(&hmac->hash.sha3, (byte*)hmac->ipad,
- WC_SHA3_384_BLOCK_SIZE);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_512
- case WC_SHA3_512:
- ret = wc_Sha3_512_Update(&hmac->hash.sha3, (byte*)hmac->ipad,
- WC_SHA3_512_BLOCK_SIZE);
- break;
- #endif
- #endif /* WOLFSSL_SHA3 */
- #ifdef WOLFSSL_SM3
- case WC_SM3:
- ret = wc_Sm3Update(&hmac->hash.sm3, (byte*)hmac->ipad,
- WC_SM3_BLOCK_SIZE);
- break;
- #endif
- default:
- break;
- }
- if (ret == 0)
- hmac->innerHashKeyed = WC_HMAC_INNER_HASH_KEYED_SW;
- return ret;
- }
- int wc_HmacUpdate(Hmac* hmac, const byte* msg, word32 length)
- {
- int ret = 0;
- if (hmac == NULL || (msg == NULL && length > 0)) {
- return BAD_FUNC_ARG;
- }
- #ifdef WOLF_CRYPTO_CB
- if (hmac->devId != INVALID_DEVID) {
- ret = wc_CryptoCb_Hmac(hmac, hmac->macType, msg, length, NULL);
- if (ret != CRYPTOCB_UNAVAILABLE)
- return ret;
- /* fall-through when unavailable */
- ret = 0; /* reset error code */
- }
- #endif
- #if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC)
- if (hmac->asyncDev.marker == WOLFSSL_ASYNC_MARKER_HMAC) {
- #if defined(HAVE_CAVIUM)
- return NitroxHmacUpdate(hmac, msg, length);
- #elif defined(HAVE_INTEL_QA)
- if (IntelQaHmacGetType(hmac->macType, NULL) == 0) {
- return IntelQaHmac(&hmac->asyncDev, hmac->macType,
- (byte*)hmac->ipad, hmac->keyLen, NULL, msg, length);
- }
- #endif
- }
- #endif /* WOLFSSL_ASYNC_CRYPT */
- if (!hmac->innerHashKeyed) {
- ret = HmacKeyInnerHash(hmac);
- if (ret != 0)
- return ret;
- }
- switch (hmac->macType) {
- #ifndef NO_MD5
- case WC_MD5:
- ret = wc_Md5Update(&hmac->hash.md5, msg, length);
- break;
- #endif /* !NO_MD5 */
- #ifndef NO_SHA
- case WC_SHA:
- ret = wc_ShaUpdate(&hmac->hash.sha, msg, length);
- break;
- #endif /* !NO_SHA */
- #ifdef WOLFSSL_SHA224
- case WC_SHA224:
- ret = wc_Sha224Update(&hmac->hash.sha224, msg, length);
- break;
- #endif /* WOLFSSL_SHA224 */
- #ifndef NO_SHA256
- case WC_SHA256:
- ret = wc_Sha256Update(&hmac->hash.sha256, msg, length);
- break;
- #endif /* !NO_SHA256 */
- #ifdef WOLFSSL_SHA384
- case WC_SHA384:
- ret = wc_Sha384Update(&hmac->hash.sha384, msg, length);
- break;
- #endif /* WOLFSSL_SHA384 */
- #ifdef WOLFSSL_SHA512
- case WC_SHA512:
- ret = wc_Sha512Update(&hmac->hash.sha512, msg, length);
- break;
- #endif /* WOLFSSL_SHA512 */
- #ifdef WOLFSSL_SHA3
- #ifndef WOLFSSL_NOSHA3_224
- case WC_SHA3_224:
- ret = wc_Sha3_224_Update(&hmac->hash.sha3, msg, length);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_256
- case WC_SHA3_256:
- ret = wc_Sha3_256_Update(&hmac->hash.sha3, msg, length);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_384
- case WC_SHA3_384:
- ret = wc_Sha3_384_Update(&hmac->hash.sha3, msg, length);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_512
- case WC_SHA3_512:
- ret = wc_Sha3_512_Update(&hmac->hash.sha3, msg, length);
- break;
- #endif
- #endif /* WOLFSSL_SHA3 */
- #ifdef WOLFSSL_SM3
- case WC_SM3:
- ret = wc_Sm3Update(&hmac->hash.sm3, msg, length);
- break;
- #endif
- default:
- break;
- }
- return ret;
- }
- int wc_HmacFinal(Hmac* hmac, byte* hash)
- {
- int ret;
- if (hmac == NULL || hash == NULL) {
- return BAD_FUNC_ARG;
- }
- #ifdef WOLF_CRYPTO_CB
- if (hmac->devId != INVALID_DEVID) {
- ret = wc_CryptoCb_Hmac(hmac, hmac->macType, NULL, 0, hash);
- if (ret != CRYPTOCB_UNAVAILABLE)
- return ret;
- /* fall-through when unavailable */
- }
- #endif
- #if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC)
- if (hmac->asyncDev.marker == WOLFSSL_ASYNC_MARKER_HMAC) {
- int hashLen = wc_HmacSizeByType(hmac->macType);
- if (hashLen <= 0)
- return hashLen;
- #if defined(HAVE_CAVIUM)
- return NitroxHmacFinal(hmac, hash, hashLen);
- #elif defined(HAVE_INTEL_QA)
- if (IntelQaHmacGetType(hmac->macType, NULL) == 0) {
- return IntelQaHmac(&hmac->asyncDev, hmac->macType,
- (byte*)hmac->ipad, hmac->keyLen, hash, NULL, hashLen);
- }
- #endif
- }
- #endif /* WOLFSSL_ASYNC_CRYPT */
- if (!hmac->innerHashKeyed) {
- ret = HmacKeyInnerHash(hmac);
- if (ret != 0)
- return ret;
- }
- switch (hmac->macType) {
- #ifndef NO_MD5
- case WC_MD5:
- ret = wc_Md5Final(&hmac->hash.md5, (byte*)hmac->innerHash);
- if (ret != 0)
- break;
- ret = wc_Md5Update(&hmac->hash.md5, (byte*)hmac->opad,
- WC_MD5_BLOCK_SIZE);
- if (ret != 0)
- break;
- ret = wc_Md5Update(&hmac->hash.md5, (byte*)hmac->innerHash,
- WC_MD5_DIGEST_SIZE);
- if (ret != 0)
- break;
- ret = wc_Md5Final(&hmac->hash.md5, hash);
- break;
- #endif /* !NO_MD5 */
- #ifndef NO_SHA
- case WC_SHA:
- ret = wc_ShaFinal(&hmac->hash.sha, (byte*)hmac->innerHash);
- if (ret != 0)
- break;
- ret = wc_ShaUpdate(&hmac->hash.sha, (byte*)hmac->opad,
- WC_SHA_BLOCK_SIZE);
- if (ret != 0)
- break;
- ret = wc_ShaUpdate(&hmac->hash.sha, (byte*)hmac->innerHash,
- WC_SHA_DIGEST_SIZE);
- if (ret != 0)
- break;
- ret = wc_ShaFinal(&hmac->hash.sha, hash);
- break;
- #endif /* !NO_SHA */
- #ifdef WOLFSSL_SHA224
- case WC_SHA224:
- ret = wc_Sha224Final(&hmac->hash.sha224, (byte*)hmac->innerHash);
- if (ret != 0)
- break;
- ret = wc_Sha224Update(&hmac->hash.sha224, (byte*)hmac->opad,
- WC_SHA224_BLOCK_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha224Update(&hmac->hash.sha224, (byte*)hmac->innerHash,
- WC_SHA224_DIGEST_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha224Final(&hmac->hash.sha224, hash);
- if (ret != 0)
- break;
- break;
- #endif /* WOLFSSL_SHA224 */
- #ifndef NO_SHA256
- case WC_SHA256:
- ret = wc_Sha256Final(&hmac->hash.sha256, (byte*)hmac->innerHash);
- if (ret != 0)
- break;
- ret = wc_Sha256Update(&hmac->hash.sha256, (byte*)hmac->opad,
- WC_SHA256_BLOCK_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha256Update(&hmac->hash.sha256, (byte*)hmac->innerHash,
- WC_SHA256_DIGEST_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha256Final(&hmac->hash.sha256, hash);
- break;
- #endif /* !NO_SHA256 */
- #ifdef WOLFSSL_SHA384
- case WC_SHA384:
- ret = wc_Sha384Final(&hmac->hash.sha384, (byte*)hmac->innerHash);
- if (ret != 0)
- break;
- ret = wc_Sha384Update(&hmac->hash.sha384, (byte*)hmac->opad,
- WC_SHA384_BLOCK_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha384Update(&hmac->hash.sha384, (byte*)hmac->innerHash,
- WC_SHA384_DIGEST_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha384Final(&hmac->hash.sha384, hash);
- break;
- #endif /* WOLFSSL_SHA384 */
- #ifdef WOLFSSL_SHA512
- case WC_SHA512:
- ret = wc_Sha512Final(&hmac->hash.sha512, (byte*)hmac->innerHash);
- if (ret != 0)
- break;
- ret = wc_Sha512Update(&hmac->hash.sha512, (byte*)hmac->opad,
- WC_SHA512_BLOCK_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha512Update(&hmac->hash.sha512, (byte*)hmac->innerHash,
- WC_SHA512_DIGEST_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha512Final(&hmac->hash.sha512, hash);
- break;
- #endif /* WOLFSSL_SHA512 */
- #ifdef WOLFSSL_SHA3
- #ifndef WOLFSSL_NOSHA3_224
- case WC_SHA3_224:
- ret = wc_Sha3_224_Final(&hmac->hash.sha3, (byte*)hmac->innerHash);
- if (ret != 0)
- break;
- ret = wc_Sha3_224_Update(&hmac->hash.sha3, (byte*)hmac->opad,
- WC_SHA3_224_BLOCK_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha3_224_Update(&hmac->hash.sha3, (byte*)hmac->innerHash,
- WC_SHA3_224_DIGEST_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha3_224_Final(&hmac->hash.sha3, hash);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_256
- case WC_SHA3_256:
- ret = wc_Sha3_256_Final(&hmac->hash.sha3, (byte*)hmac->innerHash);
- if (ret != 0)
- break;
- ret = wc_Sha3_256_Update(&hmac->hash.sha3, (byte*)hmac->opad,
- WC_SHA3_256_BLOCK_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha3_256_Update(&hmac->hash.sha3, (byte*)hmac->innerHash,
- WC_SHA3_256_DIGEST_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha3_256_Final(&hmac->hash.sha3, hash);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_384
- case WC_SHA3_384:
- ret = wc_Sha3_384_Final(&hmac->hash.sha3, (byte*)hmac->innerHash);
- if (ret != 0)
- break;
- ret = wc_Sha3_384_Update(&hmac->hash.sha3, (byte*)hmac->opad,
- WC_SHA3_384_BLOCK_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha3_384_Update(&hmac->hash.sha3, (byte*)hmac->innerHash,
- WC_SHA3_384_DIGEST_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha3_384_Final(&hmac->hash.sha3, hash);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_512
- case WC_SHA3_512:
- ret = wc_Sha3_512_Final(&hmac->hash.sha3, (byte*)hmac->innerHash);
- if (ret != 0)
- break;
- ret = wc_Sha3_512_Update(&hmac->hash.sha3, (byte*)hmac->opad,
- WC_SHA3_512_BLOCK_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha3_512_Update(&hmac->hash.sha3, (byte*)hmac->innerHash,
- WC_SHA3_512_DIGEST_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sha3_512_Final(&hmac->hash.sha3, hash);
- break;
- #endif
- #endif /* WOLFSSL_SHA3 */
- #ifdef WOLFSSL_SM3
- case WC_SM3:
- ret = wc_Sm3Final(&hmac->hash.sm3, (byte*)hmac->innerHash);
- if (ret != 0)
- break;
- ret = wc_Sm3Update(&hmac->hash.sm3, (byte*)hmac->opad,
- WC_SM3_BLOCK_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sm3Update(&hmac->hash.sm3, (byte*)hmac->innerHash,
- WC_SM3_DIGEST_SIZE);
- if (ret != 0)
- break;
- ret = wc_Sm3Final(&hmac->hash.sm3, hash);
- break;
- #endif
- default:
- ret = BAD_FUNC_ARG;
- break;
- }
- if (ret == 0) {
- hmac->innerHashKeyed = 0;
- }
- return ret;
- }
- #ifdef WOLFSSL_KCAPI_HMAC
- /* implemented in wolfcrypt/src/port/kcapi/kcapi_hmac.c */
- /* unmap the _Software calls used by kcapi_hmac.c */
- #undef wc_HmacSetKey
- #undef wc_HmacUpdate
- #undef wc_HmacFinal
- #else
- /* Initialize Hmac for use with async device */
- int wc_HmacInit(Hmac* hmac, void* heap, int devId)
- {
- int ret = 0;
- if (hmac == NULL)
- return BAD_FUNC_ARG;
- XMEMSET(hmac, 0, sizeof(Hmac));
- hmac->macType = WC_HASH_TYPE_NONE;
- hmac->heap = heap;
- #ifdef WOLF_CRYPTO_CB
- hmac->devId = devId;
- hmac->devCtx = NULL;
- #endif
- #if defined(WOLFSSL_DEVCRYPTO_HMAC)
- hmac->ctx.cfd = -1;
- #endif
- #if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC)
- ret = wolfAsync_DevCtxInit(&hmac->asyncDev, WOLFSSL_ASYNC_MARKER_HMAC,
- hmac->heap, devId);
- #else
- (void)devId;
- #endif /* WOLFSSL_ASYNC_CRYPT */
- return ret;
- }
- #ifdef WOLF_PRIVATE_KEY_ID
- int wc_HmacInit_Id(Hmac* hmac, unsigned char* id, int len, void* heap,
- int devId)
- {
- int ret = 0;
- if (hmac == NULL)
- ret = BAD_FUNC_ARG;
- if (ret == 0 && (len < 0 || len > HMAC_MAX_ID_LEN))
- ret = BUFFER_E;
- if (ret == 0)
- ret = wc_HmacInit(hmac, heap, devId);
- if (ret == 0) {
- XMEMCPY(hmac->id, id, (size_t)len);
- hmac->idLen = len;
- }
- return ret;
- }
- int wc_HmacInit_Label(Hmac* hmac, const char* label, void* heap, int devId)
- {
- int ret = 0;
- int labelLen = 0;
- if (hmac == NULL || label == NULL)
- ret = BAD_FUNC_ARG;
- if (ret == 0) {
- labelLen = (int)XSTRLEN(label);
- if (labelLen == 0 || labelLen > HMAC_MAX_LABEL_LEN)
- ret = BUFFER_E;
- }
- if (ret == 0)
- ret = wc_HmacInit(hmac, heap, devId);
- if (ret == 0) {
- XMEMCPY(hmac->label, label, (size_t)labelLen);
- hmac->labelLen = labelLen;
- }
- return ret;
- }
- #endif /* WOLF_PRIVATE_KEY_ID */
- /* Free Hmac from use with async device */
- void wc_HmacFree(Hmac* hmac)
- {
- if (hmac == NULL)
- return;
- #ifdef WOLF_CRYPTO_CB
- /* handle cleanup case where final is not called */
- if (hmac->devId != INVALID_DEVID && hmac->devCtx != NULL) {
- int ret;
- byte finalHash[WC_HMAC_BLOCK_SIZE];
- ret = wc_CryptoCb_Hmac(hmac, hmac->macType, NULL, 0, finalHash);
- (void)ret; /* must ignore return code here */
- (void)finalHash;
- }
- #endif
- #if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_HMAC)
- wolfAsync_DevCtxFree(&hmac->asyncDev, WOLFSSL_ASYNC_MARKER_HMAC);
- #endif /* WOLFSSL_ASYNC_CRYPT */
- switch (hmac->macType) {
- #ifndef NO_MD5
- case WC_MD5:
- wc_Md5Free(&hmac->hash.md5);
- break;
- #endif /* !NO_MD5 */
- #ifndef NO_SHA
- case WC_SHA:
- wc_ShaFree(&hmac->hash.sha);
- break;
- #endif /* !NO_SHA */
- #ifdef WOLFSSL_SHA224
- case WC_SHA224:
- wc_Sha224Free(&hmac->hash.sha224);
- break;
- #endif /* WOLFSSL_SHA224 */
- #ifndef NO_SHA256
- case WC_SHA256:
- wc_Sha256Free(&hmac->hash.sha256);
- break;
- #endif /* !NO_SHA256 */
- #ifdef WOLFSSL_SHA384
- case WC_SHA384:
- wc_Sha384Free(&hmac->hash.sha384);
- break;
- #endif /* WOLFSSL_SHA384 */
- #ifdef WOLFSSL_SHA512
- case WC_SHA512:
- wc_Sha512Free(&hmac->hash.sha512);
- break;
- #endif /* WOLFSSL_SHA512 */
- #ifdef WOLFSSL_SHA3
- #ifndef WOLFSSL_NOSHA3_224
- case WC_SHA3_224:
- wc_Sha3_224_Free(&hmac->hash.sha3);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_256
- case WC_SHA3_256:
- wc_Sha3_256_Free(&hmac->hash.sha3);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_384
- case WC_SHA3_384:
- wc_Sha3_384_Free(&hmac->hash.sha3);
- break;
- #endif
- #ifndef WOLFSSL_NOSHA3_512
- case WC_SHA3_512:
- wc_Sha3_512_Free(&hmac->hash.sha3);
- break;
- #endif
- #endif /* WOLFSSL_SHA3 */
- #ifdef WOLFSSL_SM3
- case WC_SM3:
- wc_Sm3Free(&hmac->hash.sm3);
- break;
- #endif
- default:
- break;
- }
- ForceZero(hmac, sizeof(*hmac));
- }
- #endif /* WOLFSSL_KCAPI_HMAC */
- int wolfSSL_GetHmacMaxSize(void)
- {
- return WC_MAX_DIGEST_SIZE;
- }
- #ifdef HAVE_HKDF
- /* HMAC-KDF-Extract.
- * RFC 5869 - HMAC-based Extract-and-Expand Key Derivation Function (HKDF).
- *
- * type The hash algorithm type.
- * salt The optional salt value.
- * saltSz The size of the salt.
- * inKey The input keying material.
- * inKeySz The size of the input keying material.
- * out The pseudorandom key with the length that of the hash.
- * returns 0 on success, otherwise failure.
- */
- int wc_HKDF_Extract(int type, const byte* salt, word32 saltSz,
- const byte* inKey, word32 inKeySz, byte* out)
- {
- byte tmp[WC_MAX_DIGEST_SIZE]; /* localSalt helper */
- #ifdef WOLFSSL_SMALL_STACK
- Hmac* myHmac;
- #else
- Hmac myHmac[1];
- #endif
- int ret;
- const byte* localSalt; /* either points to user input or tmp */
- word32 hashSz;
- ret = wc_HmacSizeByType(type);
- if (ret < 0) {
- return ret;
- }
- #ifdef WOLFSSL_SMALL_STACK
- myHmac = (Hmac*)XMALLOC(sizeof(Hmac), NULL, DYNAMIC_TYPE_HMAC);
- if (myHmac == NULL) {
- return MEMORY_E;
- }
- #endif
- hashSz = (word32)ret;
- localSalt = salt;
- if (localSalt == NULL) {
- XMEMSET(tmp, 0, hashSz);
- localSalt = tmp;
- saltSz = hashSz;
- }
- ret = wc_HmacInit(myHmac, NULL, INVALID_DEVID);
- if (ret == 0) {
- ret = wc_HmacSetKey(myHmac, type, localSalt, saltSz);
- if (ret == 0)
- ret = wc_HmacUpdate(myHmac, inKey, inKeySz);
- if (ret == 0)
- ret = wc_HmacFinal(myHmac, out);
- wc_HmacFree(myHmac);
- }
- #ifdef WOLFSSL_SMALL_STACK
- XFREE(myHmac, NULL, DYNAMIC_TYPE_HMAC);
- #endif
- return ret;
- }
- /* HMAC-KDF-Expand.
- * RFC 5869 - HMAC-based Extract-and-Expand Key Derivation Function (HKDF).
- *
- * type The hash algorithm type.
- * inKey The input key.
- * inKeySz The size of the input key.
- * info The application specific information.
- * infoSz The size of the application specific information.
- * out The output keying material.
- * returns 0 on success, otherwise failure.
- */
- int wc_HKDF_Expand(int type, const byte* inKey, word32 inKeySz,
- const byte* info, word32 infoSz, byte* out, word32 outSz)
- {
- byte tmp[WC_MAX_DIGEST_SIZE];
- #ifdef WOLFSSL_SMALL_STACK
- Hmac* myHmac;
- #else
- Hmac myHmac[1];
- #endif
- int ret = 0;
- word32 outIdx = 0;
- word32 hashSz;
- byte n = 0x1;
- ret = wc_HmacSizeByType(type);
- if (ret < 0) {
- return ret;
- }
- hashSz = (word32)ret;
- /* RFC 5869 states that the length of output keying material in
- * octets must be L <= 255*HashLen or N = ceil(L/HashLen) */
- if (out == NULL || ((outSz/hashSz) + ((outSz % hashSz) != 0)) > 255) {
- return BAD_FUNC_ARG;
- }
- #ifdef WOLFSSL_SMALL_STACK
- myHmac = (Hmac*)XMALLOC(sizeof(Hmac), NULL, DYNAMIC_TYPE_HMAC);
- if (myHmac == NULL) {
- return MEMORY_E;
- }
- #endif
- ret = wc_HmacInit(myHmac, NULL, INVALID_DEVID);
- if (ret != 0) {
- #ifdef WOLFSSL_SMALL_STACK
- XFREE(myHmac, NULL, DYNAMIC_TYPE_HMAC);
- #endif
- return ret;
- }
- XMEMSET(tmp, 0, WC_MAX_DIGEST_SIZE);
- while (outIdx < outSz) {
- word32 tmpSz = (n == 1) ? 0 : hashSz;
- word32 left = outSz - outIdx;
- ret = wc_HmacSetKey(myHmac, type, inKey, inKeySz);
- if (ret != 0)
- break;
- ret = wc_HmacUpdate(myHmac, tmp, tmpSz);
- if (ret != 0)
- break;
- ret = wc_HmacUpdate(myHmac, info, infoSz);
- if (ret != 0)
- break;
- ret = wc_HmacUpdate(myHmac, &n, 1);
- if (ret != 0)
- break;
- ret = wc_HmacFinal(myHmac, tmp);
- if (ret != 0)
- break;
- left = min(left, hashSz);
- XMEMCPY(out+outIdx, tmp, left);
- outIdx += hashSz;
- n++;
- }
- wc_HmacFree(myHmac);
- #ifdef WOLFSSL_SMALL_STACK
- XFREE(myHmac, NULL, DYNAMIC_TYPE_HMAC);
- #endif
- return ret;
- }
- /* HMAC-KDF.
- * RFC 5869 - HMAC-based Extract-and-Expand Key Derivation Function (HKDF).
- *
- * type The hash algorithm type.
- * inKey The input keying material.
- * inKeySz The size of the input keying material.
- * salt The optional salt value.
- * saltSz The size of the salt.
- * info The application specific information.
- * infoSz The size of the application specific information.
- * out The output keying material.
- * returns 0 on success, otherwise failure.
- */
- int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
- const byte* salt, word32 saltSz,
- const byte* info, word32 infoSz,
- byte* out, word32 outSz)
- {
- byte prk[WC_MAX_DIGEST_SIZE];
- word32 hashSz;
- int ret;
- ret = wc_HmacSizeByType(type);
- if (ret < 0) {
- return ret;
- }
- hashSz = (word32)ret;
- ret = wc_HKDF_Extract(type, salt, saltSz, inKey, inKeySz, prk);
- if (ret != 0)
- return ret;
- return wc_HKDF_Expand(type, prk, hashSz, info, infoSz, out, outSz);
- }
- #endif /* HAVE_HKDF */
- #endif /* NO_HMAC */
|