"veyron2/security": CreatePrincipal
Allow CreatePrincipal to take a nil BlessingStore and/or a nil
BlessingRoots. This simplifies principal creation within tests
that just need a principal for private key operations. Also it
provides other packages that need a signer (e.g., serialization)
to cheaply obtain one by creating a principal.
Change-Id: I7ad0ecc92f858cc4af923f14242d488d27e7a2ad
diff --git a/security/serialization/serialization_test.go b/security/serialization/serialization_test.go
index 0ee4df8..5a4dcd4 100644
--- a/security/serialization/serialization_test.go
+++ b/security/serialization/serialization_test.go
@@ -50,19 +50,16 @@
return ioutil.ReadAll(vr)
}
-type signerAdapter struct {
- s security.Signer
-}
-
-func (s signerAdapter) Sign(message []byte) (security.Signature, error) { return s.s.Sign(nil, message) }
-func (s signerAdapter) PublicKey() security.PublicKey { return s.s.PublicKey() }
-
func newSigner() Signer {
key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
panic(err)
}
- return signerAdapter{security.NewInMemoryECDSASigner(key)}
+ p, err := security.CreatePrincipal(security.NewInMemoryECDSASigner(key), nil, nil)
+ if err != nil {
+ panic(err)
+ }
+ return p
}
func matchesErrorPattern(err error, pattern string) bool {