Commit d171b10
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 fa81c8f commit d171b10
2 files changed
Lines changed: 76 additions & 30 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 | | |
| |||
2856 | 2848 | | |
2857 | 2849 | | |
2858 | 2850 | | |
| 2851 | + | |
| 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 | + | |
2859 | 2921 | | |
2860 | 2922 | | |
2861 | 2923 | | |
| |||
7938 | 8000 | | |
7939 | 8001 | | |
7940 | 8002 | | |
7941 | | - | |
7942 | 8003 | | |
7943 | 8004 | | |
7944 | 8005 | | |
| |||
7952 | 8013 | | |
7953 | 8014 | | |
7954 | 8015 | | |
7955 | | - | |
7956 | | - | |
7957 | | - | |
7958 | | - | |
7959 | | - | |
7960 | | - | |
7961 | 8016 | | |
7962 | 8017 | | |
7963 | 8018 | | |
7964 | 8019 | | |
7965 | 8020 | | |
7966 | 8021 | | |
7967 | | - | |
7968 | 8022 | | |
7969 | 8023 | | |
7970 | 8024 | | |
| |||
7981 | 8035 | | |
7982 | 8036 | | |
7983 | 8037 | | |
7984 | | - | |
7985 | | - | |
7986 | | - | |
7987 | | - | |
7988 | | - | |
7989 | | - | |
7990 | 8038 | | |
7991 | 8039 | | |
7992 | 8040 | | |
7993 | 8041 | | |
7994 | 8042 | | |
7995 | 8043 | | |
7996 | | - | |
7997 | 8044 | | |
7998 | 8045 | | |
7999 | 8046 | | |
| |||
8010 | 8057 | | |
8011 | 8058 | | |
8012 | 8059 | | |
8013 | | - | |
8014 | 8060 | | |
8015 | 8061 | | |
8016 | 8062 | | |
| |||
12952 | 12998 | | |
12953 | 12999 | | |
12954 | 13000 | | |
12955 | | - | |
12956 | | - | |
12957 | 13001 | | |
12958 | 13002 | | |
12959 | 13003 | | |
| |||
13002 | 13046 | | |
13003 | 13047 | | |
13004 | 13048 | | |
13005 | | - | |
13006 | | - | |
13007 | 13049 | | |
13008 | 13050 | | |
13009 | 13051 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
672 | | - | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
673 | 677 | | |
674 | 678 | | |
675 | 679 | | |
| |||
0 commit comments