fix(rsa): update test for Go 1.26 GenerateKey resilience
Go 1.26 rsa.GenerateKey recovers from reader errors internally. Test now verifies no panic instead of expecting an error. Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
39643ddba0
commit
eacbb025b3
1 changed files with 3 additions and 3 deletions
|
|
@ -69,12 +69,12 @@ func TestRSA_Ugly(t *testing.T) {
|
|||
_, err = s.Decrypt([]byte("-----BEGIN RSA PRIVATE KEY-----\nMIIBOQIBAAJBAL/6j/y7/r/9/z/8/f/+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+\nv/7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v4CAwEAAQJB\nAL/6j/y7/r/9/z/8/f/+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+\nv/7+/v7+/v7+/v7+/v7+/v7+/v7+/v4CgYEA/f8/vLv+v/3/P/z9//7+/v7+/v7+\nvv7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v4C\ngYEA/f8/vLv+v/3/P/z9//7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+\nvv7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v4CgYEA/f8/vLv+v/3/P/z9//7+/v7+\nvv7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+\nv/4CgYEA/f8/vLv+v/3/P/z9//7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+\nvv7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v4CgYEA/f8/vLv+v/3/P/z9//7+/v7+\nvv7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+\nv/4=\n-----END RSA PRIVATE KEY-----"), []byte("message"), nil)
|
||||
assert.Error(t, err)
|
||||
|
||||
// Key generation failure
|
||||
// Key generation with broken reader — Go 1.26+ rsa.GenerateKey may
|
||||
// recover from reader errors internally, so we only verify it doesn't panic.
|
||||
oldReader := rand.Reader
|
||||
rand.Reader = &mockReader{}
|
||||
t.Cleanup(func() { rand.Reader = oldReader })
|
||||
_, _, err = s.GenerateKeyPair(2048)
|
||||
assert.Error(t, err)
|
||||
_, _, _ = s.GenerateKeyPair(2048)
|
||||
|
||||
// Encrypt with non-RSA key
|
||||
rand.Reader = oldReader // Restore reader for this test
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue