-
Notifications
You must be signed in to change notification settings - Fork 2
Fix MGF issues #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
60768bd to
544cb81
Compare
[ Major change since 0.08 ]
@NGEfreak asked if Crypt::Random could be replaced with Crypt::PRNG
to eliminate the need for pari which requires network connectivity.
Makes sense because CryptX is already a dependency.
Known issue:
rsa-oaep with different digests for the MGF and the label is broken and
was broken from the initial implementation.
This is being resolved via #4
- f04a0d5 Increment version for official release
- 33cccb7 v0.10
ad69a86 to
544b250
Compare
| my $self = shift; | ||
| my $method = shift; | ||
|
|
||
| return if ! defined $method; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same exists logic.
| my $self = shift; | ||
| my $method = shift; | ||
|
|
||
| return if ! defined $method; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same exists logic.
| my $self = shift; | ||
| my $method = shift; | ||
|
|
||
| return if ! defined $method; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do an exists later on, shouldn't it either croak/die/warn about method not being specified or use the default which is used later on?
So, method having value '' or 0 is fine, but undef isn't. I would perhaps do $method //= ''; and continue with the function. Or just croak if it is undef.
| my $self = shift; | ||
| my $method = shift; | ||
|
|
||
| return if ! defined $method; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same exists logic.
| $method{OAEPparams} = $keyinfo->[0]->findvalue('//xenc:EncryptedKey/xenc:EncryptionMethod/xenc:OAEPparams', $context); | ||
| $method{MGF} = $keyinfo->[0]->findvalue('//xenc:EncryptedKey/xenc:EncryptionMethod/xenc:MGF/@Algorithm', $context); | ||
|
|
||
| if ($method{Algorithm} eq 'http://www.w3.org/2009/xmlenc11#rsa-oaep') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L511-519 and 529-540 are the same. Perhaps make a function for it?
| } | ||
| elsif ($keymethod->{Algorithm} eq 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p') { | ||
| return $self->{key_obj}->decrypt($encryptedkey, 'oaep', 'SHA1', decode_base64($keymethod->{OAEPparams})); | ||
| my $oaep_params = defined $keymethod->{OAEPparams} ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also almost the same as the additions starting at 652.
| } | ||
| elsif ($keymethod eq 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p') { | ||
| ${$key} = $rsa_pub->encrypt(${$key}, 'oaep', 'SHA1', $self->{oaep_params}); | ||
| my $oaep_label_hash = (defined $self->{oaep_label_hash} && $self->{oaep_label_hash} ne '') ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
683 and below matches 692 and below as well.
|
Closing in favour of #12 which is a rebase and seems to fix most of these issues |
libtom (CryptX <= 0.077) does not support specifying the a MGF and OEAPparam digest that differ.
This sorts out most of the issues. Thinking now I suspect that it will still allow you to generate XML that will not properly decrypt but basically, the two must use the same hash in both