OpenSSL with Ruby

V

vaibhavb

hi all -

I'm not sure if this is the correct forum but i was wondering if
anyone has successfully done RSA-SHA1 signing with Ruby OpenSSL and
interoperated with Java Servers.

I'm using the following code but i'm not sure if the "sign" method on
works properly -

@key = OpenSSL::pKey::RSA.new(2048)
#sign
@key.send("sign", OpenSSL::Digest.::SHA1.new, "text to sign")

The expected signature from above "sign" is not what i know the Java
crytpo api likes.

Thanks in advance.

regards,
Vaibhav
 
R

Rolando Abarca

hi all -

I'm not sure if this is the correct forum but i was wondering if
anyone has successfully done RSA-SHA1 signing with Ruby OpenSSL and
interoperated with Java Servers.

I'm using the following code but i'm not sure if the "sign" method on
works properly -

@key = OpenSSL::pKey::RSA.new(2048)
#sign
@key.send("sign", OpenSSL::Digest.::SHA1.new, "text to sign")

The expected signature from above "sign" is not what i know the Java
crytpo api likes.

Thanks in advance.

after digging forums and searching through the source, this is what
i'm doing to sign:

digest = OpenSSL::Digest::SHA1.new(text_to_sign)
sign = key.private_encrypt(digest)
# sign is what you want, if you need it in Base64:
enc_sign = Base64.encode64(sign)
regards,
Vaibhav

regards,
 
M

Matt Todd

enc_sign = Base64.encode64(sign)

Bawse64.encode64 is deprecated. Check out String#pack instead
(specifically the "m*" option).
 
V

vaibhavb

I tried the above but it still is not same as Java output - I want to
be able to sign and update each byte of the text instead of string
(thats what Java does) .. any ideas?

Thanks in advance.

regards,
Vaibhav
 
E

Eric I.

Hi Vaibhav,

Any chance you're dealing with a character encoding issue? By default
Java uses UTF-16. And you may be using UTF-8 with Ruby. Just a
thought....

Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top