Commit b7f6fce
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 fc81f06 commit b7f6fce
4 files changed
Lines changed: 15 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10905 | 10905 | | |
10906 | 10906 | | |
10907 | 10907 | | |
10908 | | - | |
10909 | | - | |
10910 | | - | |
10911 | | - | |
10912 | 10908 | | |
10913 | 10909 | | |
10914 | 10910 | | |
10915 | | - | |
| 10911 | + | |
10916 | 10912 | | |
10917 | 10913 | | |
10918 | 10914 | | |
10919 | | - | |
10920 | | - | |
10921 | | - | |
| 10915 | + | |
10922 | 10916 | | |
10923 | | - | |
10924 | 10917 | | |
10925 | 10918 | | |
10926 | 10919 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7945 | 7945 | | |
7946 | 7946 | | |
7947 | 7947 | | |
7948 | | - | |
7949 | | - | |
7950 | | - | |
7951 | | - | |
7952 | 7948 | | |
7953 | 7949 | | |
7954 | 7950 | | |
7955 | 7951 | | |
7956 | 7952 | | |
7957 | 7953 | | |
7958 | | - | |
| 7954 | + | |
| 7955 | + | |
| 7956 | + | |
| 7957 | + | |
7959 | 7958 | | |
7960 | | - | |
7961 | | - | |
7962 | | - | |
| 7959 | + | |
7963 | 7960 | | |
7964 | | - | |
7965 | 7961 | | |
7966 | 7962 | | |
7967 | 7963 | | |
| |||
7975 | 7971 | | |
7976 | 7972 | | |
7977 | 7973 | | |
| 7974 | + | |
7978 | 7975 | | |
7979 | 7976 | | |
7980 | 7977 | | |
| |||
8040 | 8037 | | |
8041 | 8038 | | |
8042 | 8039 | | |
8043 | | - | |
| 8040 | + | |
8044 | 8041 | | |
| 8042 | + | |
| 8043 | + | |
8045 | 8044 | | |
8046 | 8045 | | |
8047 | 8046 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
392 | | - | |
393 | 392 | | |
394 | | - | |
395 | 393 | | |
396 | 394 | | |
397 | 395 | | |
398 | 396 | | |
399 | 397 | | |
400 | 398 | | |
401 | | - | |
402 | | - | |
| 399 | + | |
| 400 | + | |
403 | 401 | | |
404 | | - | |
| 402 | + | |
405 | 403 | | |
406 | | - | |
407 | 404 | | |
408 | 405 | | |
409 | 406 | | |
| |||
416 | 413 | | |
417 | 414 | | |
418 | 415 | | |
419 | | - | |
| 416 | + | |
420 | 417 | | |
421 | 418 | | |
422 | 419 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6574 | 6574 | | |
6575 | 6575 | | |
6576 | 6576 | | |
6577 | | - | |
6578 | | - | |
6579 | | - | |
6580 | | - | |
6581 | | - | |
6582 | | - | |
6583 | 6577 | | |
6584 | 6578 | | |
6585 | 6579 | | |
| |||
6593 | 6587 | | |
6594 | 6588 | | |
6595 | 6589 | | |
6596 | | - | |
6597 | | - | |
6598 | | - | |
6599 | | - | |
6600 | | - | |
6601 | 6590 | | |
6602 | 6591 | | |
6603 | 6592 | | |
| |||
6611 | 6600 | | |
6612 | 6601 | | |
6613 | 6602 | | |
6614 | | - | |
6615 | | - | |
6616 | | - | |
6617 | | - | |
6618 | | - | |
6619 | | - | |
6620 | | - | |
6621 | | - | |
6622 | 6603 | | |
6623 | 6604 | | |
6624 | 6605 | | |
| |||
0 commit comments