Skip to content

Commit

Permalink
Test cross compatibility
Browse files Browse the repository at this point in the history
* Add tests verifying Metablock signatures
* Fix RSA key load with trailing newline

Signed-off-by: Aditya Sirish <aditya@saky.in>
  • Loading branch information
adityasaky committed May 1, 2023
1 parent 1c3e073 commit 13d3e0d
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 6 deletions.
65 changes: 65 additions & 0 deletions signerverifier/ecdsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package signerverifier

import (
"context"
"encoding/json"
"os"
"path/filepath"
"testing"

"github.com/secure-systems-lab/go-securesystemslib/cjson"
"github.com/secure-systems-lab/go-securesystemslib/dsse"
"github.com/stretchr/testify/assert"
)
Expand All @@ -29,6 +32,28 @@ func TestNewECDSASignerVerifierFromSSLibKey(t *testing.T) {
assert.Nil(t, sv.private)
}

func TestLoadECDSAKeyFromFile(t *testing.T) {
t.Run("ecdsa public key", func(t *testing.T) {
key, err := LoadECDSAKeyFromFile(filepath.Join("test-data", "ecdsa-test-key.pub"))
assert.Nil(t, err)

assert.Equal(t, "98adf38602c48c5479e9a991ee3f8cbf541ee4f985e00f7a5fc4148d9a45b704", key.KeyID)
assert.Equal(t, "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEu+HEqqpXLa48lXH9rkRygsfsCKq1\nXM36oXymJ9wxpM68nCqkrZCVnZ9lkEeCwD8qWYTNxD5yfWXwJjFh+K7qLQ==\n-----END PUBLIC KEY-----", key.KeyVal.Public)
assert.Equal(t, "ecdsa-sha2-nistp256", key.Scheme)
assert.Equal(t, ECDSAKeyType, key.KeyType)
})
t.Run("ecdsa private key", func(t *testing.T) {
key, err := LoadECDSAKeyFromFile(filepath.Join("test-data", "ecdsa-test-key"))
assert.Nil(t, err)

assert.Equal(t, "98adf38602c48c5479e9a991ee3f8cbf541ee4f985e00f7a5fc4148d9a45b704", key.KeyID)
assert.Equal(t, "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEu+HEqqpXLa48lXH9rkRygsfsCKq1\nXM36oXymJ9wxpM68nCqkrZCVnZ9lkEeCwD8qWYTNxD5yfWXwJjFh+K7qLQ==\n-----END PUBLIC KEY-----", key.KeyVal.Public)
assert.Equal(t, "-----BEGIN EC PRIVATE KEY-----\nMHcCAQEEIAo6DxXlgqYy+TkvocIOyWlqA3KVtp6dlSY7lS3kkeEMoAoGCCqGSM49\nAwEHoUQDQgAEu+HEqqpXLa48lXH9rkRygsfsCKq1XM36oXymJ9wxpM68nCqkrZCV\nnZ9lkEeCwD8qWYTNxD5yfWXwJjFh+K7qLQ==\n-----END EC PRIVATE KEY-----", key.KeyVal.Private)
assert.Equal(t, "ecdsa-sha2-nistp256", key.Scheme)
assert.Equal(t, ECDSAKeyType, key.KeyType)
})
}

