<s> from __future__ import unicode_literals , division , absolute_import , print_function <EOL> from ctypes import windll , wintypes , POINTER , Structure , c_void_p , c_ulonglong , c_char_p , c_byte <EOL> from ctypes . wintypes import ULONG , DWORD , LPCWSTR <EOL> from . . _ffi import FFIEngineError , LibraryNotFoundError <EOL> from . . _types import str_cls <EOL> __all__ = [ <EOL> '<STR_LIT>' , <EOL> ] <EOL> try : <EOL> bcrypt = windll . bcrypt <EOL> except ( OSError ) as e : <EOL> if str_cls ( e ) . find ( '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> raise LibraryNotFoundError ( '<STR_LIT>' ) <EOL> raise <EOL> BCRYPT_ALG_HANDLE = wintypes . HANDLE <EOL> BCRYPT_KEY_HANDLE = wintypes . HANDLE <EOL> NTSTATUS = wintypes . ULONG <EOL> PUCHAR = c_char_p <EOL> PBYTE = c_char_p <EOL> try : <EOL> bcrypt . BCryptOpenAlgorithmProvider . argtypes = [ <EOL> POINTER ( BCRYPT_ALG_HANDLE ) , <EOL> LPCWSTR , <EOL> LPCWSTR , <EOL> DWORD <EOL> ] <EOL> bcrypt . BCryptOpenAlgorithmProvider . restype = NTSTATUS <EOL> bcrypt . BCryptCloseAlgorithmProvider . argtypes = [ <EOL> BCRYPT_ALG_HANDLE , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptCloseAlgorithmProvider . restype = NTSTATUS <EOL> bcrypt . BCryptImportKeyPair . argtypes = [ <EOL> BCRYPT_ALG_HANDLE , <EOL> BCRYPT_KEY_HANDLE , <EOL> LPCWSTR , <EOL> POINTER ( BCRYPT_KEY_HANDLE ) , <EOL> PUCHAR , <EOL> ULONG , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptImportKeyPair . restype = NTSTATUS <EOL> bcrypt . BCryptImportKey . argtypes = [ <EOL> BCRYPT_ALG_HANDLE , <EOL> BCRYPT_KEY_HANDLE , <EOL> LPCWSTR , <EOL> POINTER ( BCRYPT_KEY_HANDLE ) , <EOL> PUCHAR , <EOL> ULONG , <EOL> PUCHAR , <EOL> ULONG , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptImportKey . restype = NTSTATUS <EOL> bcrypt . BCryptDestroyKey . argtypes = [ <EOL> BCRYPT_KEY_HANDLE <EOL> ] <EOL> bcrypt . BCryptDestroyKey . restype = NTSTATUS <EOL> bcrypt . BCryptVerifySignature . argtypes = [ <EOL> BCRYPT_KEY_HANDLE , <EOL> c_void_p , <EOL> PUCHAR , <EOL> ULONG , <EOL> PUCHAR , <EOL> ULONG , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptVerifySignature . restype = NTSTATUS <EOL> bcrypt . BCryptSignHash . argtypes = [ <EOL> BCRYPT_KEY_HANDLE , <EOL> c_void_p , <EOL> PBYTE , <EOL> DWORD , <EOL> PBYTE , <EOL> DWORD , <EOL> POINTER ( DWORD ) , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptSignHash . restype = NTSTATUS <EOL> bcrypt . BCryptSetProperty . argtypes = [ <EOL> BCRYPT_KEY_HANDLE , <EOL> LPCWSTR , <EOL> c_void_p , <EOL> ULONG , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptSetProperty . restype = NTSTATUS <EOL> bcrypt . BCryptEncrypt . argtypes = [ <EOL> BCRYPT_KEY_HANDLE , <EOL> PUCHAR , <EOL> ULONG , <EOL> c_void_p , <EOL> PUCHAR , <EOL> ULONG , <EOL> PUCHAR , <EOL> ULONG , <EOL> POINTER ( ULONG ) , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptEncrypt . restype = NTSTATUS <EOL> bcrypt . BCryptDecrypt . argtypes = [ <EOL> BCRYPT_KEY_HANDLE , <EOL> PUCHAR , <EOL> ULONG , <EOL> c_void_p , <EOL> PUCHAR , <EOL> ULONG , <EOL> PUCHAR , <EOL> ULONG , <EOL> POINTER ( ULONG ) , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptDecrypt . restype = NTSTATUS <EOL> bcrypt . BCryptDeriveKeyPBKDF2 . argtypes = [ <EOL> BCRYPT_ALG_HANDLE , <EOL> PUCHAR , <EOL> ULONG , <EOL> PUCHAR , <EOL> ULONG , <EOL> c_ulonglong , <EOL> PUCHAR , <EOL> ULONG , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptDeriveKeyPBKDF2 . restype = NTSTATUS <EOL> bcrypt . BCryptGenRandom . argtypes = [ <EOL> BCRYPT_ALG_HANDLE , <EOL> PUCHAR , <EOL> ULONG , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptGenRandom . restype = NTSTATUS <EOL> bcrypt . BCryptGenerateKeyPair . argtypes = [ <EOL> BCRYPT_ALG_HANDLE , <EOL> POINTER ( BCRYPT_KEY_HANDLE ) , <EOL> ULONG , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptGenerateKeyPair . restype = NTSTATUS <EOL> bcrypt . BCryptFinalizeKeyPair . argtypes = [ <EOL> BCRYPT_KEY_HANDLE , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptFinalizeKeyPair . restype = NTSTATUS <EOL> bcrypt . BCryptExportKey . argtypes = [ <EOL> BCRYPT_KEY_HANDLE , <EOL> BCRYPT_KEY_HANDLE , <EOL> LPCWSTR , <EOL> PUCHAR , <EOL> ULONG , <EOL> POINTER ( ULONG ) , <EOL> ULONG <EOL> ] <EOL> bcrypt . BCryptExportKey . restype = NTSTATUS <EOL> except ( AttributeError ) : <EOL> raise FFIEngineError ( '<STR_LIT>' ) <EOL> class BCRYPT_RSAKEY_BLOB ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ] <EOL> class BCRYPT_DSA_KEY_BLOB ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , c_byte * <NUM_LIT:4> ) , <EOL> ( '<STR_LIT>' , c_byte * <NUM_LIT:20> ) , <EOL> ( '<STR_LIT:q>' , c_byte * <NUM_LIT:20> ) , <EOL> ] <EOL> class BCRYPT_DSA_KEY_BLOB_V2 ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , wintypes . INT ) , <EOL> ( '<STR_LIT>' , wintypes . INT ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , c_byte * <NUM_LIT:4> ) , <EOL> ] <EOL> class BCRYPT_ECCKEY_BLOB ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ] <EOL> class BCRYPT_PKCS1_PADDING_INFO ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , LPCWSTR ) , <EOL> ] <EOL> class BCRYPT_PSS_PADDING_INFO ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , LPCWSTR ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ] <EOL> class BCRYPT_OAEP_PADDING_INFO ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , LPCWSTR ) , <EOL> ( '<STR_LIT>' , PUCHAR ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ] <EOL> class BCRYPT_KEY_DATA_BLOB_HEADER ( Structure ) : <EOL> _fields_ = [ <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ( '<STR_LIT>' , ULONG ) , <EOL> ] <EOL> setattr ( bcrypt , '<STR_LIT>' , BCRYPT_ALG_HANDLE ) <EOL> setattr ( bcrypt , '<STR_LIT>' , BCRYPT_KEY_HANDLE ) <EOL> setattr ( bcrypt , '<STR_LIT>' , BCRYPT_RSAKEY_BLOB ) <EOL> setattr ( bcrypt , '<STR_LIT>' , BCRYPT_DSA_KEY_BLOB ) <EOL> setattr ( bcrypt , '<STR_LIT>' , BCRYPT_DSA_KEY_BLOB_V2 ) <EOL> setattr ( bcrypt , '<STR_LIT>' , BCRYPT_ECCKEY_BLOB ) <EOL> setattr ( bcrypt , '<STR_LIT>' , BCRYPT_PKCS1_PADDING_INFO ) <EOL> setattr ( bcrypt , '<STR_LIT>' , BCRYPT_PSS_PADDING_INFO ) <EOL> setattr ( bcrypt , '<STR_LIT>' , BCRYPT_OAEP_PADDING_INFO ) <EOL> setattr ( bcrypt , '<STR_LIT>' , BCRYPT_KEY_DATA_BLOB_HEADER ) </s>
