diff options
author | Sebastien Pouliot <sebastien@ximian.com> | 2006-02-28 17:19:08 +0300 |
---|---|---|
committer | Sebastien Pouliot <sebastien@ximian.com> | 2006-02-28 17:19:08 +0300 |
commit | b767344ef4667f639ba805438005fe727465a591 (patch) | |
tree | 3cd323a9aa376cb9a40d964fe0da66c6c824143d /mcs | |
parent | d4d091c6e565606e945bbb1f25d556c18adc9ba7 (diff) |
2006-02-28 Sebastien Pouliot <sebastien@ximian.com>
* CryptoConvert.cs: Make sure we can import a keypair into our RSA
instance (even if the key store isn't available). See bug #77559.
* PKCS8.cs: Make sure we can import a keypair into our RSA instance
(even if the key store isn't available). See bug #77559.
svn path=/trunk/mcs/; revision=57390
Diffstat (limited to 'mcs')
3 files changed, 51 insertions, 12 deletions
diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog b/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog index f4c50707dcc..3353d513a6e 100644 --- a/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog +++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/ChangeLog @@ -1,3 +1,10 @@ +2006-02-28 Sebastien Pouliot <sebastien@ximian.com> + + * CryptoConvert.cs: Make sure we can import a keypair into our RSA + instance (even if the key store isn't available). See bug #77559. + * PKCS8.cs: Make sure we can import a keypair into our RSA instance + (even if the key store isn't available). See bug #77559. + 2005-11-23 Sebastien Pouliot <sebastien@ximian.com> * SymmetricTransform.cs: Synched with corlib version (IV behaviour for diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoConvert.cs b/mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoConvert.cs index 1d876703f0c..e0e9cbd7ede 100644 --- a/mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoConvert.cs +++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/CryptoConvert.cs @@ -5,11 +5,7 @@ // Sebastien Pouliot <sebastien@ximian.com> // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) -// (C) 2004 Novell (http://www.novell.com) -// - -// -// Copyright (C) 2004 Novell, Inc (http://www.novell.com) +// Copyright (C) 2004-2006 Novell Inc. (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -166,8 +162,20 @@ namespace Mono.Security.Cryptography { Array.Reverse (rsap.D); } - RSA rsa = (RSA)RSA.Create (); - rsa.ImportParameters (rsap); + RSA rsa = null; + try { + rsa = RSA.Create (); + rsa.ImportParameters (rsap); + } + catch (CryptographicException) { + // this may cause problem when this code is run under + // the SYSTEM identity on Windows (e.g. ASP.NET). See + // http://bugzilla.ximian.com/show_bug.cgi?id=77559 + CspParameters csp = new CspParameters (); + csp.Flags = CspProviderFlags.UseMachineKeyStore; + rsa = new RSACryptoServiceProvider (csp); + rsa.ImportParameters (rsap); + } return rsa; } catch (Exception e) { @@ -287,8 +295,20 @@ namespace Mono.Security.Cryptography { Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen); Array.Reverse (rsap.Modulus); - RSA rsa = (RSA)RSA.Create (); - rsa.ImportParameters (rsap); + RSA rsa = null; + try { + rsa = RSA.Create (); + rsa.ImportParameters (rsap); + } + catch (CryptographicException) { + // this may cause problem when this code is run under + // the SYSTEM identity on Windows (e.g. ASP.NET). See + // http://bugzilla.ximian.com/show_bug.cgi?id=77559 + CspParameters csp = new CspParameters (); + csp.Flags = CspProviderFlags.UseMachineKeyStore; + rsa = new RSACryptoServiceProvider (csp); + rsa.ImportParameters (rsap); + } return rsa; } catch (Exception e) { diff --git a/mcs/class/Mono.Security/Mono.Security.Cryptography/PKCS8.cs b/mcs/class/Mono.Security/Mono.Security.Cryptography/PKCS8.cs index d7cedf758f6..cc83e116844 100644 --- a/mcs/class/Mono.Security/Mono.Security.Cryptography/PKCS8.cs +++ b/mcs/class/Mono.Security/Mono.Security.Cryptography/PKCS8.cs @@ -6,7 +6,7 @@ // Sebastien Pouliot <sebastien@ximian.com> // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) -// Copyright (C) 2004-2005 Novell Inc. (http://www.novell.com) +// Copyright (C) 2004-2006 Novell Inc. (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -273,8 +273,20 @@ namespace Mono.Security.Cryptography { param.P = Normalize (privateKey [4].Value, keysize2); param.Q = Normalize (privateKey [5].Value, keysize2); - RSA rsa = RSA.Create (); - rsa.ImportParameters (param); + RSA rsa = null; + try { + rsa = RSA.Create (); + rsa.ImportParameters (param); + } + catch (CryptographicException) { + // this may cause problem when this code is run under + // the SYSTEM identity on Windows (e.g. ASP.NET). See + // http://bugzilla.ximian.com/show_bug.cgi?id=77559 + CspParameters csp = new CspParameters (); + csp.Flags = CspProviderFlags.UseMachineKeyStore; + rsa = new RSACryptoServiceProvider (csp); + rsa.ImportParameters (param); + } return rsa; } |