summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-03-09 16:57:58 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-03-09 16:57:58 +0700
commit81e2ba37a3bbc0f4da77175bdea2486dcfa2f239 (patch)
treec3539654234a45e4b300dceadce7ba41998ceb45 /crypto
parentPort X931Signer and tests from Java (diff)
downloadBouncyCastle.NET-ed25519-81e2ba37a3bbc0f4da77175bdea2486dcfa2f239.tar.xz
Add SignerUtilities handling for X931Signer
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/crypto/signers/X931Signer.cs3
-rw-r--r--crypto/src/security/SignerUtilities.cs20
2 files changed, 21 insertions, 2 deletions
diff --git a/crypto/src/crypto/signers/X931Signer.cs b/crypto/src/crypto/signers/X931Signer.cs
index cc3292159..89f512b78 100644
--- a/crypto/src/crypto/signers/X931Signer.cs
+++ b/crypto/src/crypto/signers/X931Signer.cs
@@ -81,10 +81,9 @@ namespace Org.BouncyCastle.Crypto.Signers
             }
         }
 
-        [Obsolete]
         public virtual string AlgorithmName
         {
-            get { return digest.AlgorithmName + "withX931"; }
+            get { return digest.AlgorithmName + "with" + cipher.AlgorithmName + "/X9.31"; }
         }
 
         /**
diff --git a/crypto/src/security/SignerUtilities.cs b/crypto/src/security/SignerUtilities.cs
index c1aea50d6..bd1515147 100644
--- a/crypto/src/security/SignerUtilities.cs
+++ b/crypto/src/security/SignerUtilities.cs
@@ -534,6 +534,26 @@ namespace Org.BouncyCastle.Security
                 return new Iso9796d2Signer(new RsaBlindedEngine(), new RipeMD160Digest(), true);
             }
 
+            if (mechanism.EndsWith("/X9.31"))
+            {
+                string x931 = mechanism.Substring(0, mechanism.Length - "/X9.31".Length);
+                int withPos = x931.IndexOf("WITH");
+                if (withPos > 0)
+                {
+                    int endPos = withPos + "WITH".Length;
+
+                    string digestName = x931.Substring(0, withPos);
+                    IDigest digest = DigestUtilities.GetDigest(digestName);
+
+                    string cipherName = x931.Substring(endPos, x931.Length - endPos);
+                    if (cipherName.Equals("RSA"))
+                    {
+                        IAsymmetricBlockCipher cipher = new RsaBlindedEngine();
+                        return new X931Signer(cipher, digest);
+                    }
+                }
+            }
+
             throw new SecurityUtilityException("Signer " + algorithm + " not recognised.");
         }