mirror of
https://github.com/openssl/openssl.git
synced 2025-01-06 13:26:43 +08:00
6c73ca4a2f
FIPS 186-4 section 5 "The RSA Digital Signature Algorithm", subsection 5.5 "PKCS #1" says: "For RSASSA-PSS […] the length (in bytes) of the salt (sLen) shall satisfy 0 <= sLen <= hLen, where hLen is the length of the hash function output block (in bytes)." Introduce a new option RSA_PSS_SALTLEN_AUTO_DIGEST_MAX and make it the default. The new value will behave like RSA_PSS_SALTLEN_AUTO, but will not use more than the digest length when signing, so that FIPS 186-4 is not violated. This value has two advantages when compared with RSA_PSS_SALTLEN_DIGEST: (1) It will continue to do auto-detection when verifying signatures for maximum compatibility, where RSA_PSS_SALTLEN_DIGEST would fail for other digest sizes. (2) It will work for combinations where the maximum salt length is smaller than the digest size, which typically happens with large digest sizes (e.g., SHA-512) and small RSA keys. J.-S. Coron shows in "Optimal Security Proofs for PSS and Other Signature Schemes. Advances in Cryptology – Eurocrypt 2002, volume 2332 of Lecture Notes in Computer Science, pp. 272 – 287. Springer Verlag, 2002." that longer salts than the output size of modern hash functions do not increase security: "For example,for an application in which at most one billion signatures will be generated, k0 = 30 bits of random salt are actually sufficient to guarantee the same level of security as RSA, and taking a larger salt does not increase the security level." Signed-off-by: Clemens Lang <cllang@redhat.com> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19724)
100 lines
4.3 KiB
Bash
100 lines
4.3 KiB
Bash
#!/bin/sh
|
|
# Copyright 2013-2021 The OpenSSL Project Authors. All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
# in the file LICENSE in the source distribution or at
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
|
# Utility to recreate S/MIME certificates
|
|
|
|
OPENSSL=../../apps/openssl
|
|
OPENSSL_CONF=./ca.cnf
|
|
export OPENSSL_CONF
|
|
|
|
# Root CA: create certificate directly
|
|
CN="Test S/MIME RSA Root" $OPENSSL req -config ca.cnf -x509 -noenc \
|
|
-keyout smroot.pem -out smroot.pem -newkey rsa:2048 -days 36501
|
|
|
|
# EE RSA certificates: create request first
|
|
CN="Test S/MIME EE RSA #1" $OPENSSL req -config ca.cnf -noenc \
|
|
-keyout smrsa1.pem -out req.pem -newkey rsa:2048
|
|
# Sign request: end entity extensions
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smrsa1.pem
|
|
|
|
CN="Test S/MIME EE RSA #2" $OPENSSL req -config ca.cnf -noenc \
|
|
-keyout smrsa2.pem -out req.pem -newkey rsa:2048
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smrsa2.pem
|
|
|
|
CN="Test S/MIME EE RSA #3" $OPENSSL req -config ca.cnf -noenc \
|
|
-keyout smrsa3.pem -out req.pem -newkey rsa:2048
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smrsa3.pem
|
|
|
|
CN="Test S/MIME EE RSA 1024" $OPENSSL req -config ca.cnf -noenc \
|
|
-keyout smrsa1024.pem -out req.pem -newkey rsa:1024
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smrsa1024.pem
|
|
|
|
# Create DSA parameters
|
|
|
|
$OPENSSL dsaparam -out dsap.pem 2048
|
|
|
|
CN="Test S/MIME EE DSA #1" $OPENSSL req -config ca.cnf -noenc \
|
|
-keyout smdsa1.pem -out req.pem -newkey dsa:dsap.pem
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smdsa1.pem
|
|
CN="Test S/MIME EE DSA #2" $OPENSSL req -config ca.cnf -noenc \
|
|
-keyout smdsa2.pem -out req.pem -newkey dsa:dsap.pem
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smdsa2.pem
|
|
CN="Test S/MIME EE DSA #3" $OPENSSL req -config ca.cnf -noenc \
|
|
-keyout smdsa3.pem -out req.pem -newkey dsa:dsap.pem
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smdsa3.pem
|
|
|
|
# Create EC parameters
|
|
|
|
$OPENSSL ecparam -out ecp.pem -name P-256
|
|
$OPENSSL ecparam -out ecp2.pem -name K-283
|
|
|
|
CN="Test S/MIME EE EC #1" $OPENSSL req -config ca.cnf -noenc \
|
|
-keyout smec1.pem -out req.pem -newkey ec:ecp.pem
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smec1.pem
|
|
CN="Test S/MIME EE EC #2" $OPENSSL req -config ca.cnf -noenc \
|
|
-keyout smec2.pem -out req.pem -newkey ec:ecp2.pem
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smec2.pem
|
|
# Do not renew this cert as it is used for legacy data decrypt test
|
|
#CN="Test S/MIME EE EC #3" $OPENSSL req -config ca.cnf -noenc \
|
|
# -keyout smec3.pem -out req.pem -newkey ec:ecp.pem
|
|
#$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
|
|
# -extfile ca.cnf -extensions usr_cert -CAcreateserial >>smec3.pem
|
|
# Create X9.42 DH parameters.
|
|
$OPENSSL genpkey -genparam -algorithm DHX -out dhp.pem
|
|
# Generate X9.42 DH key.
|
|
$OPENSSL genpkey -paramfile dhp.pem -out smdh.pem
|
|
$OPENSSL pkey -pubout -in smdh.pem -out dhpub.pem
|
|
# Generate dummy request.
|
|
CN="Test S/MIME EE DH #1" $OPENSSL req -config ca.cnf -noenc \
|
|
-keyout smtmp.pem -out req.pem -newkey rsa:2048
|
|
# Sign request but force public key to DH
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
|
|
-force_pubkey dhpub.pem \
|
|
-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smdh.pem
|
|
|
|
# EE RSA code signing certificates: create request first
|
|
CN="Test CodeSign EE RSA #1" $OPENSSL req -config ca.cnf -noenc \
|
|
-new -out req.pem -key ../certs/ee-key.pem
|
|
cat ../certs/ee-key.pem > csrsa1.pem
|
|
# Sign request: end entity extensions
|
|
$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36524 -extfile ca.cnf \
|
|
-extensions codesign_cert >>csrsa1.pem
|
|
|
|
# Remove temp files.
|
|
rm -f req.pem ecp.pem ecp2.pem dsap.pem dhp.pem dhpub.pem smtmp.pem smroot.srl
|