Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Core / System / Security / Cryptography / ECDsa.cs
index 04f11603a17954cdd8a8f3d6c32be367f8c70c65..b0c7b521a880506ce7a3eb49ecef6aeb4968e4dc 100644 (file)
@@ -41,34 +41,48 @@ namespace System.Security.Cryptography {
             return CryptoConfig.CreateFromName(algorithm) as ECDsa;
         }
 
-        public static ECDsa Create (ECCurve curve)
-        {
-            throw new NotImplementedException ();
-        }
-
-        public static ECDsa Create (ECParameters parameters)
-        {
-            throw new NotImplementedException ();
-        }
-
-        public virtual ECParameters ExportExplicitParameters (bool includePrivateParameters)
-        {
-            throw new NotImplementedException ();
-        }
-
-        public virtual ECParameters ExportParameters (bool includePrivateParameters)
-        {
-            throw new NotImplementedException ();
-        }
+        /// <summary>
+        /// Creates a new instance of the default implementation of the Elliptic Curve Digital Signature Algorithm
+        /// (ECDSA) with a newly generated key over the specified curve.
+        /// </summary>
+        /// <param name="curve">The curve to use for key generation.</param>
+        /// <returns>A new instance of the default implementation of this class.</returns>
+        public static ECDsa Create(ECCurve curve) {
+            ECDsa ecdsa = Create();
+
+            if (ecdsa != null) {
+                try {
+                    ecdsa.GenerateKey(curve);
+                }
+                catch {
+                    ecdsa.Dispose();
+                    throw;
+                }
+            }
 
-        public virtual void GenerateKey (ECCurve curve)
-        {
-            throw new NotImplementedException ();
-        }
+            return ecdsa;
+        }
+
+        /// <summary>
+        /// Creates a new instance of the default implementation of the Elliptic Curve Digital Signature Algorithm
+        /// (ECDSA) using the specified ECParameters as the key.
+        /// </summary>
+        /// <param name="parameters">The parameters representing the key to use.</param>
+        /// <returns>A new instance of the default implementation of this class.</returns>
+        public static ECDsa Create(ECParameters parameters) {
+            ECDsa ecdsa = Create();
+
+            if (ecdsa != null) {
+                try {
+                    ecdsa.ImportParameters(parameters);
+                }
+                catch {
+                    ecdsa.Dispose();
+                    throw;
+                }
+            }
 
-        public virtual void ImportParameters (ECParameters parameters)
-        {
-            throw new NotImplementedException ();
+            return ecdsa;
         }
 
         //
@@ -160,6 +174,42 @@ namespace System.Security.Cryptography {
             return VerifyHash(hash, signature);
         }
 
+        /// <summary>
+        /// When overridden in a derived class, exports the named or explicit ECParameters for an ECCurve.
+        /// If the curve has a name, the Curve property will contain named curve parameters, otherwise it
+        /// will contain explicit parameters.
+        /// </summary>
+        /// <param name="includePrivateParameters">true to include private parameters, otherwise, false.</param>
+        /// <returns>The ECParameters representing the point on the curve for this key.</returns>
+        public virtual ECParameters ExportParameters(bool includePrivateParameters) {
+            throw new NotSupportedException(SR.GetString(SR.NotSupported_SubclassOverride));
+        }
+
+        /// <summary>
+        /// When overridden in a derived class, exports the explicit ECParameters for an ECCurve.
+        /// </summary>
+        /// <param name="includePrivateParameters">true to include private parameters, otherwise, false.</param>
+        /// <returns>The ECParameters representing the point on the curve for this key, using the explicit curve format.</returns>
+        public virtual ECParameters ExportExplicitParameters(bool includePrivateParameters) {
+            throw new NotSupportedException(SR.GetString(SR.NotSupported_SubclassOverride));
+        }
+
+        /// <summary>
+        /// When overridden in a derived class, imports the specified ECParameters.
+        /// </summary>
+        /// <param name="parameters">The curve parameters.</param>
+        public virtual void ImportParameters(ECParameters parameters) {
+            throw new NotSupportedException(SR.GetString(SR.NotSupported_SubclassOverride));
+        }
+
+        /// <summary>
+        /// When overridden in a derived class, generates a new public/private keypair for the specified curve.
+        /// </summary>
+        /// <param name="curve">The curve to use.</param>
+        public virtual void GenerateKey(ECCurve curve) {
+            throw new NotSupportedException(SR.GetString(SR.NotSupported_SubclassOverride));
+        }
+
         private static Exception DerivedClassMustOverride() {
             return new NotImplementedException(SR.GetString(SR.NotSupported_SubclassOverride));
         }