(t *testing.T)
| 72 | } |
| 73 | |
| 74 | func TestRSAPSSSign(t *testing.T) { |
| 75 | var err error |
| 76 | |
| 77 | key, _ := os.ReadFile("test/sample_key") |
| 78 | var rsaPSSKey *rsa.PrivateKey |
| 79 | if rsaPSSKey, err = jwt.ParseRSAPrivateKeyFromPEM(key); err != nil { |
| 80 | t.Errorf("Unable to parse RSA private key: %v", err) |
| 81 | } |
| 82 | |
| 83 | for _, data := range rsaPSSTestData { |
| 84 | if !data.valid { |
| 85 | continue |
| 86 | } |
| 87 | parts := strings.Split(data.tokenString, ".") |
| 88 | method := jwt.GetSigningMethod(data.alg) |
| 89 | sig, err := method.Sign(strings.Join(parts[0:2], "."), rsaPSSKey) |
| 90 | if err != nil { |
| 91 | t.Errorf("[%v] Error signing token: %v", data.name, err) |
| 92 | } |
| 93 | |
| 94 | ssig := encodeSegment(sig) |
| 95 | if ssig == parts[2] { |
| 96 | t.Errorf("[%v] Signatures shouldn't match\nnew:\n%v\noriginal:\n%v", data.name, ssig, parts[2]) |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | func TestRSAPSSSaltLengthCompatibility(t *testing.T) { |
| 102 | // Fails token verify, if salt length is auto. |
nothing calls this directly
no test coverage detected