aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-01-07 01:30:44 +0800
committerGitHub <noreply@github.com>2017-01-07 01:30:44 +0800
commitac93a6ff6cd1200ab0fb67a5bd0c02cb70646632 (patch)
tree2b06aa1b360f1488264058d04e399e84b898f0d8 /crypto
parent444fc892b0a860218dab3e421d92c33408b9eb6d (diff)
parent13e3b2f433c48fe81423c1a13e9a5194ece61b01 (diff)
downloadgo-tangerine-ac93a6ff6cd1200ab0fb67a5bd0c02cb70646632.tar.gz
go-tangerine-ac93a6ff6cd1200ab0fb67a5bd0c02cb70646632.tar.zst
go-tangerine-ac93a6ff6cd1200ab0fb67a5bd0c02cb70646632.zip
Merge pull request #3525 from fjl/all-gosimple-cleanup
all: clean up lint issues, remove more dead code
Diffstat (limited to 'crypto')
-rw-r--r--crypto/crypto_test.go2
-rw-r--r--crypto/ecies/asn1.go12
-rw-r--r--crypto/ecies/ecies.go5
-rw-r--r--crypto/ecies/ecies_test.go6
-rw-r--r--crypto/sha3/sha3_test.go2
5 files changed, 13 insertions, 14 deletions
diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go
index 86a582306..f42605d32 100644
--- a/crypto/crypto_test.go
+++ b/crypto/crypto_test.go
@@ -217,7 +217,7 @@ func TestValidateSignatureValues(t *testing.T) {
func checkhash(t *testing.T, name string, f func([]byte) []byte, msg, exp []byte) {
sum := f(msg)
- if bytes.Compare(exp, sum) != 0 {
+ if !bytes.Equal(exp, sum) {
t.Fatalf("hash %s mismatch: want: %x have: %x", name, exp, sum)
}
}
diff --git a/crypto/ecies/asn1.go b/crypto/ecies/asn1.go
index 40dabd329..508a645cd 100644
--- a/crypto/ecies/asn1.go
+++ b/crypto/ecies/asn1.go
@@ -109,7 +109,7 @@ func (curve secgNamedCurve) Equal(curve2 secgNamedCurve) bool {
if len(curve) != len(curve2) {
return false
}
- for i, _ := range curve {
+ for i := range curve {
if curve[i] != curve2[i] {
return false
}
@@ -157,7 +157,7 @@ func (a asnAlgorithmIdentifier) Cmp(b asnAlgorithmIdentifier) bool {
if len(a.Algorithm) != len(b.Algorithm) {
return false
}
- for i, _ := range a.Algorithm {
+ for i := range a.Algorithm {
if a.Algorithm[i] != b.Algorithm[i] {
return false
}
@@ -306,7 +306,7 @@ func (a asnECDHAlgorithm) Cmp(b asnECDHAlgorithm) bool {
if len(a.Algorithm) != len(b.Algorithm) {
return false
}
- for i, _ := range a.Algorithm {
+ for i := range a.Algorithm {
if a.Algorithm[i] != b.Algorithm[i] {
return false
}
@@ -325,7 +325,7 @@ func (a asnKeyDerivationFunction) Cmp(b asnKeyDerivationFunction) bool {
if len(a.Algorithm) != len(b.Algorithm) {
return false
}
- for i, _ := range a.Algorithm {
+ for i := range a.Algorithm {
if a.Algorithm[i] != b.Algorithm[i] {
return false
}
@@ -360,7 +360,7 @@ func (a asnSymmetricEncryption) Cmp(b asnSymmetricEncryption) bool {
if len(a.Algorithm) != len(b.Algorithm) {
return false
}
- for i, _ := range a.Algorithm {
+ for i := range a.Algorithm {
if a.Algorithm[i] != b.Algorithm[i] {
return false
}
@@ -380,7 +380,7 @@ func (a asnMessageAuthenticationCode) Cmp(b asnMessageAuthenticationCode) bool {
if len(a.Algorithm) != len(b.Algorithm) {
return false
}
- for i, _ := range a.Algorithm {
+ for i := range a.Algorithm {
if a.Algorithm[i] != b.Algorithm[i] {
return false
}
diff --git a/crypto/ecies/ecies.go b/crypto/ecies/ecies.go
index 86a70261d..b1a716c00 100644
--- a/crypto/ecies/ecies.go
+++ b/crypto/ecies/ecies.go
@@ -291,9 +291,8 @@ func Encrypt(rand io.Reader, pub *PublicKey, m, s1, s2 []byte) (ct []byte, err e
// Decrypt decrypts an ECIES ciphertext.
func (prv *PrivateKey) Decrypt(rand io.Reader, c, s1, s2 []byte) (m []byte, err error) {
- if c == nil || len(c) == 0 {
- err = ErrInvalidMessage
- return
+ if len(c) == 0 {
+ return nil, ErrInvalidMessage
}
params := prv.PublicKey.Params
if params == nil {
diff --git a/crypto/ecies/ecies_test.go b/crypto/ecies/ecies_test.go
index cb09061ce..3b3517baf 100644
--- a/crypto/ecies/ecies_test.go
+++ b/crypto/ecies/ecies_test.go
@@ -492,17 +492,17 @@ type testCase struct {
}
var testCases = []testCase{
- testCase{
+ {
Curve: elliptic.P256(),
Name: "P256",
Expected: true,
},
- testCase{
+ {
Curve: elliptic.P384(),
Name: "P384",
Expected: true,
},
- testCase{
+ {
Curve: elliptic.P521(),
Name: "P521",
Expected: true,
diff --git a/crypto/sha3/sha3_test.go b/crypto/sha3/sha3_test.go
index caf72f279..c433761a8 100644
--- a/crypto/sha3/sha3_test.go
+++ b/crypto/sha3/sha3_test.go
@@ -201,7 +201,7 @@ func TestSqueezing(t *testing.T) {
d1 := newShakeHash()
d1.Write([]byte(testString))
var multiple []byte
- for _ = range ref {
+ for range ref {
one := make([]byte, 1)
d1.Read(one)
multiple = append(multiple, one...)