mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 04:55:44 +01:00
Merge remote-tracking branch 'upstream-public/pr/1546' into mbedtls-2.1-proposed
This commit is contained in:
commit
b40dae5c21
@ -219,8 +219,8 @@ int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx,
|
|||||||
*
|
*
|
||||||
* \return 0 if successful,
|
* \return 0 if successful,
|
||||||
* MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid,
|
* MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid,
|
||||||
* MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if the signature is
|
* MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if there is a valid
|
||||||
* valid but its actual length is less than siglen,
|
* signature in sig but its length is less than siglen,
|
||||||
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_ERR_MPI_XXX error code
|
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_ERR_MPI_XXX error code
|
||||||
*/
|
*/
|
||||||
int mbedtls_ecdsa_read_signature( mbedtls_ecdsa_context *ctx,
|
int mbedtls_ecdsa_read_signature( mbedtls_ecdsa_context *ctx,
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80 /**< Memory allocation failed. */
|
#define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80 /**< Memory allocation failed. */
|
||||||
#define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00 /**< Generation of random value, such as (ephemeral) key, failed. */
|
#define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00 /**< Generation of random value, such as (ephemeral) key, failed. */
|
||||||
#define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80 /**< Invalid private or public key. */
|
#define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80 /**< Invalid private or public key. */
|
||||||
#define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00 /**< Signature is valid but shorter than the user-supplied length. */
|
#define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00 /**< The buffer contains a valid signature followed by more data. */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
#define MBEDTLS_ERR_PK_INVALID_ALG -0x3A80 /**< The algorithm tag or value is invalid. */
|
#define MBEDTLS_ERR_PK_INVALID_ALG -0x3A80 /**< The algorithm tag or value is invalid. */
|
||||||
#define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00 /**< Elliptic curve is unsupported (only NIST curves are supported). */
|
#define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00 /**< Elliptic curve is unsupported (only NIST curves are supported). */
|
||||||
#define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980 /**< Unavailable feature, e.g. RSA disabled for RSA key. */
|
#define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980 /**< Unavailable feature, e.g. RSA disabled for RSA key. */
|
||||||
#define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900 /**< The signature is valid but its length is less than expected. */
|
#define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900 /**< The buffer contains a valid signature followed by more data. */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -267,8 +267,8 @@ int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type );
|
|||||||
* \param sig_len Signature length
|
* \param sig_len Signature length
|
||||||
*
|
*
|
||||||
* \return 0 on success (signature is valid),
|
* \return 0 on success (signature is valid),
|
||||||
* MBEDTLS_ERR_PK_SIG_LEN_MISMATCH if the signature is
|
* #MBEDTLS_ERR_PK_SIG_LEN_MISMATCH if there is a valid
|
||||||
* valid but its actual length is less than sig_len,
|
* signature in sig but its length is less than \p siglen,
|
||||||
* or a specific error code.
|
* or a specific error code.
|
||||||
*
|
*
|
||||||
* \note For RSA keys, the default padding type is PKCS#1 v1.5.
|
* \note For RSA keys, the default padding type is PKCS#1 v1.5.
|
||||||
@ -298,10 +298,10 @@ int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
|
|||||||
* \param sig_len Signature length
|
* \param sig_len Signature length
|
||||||
*
|
*
|
||||||
* \return 0 on success (signature is valid),
|
* \return 0 on success (signature is valid),
|
||||||
* MBEDTLS_ERR_PK_TYPE_MISMATCH if the PK context can't be
|
* #MBEDTLS_ERR_PK_TYPE_MISMATCH if the PK context can't be
|
||||||
* used for this type of signatures,
|
* used for this type of signatures,
|
||||||
* MBEDTLS_ERR_PK_SIG_LEN_MISMATCH if the signature is
|
* #MBEDTLS_ERR_PK_SIG_LEN_MISMATCH if there is a valid
|
||||||
* valid but its actual length is less than sig_len,
|
* signature in sig but its length is less than \p siglen,
|
||||||
* or a specific error code.
|
* or a specific error code.
|
||||||
*
|
*
|
||||||
* \note If hash_len is 0, then the length associated with md_alg
|
* \note If hash_len is 0, then the length associated with md_alg
|
||||||
|
@ -396,6 +396,9 @@ int mbedtls_ecdsa_read_signature( mbedtls_ecdsa_context *ctx,
|
|||||||
&ctx->Q, &r, &s ) ) != 0 )
|
&ctx->Q, &r, &s ) ) != 0 )
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
/* At this point we know that the buffer starts with a valid signature.
|
||||||
|
* Return 0 if the buffer just contains the signature, and a specific
|
||||||
|
* error code if the valid signature is followed by more data. */
|
||||||
if( p != end )
|
if( p != end )
|
||||||
ret = MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH;
|
ret = MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH;
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
|
|||||||
if( use_ret == -(MBEDTLS_ERR_ECP_INVALID_KEY) )
|
if( use_ret == -(MBEDTLS_ERR_ECP_INVALID_KEY) )
|
||||||
mbedtls_snprintf( buf, buflen, "ECP - Invalid private or public key" );
|
mbedtls_snprintf( buf, buflen, "ECP - Invalid private or public key" );
|
||||||
if( use_ret == -(MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH) )
|
if( use_ret == -(MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH) )
|
||||||
mbedtls_snprintf( buf, buflen, "ECP - Signature is valid but shorter than the user-supplied length" );
|
mbedtls_snprintf( buf, buflen, "ECP - The buffer contains a valid signature followed by more data" );
|
||||||
#endif /* MBEDTLS_ECP_C */
|
#endif /* MBEDTLS_ECP_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_MD_C)
|
#if defined(MBEDTLS_MD_C)
|
||||||
@ -284,7 +284,7 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
|
|||||||
if( use_ret == -(MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE) )
|
if( use_ret == -(MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE) )
|
||||||
mbedtls_snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" );
|
mbedtls_snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" );
|
||||||
if( use_ret == -(MBEDTLS_ERR_PK_SIG_LEN_MISMATCH) )
|
if( use_ret == -(MBEDTLS_ERR_PK_SIG_LEN_MISMATCH) )
|
||||||
mbedtls_snprintf( buf, buflen, "PK - The signature is valid but its length is less than expected" );
|
mbedtls_snprintf( buf, buflen, "PK - The buffer contains a valid signature followed by more data" );
|
||||||
#endif /* MBEDTLS_PK_C */
|
#endif /* MBEDTLS_PK_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_PKCS12_C)
|
#if defined(MBEDTLS_PKCS12_C)
|
||||||
|
@ -90,6 +90,11 @@ static int rsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg,
|
|||||||
(unsigned int) hash_len, hash, sig ) ) != 0 )
|
(unsigned int) hash_len, hash, sig ) ) != 0 )
|
||||||
return( ret );
|
return( ret );
|
||||||
|
|
||||||
|
/* The buffer contains a valid signature followed by extra data.
|
||||||
|
* We have a special error code for that so that so that callers can
|
||||||
|
* use mbedtls_pk_verify() to check "Does the buffer start with a
|
||||||
|
* valid signature?" and not just "Does the buffer contain a valid
|
||||||
|
* signature?". */
|
||||||
if( sig_len > ((mbedtls_rsa_context *) ctx)->len )
|
if( sig_len > ((mbedtls_rsa_context *) ctx)->len )
|
||||||
return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH );
|
return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user