diff --git a/aead/aesctrhmac/key_parameters.go b/aead/aesctrhmac/key_parameters.go index f34be1d..e9961aa 100644 --- a/aead/aesctrhmac/key_parameters.go +++ b/aead/aesctrhmac/key_parameters.go @@ -204,8 +204,8 @@ func NewParameters(opts ParametersOpts) (*Parameters, error) { // HasIDRequirement returns whether the key has an ID requirement. func (p *Parameters) HasIDRequirement() bool { return p.variant != VariantNoPrefix } -// Equals returns whether this Parameters object is equal to other. -func (p *Parameters) Equals(other key.Parameters) bool { +// Equal returns whether this Parameters object is equal to other. +func (p *Parameters) Equal(other key.Parameters) bool { actualParams, ok := other.(*Parameters) return ok && p.HasIDRequirement() == actualParams.HasIDRequirement() && p.aesKeySizeInBytes == actualParams.aesKeySizeInBytes && diff --git a/aead/aesctrhmac/key_parameters_test.go b/aead/aesctrhmac/key_parameters_test.go index 2e0b291..600cca1 100644 --- a/aead/aesctrhmac/key_parameters_test.go +++ b/aead/aesctrhmac/key_parameters_test.go @@ -233,14 +233,14 @@ func TestNewParametersWorks(t *testing.T) { if err != nil { t.Fatalf("aesctrhmac.NewParameters(%v) err = %v, want nil", tc.paramsOpts, err) } - if !params.Equals(otherParams) { - t.Errorf("params.Equals(otherParams) = %v, want true", params.Equals(otherParams)) + if !params.Equal(otherParams) { + t.Errorf("params.Equal(otherParams) = %v, want true", params.Equal(otherParams)) } }) } } -func TestParametersEqualsFalseIfDifferent(t *testing.T) { +func TestParametersEqualFalseIfDifferent(t *testing.T) { for _, tc := range []struct { name string opts1 aesctrhmac.ParametersOpts @@ -370,8 +370,8 @@ func TestParametersEqualsFalseIfDifferent(t *testing.T) { if err != nil { t.Errorf("aesctrhmac.NewParameters(%v) err = %v, want nil", tc.opts2, err) } - if params1.Equals(params2) { - t.Errorf("params.Equals(params2) = %v, want false", params1.Equals(params2)) + if params1.Equal(params2) { + t.Errorf("params.Equal(params2) = %v, want false", params1.Equal(params2)) } }) } diff --git a/aead/aesgcm/aesgcm_test.go b/aead/aesgcm/aesgcm_test.go index 8888768..c03f5eb 100644 --- a/aead/aesgcm/aesgcm_test.go +++ b/aead/aesgcm/aesgcm_test.go @@ -60,8 +60,8 @@ func TestGetKeyFromHandle(t *testing.T) { if err != nil { t.Fatalf("aesgcm.NewParameters(%v) err = %v, want nil", opts, err) } - if !key.Parameters().Equals(expectedParameters) { - t.Errorf("key.Parameters().Equals(expectedParameters) = false, want true") + if !key.Parameters().Equal(expectedParameters) { + t.Errorf("key.Parameters().Equal(expectedParameters) = false, want true") } if _, hasIDRequirement := key.IDRequirement(); !hasIDRequirement { t.Errorf("expected ID requirement, got none") diff --git a/aead/aesgcm/key.go b/aead/aesgcm/key.go index 8bee07d..a648158 100644 --- a/aead/aesgcm/key.go +++ b/aead/aesgcm/key.go @@ -133,8 +133,8 @@ func NewParameters(opts ParametersOpts) (*Parameters, error) { // HasIDRequirement returns whether the key has an ID requirement. func (p *Parameters) HasIDRequirement() bool { return p.variant != VariantNoPrefix } -// Equals returns whether this Parameters object is equal to other. -func (p *Parameters) Equals(other key.Parameters) bool { +// Equal returns whether this Parameters object is equal to other. +func (p *Parameters) Equal(other key.Parameters) bool { actualParams, ok := other.(*Parameters) return ok && p.HasIDRequirement() == actualParams.HasIDRequirement() && p.keySizeInBytes == actualParams.keySizeInBytes && @@ -211,14 +211,14 @@ func (k *Key) IDRequirement() (uint32, bool) { // OutputPrefix returns the output prefix. func (k *Key) OutputPrefix() []byte { return bytes.Clone(k.outputPrefix) } -// Equals returns whether this key object is equal to other. -func (k *Key) Equals(other key.Key) bool { +// Equal returns whether this key object is equal to other. +func (k *Key) Equal(other key.Key) bool { that, ok := other.(*Key) thisIDRequirement, thisIDRequired := k.IDRequirement() thatIDRequirement, thatIDRequired := that.IDRequirement() - return ok && k.Parameters().Equals(that.Parameters()) && + return ok && k.Parameters().Equal(that.Parameters()) && thisIDRequired == thatIDRequired && thisIDRequirement == thatIDRequirement && - k.keyBytes.Equals(that.keyBytes) && + k.keyBytes.Equal(that.keyBytes) && bytes.Equal(k.outputPrefix, that.outputPrefix) } diff --git a/aead/aesgcm/key_test.go b/aead/aesgcm/key_test.go index f26ad9c..7eabdde 100644 --- a/aead/aesgcm/key_test.go +++ b/aead/aesgcm/key_test.go @@ -291,14 +291,14 @@ func TestNewParametersWorks(t *testing.T) { if err != nil { t.Fatalf("aesgcm.NewParameters(%v) err = %v, want nil", opts, err) } - if !params.Equals(otherParams) { - t.Errorf("params.Equals(otherParams) = %v, want true", params.Equals(otherParams)) + if !params.Equal(otherParams) { + t.Errorf("params.Equal(otherParams) = %v, want true", params.Equal(otherParams)) } }) } } -func TestParametersEqualsFalseIfDifferent(t *testing.T) { +func TestParametersEqualFalseIfDifferent(t *testing.T) { for _, test := range []struct { name string key1Size int @@ -342,8 +342,8 @@ func TestParametersEqualsFalseIfDifferent(t *testing.T) { if err != nil { t.Errorf("aesgcm.NewParameters(%v) err = %v, want nil", opts2, err) } - if params1.Equals(params2) { - t.Errorf("params.Equals(params2) = %v, want false", params1.Equals(params2)) + if params1.Equal(params2) { + t.Errorf("params.Equal(params2) = %v, want false", params1.Equal(params2)) } }) } @@ -420,12 +420,12 @@ func TestNewKeyWorks(t *testing.T) { if err != nil { t.Fatalf("aesgcm.NewKey(keyBytes, %v, %v) err = %v, want nil", test.id, params, err) } - if !key1.Parameters().Equals(params) { + if !key1.Parameters().Equal(params) { t.Errorf("key1.Parameters() = %v, want %v", key1.Parameters(), params) } key1Bytes := key1.KeyBytes() - if !keyBytes.Equals(key1Bytes) { - t.Errorf("keyBytes.Equals(key1Bytes) = false, want true") + if !keyBytes.Equal(key1Bytes) { + t.Errorf("keyBytes.Equal(key1Bytes) = false, want true") } keyID1, required := key1.IDRequirement() if wantRequired := test.variant != aesgcm.VariantNoPrefix; required != wantRequired { @@ -442,15 +442,15 @@ func TestNewKeyWorks(t *testing.T) { if err != nil { t.Fatalf("aesgcm.NewKey(keyBytes, %v, %v) err = %v, want nil", keyID1, params, err) } - // Test Equals. - if !key1.Equals(key2) { - t.Errorf("key1.Equals(key2) = %v, want true", key1.Equals(key2)) + // Test Equal. + if !key1.Equal(key2) { + t.Errorf("key1.Equal(key2) = %v, want true", key1.Equal(key2)) } }) } } -func TestKeyEqualsReturnsFalseIfDifferent(t *testing.T) { +func TestKeyEqualReturnsFalseIfDifferent(t *testing.T) { for _, test := range []struct { name string first TestKey @@ -552,8 +552,8 @@ func TestKeyEqualsReturnsFalseIfDifferent(t *testing.T) { if err != nil { t.Fatalf("aesgcm.NewKey(secondKeyBytes, %v, %v) err = %v, want nil", test.second.id, secondParams, err) } - if firstKey.Equals(secondKey) { - t.Errorf("firstKey.Equals(secondKey) = true, want false") + if firstKey.Equal(secondKey) { + t.Errorf("firstKey.Equal(secondKey) = true, want false") } }) } diff --git a/aead/aesgcm/protoserialization_test.go b/aead/aesgcm/protoserialization_test.go index 8b449b4..0864e1a 100644 --- a/aead/aesgcm/protoserialization_test.go +++ b/aead/aesgcm/protoserialization_test.go @@ -216,8 +216,8 @@ func TestParseKey(t *testing.T) { if err != nil { t.Errorf("protoserialization.ParseKey(%v) err = %v, want nil", tc.keySerialization, err) } - if !gotKey.Equals(wantKey) { - t.Errorf("key.Equals(wantKey) = false, want true") + if !gotKey.Equal(wantKey) { + t.Errorf("key.Equal(wantKey) = false, want true") } }) } @@ -229,7 +229,7 @@ type testParams struct { func (p *testParams) HasIDRequirement() bool { return p.hasIDRequirement } -func (p *testParams) Equals(params key.Parameters) bool { +func (p *testParams) Equal(params key.Parameters) bool { _, ok := params.(*testParams) return ok && p.hasIDRequirement == params.HasIDRequirement() } @@ -242,12 +242,12 @@ type testKey struct { func (k *testKey) Parameters() key.Parameters { return &k.params } -func (k *testKey) Equals(other key.Key) bool { +func (k *testKey) Equal(other key.Key) bool { fallbackProtoKey, ok := other.(*testKey) if !ok { return false } - return k.params.Equals(fallbackProtoKey.Parameters()) + return k.params.Equal(fallbackProtoKey.Parameters()) } func (k *testKey) IDRequirement() (uint32, bool) { return k.id, k.params.HasIDRequirement() } @@ -344,8 +344,8 @@ func TestSerializeKey(t *testing.T) { if err != nil { t.Errorf("protoserialization.SerializeKey(&testKey{}) err = %v, want nil", err) } - if !got.Equals(tc.wantKeySerialization) { - t.Errorf("got.Equals(tc.wantKeySerialization) = false, want true") + if !got.Equal(tc.wantKeySerialization) { + t.Errorf("got.Equal(tc.wantKeySerialization) = false, want true") } }) } diff --git a/aead/aesgcmsiv/aesgcmsiv_test.go b/aead/aesgcmsiv/aesgcmsiv_test.go index b642cdf..da4afff 100644 --- a/aead/aesgcmsiv/aesgcmsiv_test.go +++ b/aead/aesgcmsiv/aesgcmsiv_test.go @@ -41,8 +41,8 @@ func TestGetKeyFromHandle(t *testing.T) { if err != nil { t.Fatalf("aesgcmsiv.NewParameters(%v, %v) err = %v, want nil", keySize, aesgcmsiv.VariantTink, err) } - if !key.Parameters().Equals(expectedParameters) { - t.Errorf("key.Parameters().Equals(expectedParameters) = false, want true") + if !key.Parameters().Equal(expectedParameters) { + t.Errorf("key.Parameters().Equal(expectedParameters) = false, want true") } if _, hasIDRequirement := key.IDRequirement(); !hasIDRequirement { t.Errorf("expected ID requirement, got none") diff --git a/aead/aesgcmsiv/key.go b/aead/aesgcmsiv/key.go index 6e2a6dc..e03ac4d 100644 --- a/aead/aesgcmsiv/key.go +++ b/aead/aesgcmsiv/key.go @@ -112,8 +112,8 @@ func NewParameters(keySizeInBytes int, variant Variant) (*Parameters, error) { // HasIDRequirement returns whether the key has an ID requirement. func (p *Parameters) HasIDRequirement() bool { return p.variant != VariantNoPrefix } -// Equals returns whether this Parameters object is equal to other. -func (p *Parameters) Equals(other key.Parameters) bool { +// Equal returns whether this Parameters object is equal to other. +func (p *Parameters) Equal(other key.Parameters) bool { actualParams, ok := other.(*Parameters) return ok && p.HasIDRequirement() == actualParams.HasIDRequirement() && p.keySizeInBytes == actualParams.keySizeInBytes && @@ -182,14 +182,14 @@ func (k *Key) IDRequirement() (uint32, bool) { // OutputPrefix returns the output prefix. func (k *Key) OutputPrefix() []byte { return bytes.Clone(k.outputPrefix) } -// Equals returns whether this key object is equal to other. -func (k *Key) Equals(other key.Key) bool { +// Equal returns whether this key object is equal to other. +func (k *Key) Equal(other key.Key) bool { that, ok := other.(*Key) thisIDRequirement, thisIDRequired := k.IDRequirement() thatIDRequirement, thatIDRequired := that.IDRequirement() - return ok && k.Parameters().Equals(that.Parameters()) && + return ok && k.Parameters().Equal(that.Parameters()) && thisIDRequired == thatIDRequired && thisIDRequirement == thatIDRequirement && - k.keyBytes.Equals(that.keyBytes) && + k.keyBytes.Equal(that.keyBytes) && bytes.Equal(k.outputPrefix, that.outputPrefix) } diff --git a/aead/aesgcmsiv/key_test.go b/aead/aesgcmsiv/key_test.go index 36d16f0..dd40bfa 100644 --- a/aead/aesgcmsiv/key_test.go +++ b/aead/aesgcmsiv/key_test.go @@ -220,14 +220,14 @@ func TestNewParametersWorks(t *testing.T) { if err != nil { t.Fatalf("aesgcmsiv.NewParameters(%v, %v) err = %v, want nil", test.keySize, test.variant, err) } - if !params.Equals(otherParams) { - t.Errorf("params.Equals(otherParams) = %v, want true", params.Equals(otherParams)) + if !params.Equal(otherParams) { + t.Errorf("params.Equal(otherParams) = %v, want true", params.Equal(otherParams)) } }) } } -func TestParametersEqualsFalseIfDifferent(t *testing.T) { +func TestParametersEqualFalseIfDifferent(t *testing.T) { for _, test := range []struct { name string key1Size int @@ -259,8 +259,8 @@ func TestParametersEqualsFalseIfDifferent(t *testing.T) { if err != nil { t.Errorf("aesgcmsiv.NewParameters(%v, %v) err = %v, want nil", test.key2Size, test.key2Variant, err) } - if params1.Equals(params2) { - t.Errorf("params.Equals(params2) = %v, want false", params1.Equals(params2)) + if params1.Equal(params2) { + t.Errorf("params.Equal(params2) = %v, want false", params1.Equal(params2)) } }) } @@ -331,12 +331,12 @@ func TestNewKeyWorks(t *testing.T) { if err != nil { t.Fatalf("aesgcmsiv.NewKey(keyBytes, %v, %v) err = %v, want nil", test.id, params, err) } - if !key1.Parameters().Equals(params) { + if !key1.Parameters().Equal(params) { t.Errorf("key1.Parameters() = %v, want %v", key1.Parameters(), params) } key1Bytes := key1.KeyBytes() - if !keyBytes.Equals(key1Bytes) { - t.Errorf("keyBytes.Equals(key1Bytes) = false, want true") + if !keyBytes.Equal(key1Bytes) { + t.Errorf("keyBytes.Equal(key1Bytes) = false, want true") } keyID1, required := key1.IDRequirement() if wantRequired := test.variant != aesgcmsiv.VariantNoPrefix; required != wantRequired { @@ -353,15 +353,15 @@ func TestNewKeyWorks(t *testing.T) { if err != nil { t.Fatalf("aesgcmsiv.NewKey(keyBytes, %v, %v) err = %v, want nil", keyID1, params, err) } - // Test Equals. - if !key1.Equals(key2) { - t.Errorf("key1.Equals(key2) = %v, want true", key1.Equals(key2)) + // Test Equal. + if !key1.Equal(key2) { + t.Errorf("key1.Equal(key2) = %v, want true", key1.Equal(key2)) } }) } } -func TestKeyEqualsReturnsFalseIfDifferent(t *testing.T) { +func TestKeyEqualReturnsFalseIfDifferent(t *testing.T) { for _, test := range []struct { name string first TestKey @@ -451,8 +451,8 @@ func TestKeyEqualsReturnsFalseIfDifferent(t *testing.T) { if err != nil { t.Fatalf("aesgcmsiv.NewKey(secondKeyBytes, %v, %v) err = %v, want nil", test.second.id, secondParams, err) } - if firstKey.Equals(secondKey) { - t.Errorf("firstKey.Equals(secondKey) = true, want false") + if firstKey.Equal(secondKey) { + t.Errorf("firstKey.Equal(secondKey) = true, want false") } }) } diff --git a/aead/aesgcmsiv/protoserialization_test.go b/aead/aesgcmsiv/protoserialization_test.go index 8cf246c..43eab1e 100644 --- a/aead/aesgcmsiv/protoserialization_test.go +++ b/aead/aesgcmsiv/protoserialization_test.go @@ -211,8 +211,8 @@ func TestParseKey(t *testing.T) { if err != nil { t.Fatalf("protoserialization.ParseKey(%v) err = %v, want nil", tc.keySerialization, err) } - if !gotKey.Equals(wantKey) { - t.Errorf("key.Equals(wantKey) = false, want true") + if !gotKey.Equal(wantKey) { + t.Errorf("key.Equal(wantKey) = false, want true") } }) } @@ -224,7 +224,7 @@ type testParams struct { func (p *testParams) HasIDRequirement() bool { return p.hasIDRequirement } -func (p *testParams) Equals(params key.Parameters) bool { +func (p *testParams) Equal(params key.Parameters) bool { _, ok := params.(*testParams) return ok && p.hasIDRequirement == params.HasIDRequirement() } @@ -237,12 +237,12 @@ type testKey struct { func (k *testKey) Parameters() key.Parameters { return &k.params } -func (k *testKey) Equals(other key.Key) bool { +func (k *testKey) Equal(other key.Key) bool { fallbackProtoKey, ok := other.(*testKey) if !ok { return false } - return k.params.Equals(fallbackProtoKey.Parameters()) + return k.params.Equal(fallbackProtoKey.Parameters()) } func (k *testKey) IDRequirement() (uint32, bool) { return k.id, k.params.HasIDRequirement() } @@ -333,8 +333,8 @@ func TestSerializeKey(t *testing.T) { if err != nil { t.Fatalf("protoserialization.SerializeKey(&testKey{}) err = %v, want nil", err) } - if !got.Equals(tc.wantKeySerialization) { - t.Errorf("got.Equals(tc.wantKeySerialization) = false, want true") + if !got.Equal(tc.wantKeySerialization) { + t.Errorf("got.Equal(tc.wantKeySerialization) = false, want true") } }) } diff --git a/aead/chacha20poly1305/chacha20poly1305_test.go b/aead/chacha20poly1305/chacha20poly1305_test.go index 0255807..eae040b 100644 --- a/aead/chacha20poly1305/chacha20poly1305_test.go +++ b/aead/chacha20poly1305/chacha20poly1305_test.go @@ -40,8 +40,8 @@ func TestGetKeyFromHandle(t *testing.T) { if err != nil { t.Fatalf("chacha20poly1305.NewParameters(%v) err = %v, want nil", chacha20poly1305.VariantTink, err) } - if !key.Parameters().Equals(expectedParameters) { - t.Errorf("key.Parameters().Equals(expectedParameters) = false, want true") + if !key.Parameters().Equal(expectedParameters) { + t.Errorf("key.Parameters().Equal(expectedParameters) = false, want true") } if _, hasIDRequirement := key.IDRequirement(); !hasIDRequirement { t.Errorf("expected ID requirement, got none") diff --git a/aead/chacha20poly1305/key.go b/aead/chacha20poly1305/key.go index 2c21de5..e6eebef 100644 --- a/aead/chacha20poly1305/key.go +++ b/aead/chacha20poly1305/key.go @@ -95,8 +95,8 @@ func NewParameters(variant Variant) (*Parameters, error) { // HasIDRequirement returns whether the key has an ID requirement. func (p *Parameters) HasIDRequirement() bool { return p.variant != VariantNoPrefix } -// Equals returns whether this Parameters object is equal to other. -func (p *Parameters) Equals(other key.Parameters) bool { +// Equal returns whether this Parameters object is equal to other. +func (p *Parameters) Equal(other key.Parameters) bool { actualParams, ok := other.(*Parameters) return ok && p.variant == actualParams.variant } @@ -154,10 +154,10 @@ func (k *Key) IDRequirement() (uint32, bool) { // OutputPrefix returns the output prefix. func (k *Key) OutputPrefix() []byte { return bytes.Clone(k.outputPrefix) } -// Equals returns whether this key object is equal to other. -func (k *Key) Equals(other key.Key) bool { +// Equal returns whether this key object is equal to other. +func (k *Key) Equal(other key.Key) bool { that, ok := other.(*Key) - return ok && k.Parameters().Equals(that.Parameters()) && + return ok && k.Parameters().Equal(that.Parameters()) && k.idRequirement == that.idRequirement && - k.keyBytes.Equals(that.keyBytes) + k.keyBytes.Equal(that.keyBytes) } diff --git a/aead/chacha20poly1305/key_test.go b/aead/chacha20poly1305/key_test.go index eba908c..a9dd344 100644 --- a/aead/chacha20poly1305/key_test.go +++ b/aead/chacha20poly1305/key_test.go @@ -119,14 +119,14 @@ func TestNewParametersWorks(t *testing.T) { if err != nil { t.Fatalf("chacha20poly1305.NewParameters(%v) err = %v, want nil", test.variant, err) } - if !params.Equals(otherParams) { - t.Errorf("params.Equals(otherParams) = %v, want true", params.Equals(otherParams)) + if !params.Equal(otherParams) { + t.Errorf("params.Equal(otherParams) = %v, want true", params.Equal(otherParams)) } }) } } -func TestParametersEqualsFalseIfDifferentVariant(t *testing.T) { +func TestParametersEqualFalseIfDifferentVariant(t *testing.T) { for _, test := range []struct { name string key1Variant chacha20poly1305.Variant @@ -157,8 +157,8 @@ func TestParametersEqualsFalseIfDifferentVariant(t *testing.T) { if err != nil { t.Fatalf("chacha20poly1305.NewParameters(%v) err = %v, want nil", test.key2Variant, err) } - if params1.Equals(params2) { - t.Errorf("params.Equals(params2) = %v, want false", params1.Equals(params2)) + if params1.Equal(params2) { + t.Errorf("params.Equal(params2) = %v, want false", params1.Equal(params2)) } }) } @@ -202,12 +202,12 @@ func TestNewKeyWorks(t *testing.T) { if err != nil { t.Fatalf("chacha20poly1305.NewKey(keyBytes, %v, %v) err = %v, want nil", tc.id, params, err) } - if !firstKey.Parameters().Equals(params) { + if !firstKey.Parameters().Equal(params) { t.Errorf("firstKey.Parameters() = %v, want %v", firstKey.Parameters(), params) } firstKeyBytes := firstKey.KeyBytes() - if !keyBytes.Equals(firstKeyBytes) { - t.Errorf("keyBytes.Equals(firstKeyBytes) = false, want true") + if !keyBytes.Equal(firstKeyBytes) { + t.Errorf("keyBytes.Equal(firstKeyBytes) = false, want true") } id, required := firstKey.IDRequirement() if required != (tc.variant != chacha20poly1305.VariantNoPrefix) { @@ -216,13 +216,13 @@ func TestNewKeyWorks(t *testing.T) { if id != tc.id { t.Errorf("id = %v, want %v", id, tc.id) } - // Test Equals. + // Test Equal. secondKey, err := chacha20poly1305.NewKey(keyBytes, tc.id, params) if err != nil { t.Fatalf("chacha20poly1305.NewKey(keyBytes, %v, %v) err = %v, want nil", tc.id, params, err) } - if !firstKey.Equals(secondKey) { - t.Errorf("firstKey.Equals(secondKey) = %v, want true", firstKey.Equals(secondKey)) + if !firstKey.Equal(secondKey) { + t.Errorf("firstKey.Equal(secondKey) = %v, want true", firstKey.Equal(secondKey)) } }) } @@ -239,7 +239,7 @@ func TestNewKeyFailsIfNoPrefixAndIDIsNotZero(t *testing.T) { } } -func TestKeyEqualsReturnsFalseIfDifferent(t *testing.T) { +func TestKeyEqualReturnsFalseIfDifferent(t *testing.T) { for _, tc := range []struct { name string first TestKey @@ -309,8 +309,8 @@ func TestKeyEqualsReturnsFalseIfDifferent(t *testing.T) { if err != nil { t.Fatalf("chacha20poly1305.NewKey(secondKeyBytes, %v, %v) err = %v, want nil", tc.second.id, secondParams, err) } - if firstKey.Equals(secondKey) { - t.Errorf("firstKey.Equals(secondKey) = true, want false") + if firstKey.Equal(secondKey) { + t.Errorf("firstKey.Equal(secondKey) = true, want false") } }) } diff --git a/aead/chacha20poly1305/protoserialization_test.go b/aead/chacha20poly1305/protoserialization_test.go index 86043d1..6304f57 100644 --- a/aead/chacha20poly1305/protoserialization_test.go +++ b/aead/chacha20poly1305/protoserialization_test.go @@ -210,8 +210,8 @@ func TestParseKey(t *testing.T) { if err != nil { t.Errorf("protoserialization.ParseKey(%v) err = %v, want nil", tc.keySerialization, err) } - if !gotKey.Equals(wantKey) { - t.Errorf("key.Equals(wantKey) = false, want true") + if !gotKey.Equal(wantKey) { + t.Errorf("key.Equal(wantKey) = false, want true") } }) } @@ -223,7 +223,7 @@ type testParams struct { func (p *testParams) HasIDRequirement() bool { return p.hasIDRequirement } -func (p *testParams) Equals(params key.Parameters) bool { +func (p *testParams) Equal(params key.Parameters) bool { _, ok := params.(*testParams) return ok && p.hasIDRequirement == params.HasIDRequirement() } @@ -236,12 +236,12 @@ type testKey struct { func (k *testKey) Parameters() key.Parameters { return &k.params } -func (k *testKey) Equals(other key.Key) bool { +func (k *testKey) Equal(other key.Key) bool { fallbackProtoKey, ok := other.(*testKey) if !ok { return false } - return k.params.Equals(fallbackProtoKey.Parameters()) + return k.params.Equal(fallbackProtoKey.Parameters()) } func (k *testKey) IDRequirement() (uint32, bool) { return k.id, k.params.HasIDRequirement() } @@ -333,8 +333,8 @@ func TestSerializeKey(t *testing.T) { if err != nil { t.Errorf("protoserialization.SerializeKey(&testKey{}) err = %v, want nil", err) } - if !got.Equals(tc.wantKeySerialization) { - t.Errorf("got.Equals(tc.wantKeySerialization) = false, want true") + if !got.Equal(tc.wantKeySerialization) { + t.Errorf("got.Equal(tc.wantKeySerialization) = false, want true") } }) } diff --git a/aead/xchacha20poly1305/key.go b/aead/xchacha20poly1305/key.go index 23c57d4..7e29590 100644 --- a/aead/xchacha20poly1305/key.go +++ b/aead/xchacha20poly1305/key.go @@ -94,8 +94,8 @@ func NewParameters(variant Variant) (*Parameters, error) { // HasIDRequirement returns whether the key has an ID requirement. func (p *Parameters) HasIDRequirement() bool { return p.variant != VariantNoPrefix } -// Equals returns whether this Parameters object is equal to other. -func (p *Parameters) Equals(other key.Parameters) bool { +// Equal returns whether this Parameters object is equal to other. +func (p *Parameters) Equal(other key.Parameters) bool { actualParams, ok := other.(*Parameters) return ok && p.variant == actualParams.variant } @@ -154,10 +154,10 @@ func (k *Key) IDRequirement() (uint32, bool) { // OutputPrefix returns the output prefix. func (k *Key) OutputPrefix() []byte { return bytes.Clone(k.outputPrefix) } -// Equals returns whether this key object is equal to other. -func (k *Key) Equals(other key.Key) bool { +// Equal returns whether this key object is equal to other. +func (k *Key) Equal(other key.Key) bool { that, ok := other.(*Key) - return ok && k.Parameters().Equals(that.Parameters()) && + return ok && k.Parameters().Equal(that.Parameters()) && k.idRequirement == that.idRequirement && - k.keyBytes.Equals(that.keyBytes) + k.keyBytes.Equal(that.keyBytes) } diff --git a/aead/xchacha20poly1305/key_test.go b/aead/xchacha20poly1305/key_test.go index ba1b5e2..6b4f026 100644 --- a/aead/xchacha20poly1305/key_test.go +++ b/aead/xchacha20poly1305/key_test.go @@ -39,7 +39,6 @@ func TestNewParametersInvalidVariant(t *testing.T) { } } - func TestOutputPrefix(t *testing.T) { for _, test := range []struct { name string @@ -120,14 +119,14 @@ func TestNewParametersWorks(t *testing.T) { if err != nil { t.Fatalf("xchacha20poly1305.NewParameters(%v) err = %v, want nil", test.variant, err) } - if !params.Equals(otherParams) { - t.Errorf("params.Equals(otherParams) = %v, want true", params.Equals(otherParams)) + if !params.Equal(otherParams) { + t.Errorf("params.Equal(otherParams) = %v, want true", params.Equal(otherParams)) } }) } } -func TestParametersEqualsFalseIfDifferentVariant(t *testing.T) { +func TestParametersEqualFalseIfDifferentVariant(t *testing.T) { for _, test := range []struct { name string key1Variant xchacha20poly1305.Variant @@ -158,8 +157,8 @@ func TestParametersEqualsFalseIfDifferentVariant(t *testing.T) { if err != nil { t.Fatalf("xchacha20poly1305.NewParameters(%v) err = %v, want nil", test.key2Variant, err) } - if params1.Equals(params2) { - t.Errorf("params.Equals(params2) = %v, want false", params1.Equals(params2)) + if params1.Equal(params2) { + t.Errorf("params.Equal(params2) = %v, want false", params1.Equal(params2)) } }) } @@ -203,12 +202,12 @@ func TestNewKeyWorks(t *testing.T) { if err != nil { t.Fatalf("xchacha20poly1305.NewKey(keyBytes, %v, %v) err = %v, want nil", tc.id, params, err) } - if !firstKey.Parameters().Equals(params) { + if !firstKey.Parameters().Equal(params) { t.Errorf("firstKey.Parameters() = %v, want %v", firstKey.Parameters(), params) } firstKeyBytes := firstKey.KeyBytes() - if !keyBytes.Equals(firstKeyBytes) { - t.Errorf("keyBytes.Equals(firstKeyBytes) = false, want true") + if !keyBytes.Equal(firstKeyBytes) { + t.Errorf("keyBytes.Equal(firstKeyBytes) = false, want true") } id, required := firstKey.IDRequirement() if required != (tc.variant != xchacha20poly1305.VariantNoPrefix) { @@ -217,13 +216,13 @@ func TestNewKeyWorks(t *testing.T) { if id != tc.id { t.Errorf("id = %v, want %v", id, tc.id) } - // Test Equals. + // Test Equal. secondKey, err := xchacha20poly1305.NewKey(keyBytes, tc.id, params) if err != nil { t.Fatalf("xchacha20poly1305.NewKey(keyBytes, %v, %v) err = %v, want nil", tc.id, params, err) } - if !firstKey.Equals(secondKey) { - t.Errorf("firstKey.Equals(secondKey) = %v, want true", firstKey.Equals(secondKey)) + if !firstKey.Equal(secondKey) { + t.Errorf("firstKey.Equal(secondKey) = %v, want true", firstKey.Equal(secondKey)) } }) } @@ -240,7 +239,7 @@ func TestNewKeyFailsIfNoPrefixAndIDIsNotZero(t *testing.T) { } } -func TestKeyEqualsReturnsFalseIfDifferent(t *testing.T) { +func TestKeyEqualReturnsFalseIfDifferent(t *testing.T) { for _, tc := range []struct { name string first TestKey @@ -310,8 +309,8 @@ func TestKeyEqualsReturnsFalseIfDifferent(t *testing.T) { if err != nil { t.Fatalf("xchacha20poly1305.NewKey(secondKeyBytes, %v, %v) err = %v, want nil", tc.second.id, secondParams, err) } - if firstKey.Equals(secondKey) { - t.Errorf("firstKey.Equals(secondKey) = true, want false") + if firstKey.Equal(secondKey) { + t.Errorf("firstKey.Equal(secondKey) = true, want false") } }) } diff --git a/aead/xchacha20poly1305/protoserialization_test.go b/aead/xchacha20poly1305/protoserialization_test.go index d5f825c..d769a5e 100644 --- a/aead/xchacha20poly1305/protoserialization_test.go +++ b/aead/xchacha20poly1305/protoserialization_test.go @@ -210,8 +210,8 @@ func TestParseKey(t *testing.T) { if err != nil { t.Fatalf("protoserialization.ParseKey(%v) err = %v, want nil", tc.keySerialization, err) } - if !gotKey.Equals(wantKey) { - t.Errorf("key.Equals(wantKey) = false, want true") + if !gotKey.Equal(wantKey) { + t.Errorf("key.Equal(wantKey) = false, want true") } }) } @@ -223,7 +223,7 @@ type testParams struct { func (p *testParams) HasIDRequirement() bool { return p.hasIDRequirement } -func (p *testParams) Equals(params key.Parameters) bool { +func (p *testParams) Equal(params key.Parameters) bool { _, ok := params.(*testParams) return ok && p.hasIDRequirement == params.HasIDRequirement() } @@ -236,12 +236,12 @@ type testKey struct { func (k *testKey) Parameters() key.Parameters { return &k.params } -func (k *testKey) Equals(other key.Key) bool { +func (k *testKey) Equal(other key.Key) bool { fallbackProtoKey, ok := other.(*testKey) if !ok { return false } - return k.params.Equals(fallbackProtoKey.Parameters()) + return k.params.Equal(fallbackProtoKey.Parameters()) } func (k *testKey) IDRequirement() (uint32, bool) { return k.id, k.params.HasIDRequirement() } @@ -333,8 +333,8 @@ func TestSerializeKey(t *testing.T) { if err != nil { t.Errorf("protoserialization.SerializeKey(&testKey{}) err = %v, want nil", err) } - if !got.Equals(tc.wantKeySerialization) { - t.Errorf("got.Equals(tc.wantKeySerialization) = false, want true") + if !got.Equal(tc.wantKeySerialization) { + t.Errorf("got.Equal(tc.wantKeySerialization) = false, want true") } }) } diff --git a/aead/xchacha20poly1305/xchacha20poly1305_test.go b/aead/xchacha20poly1305/xchacha20poly1305_test.go index 49a9e61..d64e2ce 100644 --- a/aead/xchacha20poly1305/xchacha20poly1305_test.go +++ b/aead/xchacha20poly1305/xchacha20poly1305_test.go @@ -40,8 +40,8 @@ func TestGetKeyFromHandle(t *testing.T) { if err != nil { t.Fatalf("xchacha20poly1305.NewParameters(%v) err = %v, want nil", xchacha20poly1305.VariantTink, err) } - if !key.Parameters().Equals(expectedParameters) { - t.Errorf("key.Parameters().Equals(expectedParameters) = false, want true") + if !key.Parameters().Equal(expectedParameters) { + t.Errorf("key.Parameters().Equal(expectedParameters) = false, want true") } if _, hasIDRequirement := key.IDRequirement(); !hasIDRequirement { t.Errorf("expected ID requirement, got none") diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 4b79b17..31ae6a6 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -28,7 +28,7 @@ import ( type testParameters0 struct{} func (tp testParameters0) HasIDRequirement() bool { return false } -func (tp testParameters0) Equals(other key.Parameters) bool { +func (tp testParameters0) Equal(other key.Parameters) bool { return false } @@ -36,14 +36,14 @@ type testKey0 struct{} func (tk testKey0) Parameters() key.Parameters { return new(testParameters0) } func (tk testKey0) IDRequirement() (id uint32, required bool) { return 0, false } -func (tk testKey0) Equals(other key.Key) bool { return false } +func (tk testKey0) Equal(other key.Key) bool { return false } type testPrimitive0 struct{} type testParameters1 struct{} func (tp testParameters1) HasIDRequirement() bool { return false } -func (tp testParameters1) Equals(other key.Parameters) bool { +func (tp testParameters1) Equal(other key.Parameters) bool { return false } @@ -51,7 +51,7 @@ type testKey1 struct{} func (tk testKey1) Parameters() key.Parameters { return new(testParameters1) } func (tk testKey1) IDRequirement() (id uint32, required bool) { return 0, false } -func (tk testKey1) Equals(other key.Key) bool { return false } +func (tk testKey1) Equal(other key.Key) bool { return false } type testPrimitive1 struct{} @@ -59,7 +59,7 @@ type testKeyUnregistered struct{} func (tk testKeyUnregistered) Parameters() key.Parameters { return new(testParameters1) } func (tk testKeyUnregistered) IDRequirement() (id uint32, required bool) { return 0, false } -func (tk testKeyUnregistered) Equals(other key.Key) bool { return false } +func (tk testKeyUnregistered) Equal(other key.Key) bool { return false } func TestConfigPrimitiveFromKeyWorks(t *testing.T) { testConfig, err := config.New() diff --git a/internal/protoserialization/protoserialization.go b/internal/protoserialization/protoserialization.go index e3f1553..492bded 100644 --- a/internal/protoserialization/protoserialization.go +++ b/internal/protoserialization/protoserialization.go @@ -44,7 +44,7 @@ type fallbackProtoKeyParams struct { func (p *fallbackProtoKeyParams) HasIDRequirement() bool { return p.hasIDRequirement } -func (p *fallbackProtoKeyParams) Equals(parameters key.Parameters) bool { +func (p *fallbackProtoKeyParams) Equal(parameters key.Parameters) bool { _, ok := parameters.(*fallbackProtoKeyParams) return ok && p.hasIDRequirement == parameters.HasIDRequirement() } @@ -88,8 +88,8 @@ func (k *KeySerialization) IDRequirement() (uint32, bool) { return k.idRequirement, k.HasIDRequirement() } -// Equals reports whether k is equal to other. -func (k *KeySerialization) Equals(other *KeySerialization) bool { +// Equal reports whether k is equal to other. +func (k *KeySerialization) Equal(other *KeySerialization) bool { return proto.Equal(k.keyData, other.keyData) && k.outputPrefixType == other.outputPrefixType && k.idRequirement == other.idRequirement @@ -118,14 +118,14 @@ type FallbackProtoKey struct { // Parameters returns the parameters of this key. func (k *FallbackProtoKey) Parameters() key.Parameters { return k.parameters } -// Equals reports whether k is equal to other. -func (k *FallbackProtoKey) Equals(other key.Key) bool { +// Equal reports whether k is equal to other. +func (k *FallbackProtoKey) Equal(other key.Key) bool { otherFallbackProtoKey, ok := other.(*FallbackProtoKey) if !ok { return false } - return k.parameters.Equals(other.Parameters()) && - k.protoKeySerialization.Equals(otherFallbackProtoKey.protoKeySerialization) + return k.parameters.Equal(other.Parameters()) && + k.protoKeySerialization.Equal(otherFallbackProtoKey.protoKeySerialization) } // IDRequirement returns the key ID and whether it is required. diff --git a/internal/protoserialization/protoserialization_test.go b/internal/protoserialization/protoserialization_test.go index e64be7c..51da697 100644 --- a/internal/protoserialization/protoserialization_test.go +++ b/internal/protoserialization/protoserialization_test.go @@ -124,7 +124,7 @@ func TestNewKeySerialization(t *testing.T) { } } -func TestKeySerializationEquals(t *testing.T) { +func TestKeySerializationEqual(t *testing.T) { for _, tc := range []struct { name string ks1 *protoserialization.KeySerialization @@ -217,14 +217,14 @@ func TestKeySerializationEquals(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - if got := tc.ks1.Equals(tc.ks2); got != tc.want { - t.Errorf("ks1.Equals(ks2) = %v, want %v", got, tc.want) + if got := tc.ks1.Equal(tc.ks2); got != tc.want { + t.Errorf("ks1.Equal(ks2) = %v, want %v", got, tc.want) } }) } } -func TestFallbackKeyEquals(t *testing.T) { +func TestFallbackKeyEqual(t *testing.T) { keyData1 := &tinkpb.KeyData{ TypeUrl: testKeyURL, Value: []byte("123"), @@ -268,14 +268,14 @@ func TestFallbackKeyEquals(t *testing.T) { } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - if got := tc.key1.Equals(tc.key2); got != tc.want { - t.Errorf("key1.Equals(key2) = %v, want %v", got, tc.want) + if got := tc.key1.Equal(tc.key2); got != tc.want { + t.Errorf("key1.Equal(key2) = %v, want %v", got, tc.want) } }) } } -func TestFallbackKeyParametersEquals(t *testing.T) { +func TestFallbackKeyParametersEqual(t *testing.T) { keyData := &tinkpb.KeyData{ TypeUrl: testKeyURL, Value: []byte("123"), @@ -305,14 +305,14 @@ func TestFallbackKeyParametersEquals(t *testing.T) { if otherParameters == nil { t.Errorf("protoserialization.NewFallbackProtoKey(protoKey).Parameters() = nil, want not nil") } - if !params.Equals(otherParameters) { - t.Errorf("parameters.Equals(otherParameters) = false, want true") + if !params.Equal(otherParameters) { + t.Errorf("parameters.Equal(otherParameters) = false, want true") } }) } } -func TestFallbackKeyParametersNotEquals(t *testing.T) { +func TestFallbackKeyParametersNotEqual(t *testing.T) { keyData := &tinkpb.KeyData{ TypeUrl: testKeyURL, Value: []byte("123"), @@ -320,8 +320,8 @@ func TestFallbackKeyParametersNotEquals(t *testing.T) { } key1 := protoserialization.NewFallbackProtoKey(newKeySerialization(t, keyData, tinkpb.OutputPrefixType_RAW, 0)) key2 := protoserialization.NewFallbackProtoKey(newKeySerialization(t, keyData, tinkpb.OutputPrefixType_TINK, 123)) - if key1.Parameters().Equals(key2.Parameters()) { - t.Errorf("parameters.Equals(otherParameters) = true, want false") + if key1.Parameters().Equal(key2.Parameters()) { + t.Errorf("parameters.Equal(otherParameters) = true, want false") } } @@ -366,7 +366,7 @@ type testParams struct { func (p *testParams) HasIDRequirement() bool { return p.hasIDRequirement } -func (p *testParams) Equals(params key.Parameters) bool { +func (p *testParams) Equal(params key.Parameters) bool { _, ok := params.(*testParams) return ok && p.hasIDRequirement == params.HasIDRequirement() } @@ -379,12 +379,12 @@ type testKey struct { func (k *testKey) Parameters() key.Parameters { return &k.params } -func (k *testKey) Equals(other key.Key) bool { +func (k *testKey) Equal(other key.Key) bool { fallbackProtoKey, ok := other.(*testKey) if !ok { return false } - return k.params.Equals(fallbackProtoKey.Parameters()) + return k.params.Equal(fallbackProtoKey.Parameters()) } func (k *testKey) IDRequirement() (uint32, bool) { return k.id, k.params.HasIDRequirement() } @@ -601,12 +601,12 @@ func TestSerializeKeyWithFallbackKey(t *testing.T) { if err != nil { t.Fatalf("protoserialization.SerializeKey(key) err = %v, want nil", err) } - if !gotKeySerialization.Equals(keySerialization) { - t.Errorf("gotKeySerialization.Equals(keySerialization) = false, want true") + if !gotKeySerialization.Equal(keySerialization) { + t.Errorf("gotKeySerialization.Equal(keySerialization) = false, want true") } gotKeySerialization.KeyData().Value = []byte("456") - if gotKeySerialization.Equals(keySerialization) { - t.Errorf("gotKeySerialization.Equals(keySerialization) = true, want false") + if gotKeySerialization.Equal(keySerialization) { + t.Errorf("gotKeySerialization.Equal(keySerialization) = true, want false") } } @@ -625,8 +625,8 @@ func TestSerializeKeyWithFallbackPrivateKey(t *testing.T) { if err != nil { t.Fatalf("protoserialization.SerializeKey(key) err = %v, want nil", err) } - if !gotProtoSerialization.Equals(keySerialization) { - t.Errorf("gotProtoSerialization.Equals(keySerialization) = false, want true") + if !gotProtoSerialization.Equal(keySerialization) { + t.Errorf("gotProtoSerialization.Equal(keySerialization) = false, want true") } } diff --git a/internal/registryconfig/registry_config_test.go b/internal/registryconfig/registry_config_test.go index ac74366..745fc90 100644 --- a/internal/registryconfig/registry_config_test.go +++ b/internal/registryconfig/registry_config_test.go @@ -166,7 +166,7 @@ func TestRegisterKeyManager(t *testing.T) { type stubKey struct{} func (k *stubKey) Parameters() key.Parameters { return nil } -func (k *stubKey) Equals(other key.Key) bool { return true } +func (k *stubKey) Equal(other key.Key) bool { return true } func (k *stubKey) IDRequirement() (uint32, bool) { return 123, true } // stubPrimitiveConstructor creates a stubPrimitive from a stubKey. diff --git a/key/key.go b/key/key.go index b837ddd..ddbad16 100644 --- a/key/key.go +++ b/key/key.go @@ -25,8 +25,8 @@ type Parameters interface { // key id to the ciphertext). In this case, such a key should require a unique // id in key.IDRequirement() and return true. HasIDRequirement() bool - // Equals compares this parameters object with other. - Equals(other Parameters) bool + // Equal compares this parameters object with other. + Equal(other Parameters) bool } // Key represents a Tink key. @@ -48,6 +48,6 @@ type Key interface { // Parameters.HasIDRequirement(). If not required, the returned ID // is zero and unusable. IDRequirement() (idRequirement uint32, required bool) - // Equals compares this key object with other. - Equals(other Key) bool + // Equal compares this key object with other. + Equal(other Key) bool } diff --git a/keyset/handle_test.go b/keyset/handle_test.go index 3b64cd9..0d97dd6 100644 --- a/keyset/handle_test.go +++ b/keyset/handle_test.go @@ -1121,7 +1121,7 @@ func TestPrimaryReturnsPrimaryKey(t *testing.T) { if err != nil { t.Fatalf("protoserialization.NewKeySerialization(%v) err = %v, want nil", primaryKey, err) } - if !primaryKeySerialization.Equals(wantKeySerialization) { + if !primaryKeySerialization.Equal(wantKeySerialization) { t.Errorf("primaryKeySerialization = %v, want %v", primaryKeySerialization, wantKeySerialization) } // Check that is the same as Entry(1). @@ -1134,7 +1134,7 @@ func TestPrimaryReturnsPrimaryKey(t *testing.T) { t.Fatalf("type mismatch: got %T, want *protoserialization.FallbackProtoKey", entry.Key()) } entryKeySerialization := protoserialization.GetKeySerialization(entryProtoKey) - if !entryKeySerialization.Equals(wantKeySerialization) { + if !entryKeySerialization.Equal(wantKeySerialization) { t.Errorf("entryKeySerialization = %v, want %v", entryKeySerialization, wantKeySerialization) } } diff --git a/keyset/manager_test.go b/keyset/manager_test.go index b93394a..d2c73e4 100644 --- a/keyset/manager_test.go +++ b/keyset/manager_test.go @@ -667,7 +667,7 @@ type testParameters struct { } func (p *testParameters) HasIDRequirement() bool { return p.hasIDRequirement } -func (p *testParameters) Equals(params key.Parameters) bool { +func (p *testParameters) Equal(params key.Parameters) bool { _, ok := params.(*testParameters) return ok && p.hasIDRequirement == params.HasIDRequirement() } @@ -683,12 +683,12 @@ func (k *testKey) IDRequirement() (id uint32, required bool) { return k.id, k.Parameters().HasIDRequirement() } func (k *testKey) Parameters() key.Parameters { return &k.params } -func (k *testKey) Equals(other key.Key) bool { +func (k *testKey) Equal(other key.Key) bool { thisKeyID, Required := k.IDRequirement() otherkeyID, otherKeyRequired := other.IDRequirement() return thisKeyID == otherkeyID && Required == otherKeyRequired && - k.Parameters().Equals(other.Parameters()) + k.Parameters().Equal(other.Parameters()) } var _ key.Key = (*testKey)(nil) @@ -872,7 +872,7 @@ type testParams struct { } func (p *testParams) HasIDRequirement() bool { return p.hasIDRequirement } -func (p *testParams) Equals(params key.Parameters) bool { +func (p *testParams) Equal(params key.Parameters) bool { _, ok := params.(*testParams) return ok && p.hasIDRequirement == params.HasIDRequirement() } diff --git a/secretdata/secretdata.go b/secretdata/secretdata.go index e1d79d7..fec896e 100644 --- a/secretdata/secretdata.go +++ b/secretdata/secretdata.go @@ -66,11 +66,11 @@ func (b Bytes) Data(token insecuresecretdataaccess.Token) []byte { return bytes. // Len returns the size of the wrapped bytes. func (b Bytes) Len() int { return len(b.data) } -// Equals returns true if the two Bytes objects are equal. +// Equal returns true if the two Bytes objects are equal. // // The comparison is done in constant time. The time taken is a function of the // length of the wrapped bytes and is independent of the contents. If the two // wrapped slices are of different lengths, the function returns immediately. -func (b Bytes) Equals(other Bytes) bool { +func (b Bytes) Equal(other Bytes) bool { return subtle.ConstantTimeCompare(b.data, other.data) == 1 } diff --git a/secretdata/secretdata_test.go b/secretdata/secretdata_test.go index 1c32dcf..1ac8e26 100644 --- a/secretdata/secretdata_test.go +++ b/secretdata/secretdata_test.go @@ -69,20 +69,20 @@ func TestBytesData(t *testing.T) { } } -func TestBytesEquals(t *testing.T) { +func TestBytesEqual(t *testing.T) { data := []byte("secret key material") keyMaterial := secretdata.NewBytesFromData(data, insecuresecretdataaccess.Token{}) otherBytes := secretdata.NewBytesFromData(data, insecuresecretdataaccess.Token{}) - if !keyMaterial.Equals(otherBytes) { - t.Errorf("keyMaterial.Equals(otherBytes) = false, want true") + if !keyMaterial.Equal(otherBytes) { + t.Errorf("keyMaterial.Equal(otherBytes) = false, want true") } differentBytes := secretdata.NewBytesFromData([]byte("different secret key material"), insecuresecretdataaccess.Token{}) - if differentBytes.Equals(keyMaterial) { - t.Errorf("differentBytes.Equals(keyMaterial) = true, want false") + if differentBytes.Equal(keyMaterial) { + t.Errorf("differentBytes.Equal(keyMaterial) = true, want false") } } -func TestBytesEqualsEmpty(t *testing.T) { +func TestBytesEqualEmpty(t *testing.T) { nilBytes := secretdata.NewBytesFromData(nil, insecuresecretdataaccess.Token{}) emptyBytes := secretdata.NewBytesFromData([]byte(""), insecuresecretdataaccess.Token{}) randomEmptyBytes, err := secretdata.NewBytesFromRand(0) @@ -148,8 +148,8 @@ func TestBytesEqualsEmpty(t *testing.T) { } for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - if !testCase.firstBytes.Equals(testCase.secondBytes) { - t.Errorf("firstBytes.Equals(secondBytes) = false, want true") + if !testCase.firstBytes.Equal(testCase.secondBytes) { + t.Errorf("firstBytes.Equal(secondBytes) = false, want true") } }) } diff --git a/signature/ecdsa/ecdsa_test.go b/signature/ecdsa/ecdsa_test.go index 4dffb58..29cf0f4 100644 --- a/signature/ecdsa/ecdsa_test.go +++ b/signature/ecdsa/ecdsa_test.go @@ -89,8 +89,8 @@ func TestCreateKeysetHandleFromParameters(t *testing.T) { if entry.KeyID() == anotherEntry.KeyID() { t.Fatalf("entry.KeyID() = %v, want different from anotherEntry.KeyID() = %v", entry.KeyID(), anotherEntry.KeyID()) } - if entry.Key().Equals(anotherEntry.Key()) { - t.Fatalf("entry.Key().Equals(anotherEntry.Key()) = true, want false") + if entry.Key().Equal(anotherEntry.Key()) { + t.Fatalf("entry.Key().Equal(anotherEntry.Key()) = true, want false") } publicEntry, err := publicHandle.Primary() if err != nil { @@ -103,8 +103,8 @@ func TestCreateKeysetHandleFromParameters(t *testing.T) { if publicEntry.KeyID() == anotherPublicEntry.KeyID() { t.Fatalf("publicEntry.KeyID() = %v, want different from anotherPublicEntry.KeyID() = %v", publicEntry.KeyID(), anotherPublicEntry.KeyID()) } - if publicEntry.Key().Equals(anotherPublicEntry.Key()) { - t.Fatalf("publicEntry.Key().Equals(anotherPublicEntry.Key()) = true, want false") + if publicEntry.Key().Equal(anotherPublicEntry.Key()) { + t.Fatalf("publicEntry.Key().Equal(anotherPublicEntry.Key()) = true, want false") } // Make sure that a different generated key cannot verify the signature. diff --git a/signature/ecdsa/key.go b/signature/ecdsa/key.go index 399ac32..9c6acd9 100644 --- a/signature/ecdsa/key.go +++ b/signature/ecdsa/key.go @@ -247,8 +247,8 @@ func NewParameters(curveType CurveType, hashType HashType, encoding SignatureEnc // HasIDRequirement tells whether the key has an ID requirement. func (p *Parameters) HasIDRequirement() bool { return p.variant != VariantNoPrefix } -// Equals tells whether this parameters value is equal to other. -func (p *Parameters) Equals(other key.Parameters) bool { +// Equal tells whether this parameters value is equal to other. +func (p *Parameters) Equal(other key.Parameters) bool { actualParams, ok := other.(*Parameters) return ok && p.HasIDRequirement() == actualParams.HasIDRequirement() && p.curveType == actualParams.curveType && @@ -345,10 +345,10 @@ func (k *PublicKey) IDRequirement() (uint32, bool) { // OutputPrefix returns the output prefix of this key. func (k *PublicKey) OutputPrefix() []byte { return bytes.Clone(k.outputPrefix) } -// Equals tells whether this key value is equal to other. -func (k *PublicKey) Equals(other key.Key) bool { +// Equal tells whether this key value is equal to other. +func (k *PublicKey) Equal(other key.Key) bool { actualKey, ok := other.(*PublicKey) - return ok && k.Parameters().Equals(actualKey.Parameters()) && + return ok && k.Parameters().Equal(actualKey.Parameters()) && k.idRequirement == actualKey.idRequirement && bytes.Equal(k.publicPoint, actualKey.publicPoint) && bytes.Equal(k.outputPrefix, actualKey.outputPrefix) @@ -468,9 +468,9 @@ func (k *PrivateKey) IDRequirement() (uint32, bool) { return k.publicKey.IDRequi // OutputPrefix returns the output prefix of this key. func (k *PrivateKey) OutputPrefix() []byte { return k.publicKey.OutputPrefix() } -// Equals tells whether this key object is equal to other. -func (k *PrivateKey) Equals(other key.Key) bool { +// Equal tells whether this key object is equal to other. +func (k *PrivateKey) Equal(other key.Key) bool { actualKey, ok := other.(*PrivateKey) - return ok && k.publicKey.Equals(actualKey.publicKey) && - k.privateKeyValue.Equals(actualKey.privateKeyValue) + return ok && k.publicKey.Equal(actualKey.publicKey) && + k.privateKeyValue.Equal(actualKey.privateKeyValue) } diff --git a/signature/ecdsa/key_test.go b/signature/ecdsa/key_test.go index cef68af..b577ef1 100644 --- a/signature/ecdsa/key_test.go +++ b/signature/ecdsa/key_test.go @@ -256,8 +256,8 @@ func TestNewParameters(t *testing.T) { if err != nil { t.Fatalf("ecdsa.NewParameters(%v, %v, %v, %v) = %v, want nil", tc.curveType, tc.hashType, tc.encoding, ecdsa.VariantTink, err) } - if !params.Equals(other) { - t.Errorf("params.Equals(other) = false, want true") + if !params.Equal(other) { + t.Errorf("params.Equal(other) = false, want true") } }) } @@ -553,7 +553,7 @@ func TestNewPublicKey(t *testing.T) { if got, want := pubKey.PublicPoint(), point; !bytes.Equal(got, want) { t.Errorf("pubKey.PublicKey() = %v, want %v", got, want) } - if got, want := pubKey.Parameters(), params; !got.Equals(want) { + if got, want := pubKey.Parameters(), params; !got.Equal(want) { t.Errorf("pubKey.Parameters() = %v, want %v", got, want) } gotIDRequirement, gotRequired := pubKey.IDRequirement() @@ -565,8 +565,8 @@ func TestNewPublicKey(t *testing.T) { if err != nil { t.Fatalf("ecdsa.NewPublicKey(%v, %v, %v) err = %v, want nil", point, tc.id, params, err) } - if !pubKey.Equals(otherKey) { - t.Errorf("pubKey.Equals(otherKey) = false, want true") + if !pubKey.Equal(otherKey) { + t.Errorf("pubKey.Equal(otherKey) = false, want true") } }) } @@ -701,7 +701,7 @@ func TestNewPrivateKey(t *testing.T) { } // Check accessor methods. - if got, want := prvKey.PrivateKeyValue(), privateKeyValue; !got.Equals(want) { + if got, want := prvKey.PrivateKeyValue(), privateKeyValue; !got.Equal(want) { t.Errorf("prvKey.PrivateKeyValue() = %x, want %x", got.Data(token), want.Data(token)) } gotIDRequirement, gotRequired := prvKey.IDRequirement() @@ -712,14 +712,14 @@ func TestNewPrivateKey(t *testing.T) { if got, want := prvKey.OutputPrefix(), publicKey.OutputPrefix(); !bytes.Equal(got, want) { t.Errorf("prvKey.OutputPrefix() = %v, want %v", got, want) } - if got, want := prvKey.Parameters(), params; !got.Equals(want) { + if got, want := prvKey.Parameters(), params; !got.Equal(want) { t.Errorf("prvKey.Parameters() = %v, want %v", got, want) } want, err := prvKey.PublicKey() if err != nil { t.Fatalf("prvKey.PublicKey() err = %v, want nil", err) } - if got := publicKey; !got.Equals(want) { + if got := publicKey; !got.Equal(want) { t.Errorf("prvKey.PublicKey() = %v, want %v", got, want) } @@ -727,8 +727,8 @@ func TestNewPrivateKey(t *testing.T) { if err != nil { t.Fatalf("ecdsa.NewPrivateKey(privateKeyValue, %v, %v) err = %v, want nil", tc.id, params, err) } - if !otherPrvKey.Equals(prvKey) { - t.Errorf("otherPrvKey.Equals(prvKey) = false, want true") + if !otherPrvKey.Equal(prvKey) { + t.Errorf("otherPrvKey.Equal(prvKey) = false, want true") } }) } @@ -802,7 +802,7 @@ func TestNewPrivateKeyFromPublicKey(t *testing.T) { } // Check accessor methods. - if got, want := prvKey.PrivateKeyValue(), privateKeyValue; !got.Equals(want) { + if got, want := prvKey.PrivateKeyValue(), privateKeyValue; !got.Equal(want) { t.Errorf("prvKey.PrivateKeyValue() = %x, want %x", got.Data(token), want.Data(token)) } gotIDRequirement, gotRequired := prvKey.IDRequirement() @@ -813,14 +813,14 @@ func TestNewPrivateKeyFromPublicKey(t *testing.T) { if got, want := prvKey.OutputPrefix(), publicKey.OutputPrefix(); !bytes.Equal(got, want) { t.Errorf("prvKey.OutputPrefix() = %v, want %v", got, want) } - if got, want := prvKey.Parameters(), params; !got.Equals(want) { + if got, want := prvKey.Parameters(), params; !got.Equal(want) { t.Errorf("prvKey.Parameters() = %v, want %v", got, want) } want, err := prvKey.PublicKey() if err != nil { t.Fatalf("prvKey.PublicKey() err = %v, want nil", err) } - if got := publicKey; !got.Equals(want) { + if got := publicKey; !got.Equal(want) { t.Errorf("prvKey.PublicKey() = %v, want %v", got, want) } @@ -828,8 +828,8 @@ func TestNewPrivateKeyFromPublicKey(t *testing.T) { if err != nil { t.Fatalf("ecdsa.NewPrivateKeyFromPublicKey(%v, privateKeyValue) err = %v, want nil", publicKey, err) } - if !otherPrvKey.Equals(prvKey) { - t.Errorf("otherPrvKey.Equals(prvKey) = false, want true") + if !otherPrvKey.Equal(prvKey) { + t.Errorf("otherPrvKey.Equal(prvKey) = false, want true") } }) } diff --git a/signature/ecdsa/protoserialization_test.go b/signature/ecdsa/protoserialization_test.go index f87edf2..db0be7b 100644 --- a/signature/ecdsa/protoserialization_test.go +++ b/signature/ecdsa/protoserialization_test.go @@ -82,13 +82,13 @@ type testParams struct{} func (p *testParams) HasIDRequirement() bool { return true } -func (p *testParams) Equals(params key.Parameters) bool { return true } +func (p *testParams) Equal(params key.Parameters) bool { return true } type testKey struct{} func (k *testKey) Parameters() key.Parameters { return &testParams{} } -func (k *testKey) Equals(other key.Key) bool { return true } +func (k *testKey) Equal(other key.Key) bool { return true } func (k *testKey) IDRequirement() (uint32, bool) { return 123, true } @@ -134,7 +134,7 @@ func TestSerializePublicKey(t *testing.T) { if err != nil { t.Fatalf("s.SerializeKey(%v) err = nil, want non-nil", tc.publicKey) } - if !got.Equals(tc.publicKeySerialization) { + if !got.Equal(tc.publicKeySerialization) { t.Errorf("got = %v, want %v", got, tc.publicKeySerialization) } }) @@ -615,8 +615,8 @@ func TestParsePublicKey(t *testing.T) { if err != nil { t.Fatalf("p.ParseKey(%v) err = %v, want non-nil", tc.publicKeySerialization, err) } - if !gotPublicKey.Equals(tc.publicKey) { - t.Errorf("%v.Equals(%v) = false, want true", gotPublicKey, tc.publicKey) + if !gotPublicKey.Equal(tc.publicKey) { + t.Errorf("%v.Equal(%v) = false, want true", gotPublicKey, tc.publicKey) } }) } @@ -655,8 +655,8 @@ func TestParsePublicKey(t *testing.T) { if err != nil { t.Fatalf("p.ParseKey(%v) err = %v, want non-nil", publicKeySerialization, err) } - if !gotPublicKey.Equals(publicKey) { - t.Errorf("%v.Equals(%v) = false, want true", gotPublicKey, publicKey) + if !gotPublicKey.Equal(publicKey) { + t.Errorf("%v.Equal(%v) = false, want true", gotPublicKey, publicKey) } }) } @@ -812,8 +812,8 @@ func TestParsePrivateKey(t *testing.T) { if err != nil { t.Fatalf("p.ParseKey(%v) err = %v, want non-nil", tc.privateKeySerialization, err) } - if !gotPrivateKey.Equals(tc.privateKey) { - t.Errorf("%v.Equals(%v) = false, want true", gotPrivateKey, tc.privateKey) + if !gotPrivateKey.Equal(tc.privateKey) { + t.Errorf("%v.Equal(%v) = false, want true", gotPrivateKey, tc.privateKey) } }) } @@ -863,8 +863,8 @@ func TestParsePrivateKey(t *testing.T) { if err != nil { t.Fatalf("p.ParseKey(%v) err = %v, want non-nil", keySerialization, err) } - if !got.Equals(want) { - t.Errorf("%v.Equals(%v) = false, want true", got, want) + if !got.Equal(want) { + t.Errorf("%v.Equal(%v) = false, want true", got, want) } }) } @@ -885,7 +885,7 @@ func TestSerializePrivateKey(t *testing.T) { if err != nil { t.Fatalf("s.SerializeKey(%v) err = nil, want non-nil", tc.privateKey) } - if !got.Equals(tc.privateKeySerialization) { + if !got.Equal(tc.privateKeySerialization) { t.Errorf("got = %v, want %v", got, tc.privateKeySerialization) } }) diff --git a/signature/ed25519/ed25519_test.go b/signature/ed25519/ed25519_test.go index 5738e85..a9ecc98 100644 --- a/signature/ed25519/ed25519_test.go +++ b/signature/ed25519/ed25519_test.go @@ -90,8 +90,8 @@ func TestCreateKeysetHandleFromParameters(t *testing.T) { if entry.KeyID() == anotherEntry.KeyID() { t.Fatalf("entry.KeyID() = %v, want different from anotherEntry.KeyID() = %v", entry.KeyID(), anotherEntry.KeyID()) } - if entry.Key().Equals(anotherEntry.Key()) { - t.Fatalf("entry.Key().Equals(anotherEntry.Key()) = true, want false") + if entry.Key().Equal(anotherEntry.Key()) { + t.Fatalf("entry.Key().Equal(anotherEntry.Key()) = true, want false") } publicEntry, err := publicHandle.Primary() if err != nil { @@ -104,8 +104,8 @@ func TestCreateKeysetHandleFromParameters(t *testing.T) { if publicEntry.KeyID() == anotherPublicEntry.KeyID() { t.Fatalf("publicEntry.KeyID() = %v, want different from anotherPublicEntry.KeyID() = %v", publicEntry.KeyID(), anotherPublicEntry.KeyID()) } - if publicEntry.Key().Equals(anotherPublicEntry.Key()) { - t.Fatalf("publicEntry.Key().Equals(anotherPublicEntry.Key()) = true, want false") + if publicEntry.Key().Equal(anotherPublicEntry.Key()) { + t.Fatalf("publicEntry.Key().Equal(anotherPublicEntry.Key()) = true, want false") } // Make sure that a different generated key cannot verify the signature. diff --git a/signature/ed25519/key.go b/signature/ed25519/key.go index 8c69c0c..1bc59bb 100644 --- a/signature/ed25519/key.go +++ b/signature/ed25519/key.go @@ -86,8 +86,8 @@ func (p *Parameters) Variant() Variant { return p.variant } // HasIDRequirement returns true if the key has an ID requirement. func (p *Parameters) HasIDRequirement() bool { return p.variant != VariantNoPrefix } -// Equals returns true if this parameters object is equal to other. -func (p *Parameters) Equals(other key.Parameters) bool { +// Equal returns true if this parameters object is equal to other. +func (p *Parameters) Equal(other key.Parameters) bool { if p == other { return true } @@ -156,13 +156,13 @@ func (k *PublicKey) IDRequirement() (uint32, bool) { return k.idRequirement, k.params.HasIDRequirement() } -// Equals returns true if this key is equal to other. -func (k *PublicKey) Equals(other key.Key) bool { +// Equal returns true if this key is equal to other. +func (k *PublicKey) Equal(other key.Key) bool { if k == other { return true } that, ok := other.(*PublicKey) - return ok && k.params.Equals(that.Parameters()) && + return ok && k.params.Equal(that.Parameters()) && bytes.Equal(k.keyBytes, that.keyBytes) && k.idRequirement == that.idRequirement } @@ -231,11 +231,11 @@ func (k *PrivateKey) IDRequirement() (uint32, bool) { return k.publicKey.IDRequi // OutputPrefix returns the output prefix of this key. func (k *PrivateKey) OutputPrefix() []byte { return bytes.Clone(k.publicKey.outputPrefix) } -// Equals returns true if this key is equal to other. -func (k *PrivateKey) Equals(other key.Key) bool { +// Equal returns true if this key is equal to other. +func (k *PrivateKey) Equal(other key.Key) bool { if k == other { return true } that, ok := other.(*PrivateKey) - return ok && k.publicKey.Equals(that.publicKey) && k.keyBytes.Equals(that.keyBytes) + return ok && k.publicKey.Equal(that.publicKey) && k.keyBytes.Equal(that.keyBytes) } diff --git a/signature/ed25519/key_test.go b/signature/ed25519/key_test.go index 4ffb874..4a10ab7 100644 --- a/signature/ed25519/key_test.go +++ b/signature/ed25519/key_test.go @@ -103,7 +103,7 @@ func TestParametersHasIDRequirement(t *testing.T) { } } -func TestParametersEquals(t *testing.T) { +func TestParametersEqual(t *testing.T) { tinkVariant, err := ed25519.NewParameters(ed25519.VariantTink) if err != nil { t.Fatalf("ed25519.NewParameters(%v) err = %v, want nil", ed25519.VariantTink, err) @@ -122,8 +122,8 @@ func TestParametersEquals(t *testing.T) { } for _, params := range []ed25519.Parameters{tinkVariant, legacyVariant, crunchyVariant, noPrefixVariant} { - if !params.Equals(¶ms) { - t.Errorf("params.Equals(params) = false, want true") + if !params.Equal(¶ms) { + t.Errorf("params.Equal(params) = false, want true") } } @@ -165,8 +165,8 @@ func TestParametersEquals(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - if tc.firstParams.Equals(&tc.secondParams) { - t.Errorf("tc.firstParams.Equals(&tc.secondParams) = true, want false") + if tc.firstParams.Equal(&tc.secondParams) { + t.Errorf("tc.firstParams.Equal(&tc.secondParams) = true, want false") } }) } @@ -283,8 +283,8 @@ func TestPublicKey(t *testing.T) { if err != nil { t.Fatalf("ed25519.NewPublicKey(%v, %v, %v) err = %v, want nil", tc.keyBytes, tc.idRequirement, params, err) } - if !otherPubKey.Equals(pubKey) { - t.Errorf("otherPubKey.Equals(pubKey) = false, want true") + if !otherPubKey.Equal(pubKey) { + t.Errorf("otherPubKey.Equal(pubKey) = false, want true") } }) } @@ -296,7 +296,7 @@ type TestPublicKeyParams struct { variant ed25519.Variant } -func TestPublicKeyEqualsSelf(t *testing.T) { +func TestPublicKeyEqualSelf(t *testing.T) { params, err := ed25519.NewParameters(ed25519.VariantTink) if err != nil { t.Fatalf("ed25519.NewParameters(%v) err = %v, want nil", ed25519.VariantTink, err) @@ -306,12 +306,12 @@ func TestPublicKeyEqualsSelf(t *testing.T) { if err != nil { t.Fatalf("ed25519.NewPublicKey(%v, %v, %v) err = %v, want nil", keyBytes, 123, params, err) } - if !pubKey.Equals(pubKey) { - t.Errorf("pubKey.Equals(pubKey) = false, want true") + if !pubKey.Equal(pubKey) { + t.Errorf("pubKey.Equal(pubKey) = false, want true") } } -func TestPublicKeyEqualsFalse(t *testing.T) { +func TestPublicKeyEqualFalse(t *testing.T) { for _, tc := range []struct { name string firstKey *TestPublicKeyParams @@ -374,8 +374,8 @@ func TestPublicKeyEqualsFalse(t *testing.T) { if err != nil { t.Fatalf("ed25519.NewPublicKey(%v, %v, %v) err = %v, want nil", tc.secondKey.keyBytes, tc.secondKey.idRequirement, secondParams, err) } - if firstPubKey.Equals(secondPubKey) { - t.Errorf("firstPubKey.Equals(secondPubKey) = true, want false") + if firstPubKey.Equal(secondPubKey) { + t.Errorf("firstPubKey.Equal(secondPubKey) = true, want false") } }) } @@ -487,7 +487,7 @@ func TestPrivateKeyNewPrivateKeyWithPublicKey(t *testing.T) { t.Errorf("params.OutputPrefix() = %v, want %v", got, tc.wantOutputPrefix) } - // Test Equals. + // Test Equal. otherPubKey, err := ed25519.NewPublicKey(pubKeyBytes, tc.idRequirement, params) if err != nil { t.Fatalf("ed25519.NewPublicKey(%v, %v, %v) err = %v, want nil", pubKeyBytes, tc.idRequirement, params, err) @@ -496,8 +496,8 @@ func TestPrivateKeyNewPrivateKeyWithPublicKey(t *testing.T) { if err != nil { t.Fatalf("ed25519.NewPrivateKeyWithPublicKey(%v, %v) err = %v, want nil", secretSeed, pubKey, err) } - if !otherPrivKey.Equals(privKey) { - t.Errorf("otherPrivKey.Equals(privKey) = false, want true") + if !otherPrivKey.Equal(privKey) { + t.Errorf("otherPrivKey.Equal(privKey) = false, want true") } // Test PublicKey. @@ -505,13 +505,13 @@ func TestPrivateKeyNewPrivateKeyWithPublicKey(t *testing.T) { if err != nil { t.Fatalf("privKey.PublicKey() err = %v, want nil", err) } - if !got.Equals(pubKey) { - t.Errorf("privKey.PublicKey().Equals(pubKey) = false, want true") + if !got.Equal(pubKey) { + t.Errorf("privKey.PublicKey().Equal(pubKey) = false, want true") } // Test Parameters. - if got := privKey.Parameters(); !got.Equals(¶ms) { - t.Errorf("privKey.Parameters().Equals(¶ms) = false, want true") + if got := privKey.Parameters(); !got.Equal(¶ms) { + t.Errorf("privKey.Parameters().Equal(¶ms) = false, want true") } }) } @@ -545,13 +545,13 @@ func TestPrivateKeyNewPrivateKey(t *testing.T) { t.Errorf("params.OutputPrefix() = %v, want %v", got, tc.wantOutputPrefix) } - // Test Equals. + // Test Equal. otherPrivKey, err := ed25519.NewPrivateKey(secretSeed, tc.idRequirement, params) if err != nil { t.Fatalf("ed25519.NewPrivateKey(%v, %v, %v) err = %v, want nil", secretSeed, tc.idRequirement, params, err) } - if !otherPrivKey.Equals(privKey) { - t.Errorf("otherPrivKey.Equals(privKey) = false, want true") + if !otherPrivKey.Equal(privKey) { + t.Errorf("otherPrivKey.Equal(privKey) = false, want true") } // Test PublicKey. @@ -563,13 +563,13 @@ func TestPrivateKeyNewPrivateKey(t *testing.T) { if err != nil { t.Fatalf("privKey.PublicKey() err = %v, want nil", err) } - if !got.Equals(want) { - t.Errorf("privKey.PublicKey().Equals(want) = false, want true") + if !got.Equal(want) { + t.Errorf("privKey.PublicKey().Equal(want) = false, want true") } // Test Parameters. - if got := privKey.Parameters(); !got.Equals(¶ms) { - t.Errorf("privKey.Parameters().Equals(¶ms) = false, want true") + if got := privKey.Parameters(); !got.Equal(¶ms) { + t.Errorf("privKey.Parameters().Equal(¶ms) = false, want true") } }) } @@ -685,7 +685,7 @@ func TestNewPrivateKeyWithPublicKeyFails(t *testing.T) { } } -func TestPrivateKeyEqualsSelf(t *testing.T) { +func TestPrivateKeyEqualSelf(t *testing.T) { params, err := ed25519.NewParameters(ed25519.VariantTink) if err != nil { t.Fatalf("ed25519.NewParameters(%v) err = %v, want nil", ed25519.VariantTink, err) @@ -700,12 +700,12 @@ func TestPrivateKeyEqualsSelf(t *testing.T) { if err != nil { t.Fatalf("ed25519.NewPrivateKeyWithPublicKey(%v, %v) err = %v", secretSeed, pubKey, err) } - if !privKey.Equals(privKey) { - t.Errorf("privKey.Equals(privKey) = false, want true") + if !privKey.Equal(privKey) { + t.Errorf("privKey.Equal(privKey) = false, want true") } } -func TestPrivateKeyEqualsFalse(t *testing.T) { +func TestPrivateKeyEqualFalse(t *testing.T) { paramsTink, err := ed25519.NewParameters(ed25519.VariantTink) if err != nil { t.Fatalf("ed25519.NewParameters(%v) err = %v, want nil", ed25519.VariantTink, err) @@ -760,8 +760,8 @@ func TestPrivateKeyEqualsFalse(t *testing.T) { if err != nil { t.Fatalf("ed25519.NewPrivateKey(%v, %v, %v) err = %v", tc.privKeyBytes2, tc.idRequirement2, tc.params2, err) } - if firstPrivKey.Equals(secondPrivKey) { - t.Errorf("firstPrivKey.Equals(secondPrivKey) = true, want false") + if firstPrivKey.Equal(secondPrivKey) { + t.Errorf("firstPrivKey.Equal(secondPrivKey) = true, want false") } }) } diff --git a/signature/ed25519/protoserialization_test.go b/signature/ed25519/protoserialization_test.go index cfac76e..ce91fc7 100644 --- a/signature/ed25519/protoserialization_test.go +++ b/signature/ed25519/protoserialization_test.go @@ -164,8 +164,8 @@ func TestParsePublicKey(t *testing.T) { if err != nil { t.Fatalf("NewPublicKey(%v, %v, %v) err = %v, want nil", protoPublicKey.GetKeyValue(), idRequirement, wantParams, err) } - if !gotKey.Equals(wantKey) { - t.Errorf("%v.Equals(%v) = false, want true", gotKey, wantKey) + if !gotKey.Equal(wantKey) { + t.Errorf("%v.Equal(%v) = false, want true", gotKey, wantKey) } // Test serialization returns back tc.keySerialization. s := publicKeySerializer{} @@ -173,7 +173,7 @@ func TestParsePublicKey(t *testing.T) { if err != nil { t.Fatalf("s.SerializeKey(gotKey) err = %v, want nil", err) } - if got, want := keySerialization, tc.keySerialization; !got.Equals(want) { + if got, want := keySerialization, tc.keySerialization; !got.Equal(want) { t.Errorf("s.SerializeKey(gotKey) = %v, want %v", got, want) } }) @@ -184,13 +184,13 @@ type testParams struct{} func (p *testParams) HasIDRequirement() bool { return true } -func (p *testParams) Equals(params key.Parameters) bool { return true } +func (p *testParams) Equal(params key.Parameters) bool { return true } type testKey struct{} func (k *testKey) Parameters() key.Parameters { return &testParams{} } -func (k *testKey) Equals(other key.Key) bool { return true } +func (k *testKey) Equal(other key.Key) bool { return true } func (k *testKey) IDRequirement() (uint32, bool) { return 123, true } @@ -291,7 +291,7 @@ func TestSerializePublicKey(t *testing.T) { if err != nil { t.Fatalf("s.SerializeKey(%v) err = nil, want non-nil", tc.publicKey) } - if !got.Equals(tc.want) { + if !got.Equal(tc.want) { t.Errorf("s.SerializeKey(%v) = %v, want %v", tc.publicKey, got, tc.want) } }) @@ -512,8 +512,8 @@ func TestParsePrivateKey(t *testing.T) { if err != nil { t.Fatalf("NewPrivateKey(%v, %v, %v) err = %v, want nil", privateKeyBytes, idRequirement, wantParams, err) } - if !gotKey.Equals(wantKey) { - t.Errorf("%v.Equals(%v) = false, want true", gotKey, wantKey) + if !gotKey.Equal(wantKey) { + t.Errorf("%v.Equal(%v) = false, want true", gotKey, wantKey) } // Test serialization returns back tc.keySerialization. s := privateKeySerializer{} @@ -521,7 +521,7 @@ func TestParsePrivateKey(t *testing.T) { if err != nil { t.Fatalf("s.SerializeKey(gotKey) err = %v, want nil", err) } - if got, want := keySerialization, tc.keySerialization; !got.Equals(want) { + if got, want := keySerialization, tc.keySerialization; !got.Equal(want) { t.Errorf("s.SerializeKey(gotKey) = %v, want %v", got, want) } }) @@ -632,7 +632,7 @@ func TestSerializePrivateKey(t *testing.T) { if err != nil { t.Fatalf("s.SerializeKey(%v) err = nil, want non-nil", tc.privateKey) } - if !got.Equals(tc.want) { + if !got.Equal(tc.want) { t.Errorf("s.SerializeKey(%v) = %v, want %v", tc.privateKey, got, tc.want) } }) diff --git a/signature/rsassapkcs1/key.go b/signature/rsassapkcs1/key.go index 14c9593..7b936fe 100644 --- a/signature/rsassapkcs1/key.go +++ b/signature/rsassapkcs1/key.go @@ -163,8 +163,8 @@ func NewParameters(modulusSizeBits int, hashType HashType, publicExponent int, v // HasIDRequirement tells whether the key has an ID requirement. func (p *Parameters) HasIDRequirement() bool { return p.variant != VariantNoPrefix } -// Equals tells whether this parameters object is equal to other. -func (p *Parameters) Equals(other key.Parameters) bool { +// Equal tells whether this parameters object is equal to other. +func (p *Parameters) Equal(other key.Parameters) bool { that, ok := other.(*Parameters) return ok && p.HasIDRequirement() == that.HasIDRequirement() && p.modulusSizeBits == that.modulusSizeBits && @@ -240,12 +240,12 @@ func (k *PublicKey) IDRequirement() (uint32, bool) { // OutputPrefix returns the output prefix of this key. func (k *PublicKey) OutputPrefix() []byte { return bytes.Clone(k.outputPrefix) } -// Equals tells whether this key object is equal to other. -func (k *PublicKey) Equals(other key.Key) bool { +// Equal tells whether this key object is equal to other. +func (k *PublicKey) Equal(other key.Key) bool { actualKey, ok := other.(*PublicKey) return ok && bytes.Equal(k.modulus, actualKey.modulus) && k.idRequirement == actualKey.idRequirement && - k.parameters.Equals(actualKey.parameters) + k.parameters.Equal(actualKey.parameters) } // PrivateKey represents a function that can produce RSA-SSA-PKCS1 v1.5 @@ -334,8 +334,8 @@ func (k *PrivateKey) IDRequirement() (uint32, bool) { return k.publicKey.IDRequi // OutputPrefix returns the output prefix of this key. func (k *PrivateKey) OutputPrefix() []byte { return k.publicKey.OutputPrefix() } -// Equals tells whether this key object is equal to other. -func (k *PrivateKey) Equals(other key.Key) bool { +// Equal tells whether this key object is equal to other. +func (k *PrivateKey) Equal(other key.Key) bool { that, ok := other.(*PrivateKey) - return ok && k.publicKey.Equals(that.publicKey) && k.privateKey.Equal(that.privateKey) + return ok && k.publicKey.Equal(that.publicKey) && k.privateKey.Equal(that.privateKey) } diff --git a/signature/rsassapkcs1/key_test.go b/signature/rsassapkcs1/key_test.go index 3669848..6b4a362 100644 --- a/signature/rsassapkcs1/key_test.go +++ b/signature/rsassapkcs1/key_test.go @@ -120,8 +120,8 @@ func TestNewParameters(t *testing.T) { if err != nil { t.Fatalf("rsassapkcs1.NewParameters(%v, %v, %v, %v) = %v, want nil", modulusSizeBits, hashType, publicExponent, variant, err) } - if !params.Equals(other) { - t.Errorf("params.Equals(other) = false, want true") + if !params.Equal(other) { + t.Errorf("params.Equal(other) = false, want true") } }) } @@ -213,8 +213,8 @@ func TestNewParametersDifferentParameters(t *testing.T) { if err != nil { t.Fatalf("rsassapkcs1.NewParameters(%v, %v, %v, %v) = %v, want nil", tc.that.modulusSizeBits, tc.that.hashType, tc.that.publicExponent, tc.that.variant, err) } - if this.Equals(that) { - t.Errorf("this.Equals(that) = true, want false") + if this.Equal(that) { + t.Errorf("this.Equal(that) = true, want false") } }) } @@ -397,7 +397,7 @@ func TestNewPublicKey(t *testing.T) { if err != nil { t.Fatalf("rsassapkcs1.NewPublicKey(%v, %d, %v) = %v, want nil", tc.modulus, tc.idRequirement, params, err) } - if got, want := key.Parameters(), params; !got.Equals(want) { + if got, want := key.Parameters(), params; !got.Equal(want) { t.Errorf("key.Parameters() = %v, want %v", got, want) } idRequirement, required := key.IDRequirement() @@ -417,8 +417,8 @@ func TestNewPublicKey(t *testing.T) { if err != nil { t.Fatalf("rsassapkcs1.NewPublicKey(%v, %d, %v) = %v, want nil", tc.modulus, tc.idRequirement, params, err) } - if !key.Equals(otherKey) { - t.Errorf("key.Equals(otherKey) = false, want true") + if !key.Equal(otherKey) { + t.Errorf("key.Equal(otherKey) = false, want true") } }) } @@ -494,7 +494,7 @@ func mustCreatePublicKey(t *testing.T, modulus []byte, idRequirement uint32, par return key } -func TestNewPublicKeyEqualsFailsIfDifferentKeys(t *testing.T) { +func TestNewPublicKeyEqualFailsIfDifferentKeys(t *testing.T) { validModulus2048 := mustDecodeBase64(t, n2048Base64) // From: // https://github.com/C2SP/wycheproof/blob/cd27d6419bedd83cbd24611ec54b6d4bfdb0cdca/testvectors/rsa_pkcs1_2048_test.json#L353 @@ -528,11 +528,11 @@ func TestNewPublicKeyEqualsFailsIfDifferentKeys(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - if tc.this.Equals(tc.that) { - t.Errorf("tc.this.Equals(tc.that) = true, want false") + if tc.this.Equal(tc.that) { + t.Errorf("tc.this.Equal(tc.that) = true, want false") } - if tc.that.Equals(tc.this) { - t.Errorf("tc.that.Equals(tc.this) = true, want false") + if tc.that.Equal(tc.this) { + t.Errorf("tc.that.Equal(tc.this) = true, want false") } }) } @@ -775,22 +775,22 @@ func TestNewPrivateKey(t *testing.T) { if err != nil { t.Errorf("rsassapkcs1.NewPrivateKey(tc.publicKey, %v) err = %v, want nil", tc.privateKeyValues, err) } - if !privateKey.D().Equals(tc.privateKeyValues.D) { + if !privateKey.D().Equal(tc.privateKeyValues.D) { t.Errorf("privateKey.D() = %v, want %v", privateKey.D(), tc.privateKeyValues.D) } - if !privateKey.P().Equals(tc.privateKeyValues.P) { + if !privateKey.P().Equal(tc.privateKeyValues.P) { t.Errorf("privateKey.P() = %v, want %v", privateKey.P(), tc.privateKeyValues.P) } - if !privateKey.Q().Equals(tc.privateKeyValues.Q) { + if !privateKey.Q().Equal(tc.privateKeyValues.Q) { t.Errorf("privateKey.Q() = %v, want %v", privateKey.Q(), tc.privateKeyValues.Q) } - if !privateKey.DP().Equals(tc.dp) { + if !privateKey.DP().Equal(tc.dp) { t.Errorf("privateKey.DP() = %v, want %v", privateKey.DP(), tc.dp) } - if !privateKey.DQ().Equals(tc.dq) { + if !privateKey.DQ().Equal(tc.dq) { t.Errorf("privateKey.DQ() = %v, want %v", privateKey.DQ(), tc.dq) } - if !privateKey.QInv().Equals(tc.qInv) { + if !privateKey.QInv().Equal(tc.qInv) { t.Errorf("privateKey.QInv() = %v, want %v", privateKey.QInv(), tc.qInv) } gotIDRequirement, gotRequired := privateKey.IDRequirement() @@ -801,28 +801,28 @@ func TestNewPrivateKey(t *testing.T) { if got, want := privateKey.OutputPrefix(), tc.publicKey.OutputPrefix(); !bytes.Equal(got, want) { t.Errorf("privateKey.OutputPrefix() = %v, want %v", got, want) } - if got, want := privateKey.Parameters(), tc.publicKey.Parameters(); !got.Equals(want) { + if got, want := privateKey.Parameters(), tc.publicKey.Parameters(); !got.Equal(want) { t.Errorf("privateKey.Parameters() = %v, want %v", got, want) } want, err := privateKey.PublicKey() if err != nil { t.Fatalf("privateKey.PublicKey() err = %v, want nil", err) } - if got := tc.publicKey; !got.Equals(want) { + if got := tc.publicKey; !got.Equal(want) { t.Errorf("privateKey.PublicKey() = %v, want %v", got, want) } otherPrivateKey, err := rsassapkcs1.NewPrivateKey(tc.publicKey, tc.privateKeyValues) if err != nil { t.Errorf("rsassapkcs1.NewPrivateKey(tc.publicKey, %v) err = %v, want nil", tc.privateKeyValues, err) } - if !privateKey.Equals(otherPrivateKey) { - t.Errorf("privateKey.Equals(otherPrivateKey) = false, want true") + if !privateKey.Equal(otherPrivateKey) { + t.Errorf("privateKey.Equal(otherPrivateKey) = false, want true") } }) } } -func TestNewPrivateKeyEqualsFailsIfKeysAreDifferent(t *testing.T) { +func TestNewPrivateKeyEqualFailsIfKeysAreDifferent(t *testing.T) { // From: // https://github.com/C2SP/wycheproof/blob/cd27d6419bedd83cbd24611ec54b6d4bfdb0cdca/testvectors/rsa_pkcs1_2048_test.json#L353 differentN2048Base64 := "3ZBFkDl4CMQxQyliPZATRThDJRsTuLPE_vVFmBEq8-sxxxEDxiWZUWdOU72Tp-NtGUcuR06-gChobZUpSE2Lr-pKBLoZVVZnYWyEeGcFlACcm8aj7-UidMumTHJHR9ftwZTk_t3jKjKJ2Uwxk25-ehXXVvVISS9bNFuSfoxhi91VCsshoXrhSDBDg9ubPHuqPkyL2OhEqITao-GNVpmMsy-brk1B1WoY3dQxPICJt16du5EoRwusmwh_thkoqw-MTIk2CwIImQCNCOi9MfkHqAfoBWrWgA3_357Z2WSpOefkgRS4SXhVGsuFyd-RlvPv9VKG1s1LOagiqKd2Ohggjw" @@ -924,11 +924,11 @@ func TestNewPrivateKeyEqualsFailsIfKeysAreDifferent(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - if tc.this.Equals(tc.that) { - t.Errorf("tc.this.Equals(tc.that) = true, want false") + if tc.this.Equal(tc.that) { + t.Errorf("tc.this.Equal(tc.that) = true, want false") } - if tc.that.Equals(tc.this) { - t.Errorf("tc.that.Equals(tc.this) = true, want false") + if tc.that.Equal(tc.this) { + t.Errorf("tc.that.Equal(tc.this) = true, want false") } }) } diff --git a/signature/rsassapkcs1/protoserialization_test.go b/signature/rsassapkcs1/protoserialization_test.go index 45e93fe..bdd9527 100644 --- a/signature/rsassapkcs1/protoserialization_test.go +++ b/signature/rsassapkcs1/protoserialization_test.go @@ -241,8 +241,8 @@ func TestParsePublicKeyWithZeroPaddingModulus(t *testing.T) { if err != nil { t.Fatalf("parser.ParseKey(%v) err = %v, want non-nil", keySerialization, err) } - if got, want := parsedPublicKey, wantPublicKey; !got.Equals(want) { - t.Errorf("got.Equals(want) = false, want true") + if got, want := parsedPublicKey, wantPublicKey; !got.Equal(want) { + t.Errorf("got.Equal(want) = false, want true") } } @@ -452,8 +452,8 @@ func TestParseAndSerializePublicKey(t *testing.T) { if err != nil { t.Fatalf("p.ParseKey(%v) err = %v, want non-nil", tc.publicKeySerialization, err) } - if !gotKey.Equals(tc.publicKey) { - t.Errorf("%v.Equals(%v) = false, want true", gotKey, tc.publicKey) + if !gotKey.Equal(tc.publicKey) { + t.Errorf("%v.Equal(%v) = false, want true", gotKey, tc.publicKey) } // Make sure we can serialize back the key serialization. @@ -462,8 +462,8 @@ func TestParseAndSerializePublicKey(t *testing.T) { if err != nil { t.Errorf("s.SerializeKey(%v) err = %v, want nil", tc.publicKeySerialization, err) } - if !gotSerialization.Equals(tc.publicKeySerialization) { - t.Errorf("gotSerialization.Equals(tc.publicKeySerialization) = false, want true") + if !gotSerialization.Equal(tc.publicKeySerialization) { + t.Errorf("gotSerialization.Equal(tc.publicKeySerialization) = false, want true") } }) } @@ -473,13 +473,13 @@ type testParams struct{} func (p *testParams) HasIDRequirement() bool { return true } -func (p *testParams) Equals(params key.Parameters) bool { return true } +func (p *testParams) Equal(params key.Parameters) bool { return true } type testKey struct{} func (k *testKey) Parameters() key.Parameters { return &testParams{} } -func (k *testKey) Equals(other key.Key) bool { return true } +func (k *testKey) Equal(other key.Key) bool { return true } func (k *testKey) IDRequirement() (uint32, bool) { return 123, true } @@ -684,8 +684,8 @@ func TestParsePrivateKeyWithZeroPaddingModulus(t *testing.T) { if err != nil { t.Fatalf("parser.ParseKey(%v) err = %v, want non-nil", keySerialization, err) } - if got, want := parsedPrivateKey, wantPrivateKey; !got.Equals(want) { - t.Errorf("got.Equals(want) = false, want true") + if got, want := parsedPrivateKey, wantPrivateKey; !got.Equal(want) { + t.Errorf("got.Equal(want) = false, want true") } } @@ -925,8 +925,8 @@ func TestParseAndSerializePrivateKey(t *testing.T) { if err != nil { t.Fatalf("p.ParseKey(%v) err = %v, want non-nil", tc.keySerialization, err) } - if !gotKey.Equals(tc.privateKey) { - t.Errorf("%v.Equals(%v) = false, want true", gotKey, tc.privateKey) + if !gotKey.Equal(tc.privateKey) { + t.Errorf("%v.Equal(%v) = false, want true", gotKey, tc.privateKey) } s := &privateKeySerializer{} @@ -934,8 +934,8 @@ func TestParseAndSerializePrivateKey(t *testing.T) { if err != nil { t.Fatalf("s.SerializeKey(%v) err = %v, want nil", gotKey, err) } - if !gotKeySerialization.Equals(tc.keySerialization) { - t.Errorf("gotKeySerialization.Equals(tc.keySerialization) = false, want true") + if !gotKeySerialization.Equal(tc.keySerialization) { + t.Errorf("gotKeySerialization.Equal(tc.keySerialization) = false, want true") } }) } diff --git a/signature/rsassapkcs1/rsassapkcs1_test.go b/signature/rsassapkcs1/rsassapkcs1_test.go index c36783f..2fc78af 100644 --- a/signature/rsassapkcs1/rsassapkcs1_test.go +++ b/signature/rsassapkcs1/rsassapkcs1_test.go @@ -90,8 +90,8 @@ func TestCreateKeysetHandleFromParameters(t *testing.T) { if entry.KeyID() == anotherEntry.KeyID() { t.Fatalf("entry.KeyID() = %v, want different from anotherEntry.KeyID() = %v", entry.KeyID(), anotherEntry.KeyID()) } - if entry.Key().Equals(anotherEntry.Key()) { - t.Fatalf("entry.Key().Equals(anotherEntry.Key()) = true, want false") + if entry.Key().Equal(anotherEntry.Key()) { + t.Fatalf("entry.Key().Equal(anotherEntry.Key()) = true, want false") } publicEntry, err := publicHandle.Primary() if err != nil { @@ -104,8 +104,8 @@ func TestCreateKeysetHandleFromParameters(t *testing.T) { if publicEntry.KeyID() == anotherPublicEntry.KeyID() { t.Fatalf("publicEntry.KeyID() = %v, want different from anotherPublicEntry.KeyID() = %v", publicEntry.KeyID(), anotherPublicEntry.KeyID()) } - if publicEntry.Key().Equals(anotherPublicEntry.Key()) { - t.Fatalf("publicEntry.Key().Equals(anotherPublicEntry.Key()) = true, want false") + if publicEntry.Key().Equal(anotherPublicEntry.Key()) { + t.Fatalf("publicEntry.Key().Equal(anotherPublicEntry.Key()) = true, want false") } // Make sure that a different generated key cannot verify the signature. diff --git a/signature/rsassapss/key.go b/signature/rsassapss/key.go index 5cf5f7b..54ee194 100644 --- a/signature/rsassapss/key.go +++ b/signature/rsassapss/key.go @@ -188,8 +188,8 @@ func NewParameters(values ParametersValues, variant Variant) (*Parameters, error // HasIDRequirement tells whether the key has an ID requirement. func (p *Parameters) HasIDRequirement() bool { return p.variant != VariantNoPrefix } -// Equals tells whether this parameters object is equal to other. -func (p *Parameters) Equals(other key.Parameters) bool { +// Equal tells whether this parameters object is equal to other. +func (p *Parameters) Equal(other key.Parameters) bool { that, ok := other.(*Parameters) return ok && p.HasIDRequirement() == that.HasIDRequirement() && p.modulusSizeBits == that.modulusSizeBits && @@ -267,12 +267,12 @@ func (k *PublicKey) IDRequirement() (uint32, bool) { // OutputPrefix returns the output prefix of this key. func (k *PublicKey) OutputPrefix() []byte { return bytes.Clone(k.outputPrefix) } -// Equals tells whether this key object is equal to other. -func (k *PublicKey) Equals(other key.Key) bool { +// Equal tells whether this key object is equal to other. +func (k *PublicKey) Equal(other key.Key) bool { actualKey, ok := other.(*PublicKey) return ok && bytes.Equal(k.modulus, actualKey.modulus) && k.idRequirement == actualKey.idRequirement && - k.parameters.Equals(actualKey.parameters) + k.parameters.Equal(actualKey.parameters) } // PrivateKey represents a function that can produce RSA-SSA-PSS @@ -361,8 +361,8 @@ func (k *PrivateKey) IDRequirement() (uint32, bool) { return k.publicKey.IDRequi // OutputPrefix returns the output prefix of this key. func (k *PrivateKey) OutputPrefix() []byte { return k.publicKey.OutputPrefix() } -// Equals tells whether this key object is equal to other. -func (k *PrivateKey) Equals(other key.Key) bool { +// Equal tells whether this key object is equal to other. +func (k *PrivateKey) Equal(other key.Key) bool { that, ok := other.(*PrivateKey) - return ok && k.publicKey.Equals(that.publicKey) && k.privateKey.Equal(that.privateKey) + return ok && k.publicKey.Equal(that.publicKey) && k.privateKey.Equal(that.privateKey) } diff --git a/signature/rsassapss/key_test.go b/signature/rsassapss/key_test.go index 88da257..0c0d126 100644 --- a/signature/rsassapss/key_test.go +++ b/signature/rsassapss/key_test.go @@ -188,8 +188,8 @@ func TestNewParameters(t *testing.T) { if err != nil { t.Fatalf("rsassapss.NewParameters(%v, %v) = %v, want nil", paramsValues, variant, err) } - if !params.Equals(other) { - t.Errorf("params.Equals(other) = false, want true") + if !params.Equal(other) { + t.Errorf("params.Equal(other) = false, want true") } }) } @@ -334,8 +334,8 @@ func TestNewParametersDifferentParameters(t *testing.T) { if err != nil { t.Fatalf("rsassapss.NewParameters(%v, %v) = %v, want nil", tc.that.parametersValues, tc.that.variant, err) } - if this.Equals(that) { - t.Errorf("this.Equals(that) = true, want false") + if this.Equal(that) { + t.Errorf("this.Equal(that) = true, want false") } }) } @@ -526,7 +526,7 @@ func TestNewPublicKey(t *testing.T) { if err != nil { t.Fatalf("rsassapss.NewPublicKey(%v, %d, %v) = %v, want nil", tc.modulus, tc.idRequirement, params, err) } - if got, want := key.Parameters(), params; !got.Equals(want) { + if got, want := key.Parameters(), params; !got.Equal(want) { t.Errorf("key.Parameters() = %v, want %v", got, want) } idRequirement, required := key.IDRequirement() @@ -546,8 +546,8 @@ func TestNewPublicKey(t *testing.T) { if err != nil { t.Fatalf("rsassapss.NewPublicKey(%v, %d, %v) = %v, want nil", tc.modulus, tc.idRequirement, params, err) } - if !key.Equals(otherKey) { - t.Errorf("key.Equals(otherKey) = false, want true") + if !key.Equal(otherKey) { + t.Errorf("key.Equal(otherKey) = false, want true") } }) } @@ -659,7 +659,7 @@ func mustCreatePublicKey(t *testing.T, modulus []byte, idRequirement uint32, par return key } -func TestNewPublicKeyEqualsFailsIfDifferentKeys(t *testing.T) { +func TestNewPublicKeyEqualFailsIfDifferentKeys(t *testing.T) { validModulus2048 := mustDecodeBase64(t, n2048Base64) // From: // https://github.com/C2SP/wycheproof/blob/cd27d6419bedd83cbd24611ec54b6d4bfdb0cdca/testvectors/rsa_pkcs1_2048_test.json#L353 @@ -740,11 +740,11 @@ func TestNewPublicKeyEqualsFailsIfDifferentKeys(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - if tc.this.Equals(tc.that) { - t.Errorf("tc.this.Equals(tc.that) = true, want false") + if tc.this.Equal(tc.that) { + t.Errorf("tc.this.Equal(tc.that) = true, want false") } - if tc.that.Equals(tc.this) { - t.Errorf("tc.that.Equals(tc.this) = true, want false") + if tc.that.Equal(tc.this) { + t.Errorf("tc.that.Equal(tc.this) = true, want false") } }) } @@ -1008,22 +1008,22 @@ func TestNewPrivateKey(t *testing.T) { if err != nil { t.Errorf("rsassapss.NewPrivateKey(tc.publicKey, %v) err = %v, want nil", tc.privateKeyValues, err) } - if !privateKey.D().Equals(tc.privateKeyValues.D) { + if !privateKey.D().Equal(tc.privateKeyValues.D) { t.Errorf("privateKey.D() = %v, want %v", privateKey.D(), tc.privateKeyValues.D) } - if !privateKey.P().Equals(tc.privateKeyValues.P) { + if !privateKey.P().Equal(tc.privateKeyValues.P) { t.Errorf("privateKey.P() = %v, want %v", privateKey.P(), tc.privateKeyValues.P) } - if !privateKey.Q().Equals(tc.privateKeyValues.Q) { + if !privateKey.Q().Equal(tc.privateKeyValues.Q) { t.Errorf("privateKey.Q() = %v, want %v", privateKey.Q(), tc.privateKeyValues.Q) } - if !privateKey.DP().Equals(tc.dp) { + if !privateKey.DP().Equal(tc.dp) { t.Errorf("privateKey.DP() = %v, want %v", privateKey.DP(), tc.dp) } - if !privateKey.DQ().Equals(tc.dq) { + if !privateKey.DQ().Equal(tc.dq) { t.Errorf("privateKey.DQ() = %v, want %v", privateKey.DQ(), tc.dq) } - if !privateKey.QInv().Equals(tc.qInv) { + if !privateKey.QInv().Equal(tc.qInv) { t.Errorf("privateKey.QInv() = %v, want %v", privateKey.QInv(), tc.qInv) } gotIDRequirement, gotRequired := privateKey.IDRequirement() @@ -1034,28 +1034,28 @@ func TestNewPrivateKey(t *testing.T) { if got, want := privateKey.OutputPrefix(), tc.publicKey.OutputPrefix(); !bytes.Equal(got, want) { t.Errorf("privateKey.OutputPrefix() = %v, want %v", got, want) } - if got, want := privateKey.Parameters(), tc.publicKey.Parameters(); !got.Equals(want) { + if got, want := privateKey.Parameters(), tc.publicKey.Parameters(); !got.Equal(want) { t.Errorf("privateKey.Parameters() = %v, want %v", got, want) } want, err := privateKey.PublicKey() if err != nil { t.Fatalf("privateKey.PublicKey() err = %v, want nil", err) } - if got := tc.publicKey; !got.Equals(want) { + if got := tc.publicKey; !got.Equal(want) { t.Errorf("privateKey.PublicKey() = %v, want %v", got, want) } otherPrivateKey, err := rsassapss.NewPrivateKey(tc.publicKey, tc.privateKeyValues) if err != nil { t.Errorf("rsassapss.NewPrivateKey(tc.publicKey, %v) err = %v, want nil", tc.privateKeyValues, err) } - if !privateKey.Equals(otherPrivateKey) { - t.Errorf("privateKey.Equals(otherPrivateKey) = false, want true") + if !privateKey.Equal(otherPrivateKey) { + t.Errorf("privateKey.Equal(otherPrivateKey) = false, want true") } }) } } -func TestNewPrivateKeyEqualsFailsIfKeysAreDifferent(t *testing.T) { +func TestNewPrivateKeyEqualFailsIfKeysAreDifferent(t *testing.T) { // From: // https://github.com/C2SP/wycheproof/blob/cd27d6419bedd83cbd24611ec54b6d4bfdb0cdca/testvectors/rsa_pkcs1_2048_test.json#L353 differentN2048Base64 := "3ZBFkDl4CMQxQyliPZATRThDJRsTuLPE_vVFmBEq8-sxxxEDxiWZUWdOU72Tp-NtGUcuR06-gChobZUpSE2Lr-pKBLoZVVZnYWyEeGcFlACcm8aj7-UidMumTHJHR9ftwZTk_t3jKjKJ2Uwxk25-ehXXVvVISS9bNFuSfoxhi91VCsshoXrhSDBDg9ubPHuqPkyL2OhEqITao-GNVpmMsy-brk1B1WoY3dQxPICJt16du5EoRwusmwh_thkoqw-MTIk2CwIImQCNCOi9MfkHqAfoBWrWgA3_357Z2WSpOefkgRS4SXhVGsuFyd-RlvPv9VKG1s1LOagiqKd2Ohggjw" @@ -1193,11 +1193,11 @@ func TestNewPrivateKeyEqualsFailsIfKeysAreDifferent(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - if tc.this.Equals(tc.that) { - t.Errorf("tc.this.Equals(tc.that) = true, want false") + if tc.this.Equal(tc.that) { + t.Errorf("tc.this.Equal(tc.that) = true, want false") } - if tc.that.Equals(tc.this) { - t.Errorf("tc.that.Equals(tc.this) = true, want false") + if tc.that.Equal(tc.this) { + t.Errorf("tc.that.Equal(tc.this) = true, want false") } }) } diff --git a/signature/rsassapss/protoserialization_test.go b/signature/rsassapss/protoserialization_test.go index 0e79254..7233e1f 100644 --- a/signature/rsassapss/protoserialization_test.go +++ b/signature/rsassapss/protoserialization_test.go @@ -306,8 +306,8 @@ func TestParsePublicKeyWithZeroPaddingModulus(t *testing.T) { if err != nil { t.Fatalf("parser.ParseKey(%v) err = %v, want non-nil", keySerialization, err) } - if got, want := parsedPublicKey, wantPublicKey; !got.Equals(want) { - t.Errorf("got.Equals(want) = false, want true") + if got, want := parsedPublicKey, wantPublicKey; !got.Equal(want) { + t.Errorf("got.Equal(want) = false, want true") } } @@ -525,8 +525,8 @@ func TestParseAndSerializePublicKey(t *testing.T) { if err != nil { t.Fatalf("p.ParseKey(%v) err = %v, want non-nil", tc.publicKeySerialization, err) } - if !gotKey.Equals(tc.publicKey) { - t.Errorf("%v.Equals(%v) = false, want true", gotKey, tc.publicKey) + if !gotKey.Equal(tc.publicKey) { + t.Errorf("%v.Equal(%v) = false, want true", gotKey, tc.publicKey) } // Make sure we can serialize back the key serialization. @@ -535,8 +535,8 @@ func TestParseAndSerializePublicKey(t *testing.T) { if err != nil { t.Errorf("s.SerializeKey(%v) err = %v, want nil", tc.publicKeySerialization, err) } - if !gotSerialization.Equals(tc.publicKeySerialization) { - t.Errorf("gotSerialization.Equals(tc.publicKeySerialization) = false, want true") + if !gotSerialization.Equal(tc.publicKeySerialization) { + t.Errorf("gotSerialization.Equal(tc.publicKeySerialization) = false, want true") } }) } @@ -546,13 +546,13 @@ type testParams struct{} func (p *testParams) HasIDRequirement() bool { return true } -func (p *testParams) Equals(params key.Parameters) bool { return true } +func (p *testParams) Equal(params key.Parameters) bool { return true } type testKey struct{} func (k *testKey) Parameters() key.Parameters { return &testParams{} } -func (k *testKey) Equals(other key.Key) bool { return true } +func (k *testKey) Equal(other key.Key) bool { return true } func (k *testKey) IDRequirement() (uint32, bool) { return 123, true } @@ -823,8 +823,8 @@ func TestParsePrivateKeyWithZeroPaddingModulus(t *testing.T) { if err != nil { t.Fatalf("parser.ParseKey(%v) err = %v, want non-nil", keySerialization, err) } - if got, want := parsedPrivateKey, wantPrivateKey; !got.Equals(want) { - t.Errorf("got.Equals(want) = false, want true") + if got, want := parsedPrivateKey, wantPrivateKey; !got.Equal(want) { + t.Errorf("got.Equal(want) = false, want true") } } @@ -1070,8 +1070,8 @@ func TestParseAndSerializePrivateKey(t *testing.T) { if err != nil { t.Fatalf("p.ParseKey(%v) err = %v, want non-nil", tc.keySerialization, err) } - if !gotKey.Equals(tc.privateKey) { - t.Errorf("%v.Equals(%v) = false, want true", gotKey, tc.privateKey) + if !gotKey.Equal(tc.privateKey) { + t.Errorf("%v.Equal(%v) = false, want true", gotKey, tc.privateKey) } s := &privateKeySerializer{} @@ -1079,8 +1079,8 @@ func TestParseAndSerializePrivateKey(t *testing.T) { if err != nil { t.Fatalf("s.SerializeKey(%v) err = %v, want nil", gotKey, err) } - if !gotKeySerialization.Equals(tc.keySerialization) { - t.Errorf("gotKeySerialization.Equals(tc.keySerialization) = false, want true") + if !gotKeySerialization.Equal(tc.keySerialization) { + t.Errorf("gotKeySerialization.Equal(tc.keySerialization) = false, want true") } }) } diff --git a/signature/rsassapss/rsassapss_test.go b/signature/rsassapss/rsassapss_test.go index 6c7e491..8a5d8a7 100644 --- a/signature/rsassapss/rsassapss_test.go +++ b/signature/rsassapss/rsassapss_test.go @@ -97,8 +97,8 @@ func TestCreateKeysetHandleFromParameters(t *testing.T) { if entry.KeyID() == anotherEntry.KeyID() { t.Fatalf("entry.KeyID() = %v, want different from anotherEntry.KeyID() = %v", entry.KeyID(), anotherEntry.KeyID()) } - if entry.Key().Equals(anotherEntry.Key()) { - t.Fatalf("entry.Key().Equals(anotherEntry.Key()) = true, want false") + if entry.Key().Equal(anotherEntry.Key()) { + t.Fatalf("entry.Key().Equal(anotherEntry.Key()) = true, want false") } publicEntry, err := publicHandle.Primary() if err != nil { @@ -111,8 +111,8 @@ func TestCreateKeysetHandleFromParameters(t *testing.T) { if publicEntry.KeyID() == anotherPublicEntry.KeyID() { t.Fatalf("publicEntry.KeyID() = %v, want different from anotherPublicEntry.KeyID() = %v", publicEntry.KeyID(), anotherPublicEntry.KeyID()) } - if publicEntry.Key().Equals(anotherPublicEntry.Key()) { - t.Fatalf("publicEntry.Key().Equals(anotherPublicEntry.Key()) = true, want false") + if publicEntry.Key().Equal(anotherPublicEntry.Key()) { + t.Fatalf("publicEntry.Key().Equal(anotherPublicEntry.Key()) = true, want false") } // Make sure that a different generated key cannot verify the signature. diff --git a/signature/signature_factory_test.go b/signature/signature_factory_test.go index 22453fa..d73ad70 100644 --- a/signature/signature_factory_test.go +++ b/signature/signature_factory_test.go @@ -511,8 +511,8 @@ type stubParams struct{} var _ key.Parameters = (*stubParams)(nil) -func (p *stubParams) Equals(_ key.Parameters) bool { return true } -func (p *stubParams) HasIDRequirement() bool { return true } +func (p *stubParams) Equal(_ key.Parameters) bool { return true } +func (p *stubParams) HasIDRequirement() bool { return true } type stubPublicKey struct { prefixType tinkpb.OutputPrefixType @@ -521,7 +521,7 @@ type stubPublicKey struct { var _ key.Key = (*stubPublicKey)(nil) -func (p *stubPublicKey) Equals(_ key.Key) bool { return true } +func (p *stubPublicKey) Equal(_ key.Key) bool { return true } func (p *stubPublicKey) Parameters() key.Parameters { return &stubParams{} } func (p *stubPublicKey) IDRequirement() (uint32, bool) { return p.idRequirement, p.HasIDRequirement() } func (p *stubPublicKey) HasIDRequirement() bool { return p.prefixType == tinkpb.OutputPrefixType_RAW } @@ -561,7 +561,7 @@ type stubPrivateKey struct { var _ key.Key = (*stubPrivateKey)(nil) -func (p *stubPrivateKey) Equals(_ key.Key) bool { return true } +func (p *stubPrivateKey) Equal(_ key.Key) bool { return true } func (p *stubPrivateKey) Parameters() key.Parameters { return &stubParams{} } func (p *stubPrivateKey) IDRequirement() (uint32, bool) { return p.idRequirement, p.HasIDRequirement() } func (p *stubPrivateKey) HasIDRequirement() bool { return p.prefixType != tinkpb.OutputPrefixType_RAW }