简体   繁体   中英

maximum size of string for encrypt in Openssl RSA

The function RSA_public_encrypt requires that the variable where encrypted text will be saved, should have a length of RSA_size(*rsa) bytes. Now, I need to know how big could be the text to encrypt, because if I crypt a little string (for example "asdasd"), there's no problem, but if I try with a bigger string, just a portion of it it's crypt.

Assuming you're talking about RSA_public_encrypt() , the docs state it pretty clearly:

flen must be less than RSA_size(rsa) - 11 for the PKCS #1 v1.5 based padding modes, less than RSA_size(rsa) - 41 for RSA_PKCS1_OAEP_PADDING and exactly RSA_size(rsa) for RSA_NO_PADDING.

Remember that these are block cryptos, in the general case you need to split your input into blocks and feed the blocks one at a time to the encryption function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM