mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-11-03 20:22:59 -05:00 
			
		
		
		
	Check exactly for the RSA context fields required in rsa_private
Previously, the code was also checking for the presence of D for RSA-CRT, which is not needed in this case.
This commit is contained in:
		
							parent
							
								
									a6f5539413
								
							
						
					
					
						commit
						2fdffe0da0
					
				@ -447,14 +447,19 @@ int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /* Sanity-check that all relevant fields are at least set,
 | 
					    /* Sanity-check that all relevant fields are at least set,
 | 
				
			||||||
     * but don't perform a full keycheck. */
 | 
					     * but don't perform a full keycheck. */
 | 
				
			||||||
 | 
					#if defined(MBEDTLS_RSA_NO_CRT)
 | 
				
			||||||
    if( mbedtls_mpi_cmp_int( &ctx->N, 0 ) == 0 ||
 | 
					    if( mbedtls_mpi_cmp_int( &ctx->N, 0 ) == 0 ||
 | 
				
			||||||
        mbedtls_mpi_cmp_int( &ctx->D, 0 ) == 0 ||
 | 
					        mbedtls_mpi_cmp_int( &ctx->D, 0 ) == 0 ||
 | 
				
			||||||
        mbedtls_mpi_cmp_int( &ctx->E, 0 ) == 0 )
 | 
					        mbedtls_mpi_cmp_int( &ctx->E, 0 ) == 0 ||
 | 
				
			||||||
 | 
					        mbedtls_mpi_cmp_int( &ctx->P, 0 ) == 0 ||
 | 
				
			||||||
 | 
					        mbedtls_mpi_cmp_int( &ctx->Q, 0 ) == 0 )
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
 | 
					        return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#if !defined(MBEDTLS_RSA_NO_CRT)
 | 
					#else /* ! MBEDTLS_RSA_NO_CRT */
 | 
				
			||||||
    if( mbedtls_mpi_cmp_int( &ctx->P, 0 )  == 0 ||
 | 
					    if( mbedtls_mpi_cmp_int( &ctx->N, 0 )  == 0 ||
 | 
				
			||||||
 | 
					        mbedtls_mpi_cmp_int( &ctx->E, 0 )  == 0 ||
 | 
				
			||||||
 | 
					        mbedtls_mpi_cmp_int( &ctx->P, 0 )  == 0 ||
 | 
				
			||||||
        mbedtls_mpi_cmp_int( &ctx->Q, 0 )  == 0 ||
 | 
					        mbedtls_mpi_cmp_int( &ctx->Q, 0 )  == 0 ||
 | 
				
			||||||
        mbedtls_mpi_cmp_int( &ctx->DP, 0 ) == 0 ||
 | 
					        mbedtls_mpi_cmp_int( &ctx->DP, 0 ) == 0 ||
 | 
				
			||||||
        mbedtls_mpi_cmp_int( &ctx->DQ, 0 ) == 0 ||
 | 
					        mbedtls_mpi_cmp_int( &ctx->DQ, 0 ) == 0 ||
 | 
				
			||||||
@ -462,7 +467,7 @@ int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
 | 
					        return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif /* MBEDTLS_RSA_NO_CRT */
 | 
					#endif /* ! MBEDTLS_RSA_NO_CRT */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(MBEDTLS_THREADING_C)
 | 
					#if defined(MBEDTLS_THREADING_C)
 | 
				
			||||||
    if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
 | 
					    if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user