This commit is contained in:
kkb0318
2024-03-28 22:18:54 +09:00
parent bd650cadea
commit 476746b036
3 changed files with 36 additions and 12 deletions
+3 -3
View File
@@ -14,13 +14,13 @@ import (
func TestReadKey(t *testing.T) {
t.Run("key pair check", func(t *testing.T) {
keyPair, err := createKeyPair()
keyPair, err := CreateKeyPair()
assert.NoError(t, err)
message := []byte("test message")
hashed := sha256.Sum256(message)
block, _ := pem.Decode(keyPair.PrivateKey)
block, _ := pem.Decode(keyPair.PrivateKey())
assert.NotNil(t, block, "failed to decode private key to PEM")
privateKey, err := x509.ParsePKCS1PrivateKey(block.Bytes)
@@ -29,7 +29,7 @@ func TestReadKey(t *testing.T) {
signature, err := rsa.SignPKCS1v15(rand.Reader, privateKey, crypto.SHA256, hashed[:])
assert.NoError(t, err, "failed to create signature")
block, _ = pem.Decode(keyPair.PublicKey)
block, _ = pem.Decode(keyPair.PublicKey())
assert.NotNil(t, block, "failed to decode public key to PEM")
pubKey, err := x509.ParsePKIXPublicKey(block.Bytes)