// decrypts the supplied wrapped key using the provided symmetric algorithm public static byte[] DecryptKey(byte[] keyData, KeyParameter symmetricAlgorithm) { if (keyData == null) { throw new ArgumentNullException(nameof(keyData)); } if (symmetricAlgorithm == null) { throw new ArgumentNullException(nameof(symmetricAlgorithm)); } if (symmetricAlgorithm is DesParameters) { // CMS Triple DES Key Wrap return(SymmetricKeyWrap.TripleDESKeyWrapDecrypt(symmetricAlgorithm.GetKey(), keyData)); } else { // FIPS AES Key Wrap return(SymmetricKeyWrap.AESKeyWrapDecrypt(symmetricAlgorithm.GetKey(), keyData)); } }
// decrypts the supplied wrapped key using the provided symmetric algorithm public static byte[] DecryptKey(byte[] keyData, SymmetricAlgorithm symmetricAlgorithm) { if (keyData == null) { throw new ArgumentNullException("keyData"); } if (symmetricAlgorithm == null) { throw new ArgumentNullException("symmetricAlgorithm"); } if (symmetricAlgorithm is TripleDES) { // CMS Triple DES Key Wrap return(SymmetricKeyWrap.TripleDESKeyWrapDecrypt(symmetricAlgorithm.Key, keyData)); } else if (symmetricAlgorithm is Rijndael || symmetricAlgorithm is Aes) { // FIPS AES Key Wrap return(SymmetricKeyWrap.AESKeyWrapDecrypt(symmetricAlgorithm.Key, keyData)); } // throw an exception if the transform is not in the previous categories throw new System.Security.Cryptography.CryptographicException(SR.Cryptography_Xml_NotSupportedCryptographicTransform); }