@@ -789,15 +789,18 @@ int test_wc_RsaPublicEncryptDecrypt(void)
789789 WC_DECLARE_VAR (in , byte , TEST_STRING_SZ , NULL );
790790 WC_DECLARE_VAR (plain , byte , TEST_STRING_SZ , NULL );
791791 WC_DECLARE_VAR (cipher , byte , TEST_RSA_BYTES , NULL );
792+ WC_DECLARE_VAR (shortPlain , byte , TEST_STRING_SZ - 4 , NULL );
792793
793794 WC_ALLOC_VAR (in , byte , TEST_STRING_SZ , NULL );
794795 WC_ALLOC_VAR (plain , byte , TEST_STRING_SZ , NULL );
795796 WC_ALLOC_VAR (cipher , byte , TEST_RSA_BYTES , NULL );
797+ WC_ALLOC_VAR (shortPlain , byte , TEST_STRING_SZ - 4 , NULL );
796798
797799#ifdef WC_DECLARE_VAR_IS_HEAP_ALLOC
798800 ExpectNotNull (in );
799801 ExpectNotNull (plain );
800802 ExpectNotNull (cipher );
803+ ExpectNotNull (shortPlain );
801804#endif
802805 ExpectNotNull (XMEMCPY (in , inStr , inLen ));
803806
@@ -824,6 +827,11 @@ int test_wc_RsaPublicEncryptDecrypt(void)
824827 ExpectIntEQ (XMEMCMP (plain , inStr , plainLen ), 0 );
825828 /* Pass bad args - tested in another testing function.*/
826829
830+ /* Test for when plain length is less than required. */
831+ ExpectIntEQ (wc_RsaPrivateDecrypt (cipher , cipherLenResult , shortPlain ,
832+ TEST_STRING_SZ - 4 , & key ), RSA_BUFFER_E );
833+
834+ WC_FREE_VAR (shortPlain , NULL );
827835 WC_FREE_VAR (in , NULL );
828836 WC_FREE_VAR (plain , NULL );
829837 WC_FREE_VAR (cipher , NULL );
0 commit comments