diff options
author | Russ Cox <rsc@golang.org> | 2017-08-03 15:49:33 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2017-08-17 20:23:31 +0000 |
commit | b1f201e951a7c1051de3e4ab5cef0d2367ab828e (patch) | |
tree | 47822d60a6cea9db02fb819ab075e71a62b126d8 /src/crypto/internal/boring/boring.go | |
parent | 2efded1cd2df8f6afea54acc6b06e083a3ba2f70 (diff) | |
download | go-b1f201e951a7c1051de3e4ab5cef0d2367ab828e.tar.gz go-b1f201e951a7c1051de3e4ab5cef0d2367ab828e.zip |
[dev.boringcrypto] crypto/ecdsa: use BoringCrypto
Change-Id: I108e0a527bddd673b16582d206e0697341d0a0ea
Reviewed-on: https://go-review.googlesource.com/55478
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
Diffstat (limited to 'src/crypto/internal/boring/boring.go')
-rw-r--r-- | src/crypto/internal/boring/boring.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/crypto/internal/boring/boring.go b/src/crypto/internal/boring/boring.go index 615b1efadc..bf1509122d 100644 --- a/src/crypto/internal/boring/boring.go +++ b/src/crypto/internal/boring/boring.go @@ -9,6 +9,7 @@ package boring // #include "goboringcrypto.h" import "C" +import "math/big" const available = true @@ -41,3 +42,14 @@ func UnreachableExceptTests() { type fail string func (e fail) Error() string { return "boringcrypto: " + string(e) + " failed" } + +func bigToBN(x *big.Int) *C.GO_BIGNUM { + raw := x.Bytes() + return C._goboringcrypto_BN_bin2bn(base(raw), C.size_t(len(raw)), nil) +} + +func bnToBig(bn *C.GO_BIGNUM) *big.Int { + raw := make([]byte, C._goboringcrypto_BN_num_bytes(bn)) + n := C._goboringcrypto_BN_bn2bin(bn, base(raw)) + return new(big.Int).SetBytes(raw[:n]) +} |