Ejemplo n.º 1
0
 internal static extern ErrorCode NCryptEncrypt(SafeNCryptKeyHandle hKey,
                                                [In, MarshalAs(UnmanagedType.LPArray)] byte[] pbInput,
                                                int cbInput,
                                                [In] ref BCryptNative.BCRYPT_OAEP_PADDING_INFO pvPadding,
                                                [Out, MarshalAs(UnmanagedType.LPArray)] byte[] pbOutput,
                                                int cbOutput,
                                                [Out] out int pcbResult,
                                                AsymmetricPaddingMode dwFlags);
Ejemplo n.º 2
0
        internal static byte[] EncryptDataOaep(SafeNCryptKeyHandle key,
                                               byte[] data,
                                               string hashAlgorithm)
        {
            Debug.Assert(!String.IsNullOrEmpty(hashAlgorithm), "!String.IsNullOrEmpty(hashAlgorithm)");

            BCryptNative.BCRYPT_OAEP_PADDING_INFO oaepInfo = new BCryptNative.BCRYPT_OAEP_PADDING_INFO();
            oaepInfo.pszAlgId = hashAlgorithm;

            return(EncryptData(key,
                               data,
                               ref oaepInfo,
                               AsymmetricPaddingMode.Oaep,
                               UnsafeNativeMethods.NCryptEncrypt));
        }