@@ -386,7 +386,7 @@ static int sce_aesgcm256_test(int prnt, sce_aes_wrapped_key_t* aes256_key)
386386 goto out ;
387387 } else {
388388 userContext .sce_wrapped_key_aes256 = (void * )aes256_key ;
389- userContext .flags2 .bits .aes256_installedkey_set = 1 ;
389+ userContext .keyflgs_crypt .bits .aes256_installedkey_set = 1 ;
390390 enc -> ctx .keySize = (word32 )enc -> keylen ;
391391 }
392392
@@ -582,7 +582,7 @@ static int sce_aesgcm128_test(int prnt, sce_aes_wrapped_key_t* aes128_key)
582582 goto out ;
583583 } else {
584584 userContext .sce_wrapped_key_aes128 = aes128_key ;
585- userContext .flags2 .bits .aes128_installedkey_set = 1 ;
585+ userContext .keyflgs_crypt .bits .aes128_installedkey_set = 1 ;
586586 enc -> ctx .keySize = (word32 )enc -> keylen ;
587587 }
588588 /* AES-GCM encrypt and decrypt both use AES encrypt internally */
@@ -656,11 +656,15 @@ static int sce_rsa_test(int prnt, int keySize)
656656 const char inStr2 [] = TEST_STRING2 ;
657657 const word32 inLen = (word32 )TEST_STRING_SZ ;
658658 const word32 outSz = RSA_TEST_BYTES ;
659+ byte * in = NULL ;
660+ byte * in2 = NULL ;
661+ byte * out = NULL ;
662+ byte * out2 = NULL ;
659663
660- byte * in = (byte * )XMALLOC (inLen , NULL , DYNAMIC_TYPE_TMP_BUFFER );
661- byte * in2 = (byte * )XMALLOC (inLen , NULL , DYNAMIC_TYPE_TMP_BUFFER );
662- byte * out = (byte * )XMALLOC (outSz , NULL , DYNAMIC_TYPE_TMP_BUFFER );
663- byte * out2 = (byte * )XMALLOC (outSz , NULL , DYNAMIC_TYPE_TMP_BUFFER );
664+ in = (byte * )XMALLOC (inLen , NULL , DYNAMIC_TYPE_TMP_BUFFER );
665+ in2 = (byte * )XMALLOC (inLen , NULL , DYNAMIC_TYPE_TMP_BUFFER );
666+ out = (byte * )XMALLOC (outSz , NULL , DYNAMIC_TYPE_TMP_BUFFER );
667+ out2 = (byte * )XMALLOC (outSz , NULL , DYNAMIC_TYPE_TMP_BUFFER );
664668
665669 if (key == NULL || in == NULL || out == NULL ||
666670 in2 == NULL || out2 == NULL ) {
@@ -682,8 +686,11 @@ static int sce_rsa_test(int prnt, int keySize)
682686
683687 if ((ret = wc_InitRng (& rng )) != 0 )
684688 goto out ;
685-
686- /* make ras key by SCE */
689+
690+ if ((ret = wc_RsaSetRNG (key , & rng )) != 0 )
691+ goto out ;
692+
693+ /* make rsa key by SCE */
687694 if ((ret = wc_MakeRsaKey (key , keySize , 65537 , & rng )) != 0 ) {
688695 goto out ;
689696 }
@@ -694,7 +701,7 @@ static int sce_rsa_test(int prnt, int keySize)
694701 }
695702
696703 ret = wc_RsaPrivateDecrypt (out , keySize /8 , out2 , outSz , key );
697- if (ret != 0 ) {
704+ if (ret < 0 ) {
698705 ret = -1 ;
699706 goto out ;
700707 }
@@ -703,6 +710,7 @@ static int sce_rsa_test(int prnt, int keySize)
703710 goto out ;
704711 }
705712
713+ ret = 0 ;
706714out :
707715 if (key != NULL ) {
708716 wc_FreeRsaKey (key );
@@ -735,10 +743,14 @@ static int sce_rsa_SignVerify_test(int prnt, int keySize)
735743 const word32 inLen = (word32 )TEST_STRING_SZ ;
736744 const word32 outSz = RSA_TEST_BYTES ;
737745
738- byte * in = ( byte * ) XMALLOC ( inLen , NULL , DYNAMIC_TYPE_TMP_BUFFER ) ;
739- byte * in2 = ( byte * ) XMALLOC ( inLen , NULL , DYNAMIC_TYPE_TMP_BUFFER ) ;
740- byte * out = ( byte * ) XMALLOC ( outSz , NULL , DYNAMIC_TYPE_TMP_BUFFER ) ;
746+ byte * in = NULL ;
747+ byte * in2 = NULL ;
748+ byte * out = NULL ;
741749
750+ in = (byte * )XMALLOC (inLen , NULL , DYNAMIC_TYPE_TMP_BUFFER );
751+ in2 = (byte * )XMALLOC (inLen , NULL , DYNAMIC_TYPE_TMP_BUFFER );
752+ out = (byte * )XMALLOC (outSz , NULL , DYNAMIC_TYPE_TMP_BUFFER );
753+
742754 (void ) prnt ;
743755
744756 if (key == NULL || in == NULL || out == NULL ) {
@@ -759,12 +771,15 @@ static int sce_rsa_SignVerify_test(int prnt, int keySize)
759771 if ((ret = wc_InitRng (& rng )) != 0 )
760772 goto out ;
761773
762- /* make ras key by SCE */
774+ if ((ret = wc_RsaSetRNG (key , & rng )) != 0 )
775+ goto out ;
776+
777+ /* make rsa key by SCE */
763778 if ((ret = wc_MakeRsaKey (key , keySize , 65537 , & rng )) != 0 ) {
764779 goto out ;
765780 }
766781
767- guser_PKCbInfo .flags2 .bits .message_type = 0 ;
782+ guser_PKCbInfo .keyflgs_crypt .bits .message_type = 0 ;
768783 ret = wc_RsaSSL_Sign (in , inLen , out , outSz , key , & rng );
769784 if (ret < 0 ) {
770785 goto out ;
@@ -778,11 +793,11 @@ static int sce_rsa_SignVerify_test(int prnt, int keySize)
778793 }
779794 /* this should succeed */
780795 ret = wc_RsaSSL_Verify (in , inLen , out , keySize /8 , key );
781- if (ret != 0 ) {
796+ if (ret < 0 ) {
782797 ret = -1 ;
783798 goto out ;
784799 }
785-
800+ ret = 0 ;
786801 out :
787802 if (key != NULL ) {
788803 wc_FreeRsaKey (key );
@@ -833,11 +848,26 @@ int sce_crypt_test()
833848 if ( ret > 0 )
834849 ret = 0 ;
835850
851+ if (ret == 0 ) {
852+ printf (" sce_rsa_test(512)(this will be done"
853+ " by SW because SCE doesn't support 512 bits key size.)" );
854+ ret = sce_rsa_test (1 , 512 );
855+ RESULT_STR (ret )
856+ }
857+
836858 if (ret == 0 ) {
837859 printf (" sce_rsa_test(1024)" );
838860 ret = sce_rsa_test (1 , 1024 );
839861 RESULT_STR (ret )
840862 }
863+
864+ if (ret == 0 ) {
865+ printf (" sce_rsa_SignVerify_test(512)(this will be done"
866+ " by SW because SCE doesn't support 512 bits key size.)" );
867+ ret = sce_rsa_SignVerify_test (1 , 512 );
868+ RESULT_STR (ret )
869+ }
870+
841871 if (ret == 0 ) {
842872 printf (" sce_rsa_SignVerify_test(1024)" );
843873 ret = sce_rsa_SignVerify_test (1 , 1024 );
0 commit comments