summary refs log tree commit diff
path: root/crypto/src/cms
diff options
context:
space:
mode:
authorMW <megan@cryptoworkshop.com>2019-01-19 18:23:46 +1100
committerMW <megan@cryptoworkshop.com>2019-01-19 18:23:46 +1100
commitcf14c29752d40edd22fcdc20bddb5643ba32b1dd (patch)
tree7c6e92a11fd4aad9a60b2241ff13fac54c602860 /crypto/src/cms
parentUpdated to use nominated digtest. (diff)
downloadBouncyCastle.NET-ed25519-cf14c29752d40edd22fcdc20bddb5643ba32b1dd.tar.xz
Selecting digest.
Diffstat (limited to 'crypto/src/cms')
-rw-r--r--crypto/src/cms/KeyTransRecipientInformation.cs14
1 files changed, 10 insertions, 4 deletions
diff --git a/crypto/src/cms/KeyTransRecipientInformation.cs b/crypto/src/cms/KeyTransRecipientInformation.cs
index 3b1ea7b5e..7d2f072b5 100644
--- a/crypto/src/cms/KeyTransRecipientInformation.cs
+++ b/crypto/src/cms/KeyTransRecipientInformation.cs
@@ -55,12 +55,18 @@ namespace Org.BouncyCastle.Cms
         }
 
 		private string GetExchangeEncryptionAlgorithmName(
-			DerObjectIdentifier oid)
+			AlgorithmIdentifier algo)
 		{
-			if (Asn1Pkcs.PkcsObjectIdentifiers.RsaEncryption.Equals(oid))
+		    DerObjectIdentifier oid = algo.Algorithm;
+
+            if (Asn1Pkcs.PkcsObjectIdentifiers.RsaEncryption.Equals(oid))
 			{
 				return "RSA//PKCS1Padding";
-			}
+			} else if (Asn1Pkcs.PkcsObjectIdentifiers.IdRsaesOaep.Equals(oid))
+            {
+                 Asn1Pkcs.RsaesOaepParameters rsaParams = Asn1Pkcs.RsaesOaepParameters.GetInstance(algo.Parameters);                       
+                return "RSA//OAEPWITH"+DigestUtilities.GetAlgorithmName(rsaParams.HashAlgorithm.Algorithm)+"ANDMGF1Padding";
+            }
 
 			return oid.Id;
 		}
@@ -68,7 +74,7 @@ namespace Org.BouncyCastle.Cms
 		internal KeyParameter UnwrapKey(ICipherParameters key)
 		{
 			byte[] encryptedKey = info.EncryptedKey.GetOctets();
-            string keyExchangeAlgorithm = GetExchangeEncryptionAlgorithmName(keyEncAlg.Algorithm);
+            string keyExchangeAlgorithm = GetExchangeEncryptionAlgorithmName(keyEncAlg);
 
 			try
 			{