Exemplo n.º 1
0
 public static extern SECURITY_STATUS NCryptCreatePersistedKey(
     SafeProviderHandle hProvider,
     out SafeKeyHandle phKey,
     string pszAlgId,
     string pszKeyName                     = null,
     LegacyKeySpec dwLegacyKeySpec         = LegacyKeySpec.None,
     NCryptCreatePersistedKeyFlags dwFlags = NCryptCreatePersistedKeyFlags.None);
Exemplo n.º 2
0
 public static extern SECURITY_STATUS NCryptCreatePersistedKey(
     SafeProviderHandle hProvider,
     out SafeKeyHandle phKey,
     string pszAlgId,
     string pszKeyName = null,
     LegacyKeySpec dwLegacyKeySpec = LegacyKeySpec.None,
     NCryptCreatePersistedKeyFlags dwFlags = NCryptCreatePersistedKeyFlags.None);
Exemplo n.º 3
0
 public static extern uint NCryptCreatePersistedKey
 (
     [param: In] NCryptStorageProviderSafeHandle hProvider,
     [param: Out] out NCryptKeyOrCryptProviderSafeHandle phKey,
     [param: In, MarshalAs(UnmanagedType.LPWStr)] string pszAlgId,
     [param: In, MarshalAs(UnmanagedType.LPWStr)] string pszKeyName,
     [param: In, MarshalAs(UnmanagedType.U4)] KeySpec dwLegacyKeySpec,
     [param: In, MarshalAs(UnmanagedType.U4)] NCryptCreatePersistedKeyFlags dwFlags
 );
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new key and stores it in the specified key storage provider. After you create a key by using this function, you can use the NCryptSetProperty function to set its properties; however, the key cannot be used until the NCryptFinalizeKey function is called.
        /// </summary>
        /// <param name="provider">
        /// The handle of the key storage provider to create the key in. This handle is obtained by using the <see cref="NCryptOpenStorageProvider(string, NCryptOpenStorageProviderFlags)"/> function.
        /// </param>
        /// <param name="algorithmId">
        /// A null-terminated Unicode string that contains the identifier of the cryptographic algorithm to create the key. This can be one of the standard CNG Algorithm Identifiers defined in <see cref="BCrypt.AlgorithmIdentifiers"/> or the identifier for another registered algorithm.
        /// </param>
        /// <param name="keyName">
        /// A pointer to a null-terminated Unicode string that contains the name of the key. If this parameter is NULL, this function will create an ephemeral key that is not persisted.
        /// </param>
        /// <param name="legacyKeySpec">
        /// A legacy identifier that specifies the type of key.
        /// </param>
        /// <param name="flags">A set of flags that modify the behavior of this function.</param>
        /// <returns>
        /// The address of an <see cref="SafeKeyHandle"/> variable that receives the handle of the key. When you have finished using this handle, release it by disposing it.
        /// </returns>
        public static SafeKeyHandle NCryptCreatePersistedKey(
            SafeProviderHandle provider,
            string algorithmId,
            string keyName = null,
            LegacyKeySpec legacyKeySpec         = LegacyKeySpec.None,
            NCryptCreatePersistedKeyFlags flags = NCryptCreatePersistedKeyFlags.None)
        {
            SafeKeyHandle result;

            NCryptCreatePersistedKey(
                provider,
                out result,
                algorithmId,
                keyName,
                legacyKeySpec,
                flags).ThrowOnError();
            return(result);
        }