Re: Another RSACryptoServiceProvider question
From: Daryn Kiely (anonymous_at_discussions.microsoft.com)
Date: 10/30/03
- Next message: Ohaya: "Re: Does deleting a certificate cause private key deletion?"
- Previous message: Pieter Philippaerts: "Re: Another RSACryptoServiceProvider question"
- In reply to: Pieter Philippaerts: "Re: Another RSACryptoServiceProvider question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 29 Oct 2003 15:08:12 -0800
Thanks Pieter,
This resolved my problem, (I hate out by 1 errors), but I
still don't know why encryption worked.
Daryn
>-----Original Message-----
>"Daryn Kiely" <anonymous@discussions.microsoft.com>
wrote in message
>> This works great if the fOAEP flag is
>> false (use PKCS padding) but fails if I use OAEP
>> padding. In both cases the encryption works, but in
the
>> latter case the code throws a Cryptographic Exception
>> with the message "Error occured while decoding OAEP
>> padding".
>
>There are two problems with your code. The first is that
you use the
>rsaEncrypt object to both encrypt and decrypt.
rsaEncrypt.Decrypt will
>obviously not work because it doesn't have access to the
private key.
>However I assume it was an error in your post and not an
error in the code
>you're using because you said PKCS#1 worked.
>
>Secondly, you're trying to encrypt/decrypt too many
bytes. If you change the
>number of bytes you're trying to encrypt to 86,
everything works perfectly.
>This is in accordance with the MSDN documentation, that
states "Modulus
>size -2 -2*hLen, where hLen is the size of the hash". If
you take modulus
>size to be 128 bytes [or 1024 bits] and hLen 20 bytes
[ie. SHA-1], you get
>128 - 2 - 2 * 20 = 86.
>It's strange that the encrypt method works and the
decrypt doesn't. The
>encrypt method should have thrown an exception.
>
>Regards,
>Pieter Philippaerts
>Managed SSL/TLS: http://www.mentalis.org/go.php?sl
>
- Next message: Ohaya: "Re: Does deleting a certificate cause private key deletion?"
- Previous message: Pieter Philippaerts: "Re: Another RSACryptoServiceProvider question"
- In reply to: Pieter Philippaerts: "Re: Another RSACryptoServiceProvider question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|