diff options
author | Sebastien Pouliot <sebastien@ximian.com> | 2004-05-01 20:46:01 +0400 |
---|---|---|
committer | Sebastien Pouliot <sebastien@ximian.com> | 2004-05-01 20:46:01 +0400 |
commit | da1d4959f6f8aeb9292cdfb154ccaa8d02b97103 (patch) | |
tree | 029f72c559ea293b43012384b5b32ca6eb88aa92 /mcs/class/Mono.Security | |
parent | a4bc7e162c37039dd4592359ee823db012a6146e (diff) |
2004-05-01 Sebastien Pouliot <sebastien@ximian.com>
* CryptoConvert.cs: Added support for truncated, but still valid, RSA
private key blob. Fix #57941 (couldn't sign with nunit key).
* RSAManaged.cs: Normalized the size of D when not present. This
allows us to output a compatible base64 representation of 1024bits 0.
svn path=/trunk/mcs/; revision=26511
Diffstat (limited to 'mcs/class/Mono.Security')
3 files changed, 22 insertions, 4 deletions
diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog b/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog index 1c2431947a5..5cfc57e242e 100644 --- a/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog +++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog @@ -1,3 +1,10 @@ +2004-05-01 Sebastien Pouliot <sebastien@ximian.com> + + * CryptoConvert.cs: Added support for truncated, but still valid, RSA + private key blob. Fix #57941 (couldn't sign with nunit key). + * RSAManaged.cs: Normalized the size of D when not present. This + allows us to output a compatible base64 representation of 1024bits 0. + 2004-04-28 Sebastien Pouliot <sebastien@ximian.com> * SymmetricTransform.cs: Fixed bug when offset > 0 in destination diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoConvert.cs b/mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoConvert.cs index 70fb9fe4a81..058fe091730 100644 --- a/mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoConvert.cs +++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoConvert.cs @@ -133,10 +133,15 @@ namespace Mono.Security.Cryptography { Array.Reverse (rsap.InverseQ); pos += byteHalfLen; - // BYTE privateExponent[rsapubkey.bitlen/8]; - rsap.D = new byte [byteLen]; - Buffer.BlockCopy (blob, pos, rsap.D, 0, byteLen); - Array.Reverse (rsap.D); + // ok, this is hackish but CryptoAPI support it so... + // note: only works because CRT is used by default + // http://bugzilla.ximian.com/show_bug.cgi?id=57941 + rsap.D = new byte [byteLen]; // must be allocated + if (pos + byteLen + offset <= blob.Length) { + // BYTE privateExponent[rsapubkey.bitlen/8]; + Buffer.BlockCopy (blob, pos, rsap.D, 0, byteLen); + Array.Reverse (rsap.D); + } RSA rsa = (RSA)RSA.Create (); rsa.ImportParameters (rsap); diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/RSAManaged.cs b/mcs/class/Mono.Security/Mono.Security.Cryptography/RSAManaged.cs index 79d2ae4a186..6c811101d4e 100644 --- a/mcs/class/Mono.Security/Mono.Security.Cryptography/RSAManaged.cs +++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/RSAManaged.cs @@ -221,6 +221,12 @@ namespace Mono.Security.Cryptography { if ((d == null) || (p == null) || (q == null)) throw new CryptographicException ("Missing private key"); param.D = d.GetBytes (); + // hack for bugzilla #57941 where D wasn't provided + if (param.D.Length != param.Modulus.Length) { + byte[] normalizedD = new byte [param.Modulus.Length]; + Buffer.BlockCopy (param.D, 0, normalizedD, (normalizedD.Length - param.D.Length), param.D.Length); + param.D = normalizedD; + } param.P = p.GetBytes (); param.Q = q.GetBytes (); // but CRT parameters are optionals |