func TestECDSASignerVerifierSign(t *testing.T) {
t.Run("using valid key", func(t *testing.T) {
key, err := LoadECDSAKeyFromFile(filepath.Join("test-data", "ecdsa-test-key"))
Expand Down Expand Up @@ -116,3 +141,43 @@ func TestECDSASignerVerifierWithDSSEEnvelope(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, "98adf38602c48c5479e9a991ee3f8cbf541ee4f985e00f7a5fc4148d9a45b704", acceptedKeys[0].KeyID)
}

func TestECDSASignerVerifierWithMetablockFile(t *testing.T) {
key, err := LoadECDSAKeyFromFile(filepath.Join("test-data", "ecdsa-test-key.pub"))
if err != nil {
t.Fatal(err)
}

sv, err := NewECDSASignerVerifierFromSSLibKey(key)
if err != nil {
t.Fatal(err)
}

metadataBytes, err := os.ReadFile(filepath.Join("test-data", "test-ecdsa.98adf386.link"))
if err != nil {
t.Fatal(err)
}

mb := struct {
Signatures []struct {
KeyID string `json:"keyid"`
Sig string `json:"sig"`
} `json:"signatures"`
Signed any `json:"signed"`
}{}

if err := json.Unmarshal(metadataBytes, &mb); err != nil {
t.Fatal(err)
}

assert.Equal(t, "304502201fbb03c0937504182a48c66f9218bdcb2e99a07ada273e92e5e543867f98c8d7022100dbfa7bbf74fd76d76c1d08676419cba85bbd81dfb000f3ac6a786693ddc508f5", mb.Signatures[0].Sig)
assert.Equal(t, sv.keyID, mb.Signatures[0].KeyID)

encodedBytes, err := cjson.EncodeCanonical(mb.Signed)
if err != nil {
t.Fatal(err)
}

err = sv.Verify(context.Background(), encodedBytes, []byte(mb.Signatures[0].Sig))
assert.Nil(t, err)
}
65 changes: 65 additions & 0 deletions signerverifier/ed25519_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import (
"context"
"crypto/ed25519"
"encoding/hex"
"encoding/json"
"os"
"path/filepath"
"testing"

"github.com/secure-systems-lab/go-securesystemslib/cjson"
"github.com/secure-systems-lab/go-securesystemslib/dsse"
"github.com/stretchr/testify/assert"
)
Expand All @@ -30,6 +33,28 @@ func TestNewED25519SignerVerifierFromSSLibKey(t *testing.T) {
assert.Nil(t, sv.private)
}

func TestLoadED25519KeyFromFile(t *testing.T) {
t.Run("ED25519 public key", func(t *testing.T) {
key, err := LoadED25519KeyFromFile(filepath.Join("test-data", "ed25519-test-key.pub"))
assert.Nil(t, err)

assert.Equal(t, "52e3b8e73279d6ebdd62a5016e2725ff284f569665eb92ccb145d83817a02997", key.KeyID)
assert.Equal(t, "3f586ce67329419fb0081bd995914e866a7205da463d593b3b490eab2b27fd3f", key.KeyVal.Public)
assert.Equal(t, "ed25519", key.Scheme)
assert.Equal(t, ED25519KeyType, key.KeyType)
})
t.Run("ED25519 private key", func(t *testing.T) {
key, err := LoadED25519KeyFromFile(filepath.Join("test-data", "ed25519-test-key"))
assert.Nil(t, err)

assert.Equal(t, "52e3b8e73279d6ebdd62a5016e2725ff284f569665eb92ccb145d83817a02997", key.KeyID)
assert.Equal(t, "3f586ce67329419fb0081bd995914e866a7205da463d593b3b490eab2b27fd3f", key.KeyVal.Public)
assert.Equal(t, "66f6ebad4aeb949b91c84c9cfd6ee351fc4fd544744bab6e30fb400ba13c6e9a", key.KeyVal.Private)
assert.Equal(t, "ed25519", key.Scheme)
assert.Equal(t, ED25519KeyType, key.KeyType)
})
}

func TestED25519SignerVerifierSign(t *testing.T) {
key, err := LoadED25519KeyFromFile(filepath.Join("test-data", "ed25519-test-key"))
if err != nil {
Expand Down Expand Up @@ -142,3 +167,43 @@ func TestED25519SignerVerifierWithDSSEEnvelope(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, "52e3b8e73279d6ebdd62a5016e2725ff284f569665eb92ccb145d83817a02997", acceptedKeys[0].KeyID)
}

func TestED25519SignerVerifierWithMetablockFile(t *testing.T) {
key, err := LoadED25519KeyFromFile(filepath.Join("test-data", "ed25519-test-key.pub"))
if err != nil {
t.Fatal(err)
}

sv, err := NewED25519SignerVerifierFromSSLibKey(key)
if err != nil {
t.Fatal(err)
}

metadataBytes, err := os.ReadFile(filepath.Join("test-data", "test-ed25519.52e3b8e7.link"))
if err != nil {
t.Fatal(err)
}

mb := struct {
Signatures []struct {
KeyID string `json:"keyid"`
Sig string `json:"sig"`
} `json:"signatures"`
Signed any `json:"signed"`
}{}

if err := json.Unmarshal(metadataBytes, &mb); err != nil {
t.Fatal(err)
}

assert.Equal(t, "4c8b7605a9195d4ddba54493bbb5257a9836c1d16056a027fd77e97b95a4f3e36f8bc3c9c9960387d68187760b3072a30c44f992c5bf8f7497c303a3b0a32403", mb.Signatures[0].Sig)
assert.Equal(t, sv.keyID, mb.Signatures[0].KeyID)

encodedBytes, err := cjson.EncodeCanonical(mb.Signed)
if err != nil {
t.Fatal(err)
}

err = sv.Verify(context.Background(), encodedBytes, []byte(mb.Signatures[0].Sig))
assert.Nil(t, err)
}
7 changes: 4 additions & 3 deletions signerverifier/rsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"crypto/x509"
"fmt"
"os"
"strings"
)

const (
Expand Down Expand Up @@ -117,15 +118,15 @@ func LoadRSAPSSKeyFromFile(path string) (*SSLibKey, error) {
if err != nil {
return nil, fmt.Errorf("unable to load RSA PSS key from file: %w", err)
}
key.KeyVal.Public = string(generatePEMBlock(pubKeyBytes, PublicKeyPEM))
key.KeyVal.Public = strings.TrimSpace(string(generatePEMBlock(pubKeyBytes, PublicKeyPEM)))

case *rsa.PrivateKey:
pubKeyBytes, err := x509.MarshalPKIXPublicKey(k.Public())
if err != nil {
return nil, fmt.Errorf("unable to load RSA PSS key from file: %w", err)
}
key.KeyVal.Public = string(generatePEMBlock(pubKeyBytes, PublicKeyPEM))
key.KeyVal.Private = string(generatePEMBlock(pemData.Bytes, RSAPrivateKeyPEM))
key.KeyVal.Public = strings.TrimSpace(string(generatePEMBlock(pubKeyBytes, PublicKeyPEM)))
key.KeyVal.Private = strings.TrimSpace(string(generatePEMBlock(pemData.Bytes, RSAPrivateKeyPEM)))
}

if len(key.KeyID) == 0 {
Expand Down
72 changes: 69 additions & 3 deletions signerverifier/rsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ package signerverifier
import (
"context"
"crypto/rsa"
"encoding/json"
"os"
"path/filepath"
"testing"

"github.com/secure-systems-lab/go-securesystemslib/cjson"
"github.com/secure-systems-lab/go-securesystemslib/dsse"
"github.com/stretchr/testify/assert"
)
Expand All @@ -25,11 +28,34 @@ func TestNewRSAPSSSignerVerifierFromSSLibKey(t *testing.T) {
_, expectedPublicKey, err := decodeAndParsePEM([]byte(expectedPublicString))
assert.Nil(t, err)

assert.Equal(t, "966c5d84ba73ccded42eb473c939d77336e4def253ffaf6739f8e983ef73dad8", sv.keyID) // FIXME: mismatch?
assert.Equal(t, "4e8d20af09fcaed6c388a186427f94a5f7ff5591ec295f4aab2cff49ffe39e9b", sv.keyID)
assert.Equal(t, expectedPublicKey.(*rsa.PublicKey), sv.public)
assert.Nil(t, sv.private)
}

func TestLoadRSAPSSKeyFromFile(t *testing.T) {
t.Run("RSA public key", func(t *testing.T) {
key, err := LoadRSAPSSKeyFromFile(filepath.Join("test-data", "rsa-test-key.pub"))
assert.Nil(t, err)

assert.Equal(t, "4e8d20af09fcaed6c388a186427f94a5f7ff5591ec295f4aab2cff49ffe39e9b", key.KeyID)
assert.Equal(t, "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA04egZRic+dZMVtiQc56D\nejU4FF1q3aOkUKnD+Q4lTbj1zp6ODKJTcktupmrad68jqtMiSGG8he6ELFs377q8\nbbgEUMWgAf+06Q8oFvUSfOXzZNFI7H5SMPOJY5aDWIMIEZ8DlcO7TfkA7D3iAEJX\nxxTOVS3UAIk5umO7Y7t7yXr8O/C4u78krGazCnoblcekMLJZV4O/5BloWNAe/B1c\nvZdaZUf3brD4ZZrxEtXw/tefhn1aHsSUajVW2wwjSpKhqj7Z0XS3bDS3T95/3xsN\n6+hlS6A7rJfiWpKIRHj0vh2SXLDmmhQl1In8TD/aiycTUyWcBRHVPlYFgYPt6SaT\nVQSgMzSxC43/2fINb2fyt8SbUHJ3Ct+mzRzd/1AQikWhBdstJLxInewzjYE/sb+c\n2CmCxMPQG2BwmAWXaaumeJcXVPBlMgAcjMatM8bPByTbXpKDnQslOE7g/gswDIwn\nEm53T13mZzYUvbLJ0q3aljZVLIC3IZn3ZwA2yCWchBkVAgMBAAE=\n-----END PUBLIC KEY-----", key.KeyVal.Public)
assert.Equal(t, RSAKeyScheme, key.Scheme)
assert.Equal(t, RSAKeyType, key.KeyType)
})
t.Run("RSA private key", func(t *testing.T) {
key, err := LoadRSAPSSKeyFromFile(filepath.Join("test-data", "rsa-test-key"))
assert.Nil(t, err)

assert.Equal(t, "4e8d20af09fcaed6c388a186427f94a5f7ff5591ec295f4aab2cff49ffe39e9b", key.KeyID)
assert.Equal(t, "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA04egZRic+dZMVtiQc56D\nejU4FF1q3aOkUKnD+Q4lTbj1zp6ODKJTcktupmrad68jqtMiSGG8he6ELFs377q8\nbbgEUMWgAf+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9\nvTuDhlHvxdsz0qmVss+/67PEh4nbcuQhg2tMLQVfVm8E1VcAj3N9rwDPoH155stG\nhX97wEgme7GtW7rayohCoDFZko1rdatiUscB6MmQxK0x94U3L2fI7Zth4TA87CY/\nW4gS2w/khSH2qOE2g0S/SEE3w5AuVWtCJjc9Qh7NhayqytS+qAfIoiGMMcXzekKX\nb/rlMKni3xoFRE7e+uprYrES+uwBGdfSIAAo9UGWfGECgcEA8pCJ4qE+vJaRkQCM\nFD0mvyHl54PGFOWORUOsTy1CGrIT/s1c7l5l1rfB6QkVKYDIyLXLThALKdVFSP0O\nwe2O9pfpna42lh7VbMHWHWBmMJ7JpcUf6ozUUAIf+1j2iZKUfAYu+duwXXWuE0VA\npSqZz+znaQaRrTm2UEOagqpwT7xZ8SlCYKWXLigA4/vpL+u4+myvQ4T1C4leaveN\nLP0+He6VLE2qklTHbAynVtiZ1REFm9+Z0B6nK8U/+58ISjTtAoHBALgqMopFIOMw\nAhhasnrL3Pzxf0WKzKmj/y2yEP0Vctm0muqxFnFwPwyOAd6HODJOSiFPD5VN4jvC\n+Yw96Qn29kHGXTKgL1J9cSL8z6Qzlc+UYCdSwmaZK5r36+NBTJgvKY9KrpkXCkSa\nc5YgIYtXMitmq9NmNvcSJWmuuiept3HFlwkU3pfmwzKNEeqi2jmuIOqI2zCOqX67\nI+YQsJgrHE0TmYxxRkgeYUy7s5DoHE25rfvdy5Lx+xAOH8ZgD1SGOw==\n-----END RSA PRIVATE KEY-----"
assert.Equal(t, expectedPrivateKey, key.KeyVal.Private)
assert.Equal(t, RSAKeyScheme, key.Scheme)
assert.Equal(t, RSAKeyType, key.KeyType)
})
}

func TestRSAPSSSignerVerifierSignAndVerify(t *testing.T) {
t.Run("using valid key", func(t *testing.T) {
key, err := LoadRSAPSSKeyFromFile(filepath.Join("test-data", "rsa-test-key"))
Expand Down Expand Up @@ -93,7 +119,7 @@ func TestRSAPSSSignerVerifierWithDSSEEnvelope(t *testing.T) {
t.Error(err)
}

assert.Equal(t, "966c5d84ba73ccded42eb473c939d77336e4def253ffaf6739f8e983ef73dad8", env.Signatures[0].KeyID)
assert.Equal(t, "4e8d20af09fcaed6c388a186427f94a5f7ff5591ec295f4aab2cff49ffe39e9b", env.Signatures[0].KeyID)
envPayload, err := env.DecodeB64Payload()
assert.Equal(t, payload, envPayload)
assert.Nil(t, err)
Expand All @@ -115,5 +141,45 @@ func TestRSAPSSSignerVerifierWithDSSEEnvelope(t *testing.T) {

acceptedKeys, err := ev.Verify(context.Background(), env)
assert.Nil(t, err)
assert.Equal(t, "966c5d84ba73ccded42eb473c939d77336e4def253ffaf6739f8e983ef73dad8", acceptedKeys[0].KeyID)
assert.Equal(t, "4e8d20af09fcaed6c388a186427f94a5f7ff5591ec295f4aab2cff49ffe39e9b", acceptedKeys[0].KeyID)
}

func TestRSAPSSSignerVerifierWithMetablockFile(t *testing.T) {
key, err := LoadRSAPSSKeyFromFile(filepath.Join("test-data", "rsa-test-key.pub"))
if err != nil {
t.Fatal(err)
}

sv, err := NewRSAPSSSignerVerifierFromSSLibKey(key)
if err != nil {
t.Fatal(err)
}

metadataBytes, err := os.ReadFile(filepath.Join("test-data", "test-rsa.4e8d20af.link"))
if err != nil {
t.Fatal(err)
}

mb := struct {
Signatures []struct {
KeyID string `json:"keyid"`
Sig string `json:"sig"`
} `json:"signatures"`
Signed any `json:"signed"`
}{}

if err := json.Unmarshal(metadataBytes, &mb); err != nil {
t.Fatal(err)
}

assert.Equal(t, "8958e5be66ee4352880a531bd097d1727adcc78e66b4faeb4a2cd6ad073dcb84f9a34e8156af39a7144cb5cd925325a18ccd4f0b2f981d6ff82655a7d63210d36655c50a0bf24e4839c10430a040dd6189d04fabec90eae4314c75ae2d585da17a56aaf6755e613a3a6a471ad2eddbb24504848e34f9ac163660f8ab80d7701bfa1189578a59597b3809ee62a70a7cc9545cfa65e23018fa442a45279b9fcf9d80bc92df711bfcfe16e3eae1bcf61b3286c1f0bdda17bc28bfab5b736bdcac4a38e31db1d0e0f56a2853b1b451650305f040a3425c3be47125700e92ef82c5a91a040b5e70ab7f6ebbe037ae1a6835044b5699748037e2e39a55a420c41cd9fa6e16868776367e3620e7d28eb9d8a3d710bdc98d488df1a9947d2ec8400f3c6209e8ca587cbffa30ceb3be98105e03182aab1bbb3c4e2560d99f0b09c012df2271f273ac70a6abb185abe11d559b118dca616417fa9205e74ab58e89ffd8b965da304ae9dc9cf6ffac4838b7c5375d6c2057a61cb286f06ad3b02a49c3af6178", mb.Signatures[0].Sig)
assert.Equal(t, sv.keyID, mb.Signatures[0].KeyID)

encodedBytes, err := cjson.EncodeCanonical(mb.Signed)
if err != nil {
t.Fatal(err)
}

err = sv.Verify(context.Background(), encodedBytes, []byte(mb.Signatures[0].Sig))
assert.Nil(t, err)
}
17 changes: 17 additions & 0 deletions signerverifier/test-data/test-ecdsa.98adf386.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"signatures": [
{
"keyid": "98adf38602c48c5479e9a991ee3f8cbf541ee4f985e00f7a5fc4148d9a45b704",
"sig": "304502201fbb03c0937504182a48c66f9218bdcb2e99a07ada273e92e5e543867f98c8d7022100dbfa7bbf74fd76d76c1d08676419cba85bbd81dfb000f3ac6a786693ddc508f5"
}
],
"signed": {
"_type": "link",
"byproducts": {},
"command": [],
"environment": {},
"materials": {},
"name": "test-ecdsa",
"products": {}
}
}
17 changes: 17 additions & 0 deletions signerverifier/test-data/test-ed25519.52e3b8e7.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"signatures": [
{
"keyid": "52e3b8e73279d6ebdd62a5016e2725ff284f569665eb92ccb145d83817a02997",
"sig": "4c8b7605a9195d4ddba54493bbb5257a9836c1d16056a027fd77e97b95a4f3e36f8bc3c9c9960387d68187760b3072a30c44f992c5bf8f7497c303a3b0a32403"
}
],
"signed": {
"_type": "link",
"byproducts": {},
"command": [],
"environment": {},
"materials": {},
"name": "test-ed25519",
"products": {}
}
}
17 changes: 17 additions & 0 deletions signerverifier/test-data/test-rsa.4e8d20af.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"signatures": [
{
"keyid": "4e8d20af09fcaed6c388a186427f94a5f7ff5591ec295f4aab2cff49ffe39e9b",
"sig": "8958e5be66ee4352880a531bd097d1727adcc78e66b4faeb4a2cd6ad073dcb84f9a34e8156af39a7144cb5cd925325a18ccd4f0b2f981d6ff82655a7d63210d36655c50a0bf24e4839c10430a040dd6189d04fabec90eae4314c75ae2d585da17a56aaf6755e613a3a6a471ad2eddbb24504848e34f9ac163660f8ab80d7701bfa1189578a59597b3809ee62a70a7cc9545cfa65e23018fa442a45279b9fcf9d80bc92df711bfcfe16e3eae1bcf61b3286c1f0bdda17bc28bfab5b736bdcac4a38e31db1d0e0f56a2853b1b451650305f040a3425c3be47125700e92ef82c5a91a040b5e70ab7f6ebbe037ae1a6835044b5699748037e2e39a55a420c41cd9fa6e16868776367e3620e7d28eb9d8a3d710bdc98d488df1a9947d2ec8400f3c6209e8ca587cbffa30ceb3be98105e03182aab1bbb3c4e2560d99f0b09c012df2271f273ac70a6abb185abe11d559b118dca616417fa9205e74ab58e89ffd8b965da304ae9dc9cf6ffac4838b7c5375d6c2057a61cb286f06ad3b02a49c3af6178"
}
],
"signed": {
"_type": "link",
"byproducts": {},
"command": [],
"environment": {},
"materials": {},
"name": "test-rsa",
"products": {}
}
}

0 comments on commit 13d3e0d

Please sign in to comment.