Files
data
debian
docs
eglib
external
ikvm-native
libgc
m4
man
mcs
build
class
Accessibility
Commons.Xml.Relaxng
Cscompmgd
CustomMarshalers
Facades
I18N
IBM.Data.DB2
ICSharpCode.SharpZipLib
Managed.Windows.Forms
Microsoft.Build
Microsoft.Build.Engine
Microsoft.Build.Framework
Microsoft.Build.Tasks
Microsoft.Build.Utilities
Microsoft.CSharp
Microsoft.VisualC
Microsoft.Web.Infrastructure
MicrosoftAjaxLibrary
Mono.C5
Mono.CSharp
Mono.Cairo
Mono.Cecil
Mono.Cecil.Mdb
Mono.CodeContracts
Mono.CompilerServices.SymbolWriter
Mono.Data.Sqlite
Mono.Data.Tds
Mono.Debugger.Soft
Mono.Dynamic.Interpreter
Mono.Http
Mono.Management
Mono.Messaging
Mono.Messaging.RabbitMQ
Mono.Options
Mono.Parallel
Mono.Posix
Mono.Security
Mono.Security.Win32
Mono.Simd
Mono.Tasklets
Mono.WebBrowser
Mono.XBuild.Tasks
Novell.Directory.Ldap
PEAPI
RabbitMQ.Client
System
System.ComponentModel.Composition.4.5
System.ComponentModel.DataAnnotations
System.Configuration
System.Configuration.Install
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Linq
System.Data.OracleClient
System.Data.Services
System.Data.Services.Client
System.Design
System.DirectoryServices
System.DirectoryServices.Protocols
System.Drawing
System.Drawing.Design
System.Dynamic
System.EnterpriseServices
System.IO.Compression
System.IO.Compression.FileSystem
System.IdentityModel
System.IdentityModel.Selectors
System.Json
System.Json.Microsoft
System.Management
System.Messaging
System.Net
System.Net.Http
System.Net.Http.Formatting
System.Net.Http.WebRequest
System.Numerics
System.Reactive.Core
System.Reactive.Debugger
System.Reactive.Experimental
System.Reactive.Interfaces
System.Reactive.Linq
System.Reactive.Observable.Aliases
System.Reactive.PlatformServices
System.Reactive.Providers
System.Reactive.Runtime.Remoting
System.Reactive.Windows.Forms
System.Reactive.Windows.Threading
System.Runtime.Caching
System.Runtime.DurableInstancing
System.Runtime.Remoting
System.Runtime.Serialization
System.Runtime.Serialization.Formatters.Soap
System.Security
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Discovery
System.ServiceModel.Routing
System.ServiceModel.Web
System.ServiceProcess
System.Threading.Tasks.Dataflow
System.Transactions
System.Web
System.Web.Abstractions
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Extensions
System.Web.Extensions.Design
System.Web.Http
System.Web.Http.SelfHost
System.Web.Http.WebHost
System.Web.Mvc3
System.Web.Razor
System.Web.Routing
System.Web.Services
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
System.Windows
System.Windows.Forms.DataVisualization
System.XML
System.Xaml
System.Xml.Linq
System.Xml.Serialization
SystemWebTestShim
WebMatrix.Data
WindowsBase
aot-compiler
corlib
Assembly
Documentation
Microsoft.Win32
Microsoft.Win32.SafeHandles
Mono
Mono.Globalization.Unicode
Mono.Interop
Mono.Security
Mono.Security.Cryptography
Mono.Xml
ReferenceSources
System
System.Collections
System.Collections.Concurrent
System.Collections.Generic
System.Configuration.Assemblies
System.Deployment.Internal
System.Diagnostics
System.Diagnostics.CodeAnalysis
System.Diagnostics.SymbolStore
System.Diagnostics.Tracing
System.Globalization
System.IO
System.IO.IsolatedStorage
System.Reflection
System.Reflection.Emit
System.Resources
System.Runtime
System.Runtime.CompilerServices
System.Runtime.ConstrainedExecution
System.Runtime.ExceptionServices
System.Runtime.Hosting
System.Runtime.InteropServices
System.Runtime.InteropServices.ComTypes
System.Runtime.InteropServices.Expando
System.Runtime.InteropServices.WindowsRuntime
System.Runtime.Remoting
System.Runtime.Remoting.Activation
System.Runtime.Remoting.Channels
System.Runtime.Remoting.Contexts
System.Runtime.Remoting.Lifetime
System.Runtime.Remoting.Messaging
System.Runtime.Remoting.Metadata
System.Runtime.Remoting.Metadata.W3cXsd2001
System.Runtime.Remoting.Proxies
System.Runtime.Remoting.Services
System.Runtime.Serialization
System.Runtime.Serialization.Formatters
System.Runtime.Serialization.Formatters.Binary
System.Runtime.Versioning
System.Security
System.Security.AccessControl
System.Security.Claims
System.Security.Cryptography
Aes.cs
AsymmetricAlgorithm.cs
AsymmetricKeyExchangeDeformatter.cs
AsymmetricKeyExchangeFormatter.cs
AsymmetricSignatureDeformatter.cs
AsymmetricSignatureFormatter.cs
Base64Constants.cs
ChangeLog
CipherMode.cs
CryptoAPITransform.cs
CryptoConfig.cs
CryptoConfig.fullaot.cs
CryptoConfig_2_1.cs
CryptoStream.cs
CryptoStreamMode.cs
CryptographicException.cs
CryptographicUnexpectedOperationExcpetion.cs
CspKeyContainerInfo.cs
CspParameters.cs
CspProviderFlags.cs
DES.cs
DESCryptoServiceProvider.cs
DSA.cs
DSACryptoServiceProvider.cs
DSAParameters.cs
DSASignatureDeformatter.cs
DSASignatureFormatter.cs
DeriveBytes.cs
FromBase64Transform.cs
HMAC.cs
HMACMD5.cs
HMACRIPEMD160.cs
HMACSHA1.cs
HMACSHA256.cs
HMACSHA384.cs
HMACSHA512.cs
HashAlgorithm.cs
ICryptoTransform.cs
ICspAsymmetricAlgorithm.cs
KeyNumber.cs
KeySizes.cs
KeyedHashAlgorithm.cs
MACTripleDES.cs
MD5.cs
MD5CryptoServiceProvider.cs
MaskGenerationMethod.cs
PKCS1MaskGenerationMethod.cs
PaddingMode.cs
PasswordDeriveBytes.cs
RC2.cs
RC2CryptoServiceProvider.cs
RIPEMD160.cs
RIPEMD160Managed.cs
RNGCryptoServiceProvider.cs
RSA.cs
RSACryptoServiceProvider.cs
RSAOAEPKeyExchangeDeformatter.cs
RSAOAEPKeyExchangeFormatter.cs
RSAPKCS1KeyExchangeDeformatter.cs
RSAPKCS1KeyExchangeFormatter.cs
RSAPKCS1SignatureDeformatter.cs
RSAPKCS1SignatureFormatter.cs
RSAParameters.cs
RandomNumberGenerator.cs
Rfc2898DeriveBytes.cs
Rijndael.cs
RijndaelManaged.cs
RijndaelManagedTransform.cs
SHA1.cs
SHA1CryptoServiceProvider.cs
SHA1Managed.cs
SHA256.cs
SHA256Managed.cs
SHA384.cs
SHA384Managed.cs
SHA512.cs
SHA512Managed.cs
SHAConstants.cs
SignatureDescription.cs
SymmetricAlgorithm.cs
ToBase64Transform.cs
TripleDES.cs
TripleDESCryptoServiceProvider.cs
System.Security.Cryptography.X509Certificates
System.Security.Permissions
System.Security.Policy
System.Security.Principal
System.Text
System.Threading
System.Threading.Tasks
Test
resources
ChangeLog
Makefile
corlib.dll.sources
corlib_test.dll.sources
monotouch_corlib.dll.sources
net_4_5_corlib.dll.sources
xammac_corlib.dll.sources
dlr
doc
lib
monodoc
notes
reference-assemblies
ChangeLog
LICENSE
Makefile
README
ecma.pub
mono.pub
mono.snk
msfinal.pub
reactive.pub
silverlight.pub
winfx.pub
winfx3.pub
docs
errors
ilasm
jay
mcs
nunit24
tests
tools
AUTHORS
COPYING
COPYING.LIB
ChangeLog
INSTALL.txt
LICENSE
LICENSE.GPL
LICENSE.LGPL
LICENSE.MPL
MIT.X11
Makefile
MonoIcon.png
README
ScalableMonoIcon.svg
mkinstalldirs
winexe.in
mono
msvc
po
runtime
samples
scripts
support
tools
AUTHORS
COPYING.LIB
ChangeLog.REMOVED.git-id
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
build-mingw32.sh
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-core.spec
mono-core.spec.in
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/mcs/class/corlib/System.Security.Cryptography/AsymmetricAlgorithm.cs

