System\Security\Cryptography\AesCryptoServiceProvider.cs (35)
42string providerName = CapiNative.ProviderNames.MicrosoftEnhancedRsaAes;
44providerName = CapiNative.ProviderNames.MicrosoftEnhancedRsaAesPrototype;
47m_cspHandle = CapiNative.AcquireCsp(null,
49CapiNative.ProviderType.RsaAes,
50CapiNative.CryptAcquireContextFlags.VerifyContext,
86byte[] keyValue = CapiNative.ExportSymmetricKey(m_key);
108SafeCapiKeyHandle importedKey = CapiNative.ImportSymmetricKey(m_cspHandle,
177using (SafeCapiKeyHandle importedKey = CapiNative.ImportSymmetricKey(m_cspHandle, GetAlgorithmId(keyCopy.Length * 8), keyCopy)) {
243using (SafeCapiKeyHandle importedKey = CapiNative.ImportSymmetricKey(m_cspHandle, GetAlgorithmId(keyCopy.Length * 8), keyCopy)) {
316CapiNative.PROV_ENUMALGS algorithm =
317CapiNative.GetProviderParameterStruct<CapiNative.PROV_ENUMALGS>(csp,
318CapiNative.ProviderParameter.EnumerateAlgorithms,
319CapiNative.ProviderParameterFlags.RestartEnumeration);
322while (algorithm.aiAlgId != CapiNative.AlgorithmId.None) {
324case CapiNative.AlgorithmId.Aes128:
332case CapiNative.AlgorithmId.Aes192:
339case CapiNative.AlgorithmId.Aes256:
350algorithm = CapiNative.GetProviderParameterStruct<CapiNative.PROV_ENUMALGS>(csp,
351CapiNative.ProviderParameter.EnumerateAlgorithms,
352CapiNative.ProviderParameterFlags.None);
376if (!CapiNative.UnsafeNativeMethods.CryptGenKey(m_cspHandle,
378CapiNative.KeyFlags.Exportable,
407if (!CapiNative.UnsafeNativeMethods.CryptGenRandom(m_cspHandle, iv.Length, iv)) {
417private static CapiNative.AlgorithmId GetAlgorithmId(int keySize) {
420((((int)Contract.Result<CapiNative.AlgorithmId>()) & (int)CapiNative.AlgorithmClass.DataEncryption) == (int)CapiNative.AlgorithmClass.DataEncryption) ||
421Contract.Result<CapiNative.AlgorithmId>() == CapiNative.AlgorithmId.None);
425return CapiNative.AlgorithmId.Aes128;
428return CapiNative.AlgorithmId.Aes192;
431return CapiNative.AlgorithmId.Aes256;
434return CapiNative.AlgorithmId.None;
System\Security\Cryptography\CapiNative.cs (9)
524if (throwPlatformException && (error == (int)CapiNative.ErrorCode.ProviderTypeNotDefined ||
525error == (int)CapiNative.ErrorCode.KeysetNotDefined)) {
607internal static byte[] GetHashParameter(SafeCapiHashHandle hashHandle, CapiNative.HashParameter parameter) {
609Contract.Requires(CapiNative.HashParameter.AlgorithmId <= parameter && parameter <= CapiNative.HashParameter.HashSize);
617if (!CapiNative.UnsafeNativeMethods.CryptGetHashParam(hashHandle, parameter, null, ref parameterSize, 0)) {
623if (!CapiNative.UnsafeNativeMethods.CryptGetHashParam(hashHandle, parameter, parameterValue, ref parameterSize, 0)) {
1027SafeLocalAllocHandle pb = CapiNative.LocalAlloc(CapiNative.LMEM_FIXED, new IntPtr(arr.Length));
System\Security\Cryptography\CapiSymmetricAlgorithm.cs (11)
258if (!CapiNative.UnsafeNativeMethods.CryptEncrypt(m_key,
305CapiNative.UnsafeNativeMethods.CryptGenRandom(m_provider, result.Length - 1, result);
408if (!CapiNative.UnsafeNativeMethods.CryptDecrypt(m_key,
441CapiNative.UnsafeNativeMethods.CryptEncrypt(m_key,
453CapiNative.UnsafeNativeMethods.CryptDecrypt(m_key,
592CapiNative.SetKeyParameter(encryptionKey, CapiNative.KeyParameter.Mode, (int)cipherMode);
596CapiNative.SetKeyParameter(encryptionKey, CapiNative.KeyParameter.IV, iv);
601CapiNative.SetKeyParameter(encryptionKey, CapiNative.KeyParameter.ModeBits, feedbackSize);