summary refs log tree commit diff
path: root/crypto/src/security
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-06-14 14:04:48 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-06-14 14:04:48 +0700
commit75cb55fedb8b90dc99996b88ccb55a35549be184 (patch)
tree1d9c98fa82bb48cc5cf704c6623e5e407a90671e /crypto/src/security
parentAdd new variant of GetBasicAgreementWithKdf (diff)
downloadBouncyCastle.NET-ed25519-75cb55fedb8b90dc99996b88ccb55a35549be184.tar.xz
Add ECDHCWithKdfBasicAgreement
- refactor other WithKdf agreeements
- support "ECCDHWITHSHA1KDF" in AgreementUtilities
Diffstat (limited to 'crypto/src/security')
-rw-r--r--crypto/src/security/AgreementUtilities.cs17
1 files changed, 6 insertions, 11 deletions
diff --git a/crypto/src/security/AgreementUtilities.cs b/crypto/src/security/AgreementUtilities.cs
index 5fef5f877..041aeeed2 100644
--- a/crypto/src/security/AgreementUtilities.cs
+++ b/crypto/src/security/AgreementUtilities.cs
@@ -67,24 +67,19 @@ namespace Org.BouncyCastle.Security
 			return GetBasicAgreementWithKdf(oid.Id, wrapAlgorithm);
 		}
 
-		public static IBasicAgreement GetBasicAgreementWithKdf(
-			string agreeAlgorithm,
-			string wrapAlgorithm)
+		public static IBasicAgreement GetBasicAgreementWithKdf(string agreeAlgorithm, string wrapAlgorithm)
 		{
             string mechanism = GetMechanism(agreeAlgorithm);
 
             // 'DHWITHSHA1KDF' retained for backward compatibility
 			if (mechanism == "DHWITHSHA1KDF" || mechanism == "ECDHWITHSHA1KDF")
-				return new ECDHWithKdfBasicAgreement(
-					wrapAlgorithm,
-					new ECDHKekGenerator(
-						new Sha1Digest()));
+				return new ECDHWithKdfBasicAgreement(wrapAlgorithm, new ECDHKekGenerator(new Sha1Digest()));
+
+			if (mechanism == "ECCDHWITHSHA1KDF")
+				return new ECDHCWithKdfBasicAgreement(wrapAlgorithm, new ECDHKekGenerator(new Sha1Digest()));
 
 			if (mechanism == "ECMQVWITHSHA1KDF")
-				return new ECMqvWithKdfBasicAgreement(
-					wrapAlgorithm,
-					new ECDHKekGenerator(
-						new Sha1Digest()));
+				return new ECMqvWithKdfBasicAgreement(wrapAlgorithm, new ECDHKekGenerator(new Sha1Digest()));
 
 			throw new SecurityUtilityException("Basic Agreement (with KDF) " + agreeAlgorithm + " not recognised.");
 		}