Fixes for TLS with crypto callbacks#7070
Conversation
DEBUG_CRYPTOCB61200d7 to
4a868bf
Compare
ed65d74 to
1b3afac
Compare
… KDF HMAC and ECH.
1b3afac to
2001d1c
Compare
… Fix random.c health test to use devId. Fix FIPS unused "ssl".
…e SHA1 struct from HS_Hashes when not needed. Fixes mix-match of the SHA-1 with `NO_OLD_TLS` and `WOLFSSL_ALLOW_TLS_SHA1`.
|
Retest this please |
…1 on either old TLS or `WOLFSSL_ALLOW_TLS_SHA1`.
| printf("Crypto CB: %s %s (%d) (%p ctx)\n", GetAlgoTypeStr(info->algo_type), | ||
| GetCipherTypeStr(info->cipher.type), info->cipher.type, info->cipher.ctx); |
| else if (info->algo_type == WC_ALGO_TYPE_HASH) { | ||
| printf("Crypto CB: %s %s (%d)\n", GetAlgoTypeStr(info->algo_type), | ||
| GetHashTypeStr(info->hash.type), info->hash.type); | ||
| printf("Crypto CB: %s %s (%d) (%p ctx) %s\n", GetAlgoTypeStr(info->algo_type), |
| printf("Crypto CB: %s %s (%d) (%p ctx) %s\n", GetAlgoTypeStr(info->algo_type), | ||
| GetHashTypeStr(info->hmac.macType), info->hmac.macType, info->hmac.hmac, |
| digestType); | ||
| if (ret == 0) { | ||
| PRIVATE_KEY_UNLOCK(); | ||
| ret = Tls13HKDFExpandKeyLabel(ssl, |
There was a problem hiding this comment.
note this is one of the calls to Tls13HKDFExpandKeyLabel() that happens even in FIPS builds. without the fix at line 241 I see this on fips+all builds:
src/tls13.c: In function ‘EchCheckAcceptance’:
d71e214bb6 (<david@wolfssl.com> 2023-12-18 17:16:54 -0800 4825) ret = Tls13HKDFExpandKeyLabel(ssl,
src/tls13.c:4825:15: error: implicit declaration of function ‘Tls13HKDFExpandKeyLabel’; did you mean ‘Tls13HKDFExpandLabel’? [-Werror=implicit-function-declaration]
4825 | ret = Tls13HKDFExpandKeyLabel(ssl,
| ^~~~~~~~~~~~~~~~~~~~~~~
| Tls13HKDFExpandLabel
…pto callback line lengths.
douzzer
left a comment
There was a problem hiding this comment.
The gcc sanitizers, due to multilevel inlining, have managed to figure out that there's something wrong with Tls13DeriveKey() in this PR. It's clean on master so it seems to be new to this PR:
[sp-all-asm-sanitizer] [1 of 1] [59155051bb]
autogen.sh 59155051bb... real 0m16.249s user 0m14.299s sys 0m1.088s
configure... real 0m18.709s user 0m10.000s sys 0m10.108s
build...In function ‘Tls13DeriveKey’,
6190666108 (<anthony@wolfssl.com> 2022-09-21 03:21:33 -0400 1095) return Tls13DeriveKey(ssl, secret, -1, key, finishedLabel,
inlined from ‘DeriveFinishedSecret’ at src/tls13.c:1095:12:
6190666108 (<anthony@wolfssl.com> 2022-09-21 03:21:33 -0400 502) ret = Tls13HKDFExpandKeyLabel(ssl, output, outputLen, secret, hashSz,
src/tls13.c:502:11: error: ‘hash’ may be used uninitialized [-Werror=maybe-uninitialized]
502 | ret = Tls13HKDFExpandKeyLabel(ssl, output, outputLen, secret, hashSz,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
503 | protocol, protocolLen, label, labelLen,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
504 | hash, hashOutSz, digestAlg, side);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/tls13.c: In function ‘DeriveFinishedSecret’:
6190666108 (<anthony@wolfssl.com> 2022-09-21 03:21:33 -0400 248) static int Tls13HKDFExpandKeyLabel(WOLFSSL* ssl, byte* okm, word32 okmLen,
src/tls13.c:248:12: note: by argument 8 of type ‘const byte *’ {aka ‘const unsigned char *’} to ‘Tls13HKDFExpandKeyLabel.constprop’ declared here
248 | static int Tls13HKDFExpandKeyLabel(WOLFSSL* ssl, byte* okm, word32 okmLen,
| ^~~~~~~~~~~~~~~~~~~~~~~
481f4765eb (<david@wolfssl.com> 2018-01-11 09:52:49 -0800 431) byte hash[WC_MAX_DIGEST_SIZE];
src/tls13.c:431:17: note: ‘hash’ declared here
431 | byte hash[WC_MAX_DIGEST_SIZE];
| ^~~~
In function ‘Tls13DeriveKey’,
inlined from ‘DeriveTrafficSecret’ at src/tls13.c:1116:12,
6190666108 (<anthony@wolfssl.com> 2022-09-21 03:21:33 -0400 1538) ret = DeriveTrafficSecret(ssl, ssl->clientSecret,
inlined from ‘DeriveTls13Keys’ at src/tls13.c:1538:23:
6190666108 (<anthony@wolfssl.com> 2022-09-21 03:21:33 -0400 502) ret = Tls13HKDFExpandKeyLabel(ssl, output, outputLen, secret, hashSz,
src/tls13.c:502:11: error: ‘hash’ may be used uninitialized [-Werror=maybe-uninitialized]
502 | ret = Tls13HKDFExpandKeyLabel(ssl, output, outputLen, secret, hashSz,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
503 | protocol, protocolLen, label, labelLen,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
504 | hash, hashOutSz, digestAlg, side);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/tls13.c: In function ‘DeriveTls13Keys’:
6190666108 (<anthony@wolfssl.com> 2022-09-21 03:21:33 -0400 248) static int Tls13HKDFExpandKeyLabel(WOLFSSL* ssl, byte* okm, word32 okmLen,
src/tls13.c:248:12: note: by argument 8 of type ‘const byte *’ {aka ‘const unsigned char *’} to ‘Tls13HKDFExpandKeyLabel.constprop’ declared here
248 | static int Tls13HKDFExpandKeyLabel(WOLFSSL* ssl, byte* okm, word32 okmLen,
| ^~~~~~~~~~~~~~~~~~~~~~~
481f4765eb (<david@wolfssl.com> 2018-01-11 09:52:49 -0800 431) byte hash[WC_MAX_DIGEST_SIZE];
src/tls13.c:431:17: note: ‘hash’ declared here
431 | byte hash[WC_MAX_DIGEST_SIZE];
| ^~~~
If I just XMEMSET(hash, 0, sizeof hash) at the start of the function, the sanitizing build and make check are clean. But that shouldn't be necessary -- I'm concerned one of the hash functions isn't writing out the hash value correctly.
douzzer
left a comment
There was a problem hiding this comment.
LGTM. Passing all the extra tests now. The documentation update looks great!
|
Retest this please |
Description
DeriveKeyMsgcomputations.NO_OLD_TLSandWOLFSSL_ALLOW_TLS_SHA1)devIdwith one-shot hash functions.DEBUG_CRYPTOCB.ZD 17134
Testing
Checklist