MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / sha512_self_test

Function sha512_self_test

sha512.c:684–776  ·  view source on GitHub ↗

* Checkup routine */

Source from the content-addressed store, hash-verified

682 * Checkup routine
683 */
684int sha512_self_test( int verbose )
685{
686 int i, j, k, buflen, ret = 0;
687 unsigned char buf[1024];
688 unsigned char sha512sum[64];
689 sha512_context ctx;
690
691 sha512_init( &ctx );
692
693 for( i = 0; i < 6; i++ )
694 {
695 j = i % 3;
696 k = i < 3;
697
698 if( verbose != 0 )
699 polarssl_printf( " SHA-%d test #%d: ", 512 - k * 128, j + 1 );
700
701 sha512_starts( &ctx, k );
702
703 if( j == 2 )
704 {
705 memset( buf, 'a', buflen = 1000 );
706
707 for( j = 0; j < 1000; j++ )
708 sha512_update( &ctx, buf, buflen );
709 }
710 else
711 sha512_update( &ctx, sha512_test_buf[j],
712 sha512_test_buflen[j] );
713
714 sha512_finish( &ctx, sha512sum );
715
716 if( memcmp( sha512sum, sha512_test_sum[i], 64 - k * 16 ) != 0 )
717 {
718 if( verbose != 0 )
719 polarssl_printf( "failed\n" );
720
721 ret = 1;
722 goto exit;
723 }
724
725 if( verbose != 0 )
726 polarssl_printf( "passed\n" );
727 }
728
729 if( verbose != 0 )
730 polarssl_printf( "\n" );
731
732 for( i = 0; i < 14; i++ )
733 {
734 j = i % 7;
735 k = i < 7;
736
737 if( verbose != 0 )
738 polarssl_printf( " HMAC-SHA-%d test #%d: ", 512 - k * 128, j + 1 );
739
740 if( j == 5 || j == 6 )
741 {

Callers

nothing calls this directly

Calls 8

sha512_initFunction · 0.85
sha512_startsFunction · 0.85
sha512_updateFunction · 0.85
sha512_finishFunction · 0.85
sha512_hmac_startsFunction · 0.85
sha512_hmac_updateFunction · 0.85
sha512_hmac_finishFunction · 0.85
sha512_freeFunction · 0.85

Tested by

no test coverage detected