3 // Copyright (c) Microsoft Corporation. All rights reserved.
8 using System
.Runtime
.Serialization
;
9 using System
.Diagnostics
.Contracts
;
11 namespace System
.Security
.Cryptography
{
13 /// Wrapper for public key material passed between parties during Diffie-Hellman key material generation
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() {
38 protected virtual void Dispose(bool disposing
) {
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
));
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.
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
));
63 /// When overridden in a derived class, exports the explicit ECParameters for an ECCurve.
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
));