You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello to you, I don't think I understand the reason for the "data too large for key size" error when encrypting a message like 'abcd' (4 bytes) with a 49 bits RSA public key when the key length (n) is ~7 bytes.
require('openssl')PUBLIC_MODULUS_N=OpenSSL::BN.new(379381098436349)PUBLIC_EXPONENT_E=OpenSSL::BN.new(11)PRIME_P=OpenSSL::BN.new(18464531)PRIME_Q=OpenSSL::BN.new(20546479)PRIVATE_EXPONENT_D=OpenSSL::BN.new(68978374440971)rsa=OpenSSL::PKey::RSA.new()rsa.set_key(PUBLIC_MODULUS_N,PUBLIC_EXPONENT_E,PRIVATE_EXPONENT_D)rsa.set_factors(PRIME_P,PRIME_Q)PUBLIC_KEY=rsa.public_key()if(PUBLIC_KEY.public?())pp(PUBLIC_KEY.n().num_bytes())pp(PUBLIC_KEY.to_text())pp(PUBLIC_KEY.to_pem())# pp(OpenSSL::PKey::RSA.constants())# [:PKCS1_OAEP_PADDING, :NO_PADDING, :PKCS1_PADDING, :SSLV23_PADDING]pp(PUBLIC_KEY.public_encrypt('abcd'))# => ERROR: data too large for key sizeendpp('')if(rsa.private?())pp(rsa.n().num_bytes())pp(rsa.to_text())pp(rsa.to_pem())end
Thank you for your help.
The text was updated successfully, but these errors were encountered:
Hello to you, I don't think I understand the reason for the "data too large for key size" error when encrypting a message like 'abcd' (4 bytes) with a 49 bits RSA public key when the key length (n) is ~7 bytes.
Thank you for your help.
The text was updated successfully, but these errors were encountered: