Exemplo n.º 1
0
 internal static extern ErrorCode NCryptSignHash(SafeNCryptKeyHandle hKey,
                                                 [In] ref BCryptNative.BCRYPT_PKCS1_PADDING_INFO pPaddingInfo,
                                                 [In, MarshalAs(UnmanagedType.LPArray)] byte[] pbHashValue,
                                                 int cbHashValue,
                                                 [Out, MarshalAs(UnmanagedType.LPArray)] byte[] pbSignature,
                                                 int cbSignature,
                                                 [Out] out int pcbResult,
                                                 AsymmetricPaddingMode dwFlags);
Exemplo n.º 2
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));
        }