120 lines
3.4 KiB
C#
Raw Normal View History

//
// System.Security.Cryptography.AsymmetricAlgorithm Class implementation
//
// Authors:
// Thomas Neidhart (tome@sbox.tugraz.at)
// Sebastien Pouliot (sebastien@ximian.com)
//
// Portions (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
// Copyright (C) 2004-2005, 2008 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Globalization;
using System.Runtime.InteropServices;
namespace System.Security.Cryptography {
[ComVisible (true)]
public abstract class AsymmetricAlgorithm : IDisposable {
protected int KeySizeValue;
protected KeySizes[] LegalKeySizesValue;
protected AsymmetricAlgorithm ()
{
}
public abstract string KeyExchangeAlgorithm {
get;
}
public virtual int KeySize {
get { return this.KeySizeValue; }
set {
if (!KeySizes.IsLegalKeySize (this.LegalKeySizesValue, value))
throw new CryptographicException (Locale.GetText ("Key size not supported by algorithm."));
this.KeySizeValue = value;
}
}
public virtual KeySizes[] LegalKeySizes {
get { return this.LegalKeySizesValue; }
}
public abstract string SignatureAlgorithm {
get;
}
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this); // Finalization is now unnecessary
}
public void Clear ()
{
Dispose (false);
}
protected virtual void Dispose (bool disposing)
{
}
public abstract void FromXmlString (string xmlString);
public abstract string ToXmlString (bool includePrivateParameters);
public static AsymmetricAlgorithm Create ()
{
#if FULL_AOT_RUNTIME
return new RSACryptoServiceProvider ();
#else
return Create ("System.Security.Cryptography.AsymmetricAlgorithm");
#endif
}
public static AsymmetricAlgorithm Create (string algName)
{
return (AsymmetricAlgorithm) CryptoConfig.CreateFromName (algName);
}
// parsing helper shared between DSA and RSA
internal static byte [] GetNamedParam (string xml, string param)
{
string start_element = "<" + param + ">";
int start = xml.IndexOf (start_element);
if (start == -1)
return null;
string end_element = "</" + param + ">";
int end = xml.IndexOf (end_element);
if ((end == -1) || (end <= start))
return null;
start += start_element.Length;
string base64 = xml.Substring (start, end - start);
return Convert.FromBase64String (base64);
}
}
}