Skip to content

Commit

Permalink
Merge pull request #12 from reecerussell/fix0sizes
Browse files Browse the repository at this point in the history
fix: corrected size values
  • Loading branch information
reecerussell authored Jun 20, 2022
2 parents 0c0a4f2 + fdf7e28 commit 91b9677
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions gcp/kms.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ func (kms *KMS) Size() (int, error) {
proto.CryptoKeyVersion_RSA_SIGN_PKCS1_4096_SHA256,
proto.CryptoKeyVersion_EC_SIGN_P256_SHA256,
proto.CryptoKeyVersion_EC_SIGN_SECP256K1_SHA256:
return 256, nil
return crypto.SHA256.Size(), nil
case proto.CryptoKeyVersion_EC_SIGN_P384_SHA384:
return 384, nil
return crypto.SHA384.Size(), nil
case proto.CryptoKeyVersion_RSA_SIGN_PSS_4096_SHA512,
proto.CryptoKeyVersion_RSA_SIGN_PKCS1_4096_SHA512:
return 512, nil
return crypto.SHA512.Size(), nil
default:
return 0, ErrUnsupportedAlgorithm
}
Expand Down
12 changes: 6 additions & 6 deletions gcp/kms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestVerify_WhereKeyAlgIsUnsupported_ReturnsErr(t *testing.T) {
assert.Equal(t, ErrUnsupportedAlgorithm, err)
}

func TestSize_GivenSHA256Alg_Returns256(t *testing.T) {
func TestSize_GivenSHA256Alg_ReturnsCorrectSize(t *testing.T) {
algs := []proto.CryptoKeyVersion_CryptoKeyVersionAlgorithm{
proto.CryptoKeyVersion_RSA_SIGN_PSS_2048_SHA256,
proto.CryptoKeyVersion_RSA_SIGN_PSS_3072_SHA256,
Expand All @@ -290,11 +290,11 @@ func TestSize_GivenSHA256Alg_Returns256(t *testing.T) {
}
size, err := kms.Size()
assert.Nil(t, err)
assert.Equal(t, 256, size)
assert.Equal(t, 32, size)
}
}

func TestSize_GivenSHA384Alg_Returns384(t *testing.T) {
func TestSize_GivenSHA384Alg_ReturnsCorrectSize(t *testing.T) {
algs := []proto.CryptoKeyVersion_CryptoKeyVersionAlgorithm{
proto.CryptoKeyVersion_EC_SIGN_P384_SHA384,
}
Expand All @@ -309,11 +309,11 @@ func TestSize_GivenSHA384Alg_Returns384(t *testing.T) {
}
size, err := kms.Size()
assert.Nil(t, err)
assert.Equal(t, 384, size)
assert.Equal(t, 48, size)
}
}

func TestSize_GivenSHA512Alg_Returns512(t *testing.T) {
func TestSize_GivenSHA512Alg_ReturnsCorrectSize(t *testing.T) {
algs := []proto.CryptoKeyVersion_CryptoKeyVersionAlgorithm{
proto.CryptoKeyVersion_RSA_SIGN_PKCS1_4096_SHA512,
proto.CryptoKeyVersion_RSA_SIGN_PSS_4096_SHA512,
Expand All @@ -329,7 +329,7 @@ func TestSize_GivenSHA512Alg_Returns512(t *testing.T) {
}
size, err := kms.Size()
assert.Nil(t, err)
assert.Equal(t, 512, size)
assert.Equal(t, 64, size)
}
}

Expand Down

0 comments on commit 91b9677

Please sign in to comment.