support old golang
@@ -13,6 +13,7 @@ import "C"
import (
"github.com/cossacklabs/themis/gothemis/errors"
"github.com/cossacklabs/themis/gothemis/keys"
+ "reflect"
"runtime"
"unsafe"
)
@@ -89,8 +90,8 @@ func onPublicKeyForId(ssCtx unsafe.Pointer, idPtr unsafe.Pointer, idLen C.size_t
if len(pub.Value) > int(keyLen) {
return int(C.GOTHEMIS_BUFFER_TOO_SMALL)
}
-
- key := (*[1 << 30]byte)(keyPtr)[:keyLen:keyLen]
+ sliceHeader := reflect.SliceHeader{uintptr(keyPtr), int(keyLen), int(keyLen)}
+ key := *(*[]byte)(unsafe.Pointer(&sliceHeader))
copy(key, pub.Value)
return int(C.GOTHEMIS_SUCCESS)
}
