open-quantum-safe / liboqs-go

Go bindings for liboqs
https://openquantumsafe.org/
MIT License
69 stars 24 forks source link

GenerateKeyPair() failed #12

Closed qnfm closed 2 years ago

qnfm commented 2 years ago

Here is my env: win10 x64 go ver: 1.18.1 cgo:msys Mingw64-gcc liboqs built from msvc 2019 with SHARDE-LIB=ON cmd:$ go run example\kem\kem.go code: examples/kem/kem.go:line16 kemName := "Classic-McEliece-348864" I tried to set GOGC=800 but didn't work, meanwhile other kem schemes worked just fine

Output: Enabled KEMs: [Classic-McEliece-348864 Classic-McEliece-348864f Classic-McEliece-460896 Classic-McEliece-460896f Classic-McEliece-6688128 Classic-McEliece-6688128f Classic-McEliece-6960119 Classic-McEliece-6960119f Classic-McEliece-8192128 Classic-McEliece-8192128f HQC-128 HQC-192 HQC-256 Kyber512 Kyber768 Kyber1024 Kyber512-90s Kyber768-90s Kyber1024-90s NTRU-HPS-2048-509 NTRU-HPS-2048-677 NTRU-HPS-4096-821 NTRU-HPS-4096-1229 NTRU-HRSS-701 NTRU-HRSS-1373 ntrulpr653 ntrulpr761 ntrulpr857 ntrulpr1277 sntrup653 sntrup761 sntrup857 sntrup1277 LightSaber-KEM Saber-KEM FireSaber-KEM FrodoKEM-640-AES FrodoKEM-640-SHAKE FrodoKEM-976-AES FrodoKEM-976-SHAKE FrodoKEM-1344-AES FrodoKEM-1344-SHAKE SIDH-p434 SIDH-p503 SIDH-p610 SIDH-p751 SIDH-p434-compressed SIDH-p503-compressed SIDH-p610-compressed SIDH-p751-compressed SIKE-p434 SIKE-p503 SIKE-p610 SIKE-p751 SIKE-p434-compressed SIKE-p503-compressed SIKE-p610-compressed SIKE-p751-compressed] Exception 0xc00000fd 0x1 0xdf34003000 0x7fff6e1e2a67 PC=0x7fff6e1e2a67 signal arrived during external code execution

runtime.cgocall(0x7ff78ca788e0, 0xc00014bc18) D:/dev/Go/src/runtime/cgocall.go:157 +0x4a fp=0xc00014bbf0 sp=0xc00014bbb8 pc=0x7ff78c9e378a github.com/open-quantum-safe/liboqs-go/oqs._Cfunc_OQS_KEM_keypair(0x286712750c0, 0xc000180000, 0xc000174000) _cgo_gotypes.go:197 +0x5a fp=0xc00014bc18 sp=0xc00014bbf0 pc=0x7ff78ca7617a github.com/open-quantum-safe/liboqs-go/oqs.(KeyEncapsulation).GenerateKeyPair.func1(0xc00014bca8?, {0xc000180000, 0xc00014e008?, 0xc000164000?}) D:/dev/src/golang/liboqs-go-0.7.1/oqs/oqs.go:170 +0x76 fp=0xc00014bc58 sp=0xc00014bc18 pc=0x7ff78ca771d6 github.com/open-quantum-safe/liboqs-go/oqs.(KeyEncapsulation).GenerateKeyPair(0xc00014bef0) D:/dev/src/golang/liboqs-go-0.7.1/oqs/oqs.go:170 +0x94 fp=0xc00014bcb8 sp=0xc00014bc58 pc=0x7ff78ca77094 main.main() D:/dev/src/golang/liboqs-go-0.7.1/examples/kem/kem.go:24 +0x1b2 fp=0xc00014bf80 sp=0xc00014bcb8 pc=0x7ff78ca780f2 runtime.main() D:/dev/Go/src/runtime/proc.go:250 +0x1fe fp=0xc00014bfe0 sp=0xc00014bf80 pc=0x7ff78ca168be runtime.goexit() D:/dev/Go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc00014bfe8 sp=0xc00014bfe0 pc=0x7ff78ca3d2e1 rax 0x2c0b0 rbx 0x5800 rcx 0x1 rdi 0xdf34019120 rsi 0x2 rbp 0xdf33fe50e0 rsp 0xdf34011078 r8 0x800 r9 0x5800 r10 0xdf33fe4000 r11 0xdf34003000 r12 0x800 r13 0x400 r14 0x2 r15 0x2 rip 0x7fff6e1e2a67 rflags 0x10287 cs 0x33 fs 0x53 gs 0x2b

vsoftco commented 2 years ago

That's due to the stack being too small on Windows, and currently we don't have a fix for it. BTW, the unit tests are disabled for McEliece on Windows due to the exact same reason.

baentsch commented 2 years ago

the unit tests are disabled for McEliece on Windows due to the exact same reason

So are we saying that McEliece basically doesn't work in Go on Windows? Is that already mentioned in the documentation of the wrapper? Same with the other test exclusions (HQC on Darwin)?

vsoftco commented 1 year ago

@baentsch just saw this. Yes, doesn't work, and no, not yet mentioned in the documentation.