コード例 #1
0
 private void Reset()
 {
     this.platformKey?.Dispose();
     this.platformKey = null;
     this.platformAlgorithm?.Dispose();
     this.platformAlgorithm = null;
 }
コード例 #2
0
ファイル: BCrypt.cs プロジェクト: jmelosegui/pinvoke
 public static extern NTSTATUS BCryptOpenAlgorithmProvider(
     out SafeAlgorithmHandle phAlgorithm,
     string pszAlgId,
     string pszImplementation,
     BCryptOpenAlgorithmProviderFlags dwFlags);
コード例 #3
0
ファイル: BCrypt.cs プロジェクト: jmelosegui/pinvoke
 public static extern NTSTATUS BCryptGenRandom(
     SafeAlgorithmHandle hAlgorithm,
     byte[] pbBuffer,
     int cbBuffer,
     BCryptGenRandomFlags flags = BCryptGenRandomFlags.None);
コード例 #4
0
ファイル: BCrypt.cs プロジェクト: jmelosegui/pinvoke
 public static extern NTSTATUS BCryptGenerateSymmetricKey(
     SafeAlgorithmHandle hAlgorithm,
     out SafeKeyHandle phKey,
     byte[] pbKeyObject,
     int cbKeyObject,
     byte[] pbSecret,
     int cbSecret,
     BCryptGenerateSymmetricKeyFlags flags = BCryptGenerateSymmetricKeyFlags.None);
コード例 #5
0
ファイル: BCrypt.cs プロジェクト: jmelosegui/pinvoke
 public static extern NTSTATUS BCryptImportKeyPair(
     SafeAlgorithmHandle hAlgorithm,
     SafeKeyHandle hImportKey,
     [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType,
     out SafeKeyHandle phKey,
     byte[] pbInput,
     int cbInput,
     BCryptImportKeyPairFlags dwFlags);
コード例 #6
0
ファイル: BCrypt.cs プロジェクト: jmelosegui/pinvoke
 public static extern NTSTATUS BCryptCreateHash(
     SafeAlgorithmHandle hAlgorithm,
     out SafeHashHandle phHash,
     byte[] pbHashObject,
     int cbHashObject,
     byte[] pbSecret,
     int cbSecret,
     BCryptCreateHashFlags dwFlags);
コード例 #7
0
ファイル: BCrypt.cs プロジェクト: jmelosegui/pinvoke
 public static extern NTSTATUS BCryptGenerateKeyPair(
     SafeAlgorithmHandle hAlgorithm,
     out SafeKeyHandle phKey,
     int dwLength,
     BCryptGenerateKeyPairFlags dwFlags = BCryptGenerateKeyPairFlags.None);
コード例 #8
0
ファイル: BCrypt.cs プロジェクト: caioproiete/pinvoke
 /// <summary>
 /// Gets the minimum length of a key (in bits).
 /// </summary>
 /// <param name="algorithm">The algorithm.</param>
 /// <returns>The length of the smallest key, in bits.</returns>
 private static int GetMinimumKeySize(SafeAlgorithmHandle algorithm)
 {
     var keyLengths = BCryptGetProperty<BCRYPT_KEY_LENGTHS_STRUCT>(algorithm, PropertyNames.BCRYPT_KEY_LENGTHS);
     return keyLengths.MinLength;
 }
コード例 #9
0
 /// <summary>
 /// Creates an empty public/private key pair.
 /// </summary>
 /// <param name="algorithm">The handle to the algorithm previously opened by <see cref="BCryptOpenAlgorithmProvider"/></param>
 /// <param name="keyLength">The length of the key, in bits.</param>
 /// <returns>A handle to the generated key pair.</returns>
 /// <remarks>
 /// After you create a key by using this function, you can use the BCryptSetProperty
 /// function to set its properties; however, the key cannot be used until the
 /// BCryptFinalizeKeyPair function is called.
 /// </remarks>
 public static SafeKeyHandle BCryptGenerateKeyPair(
     SafeAlgorithmHandle algorithm,
     int keyLength)
 {
     SafeKeyHandle result;
     var error = BCryptGenerateKeyPair(algorithm, out result, keyLength, 0);
     error.ThrowOnError();
     return result;
 }
コード例 #10
0
 public static SafeKeyHandle BCryptImportKeyPair(
     SafeAlgorithmHandle algorithm,
     string blobType,
     byte[] input,
     BCryptImportKeyPairFlags flags)
 {
     SafeKeyHandle result;
     var error = BCryptImportKeyPair(
         algorithm,
         SafeKeyHandle.NullHandle,
         blobType,
         out result,
         input,
         input.Length,
         flags);
     error.ThrowOnError();
     return result;
 }
コード例 #11
0
ファイル: BCrypt.cs プロジェクト: gitter-badger/pinvoke
 public static extern NTStatus BCryptImportKey(
     SafeAlgorithmHandle hAlgorithm,
     SafeKeyHandle hImportKey,
     [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType,
     out SafeKeyHandle phKey,
     byte[] pbKeyObject,
     int cbKeyObject,
     byte[] pbInput,
     int cbInput,
     BCryptImportKeyFlags dwFlags = BCryptImportKeyFlags.None);
コード例 #12
0
 private static extern NTSTATUS BCryptImportKey(SafeAlgorithmHandle hAlgorithm, IntPtr hImportKey, string pszBlobType, out SafeKeyHandle hKey, IntPtr pbKeyObject, int cbKeyObject, byte[] pbInput, int cbInput, int dwFlags);