mirror of
https://github.com/cuberite/polarssl.git
synced 2025-11-11 16:34:20 -05:00
RSA: Require hashlen to match md_alg when applicable
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
parent
ab97e003f3
commit
e7885e5441
4
ChangeLog.d/require-matching-hashlen-rsa.txt
Normal file
4
ChangeLog.d/require-matching-hashlen-rsa.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
API changes
|
||||||
|
* Functions in the RSA module that accept a hashlen parameter now require
|
||||||
|
it to match the output size of the hash algorithm used, except when
|
||||||
|
signing raw data.
|
||||||
13
docs/3.0-migration-guide.d/require-matching-hashlen-rsa.md
Normal file
13
docs/3.0-migration-guide.d/require-matching-hashlen-rsa.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
RSA signature functions now require `hashlen` to match the expected value
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
This only affects users of the low-level RSA API; users of the high-level PK
|
||||||
|
API or of the PSA Crypto API are not affected.
|
||||||
|
|
||||||
|
All the functions in the RSA module that accept a `hashlen` parameter used to
|
||||||
|
ignore it unless the `md_alg` parameter was `MBEDTLS_MD_NONE`, indicating raw
|
||||||
|
data was signed. They now require this parameter's value to be equal to the
|
||||||
|
output size of the hash algorithm used when signing a hash. (The requirements
|
||||||
|
when signing raw data are unchanged.)
|
||||||
|
|
||||||
|
The migration path is to pass the correct value to those functions.
|
||||||
@ -796,13 +796,11 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
|
|||||||
* if \p f_rng doesn't need a context argument.
|
* if \p f_rng doesn't need a context argument.
|
||||||
* \param md_alg The message-digest algorithm used to hash the original data.
|
* \param md_alg The message-digest algorithm used to hash the original data.
|
||||||
* Use #MBEDTLS_MD_NONE for signing raw data.
|
* Use #MBEDTLS_MD_NONE for signing raw data.
|
||||||
* \param hashlen The length of the message digest.
|
* \param hashlen The length of the message digest or raw data in Bytes.
|
||||||
* Ths is only used if \p md_alg is #MBEDTLS_MD_NONE.
|
* If \p md_alg is not #MBEDTLS_MD_NONE, this must match the
|
||||||
|
* output length of the corresponding hash algorithm.
|
||||||
* \param hash The buffer holding the message digest or raw data.
|
* \param hash The buffer holding the message digest or raw data.
|
||||||
* If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable
|
* This must be a readable buffer of at least \p hashlen Bytes.
|
||||||
* buffer of length \p hashlen Bytes. If \p md_alg is not
|
|
||||||
* #MBEDTLS_MD_NONE, it must be a readable buffer of length
|
|
||||||
* the size of the hash corresponding to \p md_alg.
|
|
||||||
* \param sig The buffer to hold the signature. This must be a writable
|
* \param sig The buffer to hold the signature. This must be a writable
|
||||||
* buffer of length \c ctx->len Bytes. For example, \c 256 Bytes
|
* buffer of length \c ctx->len Bytes. For example, \c 256 Bytes
|
||||||
* for an 2048-bit RSA modulus. A buffer length of
|
* for an 2048-bit RSA modulus. A buffer length of
|
||||||
@ -830,13 +828,11 @@ int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx,
|
|||||||
* if \p f_rng doesn't need a context argument.
|
* if \p f_rng doesn't need a context argument.
|
||||||
* \param md_alg The message-digest algorithm used to hash the original data.
|
* \param md_alg The message-digest algorithm used to hash the original data.
|
||||||
* Use #MBEDTLS_MD_NONE for signing raw data.
|
* Use #MBEDTLS_MD_NONE for signing raw data.
|
||||||
* \param hashlen The length of the message digest.
|
* \param hashlen The length of the message digest or raw data in Bytes.
|
||||||
* Ths is only used if \p md_alg is #MBEDTLS_MD_NONE.
|
* If \p md_alg is not #MBEDTLS_MD_NONE, this must match the
|
||||||
|
* output length of the corresponding hash algorithm.
|
||||||
* \param hash The buffer holding the message digest or raw data.
|
* \param hash The buffer holding the message digest or raw data.
|
||||||
* If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable
|
* This must be a readable buffer of at least \p hashlen Bytes.
|
||||||
* buffer of length \p hashlen Bytes. If \p md_alg is not
|
|
||||||
* #MBEDTLS_MD_NONE, it must be a readable buffer of length
|
|
||||||
* the size of the hash corresponding to \p md_alg.
|
|
||||||
* \param sig The buffer to hold the signature. This must be a writable
|
* \param sig The buffer to hold the signature. This must be a writable
|
||||||
* buffer of length \c ctx->len Bytes. For example, \c 256 Bytes
|
* buffer of length \c ctx->len Bytes. For example, \c 256 Bytes
|
||||||
* for an 2048-bit RSA modulus. A buffer length of
|
* for an 2048-bit RSA modulus. A buffer length of
|
||||||
@ -878,13 +874,11 @@ int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx,
|
|||||||
* if \p f_rng doesn't need a context argument.
|
* if \p f_rng doesn't need a context argument.
|
||||||
* \param md_alg The message-digest algorithm used to hash the original data.
|
* \param md_alg The message-digest algorithm used to hash the original data.
|
||||||
* Use #MBEDTLS_MD_NONE for signing raw data.
|
* Use #MBEDTLS_MD_NONE for signing raw data.
|
||||||
* \param hashlen The length of the message digest.
|
* \param hashlen The length of the message digest or raw data in Bytes.
|
||||||
* Ths is only used if \p md_alg is #MBEDTLS_MD_NONE.
|
* If \p md_alg is not #MBEDTLS_MD_NONE, this must match the
|
||||||
|
* output length of the corresponding hash algorithm.
|
||||||
* \param hash The buffer holding the message digest or raw data.
|
* \param hash The buffer holding the message digest or raw data.
|
||||||
* If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable
|
* This must be a readable buffer of at least \p hashlen Bytes.
|
||||||
* buffer of length \p hashlen Bytes. If \p md_alg is not
|
|
||||||
* #MBEDTLS_MD_NONE, it must be a readable buffer of length
|
|
||||||
* the size of the hash corresponding to \p md_alg.
|
|
||||||
* \param saltlen The length of the salt that should be used.
|
* \param saltlen The length of the salt that should be used.
|
||||||
* If passed #MBEDTLS_RSA_SALT_LEN_ANY, the function will use
|
* If passed #MBEDTLS_RSA_SALT_LEN_ANY, the function will use
|
||||||
* the largest possible salt length up to the hash length,
|
* the largest possible salt length up to the hash length,
|
||||||
@ -935,13 +929,11 @@ int mbedtls_rsa_rsassa_pss_sign_ext( mbedtls_rsa_context *ctx,
|
|||||||
* if \p f_rng doesn't need a context argument.
|
* if \p f_rng doesn't need a context argument.
|
||||||
* \param md_alg The message-digest algorithm used to hash the original data.
|
* \param md_alg The message-digest algorithm used to hash the original data.
|
||||||
* Use #MBEDTLS_MD_NONE for signing raw data.
|
* Use #MBEDTLS_MD_NONE for signing raw data.
|
||||||
* \param hashlen The length of the message digest.
|
* \param hashlen The length of the message digest or raw data in Bytes.
|
||||||
* This is only used if \p md_alg is #MBEDTLS_MD_NONE.
|
* If \p md_alg is not #MBEDTLS_MD_NONE, this must match the
|
||||||
|
* output length of the corresponding hash algorithm.
|
||||||
* \param hash The buffer holding the message digest or raw data.
|
* \param hash The buffer holding the message digest or raw data.
|
||||||
* If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable
|
* This must be a readable buffer of at least \p hashlen Bytes.
|
||||||
* buffer of length \p hashlen Bytes. If \p md_alg is not
|
|
||||||
* #MBEDTLS_MD_NONE, it must be a readable buffer of length
|
|
||||||
* the size of the hash corresponding to \p md_alg.
|
|
||||||
* \param sig The buffer to hold the signature. This must be a writable
|
* \param sig The buffer to hold the signature. This must be a writable
|
||||||
* buffer of length \c ctx->len Bytes. For example, \c 256 Bytes
|
* buffer of length \c ctx->len Bytes. For example, \c 256 Bytes
|
||||||
* for an 2048-bit RSA modulus. A buffer length of
|
* for an 2048-bit RSA modulus. A buffer length of
|
||||||
@ -972,13 +964,11 @@ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx,
|
|||||||
* \param ctx The initialized RSA public key context to use.
|
* \param ctx The initialized RSA public key context to use.
|
||||||
* \param md_alg The message-digest algorithm used to hash the original data.
|
* \param md_alg The message-digest algorithm used to hash the original data.
|
||||||
* Use #MBEDTLS_MD_NONE for signing raw data.
|
* Use #MBEDTLS_MD_NONE for signing raw data.
|
||||||
* \param hashlen The length of the message digest.
|
* \param hashlen The length of the message digest or raw data in Bytes.
|
||||||
* This is only used if \p md_alg is #MBEDTLS_MD_NONE.
|
* If \p md_alg is not #MBEDTLS_MD_NONE, this must match the
|
||||||
|
* output length of the corresponding hash algorithm.
|
||||||
* \param hash The buffer holding the message digest or raw data.
|
* \param hash The buffer holding the message digest or raw data.
|
||||||
* If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable
|
* This must be a readable buffer of at least \p hashlen Bytes.
|
||||||
* buffer of length \p hashlen Bytes. If \p md_alg is not
|
|
||||||
* #MBEDTLS_MD_NONE, it must be a readable buffer of length
|
|
||||||
* the size of the hash corresponding to \p md_alg.
|
|
||||||
* \param sig The buffer holding the signature. This must be a readable
|
* \param sig The buffer holding the signature. This must be a readable
|
||||||
* buffer of length \c ctx->len Bytes. For example, \c 256 Bytes
|
* buffer of length \c ctx->len Bytes. For example, \c 256 Bytes
|
||||||
* for an 2048-bit RSA modulus.
|
* for an 2048-bit RSA modulus.
|
||||||
@ -999,13 +989,11 @@ int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx,
|
|||||||
* \param ctx The initialized RSA public key context to use.
|
* \param ctx The initialized RSA public key context to use.
|
||||||
* \param md_alg The message-digest algorithm used to hash the original data.
|
* \param md_alg The message-digest algorithm used to hash the original data.
|
||||||
* Use #MBEDTLS_MD_NONE for signing raw data.
|
* Use #MBEDTLS_MD_NONE for signing raw data.
|
||||||
* \param hashlen The length of the message digest.
|
* \param hashlen The length of the message digest or raw data in Bytes.
|
||||||
* This is only used if \p md_alg is #MBEDTLS_MD_NONE.
|
* If \p md_alg is not #MBEDTLS_MD_NONE, this must match the
|
||||||
|
* output length of the corresponding hash algorithm.
|
||||||
* \param hash The buffer holding the message digest or raw data.
|
* \param hash The buffer holding the message digest or raw data.
|
||||||
* If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable
|
* This must be a readable buffer of at least \p hashlen Bytes.
|
||||||
* buffer of length \p hashlen Bytes. If \p md_alg is not
|
|
||||||
* #MBEDTLS_MD_NONE, it must be a readable buffer of length
|
|
||||||
* the size of the hash corresponding to \p md_alg.
|
|
||||||
* \param sig The buffer holding the signature. This must be a readable
|
* \param sig The buffer holding the signature. This must be a readable
|
||||||
* buffer of length \c ctx->len Bytes. For example, \c 256 Bytes
|
* buffer of length \c ctx->len Bytes. For example, \c 256 Bytes
|
||||||
* for an 2048-bit RSA modulus.
|
* for an 2048-bit RSA modulus.
|
||||||
@ -1036,13 +1024,11 @@ int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx,
|
|||||||
* \param ctx The initialized RSA public key context to use.
|
* \param ctx The initialized RSA public key context to use.
|
||||||
* \param md_alg The message-digest algorithm used to hash the original data.
|
* \param md_alg The message-digest algorithm used to hash the original data.
|
||||||
* Use #MBEDTLS_MD_NONE for signing raw data.
|
* Use #MBEDTLS_MD_NONE for signing raw data.
|
||||||
* \param hashlen The length of the message digest.
|
* \param hashlen The length of the message digest or raw data in Bytes.
|
||||||
* This is only used if \p md_alg is #MBEDTLS_MD_NONE.
|
* If \p md_alg is not #MBEDTLS_MD_NONE, this must match the
|
||||||
|
* output length of the corresponding hash algorithm.
|
||||||
* \param hash The buffer holding the message digest or raw data.
|
* \param hash The buffer holding the message digest or raw data.
|
||||||
* If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable
|
* This must be a readable buffer of at least \p hashlen Bytes.
|
||||||
* buffer of length \p hashlen Bytes. If \p md_alg is not
|
|
||||||
* #MBEDTLS_MD_NONE, it must be a readable buffer of length
|
|
||||||
* the size of the hash corresponding to \p md_alg.
|
|
||||||
* \param sig The buffer holding the signature. This must be a readable
|
* \param sig The buffer holding the signature. This must be a readable
|
||||||
* buffer of length \c ctx->len Bytes. For example, \c 256 Bytes
|
* buffer of length \c ctx->len Bytes. For example, \c 256 Bytes
|
||||||
* for an 2048-bit RSA modulus.
|
* for an 2048-bit RSA modulus.
|
||||||
@ -1069,13 +1055,11 @@ int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx,
|
|||||||
* \param ctx The initialized RSA public key context to use.
|
* \param ctx The initialized RSA public key context to use.
|
||||||
* \param md_alg The message-digest algorithm used to hash the original data.
|
* \param md_alg The message-digest algorithm used to hash the original data.
|
||||||
* Use #MBEDTLS_MD_NONE for signing raw data.
|
* Use #MBEDTLS_MD_NONE for signing raw data.
|
||||||
* \param hashlen The length of the message digest.
|
* \param hashlen The length of the message digest or raw data in Bytes.
|
||||||
* This is only used if \p md_alg is #MBEDTLS_MD_NONE.
|
* If \p md_alg is not #MBEDTLS_MD_NONE, this must match the
|
||||||
|
* output length of the corresponding hash algorithm.
|
||||||
* \param hash The buffer holding the message digest or raw data.
|
* \param hash The buffer holding the message digest or raw data.
|
||||||
* If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable
|
* This must be a readable buffer of at least \p hashlen Bytes.
|
||||||
* buffer of length \p hashlen Bytes. If \p md_alg is not
|
|
||||||
* #MBEDTLS_MD_NONE, it must be a readable buffer of length
|
|
||||||
* the size of the hash corresponding to \p md_alg.
|
|
||||||
* \param mgf1_hash_id The message digest algorithm used for the
|
* \param mgf1_hash_id The message digest algorithm used for the
|
||||||
* verification operation and the mask generation
|
* verification operation and the mask generation
|
||||||
* function (MGF1). For more details on the encoding
|
* function (MGF1). For more details on the encoding
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user