mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-05-15 02:49:39 +00:00
man: clarify the 'random number generator must be seeded' requirement
The manual pages require for some API functions that the 'random number generator must be seeded' before calling the function. Initially, this was meant literally, i.e. the OpenSSL CSPRNG had to be seeded manually before calling these functions. Since version 1.1.1, the CSPRNG is seeded automatically on first use, so it's not the responsibility of the programmer anymore. Still, he needs to be aware that the seeding might fail. Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/9257)
This commit is contained in:
parent
0588be2e01
commit
262c00882a
@ -51,7 +51,9 @@ L<openssl_user_macros(7)>:
|
|||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
BN_generate_prime_ex() generates a pseudo-random prime number of
|
BN_generate_prime_ex() generates a pseudo-random prime number of
|
||||||
at least bit length B<bits>.
|
at least bit length B<bits>. The returned number is probably prime
|
||||||
|
with a negligible error.
|
||||||
|
|
||||||
If B<ret> is not B<NULL>, it will be used to store the number.
|
If B<ret> is not B<NULL>, it will be used to store the number.
|
||||||
|
|
||||||
If B<cb> is not B<NULL>, it is used as follows:
|
If B<cb> is not B<NULL>, it is used as follows:
|
||||||
@ -89,8 +91,9 @@ generator.
|
|||||||
If B<safe> is true, it will be a safe prime (i.e. a prime p so
|
If B<safe> is true, it will be a safe prime (i.e. a prime p so
|
||||||
that (p-1)/2 is also prime).
|
that (p-1)/2 is also prime).
|
||||||
|
|
||||||
The PRNG must be seeded prior to calling BN_generate_prime_ex().
|
The random generator must be seeded prior to calling BN_generate_prime_ex().
|
||||||
The prime number generation has a negligible error probability.
|
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
|
||||||
|
external circumstances (see L<RAND(7)>), the operation will fail.
|
||||||
|
|
||||||
BN_is_prime_ex() and BN_is_prime_fasttest_ex() test if the number B<p> is
|
BN_is_prime_ex() and BN_is_prime_fasttest_ex() test if the number B<p> is
|
||||||
prime. The following tests are performed until one of them shows that
|
prime. The following tests are performed until one of them shows that
|
||||||
@ -193,7 +196,8 @@ Instead applications should create a BN_GENCB structure using BN_GENCB_new:
|
|||||||
=head1 SEE ALSO
|
=head1 SEE ALSO
|
||||||
|
|
||||||
L<DH_generate_parameters(3)>, L<DSA_generate_parameters(3)>,
|
L<DH_generate_parameters(3)>, L<DSA_generate_parameters(3)>,
|
||||||
L<RSA_generate_key(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>
|
L<RSA_generate_key(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>,
|
||||||
|
L<RAND(7)>
|
||||||
|
|
||||||
=head1 HISTORY
|
=head1 HISTORY
|
||||||
|
|
||||||
|
@ -104,9 +104,11 @@ consists of 8 bytes with odd parity. The least significant bit in
|
|||||||
each byte is the parity bit. The key schedule is an expanded form of
|
each byte is the parity bit. The key schedule is an expanded form of
|
||||||
the key; it is used to speed the encryption process.
|
the key; it is used to speed the encryption process.
|
||||||
|
|
||||||
DES_random_key() generates a random key. The PRNG must be seeded
|
DES_random_key() generates a random key. The random generator must be
|
||||||
prior to using this function (see L<RAND_bytes(3)>). If the PRNG
|
seeded when calling this function.
|
||||||
could not generate a secure key, 0 is returned.
|
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
|
||||||
|
external circumstances (see L<RAND(7)>), the operation will fail.
|
||||||
|
If the function fails, 0 is returned.
|
||||||
|
|
||||||
Before a DES key can be used, it must be converted into the
|
Before a DES key can be used, it must be converted into the
|
||||||
architecture dependent I<DES_key_schedule> via the
|
architecture dependent I<DES_key_schedule> via the
|
||||||
|
@ -15,7 +15,9 @@ DSA_generate_key - generate DSA key pair
|
|||||||
DSA_generate_key() expects B<a> to contain DSA parameters. It generates
|
DSA_generate_key() expects B<a> to contain DSA parameters. It generates
|
||||||
a new key pair and stores it in B<a-E<gt>pub_key> and B<a-E<gt>priv_key>.
|
a new key pair and stores it in B<a-E<gt>pub_key> and B<a-E<gt>priv_key>.
|
||||||
|
|
||||||
The PRNG must be seeded prior to calling DSA_generate_key().
|
The random generator must be seeded prior to calling DSA_generate_key().
|
||||||
|
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
|
||||||
|
external circumstances (see L<RAND(7)>), the operation will fail.
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
=head1 RETURN VALUES
|
||||||
|
|
||||||
|
@ -36,8 +36,10 @@ B<dsa> is the signer's public key.
|
|||||||
|
|
||||||
The B<type> parameter is ignored.
|
The B<type> parameter is ignored.
|
||||||
|
|
||||||
The PRNG must be seeded before DSA_sign() (or DSA_sign_setup())
|
The random generator must be seeded when DSA_sign() (or DSA_sign_setup())
|
||||||
is called.
|
is called.
|
||||||
|
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
|
||||||
|
external circumstances (see L<RAND(7)>), the operation will fail.
|
||||||
|
|
||||||
=head1 RETURN VALUES
|
=head1 RETURN VALUES
|
||||||
|
|
||||||
@ -54,7 +56,8 @@ Standard, DSS), ANSI X9.30
|
|||||||
=head1 SEE ALSO
|
=head1 SEE ALSO
|
||||||
|
|
||||||
L<DSA_new(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>,
|
L<DSA_new(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>,
|
||||||
L<DSA_do_sign(3)>
|
L<DSA_do_sign(3)>,
|
||||||
|
L<RAND(7)>
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
=head1 COPYRIGHT
|
||||||
|
|
||||||
|
@ -125,8 +125,9 @@ and public key algorithms. This meant that "clone" digests such as EVP_dss1()
|
|||||||
needed to be used to sign using SHA1 and DSA. This is no longer necessary and
|
needed to be used to sign using SHA1 and DSA. This is no longer necessary and
|
||||||
the use of clone digest is now discouraged.
|
the use of clone digest is now discouraged.
|
||||||
|
|
||||||
For some key types and parameters the random number generator must be seeded
|
For some key types and parameters the random number generator must be seeded.
|
||||||
or the operation will fail.
|
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
|
||||||
|
external circumstances (see L<RAND(7)>), the operation will fail.
|
||||||
|
|
||||||
The call to EVP_DigestSignFinal() internally finalizes a copy of the digest
|
The call to EVP_DigestSignFinal() internally finalizes a copy of the digest
|
||||||
context. This means that calls to EVP_DigestSignUpdate() and
|
context. This means that calls to EVP_DigestSignUpdate() and
|
||||||
@ -147,7 +148,8 @@ L<EVP_DigestVerifyInit(3)>,
|
|||||||
L<EVP_DigestInit(3)>,
|
L<EVP_DigestInit(3)>,
|
||||||
L<evp(7)>, L<HMAC(3)>, L<MD2(3)>,
|
L<evp(7)>, L<HMAC(3)>, L<MD2(3)>,
|
||||||
L<MD5(3)>, L<MDC2(3)>, L<RIPEMD160(3)>,
|
L<MD5(3)>, L<MDC2(3)>, L<RIPEMD160(3)>,
|
||||||
L<SHA1(3)>, L<dgst(1)>
|
L<SHA1(3)>, L<dgst(1)>,
|
||||||
|
L<RAND(7)>
|
||||||
|
|
||||||
=head1 HISTORY
|
=head1 HISTORY
|
||||||
|
|
||||||
|
@ -76,8 +76,9 @@ and public key algorithms. This meant that "clone" digests such as EVP_dss1()
|
|||||||
needed to be used to sign using SHA1 and DSA. This is no longer necessary and
|
needed to be used to sign using SHA1 and DSA. This is no longer necessary and
|
||||||
the use of clone digest is now discouraged.
|
the use of clone digest is now discouraged.
|
||||||
|
|
||||||
For some key types and parameters the random number generator must be seeded
|
For some key types and parameters the random number generator must be seeded.
|
||||||
or the operation will fail.
|
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
|
||||||
|
external circumstances (see L<RAND(7)>), the operation will fail.
|
||||||
|
|
||||||
The call to EVP_DigestVerifyFinal() internally finalizes a copy of the digest
|
The call to EVP_DigestVerifyFinal() internally finalizes a copy of the digest
|
||||||
context. This means that EVP_VerifyUpdate() and EVP_VerifyFinal() can
|
context. This means that EVP_VerifyUpdate() and EVP_VerifyFinal() can
|
||||||
@ -93,7 +94,8 @@ L<EVP_DigestSignInit(3)>,
|
|||||||
L<EVP_DigestInit(3)>,
|
L<EVP_DigestInit(3)>,
|
||||||
L<evp(7)>, L<HMAC(3)>, L<MD2(3)>,
|
L<evp(7)>, L<HMAC(3)>, L<MD2(3)>,
|
||||||
L<MD5(3)>, L<MDC2(3)>, L<RIPEMD160(3)>,
|
L<MD5(3)>, L<MDC2(3)>, L<RIPEMD160(3)>,
|
||||||
L<SHA1(3)>, L<dgst(1)>
|
L<SHA1(3)>, L<dgst(1)>,
|
||||||
|
L<RAND(7)>
|
||||||
|
|
||||||
=head1 HISTORY
|
=head1 HISTORY
|
||||||
|
|
||||||
|
@ -55,7 +55,9 @@ failure.
|
|||||||
=head1 NOTES
|
=head1 NOTES
|
||||||
|
|
||||||
Because a random secret key is generated the random number generator
|
Because a random secret key is generated the random number generator
|
||||||
must be seeded before calling EVP_SealInit().
|
must be seeded when EVP_SealInit() is called.
|
||||||
|
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
|
||||||
|
external circumstances (see L<RAND(7)>), the operation will fail.
|
||||||
|
|
||||||
The public key must be RSA because it is the only OpenSSL public key
|
The public key must be RSA because it is the only OpenSSL public key
|
||||||
algorithm that supports key transport.
|
algorithm that supports key transport.
|
||||||
@ -75,7 +77,8 @@ with B<type> set to NULL.
|
|||||||
|
|
||||||
L<evp(7)>, L<RAND_bytes(3)>,
|
L<evp(7)>, L<RAND_bytes(3)>,
|
||||||
L<EVP_EncryptInit(3)>,
|
L<EVP_EncryptInit(3)>,
|
||||||
L<EVP_OpenInit(3)>
|
L<EVP_OpenInit(3)>,
|
||||||
|
L<RAND(7)>
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
=head1 COPYRIGHT
|
||||||
|
|
||||||
|
@ -66,9 +66,10 @@ The B<EVP> interface to digital signatures should almost always be used in
|
|||||||
preference to the low level interfaces. This is because the code then becomes
|
preference to the low level interfaces. This is because the code then becomes
|
||||||
transparent to the algorithm used and much more flexible.
|
transparent to the algorithm used and much more flexible.
|
||||||
|
|
||||||
When signing with DSA private keys the random number generator must be seeded
|
When signing with DSA private keys the random number generator must be seeded.
|
||||||
or the operation will fail. The random number generator does not need to be
|
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
|
||||||
seeded for RSA signatures.
|
external circumstances (see L<RAND(7)>), the operation will fail.
|
||||||
|
This requirement does not hold for RSA signatures.
|
||||||
|
|
||||||
The call to EVP_SignFinal() internally finalizes a copy of the digest context.
|
The call to EVP_SignFinal() internally finalizes a copy of the digest context.
|
||||||
This means that calls to EVP_SignUpdate() and EVP_SignFinal() can be called
|
This means that calls to EVP_SignUpdate() and EVP_SignFinal() can be called
|
||||||
|
@ -20,8 +20,7 @@ must be used to protect the RSA operation from that attack.
|
|||||||
|
|
||||||
RSA_blinding_on() turns blinding on for key B<rsa> and generates a
|
RSA_blinding_on() turns blinding on for key B<rsa> and generates a
|
||||||
random blinding factor. B<ctx> is B<NULL> or a pre-allocated and
|
random blinding factor. B<ctx> is B<NULL> or a pre-allocated and
|
||||||
initialized B<BN_CTX>. The random number generator must be seeded
|
initialized B<BN_CTX>.
|
||||||
prior to calling RSA_blinding_on().
|
|
||||||
|
|
||||||
RSA_blinding_off() turns blinding off and frees the memory used for
|
RSA_blinding_off() turns blinding off and frees the memory used for
|
||||||
the blinding factor.
|
the blinding factor.
|
||||||
|
@ -27,8 +27,10 @@ be seeded prior to calling RSA_generate_key_ex().
|
|||||||
|
|
||||||
RSA_generate_multi_prime_key() generates a multi-prime RSA key pair and stores
|
RSA_generate_multi_prime_key() generates a multi-prime RSA key pair and stores
|
||||||
it in the B<RSA> structure provided in B<rsa>. The number of primes is given by
|
it in the B<RSA> structure provided in B<rsa>. The number of primes is given by
|
||||||
the B<primes> parameter. The pseudo-random number generator must be seeded prior
|
the B<primes> parameter. The random number generator must be seeded when
|
||||||
to calling RSA_generate_multi_prime_key().
|
calling RSA_generate_multi_prime_key().
|
||||||
|
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
|
||||||
|
external circumstances (see L<RAND(7)>), the operation will fail.
|
||||||
|
|
||||||
The modulus size will be of length B<bits>, the number of primes to form the
|
The modulus size will be of length B<bits>, the number of primes to form the
|
||||||
modulus will be B<primes>, and the public exponent will be B<e>. Key sizes
|
modulus will be B<primes>, and the public exponent will be B<e>. Key sizes
|
||||||
@ -88,7 +90,8 @@ B<BN_GENCB_call(cb, 2, x)> is used with two different meanings.
|
|||||||
|
|
||||||
=head1 SEE ALSO
|
=head1 SEE ALSO
|
||||||
|
|
||||||
L<ERR_get_error(3)>, L<RAND_bytes(3)>, L<BN_generate_prime(3)>
|
L<ERR_get_error(3)>, L<RAND_bytes(3)>, L<BN_generate_prime(3)>,
|
||||||
|
L<RAND(7)>
|
||||||
|
|
||||||
=head1 HISTORY
|
=head1 HISTORY
|
||||||
|
|
||||||
|
@ -100,6 +100,8 @@ simply copy the data
|
|||||||
|
|
||||||
The random number generator must be seeded prior to calling
|
The random number generator must be seeded prior to calling
|
||||||
RSA_padding_add_xxx().
|
RSA_padding_add_xxx().
|
||||||
|
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
|
||||||
|
external circumstances (see L<RAND(7)>), the operation will fail.
|
||||||
|
|
||||||
RSA_padding_check_xxx() verifies that the B<fl> bytes at B<f> contain
|
RSA_padding_check_xxx() verifies that the B<fl> bytes at B<f> contain
|
||||||
a valid encoding for a B<rsa_len> byte RSA key in the respective
|
a valid encoding for a B<rsa_len> byte RSA key in the respective
|
||||||
@ -143,7 +145,8 @@ including PKCS1_OAEP.
|
|||||||
|
|
||||||
L<RSA_public_encrypt(3)>,
|
L<RSA_public_encrypt(3)>,
|
||||||
L<RSA_private_decrypt(3)>,
|
L<RSA_private_decrypt(3)>,
|
||||||
L<RSA_sign(3)>, L<RSA_verify(3)>
|
L<RSA_sign(3)>, L<RSA_verify(3)>,
|
||||||
|
L<RAND(7)>
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
=head1 COPYRIGHT
|
||||||
|
|
||||||
|
@ -26,7 +26,10 @@ memory.
|
|||||||
|
|
||||||
B<dummy> is ignored.
|
B<dummy> is ignored.
|
||||||
|
|
||||||
The random number generator must be seeded prior to calling RSA_sign_ASN1_OCTET_STRING().
|
The random number generator must be seeded when calling
|
||||||
|
RSA_sign_ASN1_OCTET_STRING().
|
||||||
|
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
|
||||||
|
external circumstances (see L<RAND(7)>), the operation will fail.
|
||||||
|
|
||||||
RSA_verify_ASN1_OCTET_STRING() verifies that the signature B<sigbuf>
|
RSA_verify_ASN1_OCTET_STRING() verifies that the signature B<sigbuf>
|
||||||
of size B<siglen> is the DER representation of a given octet string
|
of size B<siglen> is the DER representation of a given octet string
|
||||||
@ -49,7 +52,8 @@ These functions serve no recognizable purpose.
|
|||||||
|
|
||||||
L<ERR_get_error(3)>,
|
L<ERR_get_error(3)>,
|
||||||
L<RAND_bytes(3)>, L<RSA_sign(3)>,
|
L<RAND_bytes(3)>, L<RSA_sign(3)>,
|
||||||
L<RSA_verify(3)>
|
L<RSA_verify(3)>,
|
||||||
|
L<RAND(7)>
|
||||||
|
|
||||||
=head1 COPYRIGHT
|
=head1 COPYRIGHT
|
||||||
|
|
||||||
|
@ -28,6 +28,12 @@ As a normal application developer, you do not have to worry about any details,
|
|||||||
just use L<RAND_bytes(3)> to obtain random data.
|
just use L<RAND_bytes(3)> to obtain random data.
|
||||||
Having said that, there is one important rule to obey: Always check the error
|
Having said that, there is one important rule to obey: Always check the error
|
||||||
return value of L<RAND_bytes(3)> and do not take randomness for granted.
|
return value of L<RAND_bytes(3)> and do not take randomness for granted.
|
||||||
|
Although (re-)seeding is automatic, it can fail because no trusted random source
|
||||||
|
is available or the trusted source(s) temporarily fail to provide sufficient
|
||||||
|
random seed material.
|
||||||
|
In this case the CSPRNG enters an error state and ceases to provide output,
|
||||||
|
until it is able to recover from the error by reseeding itself.
|
||||||
|
For more details on reseeding and error recovery, see L<RAND_DRBG(7)>.
|
||||||
|
|
||||||
For values that should remain secret, you can use L<RAND_priv_bytes(3)>
|
For values that should remain secret, you can use L<RAND_priv_bytes(3)>
|
||||||
instead.
|
instead.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user