Commit f09e80d
committed
Fix ML-DSA context buffer: replace heap pointer with fixed-size array
Replace the dynamically-allocated `byte* ctx` pointer in WP11_MldsaParams
with an inline `byte ctx[256]` array. PKCS#11 v3.2 (§2.3.12) caps the
ML-DSA context length at 255 bytes, so heap allocation is unnecessary and
introduced several memory-management hazards:
- ctx was freed at the end of WP11_Mldsa_Sign/Verify before session
teardown, leaving a dangling pointer if the session was reused
- the cleanup in wp11_Session_Final checked the wrong mechanism set,
meaning it could free ctx a second time
- WP11_Session_SetMldsaParams freed ctx before re-initialising, which
was safe only if the pointer was always valid (it wasn't on first call)
Embedding the buffer in the struct eliminates all manual lifetime
tracking.1 parent 89c66b0 commit f09e80d
1 file changed
Lines changed: 1 addition & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
359 | | - | |
| 359 | + | |
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| |||
911 | 911 | | |
912 | 912 | | |
913 | 913 | | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | 914 | | |
923 | 915 | | |
924 | 916 | | |
| |||
7851 | 7843 | | |
7852 | 7844 | | |
7853 | 7845 | | |
7854 | | - | |
7855 | 7846 | | |
7856 | 7847 | | |
7857 | 7848 | | |
| |||
7865 | 7856 | | |
7866 | 7857 | | |
7867 | 7858 | | |
7868 | | - | |
7869 | | - | |
7870 | | - | |
7871 | | - | |
7872 | | - | |
7873 | | - | |
7874 | 7859 | | |
7875 | 7860 | | |
7876 | 7861 | | |
7877 | 7862 | | |
7878 | 7863 | | |
7879 | 7864 | | |
7880 | | - | |
7881 | 7865 | | |
7882 | 7866 | | |
7883 | 7867 | | |
| |||
7894 | 7878 | | |
7895 | 7879 | | |
7896 | 7880 | | |
7897 | | - | |
7898 | | - | |
7899 | | - | |
7900 | | - | |
7901 | | - | |
7902 | | - | |
7903 | 7881 | | |
7904 | 7882 | | |
7905 | 7883 | | |
7906 | 7884 | | |
7907 | 7885 | | |
7908 | 7886 | | |
7909 | | - | |
7910 | 7887 | | |
7911 | 7888 | | |
7912 | 7889 | | |
| |||
7923 | 7900 | | |
7924 | 7901 | | |
7925 | 7902 | | |
7926 | | - | |
7927 | 7903 | | |
7928 | 7904 | | |
7929 | 7905 | | |
| |||
12798 | 12774 | | |
12799 | 12775 | | |
12800 | 12776 | | |
12801 | | - | |
12802 | | - | |
12803 | 12777 | | |
12804 | 12778 | | |
12805 | 12779 | | |
| |||
12848 | 12822 | | |
12849 | 12823 | | |
12850 | 12824 | | |
12851 | | - | |
12852 | | - | |
12853 | 12825 | | |
12854 | 12826 | | |
12855 | 12827 | | |
| |||
0 commit comments