Forum: Ruby openssl help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Steven H. (Guest)
on 2005-12-03 23:46
Hi, I'm trying to use ruby's openssl library to verify a DSA
signature....I think.  Anyway, the openssl library does not seem to have
much documentation so I'm not sure what I'm doing wrong.  Here is what
I'm trying to accomplish.

1) Receive a cleartext authtoken: AWSAuthToken
2) Receive base64-encoded signature of a SHA-1 hash of the authtoken:
AWSSignatureBase64
3) Base64-decode AWSSignatureBase64, to obtain the DSA signature of the
hash of the authtoken: DSASignature
4) Provide the DSASignature and AWSAuthToken as input to a DSA signature
verification method using the SHA-1 hashing algorithm and a public key
file.
5) The verification method should indicate that the signature was, in
fact, made with the AWS private key, applied to the hash of the
authtoken.

Here is how I'm trying to accomplish this in ruby:

[code]
aws_pub_key_file = '/srv/www/work/softdist/app/apis/AWSPublicKey3'

str = ''
File.open(aws_pub_key_file) do |f|
	f.each do |line|
		str += line
	end
end

aws_sig_base_64 = params[:AWSSignatureBase64]
aws_auth_token = params[:AWSAuthToken]
decoded_dsa_sig = Base64.decode64(aws_sig_base_64)
public_key = OpenSSL::PKey::DSA.new(str)
public_key.verify(OpenSSL::Digest::SHA1.new, aws_auth_token,
decoded_dsa_sig)
[/code]

When I make the call to public_key.verify the script bombs an spits ot
the following error:
"wrong public key type"

Any ideas?

Is there any known source of documentation for the openssl library?

Thanks,
Steven
This topic is locked and can not be replied to.