简体   繁体   English

Openssl RSA中用于加密的最大字符串大小

[英]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. 函数RSA_public_encrypt要求保存加密文本的变量的长度应为RSA_size(* rsa)字节。 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. 现在,我需要知道要加密的文本有多大,因为如果我加密了一个小的字符串(例如“ asdasd”),就没问题了,但是如果我尝试使用一个更大的字符串,则仅加密了一部分。

Assuming you're talking about RSA_public_encrypt() , the docs state it pretty clearly: 假设您正在谈论RSA_public_encrypt() ,则文档将其清楚地声明为:

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. 对于基于PKCS#1 v1.5的填充模式,flen必须小于RSA_size(rsa)-11;对于RSA_PKCS1_OAEP_PADDING,小于RSA_size(rsa)-41;对于RSA_NO_PADDING,小于RSA_size(rsa)。

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. 请记住,这些是块加密,通常情况下,您需要将输入分成多个块,然后一次将一个块提供给加密功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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