fix signature printing routines
[openssl.git] / crypto / rsa / rsa_ameth.c
index 4daeca18a99df60524ed46e4d5a2a89c05720645..2460910ab2783e5dc198e6437462a18e32f7f9b8 100644 (file)
@@ -400,6 +400,8 @@ static int rsa_sig_print(BIO *bp, const X509_ALGOR *sigalg,
                if (!rv)
                        return 0;
                }
+       else if (!sig && BIO_puts(bp, "\n") <= 0)
+               return 0;
        if (sig)
                return X509_signature_dump(bp, sig, indent);
        return 1;
@@ -530,6 +532,15 @@ static int rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
        else
                saltlen = 20;
 
+       /* low-level routines support only trailer field 0xbc (value 1)
+        * and PKCS#1 says we should reject any other value anyway.
+        */
+       if (pss->trailerField && ASN1_INTEGER_get(pss->trailerField) != 1)
+               {
+               RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_INVALID_TRAILER);
+               goto err;
+               }
+
        /* We have all parameters now set up context */
 
        if (!EVP_DigestVerifyInit(ctx, &pkctx, md, NULL, pkey))
@@ -579,7 +590,11 @@ static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
                if (saltlen == -1)
                        saltlen = EVP_MD_size(sigmd);
                else if (saltlen == -2)
+                       {
                        saltlen = EVP_PKEY_size(pk) - EVP_MD_size(sigmd) - 2;
+                       if (((EVP_PKEY_bits(pk) - 1) & 0x7) == 0)
+                               saltlen--;
+                       }
                pss = RSA_PSS_PARAMS_new();
                if (!pss)
                        goto err;