| 1 | package Net::OAuth::SignatureMethod::RSA_SHA1; | ||
| 2 | use warnings; | ||
| 3 | use strict; | ||
| 4 | use MIME::Base64; | ||
| 5 | |||
| 6 | sub sign { | ||
| 7 | my $self = shift; | ||
| 8 | my $request = shift; | ||
| 9 | my $key = shift || $request->signature_key; | ||
| 10 | die '$request->signature_key must be an RSA key object (e.g. Crypt::OpenSSL::RSA) that can sign($text)' | ||
| 11 | unless UNIVERSAL::can($key, 'sign'); | ||
| 12 | return encode_base64($key->sign($request->signature_base_string), ""); | ||
| 13 | } | ||
| 14 | |||
| 15 | sub verify { | ||
| 16 | my $self = shift; | ||
| 17 | my $request = shift; | ||
| 18 | my $key = shift || $request->signature_key; | ||
| 19 | die 'You must pass an RSA key object (e.g. Crypt::OpenSSL::RSA) that can verify($text,$sig)' | ||
| 20 | unless UNIVERSAL::can($key, 'verify'); | ||
| 21 | return $key->verify($request->signature_base_string, decode_base64($request->signature)); | ||
| 22 | } | ||
| 23 | |||
| 24 | =head1 NAME | ||
| 25 | |||
| 26 | Net::OAuth::SignatureMethod::RSA_SHA1 - RSA_SHA1 Signature Method for OAuth protocol | ||
| 27 | |||
| 28 | =head1 SEE ALSO | ||
| 29 | |||
| 30 | L<Net::OAuth>, L<http://oauth.net> | ||
| 31 | |||
| 32 | =head1 AUTHOR | ||
| 33 | |||
| 34 | Originally by Keith Grennan <kgrennan@cpan.org> | ||
| 35 | |||
| 36 | Currently maintained by Robert Rothenberg <rrwo@cpan.org> | ||
| 37 | |||
| 38 | =head1 COPYRIGHT & LICENSE | ||
| 39 | |||
| 40 | Copyright 2007-2012, 2024-2025 Keith Grennan | ||
| 41 | |||
| 42 | This program is free software; you can redistribute it and/or modify it | ||
| 43 | under the same terms as Perl itself. | ||
| 44 | |||
| 45 | =cut | ||
| 46 | |||
| 47 | 1; |