MCPcopy
hub / github.com/gtank/cryptopasta / TestSignWithP384

Function TestSignWithP384

sign_test.go:83–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

81}
82
83func TestSignWithP384(t *testing.T) {
84 message := []byte("Hello, world!")
85
86 key, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader)
87 if err != nil {
88 t.Error(err)
89 return
90 }
91
92 signature, err := Sign(message, key)
93 if err != nil {
94 t.Error(err)
95 return
96 }
97
98 if !Verify(message, signature, &key.PublicKey) {
99 t.Error("signature was not correct")
100 return
101 }
102
103 message[0] ^= 0xff
104 if Verify(message, signature, &key.PublicKey) {
105 t.Error("signature was good for altered message")
106 }
107}

Callers

nothing calls this directly

Calls 2

SignFunction · 0.85
VerifyFunction · 0.85

Tested by

no test coverage detected