Commit aca7408
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 13dc13b commit aca7408
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 | | |
| |||
7849 | 7841 | | |
7850 | 7842 | | |
7851 | 7843 | | |
7852 | | - | |
7853 | 7844 | | |
7854 | 7845 | | |
7855 | 7846 | | |
| |||
7863 | 7854 | | |
7864 | 7855 | | |
7865 | 7856 | | |
7866 | | - | |
7867 | | - | |
7868 | | - | |
7869 | | - | |
7870 | | - | |
7871 | | - | |
7872 | 7857 | | |
7873 | 7858 | | |
7874 | 7859 | | |
7875 | 7860 | | |
7876 | 7861 | | |
7877 | 7862 | | |
7878 | | - | |
7879 | 7863 | | |
7880 | 7864 | | |
7881 | 7865 | | |
| |||
7892 | 7876 | | |
7893 | 7877 | | |
7894 | 7878 | | |
7895 | | - | |
7896 | | - | |
7897 | | - | |
7898 | | - | |
7899 | | - | |
7900 | | - | |
7901 | 7879 | | |
7902 | 7880 | | |
7903 | 7881 | | |
7904 | 7882 | | |
7905 | 7883 | | |
7906 | 7884 | | |
7907 | | - | |
7908 | 7885 | | |
7909 | 7886 | | |
7910 | 7887 | | |
| |||
7921 | 7898 | | |
7922 | 7899 | | |
7923 | 7900 | | |
7924 | | - | |
7925 | 7901 | | |
7926 | 7902 | | |
7927 | 7903 | | |
| |||
12779 | 12755 | | |
12780 | 12756 | | |
12781 | 12757 | | |
12782 | | - | |
12783 | | - | |
12784 | 12758 | | |
12785 | 12759 | | |
12786 | 12760 | | |
| |||
12829 | 12803 | | |
12830 | 12804 | | |
12831 | 12805 | | |
12832 | | - | |
12833 | | - | |
12834 | 12806 | | |
12835 | 12807 | | |
12836 | 12808 | | |
| |||
0 commit comments