Commit 85dd923
committed
cryptocb: always run software cleanup in key Free functions
The WOLF_CRYPTO_CB_FREE path in wc_MlKemKey_Free, wc_dilithium_free,
and wc_ecc_free returned early when the crypto callback succeeded,
skipping local cleanup: ForceZero on private key material, PRF/hash
object frees (ML-KEM), SHAKE free and cached vector frees (ML-DSA),
and mp_forcezero on the private scalar and all hardware port frees
(ECC).
Any non-PKCS#11 callback returning 0 would silently leave key material
in memory. The PKCS#11 backend worked around this by returning
CRYPTOCB_UNAVAILABLE on success to force the fallthrough — a fragile
contract that is not part of the documented callback interface.
Fix by always continuing to software cleanup after invoking the
callback.
Remove the CRYPTOCB_UNAVAILABLE workaround from the three PKCS#11 free
dispatchers (ECC, ML-DSA, ML-KEM); they now return the real result of
C_DestroyObject.1 parent 21f1587 commit 85dd923
4 files changed
Lines changed: 16 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10963 | 10963 | | |
10964 | 10964 | | |
10965 | 10965 | | |
10966 | | - | |
10967 | | - | |
10968 | | - | |
10969 | | - | |
10970 | 10966 | | |
10971 | 10967 | | |
10972 | 10968 | | |
10973 | | - | |
| 10969 | + | |
10974 | 10970 | | |
10975 | 10971 | | |
10976 | 10972 | | |
10977 | | - | |
10978 | | - | |
10979 | | - | |
| 10973 | + | |
10980 | 10974 | | |
10981 | | - | |
10982 | 10975 | | |
10983 | 10976 | | |
10984 | 10977 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7930 | 7930 | | |
7931 | 7931 | | |
7932 | 7932 | | |
7933 | | - | |
7934 | | - | |
7935 | | - | |
7936 | | - | |
7937 | 7933 | | |
7938 | 7934 | | |
7939 | 7935 | | |
7940 | 7936 | | |
7941 | 7937 | | |
7942 | 7938 | | |
7943 | | - | |
| 7939 | + | |
| 7940 | + | |
| 7941 | + | |
| 7942 | + | |
7944 | 7943 | | |
7945 | | - | |
7946 | | - | |
7947 | | - | |
| 7944 | + | |
7948 | 7945 | | |
7949 | | - | |
7950 | 7946 | | |
7951 | 7947 | | |
7952 | 7948 | | |
| |||
7960 | 7956 | | |
7961 | 7957 | | |
7962 | 7958 | | |
| 7959 | + | |
7963 | 7960 | | |
7964 | 7961 | | |
7965 | 7962 | | |
| |||
8025 | 8022 | | |
8026 | 8023 | | |
8027 | 8024 | | |
8028 | | - | |
| 8025 | + | |
8029 | 8026 | | |
| 8027 | + | |
| 8028 | + | |
8030 | 8029 | | |
8031 | 8030 | | |
8032 | 8031 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | 394 | | |
399 | 395 | | |
400 | 396 | | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
407 | 402 | | |
408 | | - | |
409 | 403 | | |
410 | 404 | | |
411 | 405 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6582 | 6582 | | |
6583 | 6583 | | |
6584 | 6584 | | |
6585 | | - | |
6586 | | - | |
6587 | | - | |
6588 | | - | |
6589 | | - | |
6590 | | - | |
6591 | 6585 | | |
6592 | 6586 | | |
6593 | 6587 | | |
| |||
6601 | 6595 | | |
6602 | 6596 | | |
6603 | 6597 | | |
6604 | | - | |
6605 | | - | |
6606 | | - | |
6607 | | - | |
6608 | | - | |
6609 | 6598 | | |
6610 | 6599 | | |
6611 | 6600 | | |
| |||
6619 | 6608 | | |
6620 | 6609 | | |
6621 | 6610 | | |
6622 | | - | |
6623 | | - | |
6624 | | - | |
6625 | | - | |
6626 | | - | |
6627 | | - | |
6628 | | - | |
6629 | | - | |
6630 | 6611 | | |
6631 | 6612 | | |
6632 | 6613 | | |
| |||
0 commit comments