@@ -785,15 +785,18 @@ int test_wc_RsaPublicEncryptDecrypt(void)
785785 WC_DECLARE_VAR (in , byte , TEST_STRING_SZ , NULL );
786786 WC_DECLARE_VAR (plain , byte , TEST_STRING_SZ , NULL );
787787 WC_DECLARE_VAR (cipher , byte , TEST_RSA_BYTES , NULL );
788+ WC_DECLARE_VAR (shortPlain , byte , TEST_STRING_SZ - 4 , NULL );
788789
789790 WC_ALLOC_VAR (in , byte , TEST_STRING_SZ , NULL );
790791 WC_ALLOC_VAR (plain , byte , TEST_STRING_SZ , NULL );
791792 WC_ALLOC_VAR (cipher , byte , TEST_RSA_BYTES , NULL );
793+ WC_ALLOC_VAR (shortPlain , byte , TEST_STRING_SZ - 4 , NULL );
792794
793795#ifdef WC_DECLARE_VAR_IS_HEAP_ALLOC
794796 ExpectNotNull (in );
795797 ExpectNotNull (plain );
796798 ExpectNotNull (cipher );
799+ ExpectNotNull (shortPlain );
797800#endif
798801 ExpectNotNull (XMEMCPY (in , inStr , inLen ));
799802
@@ -820,6 +823,11 @@ int test_wc_RsaPublicEncryptDecrypt(void)
820823 ExpectIntEQ (XMEMCMP (plain , inStr , plainLen ), 0 );
821824 /* Pass bad args - tested in another testing function.*/
822825
826+ /* Test for when plain length is less than required. */
827+ ExpectIntEQ (wc_RsaPrivateDecrypt (cipher , cipherLenResult , shortPlain ,
828+ TEST_STRING_SZ - 4 , & key ), RSA_BUFFER_E );
829+
830+ WC_FREE_VAR (shortPlain , NULL );
823831 WC_FREE_VAR (in , NULL );
824832 WC_FREE_VAR (plain , NULL );
825833 WC_FREE_VAR (cipher , NULL );
0 commit comments