Пример #1
0
 internal static extern ErrorCode NCryptVerifySignature(SafeNCryptKeyHandle hKey,
                                                        [In] ref BCryptNative.BCRYPT_PKCS1_PADDING_INFO pPaddingInfo,
                                                        [In, MarshalAs(UnmanagedType.LPArray)] byte[] pbHashValue,
                                                        int cbHashValue,
                                                        [In, MarshalAs(UnmanagedType.LPArray)] byte[] pbSignature,
                                                        int cbSignature,
                                                        AsymmetricPaddingMode dwFlags);
Пример #2
0
 internal static extern ErrorCode NCryptEncrypt(SafeNCryptKeyHandle hKey,
                                                [In, MarshalAs(UnmanagedType.LPArray)] byte[] pbInput,
                                                int cbInput,
                                                [In] ref BCryptNative.BCRYPT_PKCS1_PADDING_INFO pvPadding,
                                                [Out, MarshalAs(UnmanagedType.LPArray)] byte[] pbOutput,
                                                int cbOutput,
                                                [Out] out int pcbResult,
                                                AsymmetricPaddingMode dwFlags);
Пример #3
0
        internal static byte[] EncryptDataPkcs1(SafeNCryptKeyHandle key, byte[] data)
        {
            BCryptNative.BCRYPT_PKCS1_PADDING_INFO pkcs1Info = new BCryptNative.BCRYPT_PKCS1_PADDING_INFO();

            return(EncryptData(key,
                               data,
                               ref pkcs1Info,
                               AsymmetricPaddingMode.Pkcs1,
                               UnsafeNativeMethods.NCryptEncrypt));
        }
Пример #4
0
        internal static byte[] SignHashPkcs1(SafeNCryptKeyHandle key,
                                             byte[] hash,
                                             string hashAlgorithm)
        {
            Debug.Assert(key != null, "key != null");
            Debug.Assert(!key.IsClosed && !key.IsInvalid, "!key.IsClosed && !key.IsInvalid");
            Debug.Assert(hash != null, "hash != null");
            Debug.Assert(!String.IsNullOrEmpty(hashAlgorithm), "!String.IsNullOrEmpty(hashAlgorithm)");

            BCryptNative.BCRYPT_PKCS1_PADDING_INFO pkcs1Info = new BCryptNative.BCRYPT_PKCS1_PADDING_INFO();
            pkcs1Info.pszAlgId = hashAlgorithm;

            return(SignHash(key,
                            hash,
                            ref pkcs1Info,
                            AsymmetricPaddingMode.Pkcs1,
                            UnsafeNativeMethods.NCryptSignHash));
        }