Skip to content

Commit ccd4446

Browse files
committed
Render bad RSA key useless for signing by setting modulus
In more recent Go versions requirements for RSA keys have been strengthened, resulting in errors when trying to generate insecure keys. In this specific test case we need a bad RSA key. Also see smallstep/cli#1483.
1 parent 1ae55e9 commit ccd4446

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

token/token_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"crypto/ed25519"
55
"crypto/rand"
66
"crypto/rsa"
7+
"math/big"
78
"reflect"
89
"testing"
910
"time"
@@ -95,10 +96,11 @@ func TestClaims_Sign(t *testing.T) {
9596
t.Fatal(err)
9697
}
9798

98-
badKey, err := rsa.GenerateKey(rand.Reader, 123)
99+
badKey, err := rsa.GenerateKey(rand.Reader, 1024)
99100
if err != nil {
100101
t.Fatal(err)
101102
}
103+
badKey.N = big.NewInt(10) // render key useless for signing
102104

103105
tests := []struct {
104106
name string

0 commit comments

Comments
 (0)