Updates referencesource to .NET 4.7
[mono-project.git] / mcs / class / referencesource / System.Core / System / Security / Cryptography / ECDiffieHellmanPublicKey.cs
blob62b83951fd7a2af3ecee06df1dd77e5935081956
1 // ==++==
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // ==--==
7 using System;
8 using System.Runtime.Serialization;
9 using System.Diagnostics.Contracts;
11 namespace System.Security.Cryptography {
12 /// <summary>
13 /// Wrapper for public key material passed between parties during Diffie-Hellman key material generation
14 /// </summary>
15 [Serializable]
16 [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
17 public abstract class ECDiffieHellmanPublicKey : IDisposable {
18 private byte[] m_keyBlob;
20 protected ECDiffieHellmanPublicKey() {
21 m_keyBlob = new byte[0];
24 protected ECDiffieHellmanPublicKey(byte[] keyBlob) {
25 Contract.Ensures(m_keyBlob != null);
27 if (keyBlob == null) {
28 throw new ArgumentNullException("keyBlob");
31 m_keyBlob = keyBlob.Clone() as byte[];
34 public void Dispose() {
35 Dispose(true);
38 protected virtual void Dispose(bool disposing) {
39 return;
42 public virtual byte[] ToByteArray() {
43 Contract.Assert(m_keyBlob != null);
44 return m_keyBlob.Clone() as byte[];
47 // This method must be implemented by derived classes. In order to conform to the contract, it cannot be abstract.
48 public virtual string ToXmlString() {
49 throw new NotImplementedException(SR.GetString(SR.NotSupported_SubclassOverride));
52 /// <summary>
53 /// When overridden in a derived class, exports the named or explicit ECParameters for an ECCurve.
54 /// If the curve has a name, the Curve property will contain named curve parameters, otherwise it
55 /// will contain explicit parameters.
56 /// </summary>
57 /// <returns>The ECParameters representing the point on the curve for this key.</returns>
58 public virtual ECParameters ExportParameters() {
59 throw new NotSupportedException(SR.GetString(SR.NotSupported_SubclassOverride));
62 /// <summary>
63 /// When overridden in a derived class, exports the explicit ECParameters for an ECCurve.
64 /// </summary>
65 /// <returns>The ECParameters representing the point on the curve for this key, using the explicit curve format.</returns>
66 public virtual ECParameters ExportExplicitParameters() {
67 throw new NotSupportedException(SR.GetString(SR.NotSupported_SubclassOverride));