| OAuth-Lite documentation | view source | Contained in the OAuth-Lite distribution. |
OAuth::Lite::SignatureMethod::RSA_SHA1 - RSA_SHA1 signature method class;
# Consumer side
my $signer = OAuth::Lite::SignatureMethod::RSA_SHA1->new(
consumer_secret => $rsa_private_key,
);
my $signature = $signer->sign($base_string);
# Service Provider side
my $verifier = OAuth::Lite::SignatureMethod::RSA_SHA1->new(
consumer_secret => $rsa_public_key,
);
unless ($verifier->verify($base_string, $signature)) {
say "Signature is invalid!";
}
RSA_SHA1 signature method class.
RSA needs two keys that called public key and private key. If you runs OAuth consumer application and want to use this RSA_SHA1 method for signature on OAuth protocol, you have to prepare these keys.
To generate them in Perl, here is an example.
my $rsa = Crypt::OpenSSL::RSA->generate_key(1024);
my $public_key = $rsa->get_public_key_string();
my $private_key = $rsa->get_private_key_string();
And prior to use OAuth protocol with a service provider, you have to register public key onto the service provider.
Class method. Returns this method's name.
say OAuth::Lite::SignatureMethod::RSA_SHA1->method_name;
# RSA_SHA1
say OAuth::Lite::SignatureMethod::RSA_SHA1->build_body_hash($content);
On the consumer side, you should pass RSA private key for consumer_secret, But for service provider to verify signature, pass RSA public key that consumer register on service provider beforehand.
my $signer = OAuth::Lite::SignatureMethod::RSA_SHA1->new(
consumer_secret => $rsa_private_key,
);
my $verifier = OAuth::Lite::SignatureMethod::RSA_SHA1->new(
consumer_secret => $rsa_public_key,
);
Generate signature from base string.
my $signature = $method->sign($base_string);
Verify signature with base string.
my $signature_is_valid = $method->verify($base_string, $signature);
unless ($signature_is_valid) {
say "Signature is invalid!";
}
Lyo Kato, lyo.kato _at_ gmail.com
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
| OAuth-Lite documentation | view source | Contained in the OAuth-Lite distribution. |