This commit is contained in:
Henry Case 2018-08-22 14:20:11 +01:00
parent 2f4912c8fd
commit f530de063a

View File

@ -21,14 +21,18 @@ const (
) )
// Helpers for byte convertion // Helpers for byte convertion
// ------------------------------
// cBytes must be initialized to proper size
func convBytesGoToC(goBytes []byte, cBytes []C.uchar) { func convBytesGoToC(goBytes []byte, cBytes []C.uchar) {
for i,v:=range(goBytes) { for i,v:=range(goBytes) {
cBytes[i] = C.uchar(v) cBytes[i] = C.uchar(v)
} }
} }
// goBytes must be initialized to proper size
func convBytesCToGo(cBytes []C.uchar, goBytes []byte) { func convBytesCToGo(cBytes []C.uchar, goBytes []byte) {
goBytes=C.GoBytes(unsafe.Pointer(&cBytes[0]), GSKsz) copy(goBytes, C.GoBytes(unsafe.Pointer(&cBytes[0]), C.int(len(cBytes))))
} }
// Helpers for key generation // Helpers for key generation
@ -154,9 +158,6 @@ func test_cfK_msrE_cfD() {
for i,_:=range(gSS) { for i,_:=range(gSS) {
if gSS[i] != byte(cSS[i]) { if gSS[i] != byte(cSS[i]) {
fmt.Printf("LEN=%d %X\n", len(gSS), gSS)
fmt.Printf("LEN=%d %X\n", len(cSS), cSS)
fmt.Printf("LEN=%d %X\n", len(gCT), gCT)
fmt.Println("ERR: shared secrets differ") fmt.Println("ERR: shared secrets differ")
break break
} }