summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-05-10 17:15:55 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-05-10 17:15:55 +0700
commiteda54f7b1f46d4965eb483cb41d47358f7cea530 (patch)
tree9095d952bdb2e0cfb6a7b6b09a87a264cba9f4d5
parentImprove TLS handshake hash tracking (diff)
downloadBouncyCastle.NET-ed25519-eda54f7b1f46d4965eb483cb41d47358f7cea530.tar.xz
Minor SignatureAlgorithm additions
-rw-r--r--crypto/src/tls/SignatureAlgorithm.cs43
-rw-r--r--crypto/src/tls/crypto/CryptoSignatureAlgorithm.cs3
-rw-r--r--crypto/src/tls/crypto/TlsCryptoUtilities.cs6
3 files changed, 44 insertions, 8 deletions
diff --git a/crypto/src/tls/SignatureAlgorithm.cs b/crypto/src/tls/SignatureAlgorithm.cs
index 726504c52..baf5620e3 100644
--- a/crypto/src/tls/SignatureAlgorithm.cs
+++ b/crypto/src/tls/SignatureAlgorithm.cs
@@ -86,20 +86,16 @@ namespace Org.BouncyCastle.Tls
                 return "dsa";
             case ecdsa:
                 return "ecdsa";
-            case ed25519:
-                return "ed25519";
-            case ed448:
-                return "ed448";
-            case gostr34102012_256:
-                return "gostr34102012_256";
-            case gostr34102012_512:
-                return "gostr34102012_512";
             case rsa_pss_rsae_sha256:
                 return "rsa_pss_rsae_sha256";
             case rsa_pss_rsae_sha384:
                 return "rsa_pss_rsae_sha384";
             case rsa_pss_rsae_sha512:
                 return "rsa_pss_rsae_sha512";
+            case ed25519:
+                return "ed25519";
+            case ed448:
+                return "ed448";
             case rsa_pss_pss_sha256:
                 return "rsa_pss_pss_sha256";
             case rsa_pss_pss_sha384:
@@ -112,6 +108,10 @@ namespace Org.BouncyCastle.Tls
                 return "ecdsa_brainpoolP384r1tls13_sha384";
             case ecdsa_brainpoolP512r1tls13_sha512:
                 return "ecdsa_brainpoolP512r1tls13_sha512";
+            case gostr34102012_256:
+                return "gostr34102012_256";
+            case gostr34102012_512:
+                return "gostr34102012_512";
             default:
                 return "UNKNOWN";
             }
@@ -121,5 +121,32 @@ namespace Org.BouncyCastle.Tls
         {
             return GetName(signatureAlgorithm) + "(" + signatureAlgorithm + ")";
         }
+
+        public static bool IsRecognized(short signatureAlgorithm)
+        {
+            switch (signatureAlgorithm)
+            {
+            case anonymous:
+            case rsa:
+            case dsa:
+            case ecdsa:
+            case rsa_pss_rsae_sha256:
+            case rsa_pss_rsae_sha384:
+            case rsa_pss_rsae_sha512:
+            case ed25519:
+            case ed448:
+            case rsa_pss_pss_sha256:
+            case rsa_pss_pss_sha384:
+            case rsa_pss_pss_sha512:
+            case ecdsa_brainpoolP256r1tls13_sha256:
+            case ecdsa_brainpoolP384r1tls13_sha384:
+            case ecdsa_brainpoolP512r1tls13_sha512:
+            case gostr34102012_256:
+            case gostr34102012_512:
+                return true;
+            default:
+                return false;
+            }
+        }
     }
 }
diff --git a/crypto/src/tls/crypto/CryptoSignatureAlgorithm.cs b/crypto/src/tls/crypto/CryptoSignatureAlgorithm.cs
index ed58820b8..15435cab5 100644
--- a/crypto/src/tls/crypto/CryptoSignatureAlgorithm.cs
+++ b/crypto/src/tls/crypto/CryptoSignatureAlgorithm.cs
@@ -15,6 +15,9 @@ namespace Org.BouncyCastle.Tls.Crypto
         public const int rsa_pss_pss_sha256 = 9;
         public const int rsa_pss_pss_sha384 = 10;
         public const int rsa_pss_pss_sha512 = 11;
+        public const int ecdsa_brainpoolP256r1tls13_sha256 = 26;
+        public const int ecdsa_brainpoolP384r1tls13_sha384 = 27;
+        public const int ecdsa_brainpoolP512r1tls13_sha512 = 28;
         public const int gostr34102012_256 = 64;
         public const int gostr34102012_512 = 65;
         public const int sm2 = 200;
diff --git a/crypto/src/tls/crypto/TlsCryptoUtilities.cs b/crypto/src/tls/crypto/TlsCryptoUtilities.cs
index 4ce48f738..98ac87a83 100644
--- a/crypto/src/tls/crypto/TlsCryptoUtilities.cs
+++ b/crypto/src/tls/crypto/TlsCryptoUtilities.cs
@@ -163,6 +163,12 @@ namespace Org.BouncyCastle.Tls.Crypto
                 return CryptoSignatureAlgorithm.rsa_pss_pss_sha384;
             case SignatureAlgorithm.rsa_pss_pss_sha512:
                 return CryptoSignatureAlgorithm.rsa_pss_pss_sha512;
+            case SignatureAlgorithm.ecdsa_brainpoolP256r1tls13_sha256:
+                return CryptoSignatureAlgorithm.ecdsa_brainpoolP256r1tls13_sha256;
+            case SignatureAlgorithm.ecdsa_brainpoolP384r1tls13_sha384:
+                return CryptoSignatureAlgorithm.ecdsa_brainpoolP384r1tls13_sha384;
+            case SignatureAlgorithm.ecdsa_brainpoolP512r1tls13_sha512:
+                return CryptoSignatureAlgorithm.ecdsa_brainpoolP512r1tls13_sha512;
             case SignatureAlgorithm.gostr34102012_256:
                 return CryptoSignatureAlgorithm.gostr34102012_256;
             case SignatureAlgorithm.gostr34102012_512: