Ruby openssl?

Hi,

I've just begun a project where I'd like to do public
key encryption, and have been looking for docs and/or
examples using the ruby openssl library.

So far, I've found:
http://www.ruby-doc.org/stdlib/libdoc/openssl/rdoc/index.html
and:
http://www.nongnu.org/rubypki/README
which have been of limited help so far.

So I figured I'd download the source... The RAA page leads
me to: http://www.nongnu.org/rubypki/ , however the download
link there is broken.

The CVS browser seems to be working, but there are two
projects, "ossl", and "ossl2". I'm not sure which is
the most current / appropriate to checkout. Neither
seems to have any files recently modified, although the
README link above warns, "All code is under development -
API/method names can change."

If anyone can help with either a) finding the correct
source to download, and/or b) finding some documentation
and example code, I'd be grateful.. maybe even ebullient.. :slight_smile:

Thanks!

Regards,

Bill

Hi,

I've just begun a project where I'd like to do public
key encryption, and have been looking for docs and/or
examples using the ruby openssl library.

There should be a sample/openssl directory in the ruby tarball.

So I figured I'd download the source... The RAA page leads
me to: Ruby PKI , however the download
link there is broken.

ruby 1.8 includes OpenSSL, so you just need the ruby tarball. The source of openssl itself is probably not worth looking at (but sample/openssl might be).

···

On 15 Jun 2005, at 16:30, Bill Kelly wrote:

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

There should be a sample/openssl directory in the ruby tarball.

> So I figured I'd download the source... The RAA page leads
> me to: Ruby PKI , however the download
> link there is broken.

ruby 1.8 includes OpenSSL, so you just need the ruby tarball. The
source of openssl itself is probably not worth looking at (but sample/
openssl might be).

Thanks! .... Hmm..

Anyone know what I'm doing wrong here? I generated a
public/private key pair, then tried to sign some data
and verify the signature:

irb(main):001:0> require 'openssl'
=> true
irb(main):002:0> include OpenSSL
=> Object
irb(main):003:0> keypair = PKey::RSA.new(1024)
=> -----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
irb(main):004:0> sig = keypair.sign(Digest::MD5.new, "abcdefg")
=> "...binary-data..."
irb(main):005:0> keypair.verify(Digest::MD5.new, "abcdefg", sig)
=> false

...I was hoping the answer would be "true". But I'm
pretty much guessing as to how to call these methods...

Thanks!

Regards,

Bill

···

From: "Eric Hodel" <drbrain@segment7.net>

On 15 Jun 2005, at 16:30, Bill Kelly wrote:

Hi Bill,
In your verify statement you need to swap the sig and the data

Pelle

···

On 6/16/05, Bill Kelly <billk@cts.com> wrote:

From: "Eric Hodel" <drbrain@segment7.net>
>
> On 15 Jun 2005, at 16:30, Bill Kelly wrote:
>
> There should be a sample/openssl directory in the ruby tarball.
>
> > So I figured I'd download the source... The RAA page leads
> > me to: Ruby PKI , however the download
> > link there is broken.
>
> ruby 1.8 includes OpenSSL, so you just need the ruby tarball. The
> source of openssl itself is probably not worth looking at (but sample/
> openssl might be).

Thanks! .... Hmm..

Anyone know what I'm doing wrong here? I generated a
public/private key pair, then tried to sign some data
and verify the signature:

irb(main):001:0> require 'openssl'
=> true
irb(main):002:0> include OpenSSL
=> Object
irb(main):003:0> keypair = PKey::RSA.new(1024)
=> -----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
irb(main):004:0> sig = keypair.sign(Digest::MD5.new, "abcdefg")
=> "...binary-data..."
irb(main):005:0> keypair.verify(Digest::MD5.new, "abcdefg", sig)
=> false

...I was hoping the answer would be "true". But I'm
pretty much guessing as to how to call these methods...

Thanks!

Regards,

Bill

--
https://stakeitout.com + Stake out your own micro ventures
http://neubia.com + Geek blog
http://stakeventures.com + Bootstrapping blog
http://SoapBX.com + Get on the box and shout

Hi Pelle,

>
> irb(main):004:0> sig = keypair.sign(Digest::MD5.new, "abcdefg")
> => "...binary-data..."
> irb(main):005:0> keypair.verify(Digest::MD5.new, "abcdefg", sig)

In your verify statement you need to swap the sig and the data

D'oh !!!! Thanks. I was looking at http://www.nongnu.org/rubypki/README
for reference, which shows, for PKey::RSA,

  .sign(oDigest::ANY, sData) => sSig
  .verify(oDigest::ANY, sData, sSig) => bResult

...guess that document is out of date :frowning:

Thanks,

Bill

···

On 6/16/05, Bill Kelly <billk@cts.com> wrote: