diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2019-02-15 10:26:16 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2019-02-15 10:26:16 +0800 |
commit | 8aa9e83d5b41589708042de12074548eb51d0bff (patch) | |
tree | 7765a58c48e79a343318944ca3274efe4b1483bf /ffi/go | |
parent | 63cad993e279c1bede614dfa985779b3f7427c6f (diff) | |
parent | 5dba8cba5a767dff835bac9609eddaf9d2ee6db3 (diff) | |
download | dexon-bls-8aa9e83d5b41589708042de12074548eb51d0bff.tar dexon-bls-8aa9e83d5b41589708042de12074548eb51d0bff.tar.gz dexon-bls-8aa9e83d5b41589708042de12074548eb51d0bff.tar.bz2 dexon-bls-8aa9e83d5b41589708042de12074548eb51d0bff.tar.lz dexon-bls-8aa9e83d5b41589708042de12074548eb51d0bff.tar.xz dexon-bls-8aa9e83d5b41589708042de12074548eb51d0bff.tar.zst dexon-bls-8aa9e83d5b41589708042de12074548eb51d0bff.zip |
Merge branch 'prevent_segfault_when_public_key_is_empty' of https://github.com/harmony-one/bls into harmony-one-prevent_segfault_when_public_key_is_empty
Diffstat (limited to 'ffi/go')
-rw-r--r-- | ffi/go/bls/bls.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ffi/go/bls/bls.go b/ffi/go/bls/bls.go index 2e57460..a49b7ef 100644 --- a/ffi/go/bls/bls.go +++ b/ffi/go/bls/bls.go @@ -326,6 +326,9 @@ func (sign *Sign) Verify(pub *PublicKey, m string) bool { // VerifyPop -- func (sign *Sign) VerifyPop(pub *PublicKey) bool { + if pub.getPointer() == nil { + return false + } return C.blsVerifyPop(sign.getPointer(), pub.getPointer()) == 1 } @@ -348,6 +351,9 @@ func HashAndMapToSignature(buf []byte) *Sign { // VerifyPairing -- func VerifyPairing(X *Sign, Y *Sign, pub *PublicKey) bool { + if X.getPointer() == nil || Y.getPointer() == nil || pub.getPointer() == nil { + return false + } return C.blsVerifyPairing(X.getPointer(), Y.getPointer(), pub.getPointer()) == 1 } @@ -366,6 +372,9 @@ func (sec *SecretKey) SignHash(hash []byte) (sign *Sign) { // VerifyHash -- func (sign *Sign) VerifyHash(pub *PublicKey, hash []byte) bool { // #nosec + if pub.getPointer() == nil { + return false + } return C.blsVerifyHash(sign.getPointer(), pub.getPointer(), unsafe.Pointer(&hash[0]), C.size_t(len(hash))) == 1 } @@ -385,6 +394,9 @@ func (sign *Sign) VerifyAggregateHashes(pubVec []PublicKey, hash [][]byte) bool hn := len(hash[i]) copy(h[i*hashByte:(i+1)*hashByte], hash[i][0:Min(hn, hashByte)]) } + if pubVec[0].getPointer() == nil { + return false + } return C.blsVerifyAggregatedHashes(sign.getPointer(), pubVec[0].getPointer(), unsafe.Pointer(&h[0]), C.size_t(hashByte), C.size_t(n)) == 1 } |