Modulus and Exponent

Is there a way to get the modulus and exponent from an key, or is there
a way to get that information as it is being encrypted? I am using the
OpenSSL::PKey::RSA library to encrypt my data. Thanks,

-S

On Dec 6, 2007 1:16 PM, Shandy N. [email protected] wrote:

Is there a way to get the modulus and exponent from an key, or is there
a way to get that information as it is being encrypted? I am using the
OpenSSL::PKey::RSA library to encrypt my data. Thanks,

It’s in ext/openssl/ossl_pkey_rsa.c:ossl_rsa_get_params

sh-2.05b$ openssl genrsa -out test.pem 512
Generating RSA private key, 512 bit long modulus
…++++++++++++
.++++++++++++
e is 65537 (0x10001)
sh-2.05b$ cat sslparams.rb
require ‘openssl’
file = ARGV[0] || “test.pem”
OpenSSL::PKey::RSA.new(File.read(file)).params.each do |k,v|
puts “#{k} = #{v}”
end
sh-2.05b$ ruby sslparams.rb
iqmp =
59260111929228437887497692691757636132892230319984822766526877098035186370601
n =
11804463841624570992464253395735827528891316877747581110813958174030871384082650715713947258948719543061592249783350178655531273368202635182086293357491941
d =
11689187633396551317545091362483299497115519346555148562621014749226871236290914623323220129606434399743927309247086015156374960675693636631059313239642145
p =
112801836523523861906861645509931518041464374339361561066100421492644618944537
e = 65537
q =
104647798346464426891710400199240987063553868486458584292121861850498642450093
dmq1 =
99023959205578397450133824684619830214173568429859912795458096383091586608213
dmp1 =
53486077635053542407429782172225184600126728910320284879214346062284381856073

-Adam

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs