@@ -129,6 +129,35 @@ package wolfSSL
129129// (void)key; return -174;
130130// }
131131// #endif
132+ // /* unlock/op/lock must stay inside one cgo call; see fips.go */
133+ // static int wc_ecc_export_private_only_Unlocked(ecc_key* key, byte* out,
134+ // word32* outLen)
135+ // {
136+ // int ret;
137+ // PRIVATE_KEY_UNLOCK();
138+ // ret = wc_ecc_export_private_only(key, out, outLen);
139+ // PRIVATE_KEY_LOCK();
140+ // return ret;
141+ // }
142+ // static int wc_ecc_export_x963_ex_Unlocked(ecc_key* key, byte* out,
143+ // word32* outLen, int compressed)
144+ // {
145+ // int ret;
146+ // PRIVATE_KEY_UNLOCK();
147+ // ret = wc_ecc_export_x963_ex(key, out, outLen, compressed);
148+ // PRIVATE_KEY_LOCK();
149+ // return ret;
150+ // }
151+ // static int wc_ecc_shared_secret_Unlocked(ecc_key* private_key,
152+ // ecc_key* public_key,
153+ // byte* out, word32* outLen)
154+ // {
155+ // int ret;
156+ // PRIVATE_KEY_UNLOCK();
157+ // ret = wc_ecc_shared_secret(private_key, public_key, out, outLen);
158+ // PRIVATE_KEY_LOCK();
159+ // return ret;
160+ // }
132161import "C"
133162import (
134163 "unsafe"
@@ -165,10 +194,8 @@ func Wc_ecc_export_private_only(key *C.struct_ecc_key, out []byte, outLen *int)
165194 return BAD_FUNC_ARG
166195 }
167196 cOutLen := C .word32 (* outLen )
168- PRIVATE_KEY_UNLOCK ()
169- ret := int (C .wc_ecc_export_private_only (key , (* C .byte )(unsafe .Pointer (& out [0 ])), & cOutLen ))
197+ ret := int (C .wc_ecc_export_private_only_Unlocked (key , (* C .byte )(unsafe .Pointer (& out [0 ])), & cOutLen ))
170198 * outLen = int (cOutLen )
171- PRIVATE_KEY_LOCK ()
172199 return ret
173200}
174201
@@ -177,10 +204,8 @@ func Wc_ecc_export_x963_ex(key *C.struct_ecc_key, out []byte, outLen *int, compr
177204 return BAD_FUNC_ARG
178205 }
179206 cOutLen := C .word32 (* outLen )
180- PRIVATE_KEY_UNLOCK ()
181- ret := int (C .wc_ecc_export_x963_ex (key , (* C .byte )(unsafe .Pointer (& out [0 ])), & cOutLen , C .int (compressed )))
207+ ret := int (C .wc_ecc_export_x963_ex_Unlocked (key , (* C .byte )(unsafe .Pointer (& out [0 ])), & cOutLen , C .int (compressed )))
182208 * outLen = int (cOutLen )
183- PRIVATE_KEY_LOCK ()
184209 return ret
185210}
186211
@@ -254,10 +279,8 @@ func Wc_ecc_shared_secret(privKey, pubKey *C.struct_ecc_key, out []byte, outLen
254279 return BAD_FUNC_ARG
255280 }
256281 cOutLen := C .word32 (* outLen )
257- PRIVATE_KEY_UNLOCK ()
258- ret := int (C .wc_ecc_shared_secret (privKey , pubKey , (* C .uchar )(unsafe .Pointer (& out [0 ])), & cOutLen ))
282+ ret := int (C .wc_ecc_shared_secret_Unlocked (privKey , pubKey , (* C .uchar )(unsafe .Pointer (& out [0 ])), & cOutLen ))
259283 * outLen = int (cOutLen )
260- PRIVATE_KEY_LOCK ()
261284 return ret
262285}
263286
0 commit comments