Address PR comments for RSA encrypt/decrypt example

Co-Authored-By: colton@wolfssl.com <colton@wolfssl.com>
devin/1742500258-rsa-encrypt-decrypt-example
Devin AI 2025-03-21 18:31:11 +00:00
parent 0d3766df21
commit e298fbf19a
1 changed files with 11 additions and 6 deletions

View File

@ -320,19 +320,24 @@ static int rsa_sign_verify_pss(int devId)
return ret; return ret;
} }
#endif /* ifdef WC_RSA_PSS */ #endif /* ifdef WC_RSA_PSS */
#endif /* ifndef NO_RSA */
/* Define maximum RSA key size in bits */
#define MAX_RSA_KEY_BITS 2048
#ifndef NO_RSA
static int rsa_encrypt_decrypt(int devId) static int rsa_encrypt_decrypt(int devId)
{ {
int ret = 0; int ret = 0;
byte plain[128], out[2048/8], dec[2048/8]; byte plain[128], out[MAX_RSA_KEY_BITS/8], dec[MAX_RSA_KEY_BITS/8];
word32 plainSz, outSz, decSz; word32 plainSz, outSz, decSz;
RsaKey pub; RsaKey pub;
RsaKey priv; RsaKey priv;
/* Initialize plain text buffer with 9's as sample data */
memset(plain, 9, sizeof(plain)); memset(plain, 9, sizeof(plain));
plainSz = sizeof(plain); plainSz = (word32)sizeof(plain);
outSz = sizeof(out); outSz = (word32)sizeof(out);
decSz = sizeof(dec); decSz = (word32)sizeof(dec);
/* Encrypt with public key */ /* Encrypt with public key */
ret = decode_public_key(&pub, devId); ret = decode_public_key(&pub, devId);
@ -397,7 +402,7 @@ static int rsa_encrypt_decrypt(int devId)
return ret; return ret;
} }
#endif /* ifndef NO_RSA */
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {