File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -320,19 +320,24 @@ static int rsa_sign_verify_pss(int devId)
320320 return ret ;
321321}
322322#endif /* ifdef WC_RSA_PSS */
323- #endif /* ifndef NO_RSA */
323+
324+ /* Define maximum RSA key size in bits */
325+ #define MAX_RSA_KEY_BITS 2048
326+
327+ #ifndef NO_RSA
324328static int rsa_encrypt_decrypt (int devId )
325329{
326330 int ret = 0 ;
327- byte plain [128 ], out [2048 /8 ], dec [2048 /8 ];
331+ byte plain [128 ], out [MAX_RSA_KEY_BITS /8 ], dec [MAX_RSA_KEY_BITS /8 ];
328332 word32 plainSz , outSz , decSz ;
329333 RsaKey pub ;
330334 RsaKey priv ;
331335
336+ /* Initialize plain text buffer with 9's as sample data */
332337 memset (plain , 9 , sizeof (plain ));
333- plainSz = sizeof (plain );
334- outSz = sizeof (out );
335- decSz = sizeof (dec );
338+ plainSz = ( word32 ) sizeof (plain );
339+ outSz = ( word32 ) sizeof (out );
340+ decSz = ( word32 ) sizeof (dec );
336341
337342 /* Encrypt with public key */
338343 ret = decode_public_key (& pub , devId );
@@ -397,7 +402,7 @@ static int rsa_encrypt_decrypt(int devId)
397402
398403 return ret ;
399404}
400-
405+ #endif /* ifndef NO_RSA */
401406
402407int main (int argc , char * argv [])
403408{
You can’t perform that action at this time.
0 commit comments