Hi everyone,
This has been frustrating me for hours. I hope that someone has had some
experience with this, and can give me some advice. I can't find any
examples of this anywhere, and the module's documentation doesn't really
shed any light on the problem.
I've been trying to use Crypt:SA to sign a message, then to verify it
after it's been sent over the network.
I'm signing a message with
my $key = Crypt:SA::Key->new(
Type => 'PEM',
Filename => 'filename'); # load the key from disk
my $pub_key = $key->pub_key; # this is distributed to the clients
my $sig = Crypt:SA->new()->sign(
Message => $message, # $message is the message to sign/send
Key => $key); # sign it
Then sending $sig->r and $sig->s along with the message. This all appears
to work.
On the other side, I'm trying to verify it, using $pub_key from the
source...
my $key = Crypt:SA::Key->new();
$key->pub_key($pub_key); # setup the key object to contain the source's
public key
my $sig = Crypt:SA::Signature->new();
$sig->r($r); # fill out the signature's r and s values
$sig->s($s); # ($r and $s and $message are what were sent)
my $verified = Crypt:SA->new()->verify(
Message => $message,
Key => $key,
Signature => $sig); # try to verify the message
At this point, Math:ari croaks. Tracing shows that verify() is making the
following call:
my $u2 = mod_inverse($sig->s, $key->q);
Where $key->q is ''.
I realize that q is part of the public key - so shouldn't the pub_key()
method set it to something meaningful? If not (and it doesn't appear it
does, by looking at the source), do I need to work with each part of the
public key individually? If that's the case, what's the point of the
pub_key() and priv_key() methods?
I expect that I am just doing something wrong, or I haven't grasped the
whole concept, so I would be very grateful if anyone can explain what I'm
doing wrong, or what I need to do - or point me towards any examples of
Crypt:SA being used for signing/verifying.
I see that there's a Crypt::OpenSSL:SA module that I could probably use
instead, but I'd like to get this way working if at all possible.
Cheers
--
Chawmp
This has been frustrating me for hours. I hope that someone has had some
experience with this, and can give me some advice. I can't find any
examples of this anywhere, and the module's documentation doesn't really
shed any light on the problem.
I've been trying to use Crypt:SA to sign a message, then to verify it
after it's been sent over the network.
I'm signing a message with
my $key = Crypt:SA::Key->new(
Type => 'PEM',
Filename => 'filename'); # load the key from disk
my $pub_key = $key->pub_key; # this is distributed to the clients
my $sig = Crypt:SA->new()->sign(
Message => $message, # $message is the message to sign/send
Key => $key); # sign it
Then sending $sig->r and $sig->s along with the message. This all appears
to work.
On the other side, I'm trying to verify it, using $pub_key from the
source...
my $key = Crypt:SA::Key->new();
$key->pub_key($pub_key); # setup the key object to contain the source's
public key
my $sig = Crypt:SA::Signature->new();
$sig->r($r); # fill out the signature's r and s values
$sig->s($s); # ($r and $s and $message are what were sent)
my $verified = Crypt:SA->new()->verify(
Message => $message,
Key => $key,
Signature => $sig); # try to verify the message
At this point, Math:ari croaks. Tracing shows that verify() is making the
following call:
my $u2 = mod_inverse($sig->s, $key->q);
Where $key->q is ''.
I realize that q is part of the public key - so shouldn't the pub_key()
method set it to something meaningful? If not (and it doesn't appear it
does, by looking at the source), do I need to work with each part of the
public key individually? If that's the case, what's the point of the
pub_key() and priv_key() methods?
I expect that I am just doing something wrong, or I haven't grasped the
whole concept, so I would be very grateful if anyone can explain what I'm
doing wrong, or what I need to do - or point me towards any examples of
Crypt:SA being used for signing/verifying.
I see that there's a Crypt::OpenSSL:SA module that I could probably use
instead, but I'd like to get this way working if at all possible.
Cheers
--
Chawmp