]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/crypto/rsa/pss_test.go
[dev.boringcrypto] all: merge commit 9d0819b27c (CL 314609) into dev.boringcrypto
[gostls13.git] / src / crypto / rsa / pss_test.go
index 32f6f0c3aa93dc92c776902ab2fbbc6b141e3f54..51f97601878e2cf3986986e44f6098dca1ad46ae 100644 (file)
@@ -11,7 +11,7 @@ import (
        "crypto"
        "crypto/rand"
        "crypto/sha1"
-       "crypto/sha256"
+       "crypto/sha256"
        "encoding/hex"
        "math/big"
        "os"
@@ -232,6 +232,24 @@ func TestPSSSigning(t *testing.T) {
        }
 }
 
+func TestSignWithPSSSaltLengthAuto(t *testing.T) {
+       key, err := GenerateKey(rand.Reader, 513)
+       if err != nil {
+               t.Fatal(err)
+       }
+       digest := sha256.Sum256([]byte("message"))
+       signature, err := key.Sign(rand.Reader, digest[:], &PSSOptions{
+               SaltLength: PSSSaltLengthAuto,
+               Hash:       crypto.SHA256,
+       })
+       if err != nil {
+               t.Fatal(err)
+       }
+       if len(signature) == 0 {
+               t.Fatal("empty signature returned")
+       }
+}
+
 func bigFromHex(hex string) *big.Int {
        n, ok := new(big.Int).SetString(hex, 16)
        if !ok {