mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-05 22:19:11 +01:00
Move from SHA-1 to SHA-256 as default in programs
This commit is contained in:
parent
70dbfaa9ea
commit
6f60cd848b
11 changed files with 58 additions and 56 deletions
|
|
@ -45,7 +45,7 @@
|
|||
#endif
|
||||
|
||||
#if !defined(POLARSSL_BIGNUM_C) || \
|
||||
!defined(POLARSSL_SHA1_C) || !defined(POLARSSL_PK_PARSE_C) || \
|
||||
!defined(POLARSSL_SHA256_C) || !defined(POLARSSL_PK_PARSE_C) || \
|
||||
!defined(POLARSSL_FS_IO)
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
|
|
@ -53,7 +53,7 @@ int main( int argc, char *argv[] )
|
|||
((void) argv);
|
||||
|
||||
polarssl_printf("POLARSSL_BIGNUM_C and/or "
|
||||
"POLARSSL_SHA1_C and/or POLARSSL_PK_PARSE_C and/or "
|
||||
"POLARSSL_SHA256_C and/or POLARSSL_PK_PARSE_C and/or "
|
||||
"POLARSSL_FS_IO not defined.\n");
|
||||
return( 0 );
|
||||
}
|
||||
|
|
@ -108,10 +108,10 @@ int main( int argc, char *argv[] )
|
|||
fclose( f );
|
||||
|
||||
/*
|
||||
* Compute the SHA-1 hash of the input file and compare
|
||||
* Compute the SHA-256 hash of the input file and compare
|
||||
* it with the hash decrypted from the signature.
|
||||
*/
|
||||
polarssl_printf( "\n . Verifying the SHA-1 signature" );
|
||||
polarssl_printf( "\n . Verifying the SHA-256 signature" );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = sha1_file( argv[2], hash ) ) != 0 )
|
||||
|
|
@ -120,14 +120,14 @@ int main( int argc, char *argv[] )
|
|||
goto exit;
|
||||
}
|
||||
|
||||
if( ( ret = pk_verify( &pk, POLARSSL_MD_SHA1, hash, 0,
|
||||
if( ( ret = pk_verify( &pk, POLARSSL_MD_SHA256, hash, 0,
|
||||
buf, i ) ) != 0 )
|
||||
{
|
||||
polarssl_printf( " failed\n ! pk_verify returned -0x%04x\n", -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
polarssl_printf( "\n . OK (the decrypted SHA-1 hash matches)\n\n" );
|
||||
polarssl_printf( "\n . OK (the decrypted SHA-256 hash matches)\n\n" );
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
|
@ -146,5 +146,5 @@ exit:
|
|||
|
||||
return( ret );
|
||||
}
|
||||
#endif /* POLARSSL_BIGNUM_C && POLARSSL_SHA1_C &&
|
||||
#endif /* POLARSSL_BIGNUM_C && POLARSSL_SHA256_C &&
|
||||
POLARSSL_PK_PARSE_C && POLARSSL_FS_IO */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue