Commit f956587
Fix StatefulSignature.export_secret_key TypeErrors on Windows (#141)
Two failures reported in #136, both in export_secret_key:
1. On Python 3.14 32-bit: ct.util.find_library("c") returns None on
Windows, so CDLL(None) raises TypeError. Even on Unix where it
worked, liboqs's malloc and libc's free can come from different
CRT heaps on Windows. Use liboqs's own OQS_MEM_secure_free
instead — ABI-compatible by construction, and also zeroizes the
secret-key bytes before freeing.
2. On Python 3.14 64-bit: OQS_SIG_STFL_SECRET_KEY_serialize fails
with "OverflowError: int too long to convert" on argument 3 (the
secret-key handle). Cause: restype c_void_p auto-unwraps the
returned pointer to a Python int, and on Windows Python 3.14 the
int -> c_void_p arg conversion path chokes on high-bit-set
addresses. Use a c_void_p subclass as the restype so ctypes keeps
the pointer as an object; subsequent calls take the same-type
fast path and skip int conversion entirely.
Closes #136.
Signed-off-by: Douglas Stebila <dstebila@uwaterloo.ca>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent dac0c08 commit f956587
1 file changed
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1161 | 1161 | | |
1162 | 1162 | | |
1163 | 1163 | | |
1164 | | - | |
| 1164 | + | |
1165 | 1165 | | |
1166 | 1166 | | |
1167 | 1167 | | |
| |||
1212 | 1212 | | |
1213 | 1213 | | |
1214 | 1214 | | |
1215 | | - | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
1216 | 1228 | | |
1217 | 1229 | | |
1218 | 1230 | | |
| |||
1221 | 1233 | | |
1222 | 1234 | | |
1223 | 1235 | | |
| 1236 | + | |
| 1237 | + | |
1224 | 1238 | | |
1225 | 1239 | | |
1226 | 1240 | | |
| |||
0 commit comments