Skip to content

Commit 55424ac

Browse files
committed
Init N of PublicKey to avoid NPE panic
1 parent 8855a56 commit 55424ac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/crypto/rsa/pkcs1v15_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"encoding/hex"
1717
"encoding/pem"
1818
"io"
19+
"math/big"
1920
"testing"
2021
"testing/quick"
2122
)
@@ -217,7 +218,12 @@ func TestSignPKCS1v15WithPrivateKeySizeZero(t *testing.T) {
217218
h := sha1.New()
218219
h.Write([]byte("key"))
219220
digest := h.Sum(nil)
220-
_, err := SignPKCS1v15(nil, &PrivateKey{PublicKey: PublicKey{}}, crypto.SHA1, digest)
221+
_, err := SignPKCS1v15(nil,
222+
&PrivateKey{
223+
PublicKey: PublicKey{
224+
N: big.NewInt(0),
225+
},
226+
}, crypto.SHA1, digest)
221227
if err == nil {
222228
t.Error("expected error but got nil")
223229
}

0 commit comments

Comments
 (0)