Commit 8d2c40f
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 97ea4f8 commit 8d2c40f
4 files changed
Lines changed: 15 additions & 45 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 | |
|---|---|---|---|
| |||
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