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

Function sha256_self_test

sha256.c:630–722  ·  view source on GitHub ↗

* Checkup routine */

Source from the content-addressed store, hash-verified

628 * Checkup routine
629 */
630int sha256_self_test( int verbose )
631{
632 int i, j, k, buflen, ret = 0;
633 unsigned char buf[1024];
634 unsigned char sha256sum[32];
635 sha256_context ctx;
636
637 sha256_init( &ctx );
638
639 for( i = 0; i < 6; i++ )
640 {
641 j = i % 3;
642 k = i < 3;
643
644 if( verbose != 0 )
645 polarssl_printf( " SHA-%d test #%d: ", 256 - k * 32, j + 1 );
646
647 sha256_starts( &ctx, k );
648
649 if( j == 2 )
650 {
651 memset( buf, 'a', buflen = 1000 );
652
653 for( j = 0; j < 1000; j++ )
654 sha256_update( &ctx, buf, buflen );
655 }
656 else
657 sha256_update( &ctx, sha256_test_buf[j],
658 sha256_test_buflen[j] );
659
660 sha256_finish( &ctx, sha256sum );
661
662 if( memcmp( sha256sum, sha256_test_sum[i], 32 - k * 4 ) != 0 )
663 {
664 if( verbose != 0 )
665 polarssl_printf( "failed\n" );
666
667 ret = 1;
668 goto exit;
669 }
670
671 if( verbose != 0 )
672 polarssl_printf( "passed\n" );
673 }
674
675 if( verbose != 0 )
676 polarssl_printf( "\n" );
677
678 for( i = 0; i < 14; i++ )
679 {
680 j = i % 7;
681 k = i < 7;
682
683 if( verbose != 0 )
684 polarssl_printf( " HMAC-SHA-%d test #%d: ", 256 - k * 32, j + 1 );
685
686 if( j == 5 || j == 6 )
687 {

Callers

nothing calls this directly

Calls 8

sha256_initFunction · 0.85
sha256_startsFunction · 0.85
sha256_updateFunction · 0.85
sha256_finishFunction · 0.85
sha256_hmac_startsFunction · 0.85
sha256_hmac_updateFunction · 0.85
sha256_hmac_finishFunction · 0.85
sha256_freeFunction · 0.85

Tested by

no test coverage detected