Commit 58682a2
committed
Fixes for ML-DSA
When the input hash data in sized invalidly, the operations now fail
with an error.
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 e3fdc75 commit 58682a2
3 files changed
Lines changed: 78 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5923 | 5923 | | |
5924 | 5924 | | |
5925 | 5925 | | |
5926 | | - | |
5927 | | - | |
5928 | | - | |
5929 | | - | |
5930 | 5926 | | |
5931 | 5927 | | |
5932 | 5928 | | |
| |||
| 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 | | |
| |||
2858 | 2850 | | |
2859 | 2851 | | |
2860 | 2852 | | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
| 2875 | + | |
| 2876 | + | |
| 2877 | + | |
| 2878 | + | |
| 2879 | + | |
| 2880 | + | |
| 2881 | + | |
| 2882 | + | |
| 2883 | + | |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
2861 | 2923 | | |
2862 | 2924 | | |
2863 | 2925 | | |
| |||
8025 | 8087 | | |
8026 | 8088 | | |
8027 | 8089 | | |
8028 | | - | |
8029 | 8090 | | |
8030 | 8091 | | |
8031 | 8092 | | |
| |||
8039 | 8100 | | |
8040 | 8101 | | |
8041 | 8102 | | |
8042 | | - | |
8043 | | - | |
8044 | | - | |
8045 | | - | |
8046 | | - | |
8047 | | - | |
8048 | 8103 | | |
8049 | 8104 | | |
8050 | 8105 | | |
8051 | 8106 | | |
8052 | 8107 | | |
8053 | 8108 | | |
8054 | | - | |
8055 | 8109 | | |
8056 | 8110 | | |
8057 | 8111 | | |
| |||
8068 | 8122 | | |
8069 | 8123 | | |
8070 | 8124 | | |
8071 | | - | |
8072 | | - | |
8073 | | - | |
8074 | | - | |
8075 | | - | |
8076 | | - | |
8077 | 8125 | | |
8078 | 8126 | | |
8079 | 8127 | | |
8080 | 8128 | | |
8081 | 8129 | | |
8082 | 8130 | | |
8083 | | - | |
8084 | 8131 | | |
8085 | 8132 | | |
8086 | 8133 | | |
| |||
8097 | 8144 | | |
8098 | 8145 | | |
8099 | 8146 | | |
8100 | | - | |
8101 | 8147 | | |
8102 | 8148 | | |
8103 | 8149 | | |
| |||
13041 | 13087 | | |
13042 | 13088 | | |
13043 | 13089 | | |
13044 | | - | |
13045 | | - | |
13046 | 13090 | | |
13047 | 13091 | | |
13048 | 13092 | | |
| |||
13091 | 13135 | | |
13092 | 13136 | | |
13093 | 13137 | | |
13094 | | - | |
13095 | | - | |
13096 | 13138 | | |
13097 | 13139 | | |
13098 | 13140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
672 | | - | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
673 | 679 | | |
674 | 680 | | |
675 | 681 | | |
| |||
0 commit comments