=encoding utf8

=head1 NAME

XML::Compile::WSS::Sign::RSA - WSS Signing with RSA

=head1 INHERITANCE

 XML::Compile::WSS::Sign::RSA
   is a XML::Compile::WSS::Sign

=head1 SYNOPSIS

  # either
  use XML::Compile::WSS::Util qw/DSIG_RSA_SHA1/;
  my $sign = XML::Compile::WSS::Sign->new(type => DSIG_RSA_SHA1);

  # or
  use XML::Compile::WSS::Sign::RSA;
  my $token = XML::Compile::WSS::Sign::RSA->new(
     hashing => 'SHA1', ...);

=head1 DESCRIPTION

Extends L<"DESCRIPTION" in XML::Compile::WSS::Sign|XML::Compile::WSS::Sign/"DESCRIPTION">.
 
=head1 METHODS

Extends L<"METHODS" in XML::Compile::WSS::Sign|XML::Compile::WSS::Sign/"METHODS">.
 
=head2 Constructors

Extends L<"Constructors" in XML::Compile::WSS::Sign|XML::Compile::WSS::Sign/"Constructors">.
 
=over 4

=item XML::Compile::WSS::Sign::RSA-E<gt>B<fromConfig>(HASH|PAIRS)

Inherited, see L<XML::Compile::WSS::Sign/"Constructors">

=item XML::Compile::WSS::Sign::RSA-E<gt>B<new>(%options)

 -Option     --Defined in             --Default
  hashing                               <undef>
  padding                               <undef>
  private_key                           undef
  public_key                            <from private key>
  sign_method  XML::Compile::WSS::Sign  DSIG_RSA_SHA1

=over 2

=item hashing => 'SHA1'|'MD5'|...

=item padding => 'NO'|'PKCS1'|...

=item private_key => OBJECT|STRING|FILENAME

Required if you want to use this object to sign. See L<privateKey()|XML::Compile::WSS::Sign::RSA/"Attributes">

=item public_key => OBJECT|STRING|FILENAME

Required if you want to use this object to L<check()|XML::Compile::WSS::Sign::RSA/"Handlers">. See L<publicKey()|XML::Compile::WSS::Sign::RSA/"Attributes">
Usually, you need either the public or the private key, not both.  However,
when you specify a private key, you can ask for the public key as well: it
is included.

=item sign_method => TYPE

=back

=back

=head2 Attributes

Extends L<"Attributes" in XML::Compile::WSS::Sign|XML::Compile::WSS::Sign/"Attributes">.
 
=over 4

=item $obj-E<gt>B<privateKey>( [$key, %options] )

The private key must be set with L<new(private_key)|XML::Compile::WSS::Sign::RSA/"Constructors"> or this method before
you can sign.  This method will return the text of the key.

=over 4

=item * an Crypt::OpenSSL::RSA object

=item * PEM formatted key, as accepted by Crypt::OpenSSL::RSA method C<new_private_key()>

=item * a filename which contains such bytes.

=back

 -Option --Default
  hashing  <undef>
  padding  <undef>

=over 2

=item hashing => 'SHA1'|'MD5'|'RIPEMD160'|...

Enforce an hashing setting on the $key.

=item padding => 'NO'|'PKCS1'|'PKCS1_OAEP'|'SSLv23'

=back

=item $obj-E<gt>B<privateKeyRSA>()

Returns the private key wrapped in a Crypt::OpenSSL::RSA object.

=item $obj-E<gt>B<publicKey>( [$key, %options] )

Set the public key.  You can pass a $key, which is one of

=over 4

=item * an L<XML::Compile::WSS::SecToken::X509v3|XML::Compile::WSS::SecToken::X509v3> object

=item * an Crypt::OpenSSL::RSA object

=item * an Crypt::OpenSSL::X509 object

=back

=item $obj-E<gt>B<publicKeyRSA>()

Returns the Crypt::OpenSSL::RSA-wrapped public key.

=item $obj-E<gt>B<publicKeyString>('PKCS1'|'X509')

=item $obj-E<gt>B<signMethod>()

Inherited, see L<XML::Compile::WSS::Sign/"Attributes">

=item $obj-E<gt>B<toPrivateSHA>($private-$key)

=item XML::Compile::WSS::Sign::RSA-E<gt>B<toPrivateSHA>($private-$key)

=item $obj-E<gt>B<toPublicRSA>($object)

=item XML::Compile::WSS::Sign::RSA-E<gt>B<toPublicRSA>($object)

=back

=head2 Handlers

Extends L<"Handlers" in XML::Compile::WSS::Sign|XML::Compile::WSS::Sign/"Handlers">.
 
=over 4

=item $obj-E<gt>B<builder>()

Inherited, see L<XML::Compile::WSS::Sign/"Handlers">

=item $obj-E<gt>B<check>($bytes, $signature)

=item $obj-E<gt>B<checker>()

Inherited, see L<XML::Compile::WSS::Sign/"Handlers">

=back

=head1 DETAILS

Read DETAILS in L<XML::Compile::WSS::Sign|XML::Compile::WSS::Sign> first.

Extends L<"DETAILS" in XML::Compile::WSS::Sign|XML::Compile::WSS::Sign/"DETAILS">.
 
=head2 Signing, the generic part

Extends L<"Signing, the generic part" in XML::Compile::WSS::Sign|XML::Compile::WSS::Sign/"Signing, the generic part">.
 
=head2 Defend against man-in-the-middle

Extends L<"Defend against man-in-the-middle" in XML::Compile::WSS::Sign|XML::Compile::WSS::Sign/"Defend against man-in-the-middle">.
 
=head2 Signing with RSA

=head3 Limitations

The signing algorithm uses Crypt::OpenSSL::RSA.  According to its
manual-page, the current implementation is limited to 

=over 4

=item * sign_method

   DSIG_RSA_SHA1     DSIGM_RSA_MD5     DSIGM_RSA_SHA256
   DSIGM_RSA_SHA384  DSIGM_RSA_SHA512

It could support some RSA_RIPEMD160, however there is no official
constant for that in the standards.

=item * token_type

  XTP10_X509         XTP10_X509PKI

=back

=head1 SEE ALSO

This module is part of XML-Compile-WSS-Signature distribution version 2.02,
built on July 16, 2016. Website: F<http://perl.overmeer.net/xml-compile/>

Please post questions or ideas to the mailinglist at
F<http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile> .
For live contact with other developers, visit the C<#xml-compile> channel
on C<irc.perl.org>.

=head1 LICENSE

Copyrights 2012-2016 by [Mark Overmeer]. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://www.perl.com/perl/misc/Artistic.html>

