github.com/kubri/kubri@v0.5.1-0.20240317001612-bda2aaef967e/pkg/crypto/rsa/rsa_test.go (about)

     1  package rsa_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/google/go-cmp/cmp"
     7  
     8  	"github.com/kubri/kubri/internal/test"
     9  	"github.com/kubri/kubri/pkg/crypto/internal/cryptotest"
    10  	"github.com/kubri/kubri/pkg/crypto/rsa"
    11  )
    12  
    13  func TestRSA(t *testing.T) {
    14  	cryptotest.Test(t,
    15  		cryptotest.Implementation[*rsa.PrivateKey, *rsa.PublicKey]{
    16  			NewPrivateKey:       rsa.NewPrivateKey,
    17  			MarshalPrivateKey:   rsa.MarshalPrivateKey,
    18  			UnmarshalPrivateKey: rsa.UnmarshalPrivateKey,
    19  			Public:              rsa.Public,
    20  			MarshalPublicKey:    rsa.MarshalPublicKey,
    21  			UnmarshalPublicKey:  rsa.UnmarshalPublicKey,
    22  			Sign:                rsa.Sign,
    23  			Verify:              rsa.Verify,
    24  		},
    25  		cryptotest.WithCmpOptions(test.CompareRSAPrivateKeys()),
    26  		cryptotest.WithCmpOptions(cmp.Comparer(func(a, b *rsa.PublicKey) bool {
    27  			if a == nil || b == nil {
    28  				return a == b
    29  			}
    30  			return a.Equal(b)
    31  		})),
    32  		cryptotest.WithOpenSSLTest("dgst", "-sha1", "-verify", "public.pem", "-signature", "data.txt.sig", "data.txt"))
    33  }