bcrypt.h (6025B)
1/** 2 * WinPR: Windows Portable Runtime 3 * Cryptography API: Next Generation 4 * 5 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20#ifndef WINPR_BCRYPT_H 21#define WINPR_BCRYPT_H 22 23#include <winpr/winpr.h> 24#include <winpr/wtypes.h> 25 26typedef PVOID BCRYPT_HANDLE; 27typedef PVOID BCRYPT_ALG_HANDLE; 28typedef PVOID BCRYPT_KEY_HANDLE; 29typedef PVOID BCRYPT_HASH_HANDLE; 30typedef PVOID BCRYPT_SECRET_HANDLE; 31 32#define BCRYPT_RSA_ALGORITHM L"RSA" 33#define BCRYPT_RSA_SIGN_ALGORITHM L"RSA_SIGN" 34#define BCRYPT_DH_ALGORITHM L"DH" 35#define BCRYPT_DSA_ALGORITHM L"DSA" 36#define BCRYPT_RC2_ALGORITHM L"RC2" 37#define BCRYPT_RC4_ALGORITHM L"RC4" 38#define BCRYPT_AES_ALGORITHM L"AES" 39#define BCRYPT_DES_ALGORITHM L"DES" 40#define BCRYPT_DESX_ALGORITHM L"DESX" 41#define BCRYPT_3DES_ALGORITHM L"3DES" 42#define BCRYPT_3DES_112_ALGORITHM L"3DES_112" 43#define BCRYPT_MD2_ALGORITHM L"MD2" 44#define BCRYPT_MD4_ALGORITHM L"MD4" 45#define BCRYPT_MD5_ALGORITHM L"MD5" 46#define BCRYPT_SHA1_ALGORITHM L"SHA1" 47#define BCRYPT_SHA256_ALGORITHM L"SHA256" 48#define BCRYPT_SHA384_ALGORITHM L"SHA384" 49#define BCRYPT_SHA512_ALGORITHM L"SHA512" 50#define BCRYPT_AES_GMAC_ALGORITHM L"AES-GMAC" 51#define BCRYPT_ECDSA_P256_ALGORITHM L"ECDSA_P256" 52#define BCRYPT_ECDSA_P384_ALGORITHM L"ECDSA_P384" 53#define BCRYPT_ECDSA_P521_ALGORITHM L"ECDSA_P521" 54#define BCRYPT_ECDH_P256_ALGORITHM L"ECDH_P256" 55#define BCRYPT_ECDH_P384_ALGORITHM L"ECDH_P384" 56#define BCRYPT_ECDH_P521_ALGORITHM L"ECDH_P521" 57#define BCRYPT_RNG_ALGORITHM L"RNG" 58#define BCRYPT_RNG_FIPS186_DSA_ALGORITHM L"FIPS186DSARNG" 59#define BCRYPT_RNG_DUAL_EC_ALGORITHM L"DUALECRNG" 60 61#define MS_PRIMITIVE_PROVIDER L"Microsoft Primitive Provider" 62 63#define BCRYPT_ALG_HANDLE_HMAC_FLAG 0x00000008 64#define BCRYPT_PROV_DISPATCH 0x00000001 65 66#define BCRYPT_OBJECT_LENGTH L"ObjectLength" 67#define BCRYPT_ALGORITHM_NAME L"AlgorithmName" 68#define BCRYPT_PROVIDER_HANDLE L"ProviderHandle" 69#define BCRYPT_CHAINING_MODE L"ChainingMode" 70#define BCRYPT_BLOCK_LENGTH L"BlockLength" 71#define BCRYPT_KEY_LENGTH L"KeyLength" 72#define BCRYPT_KEY_OBJECT_LENGTH L"KeyObjectLength" 73#define BCRYPT_KEY_STRENGTH L"KeyStrength" 74#define BCRYPT_KEY_LENGTHS L"KeyLengths" 75#define BCRYPT_BLOCK_SIZE_LIST L"BlockSizeList" 76#define BCRYPT_EFFECTIVE_KEY_LENGTH L"EffectiveKeyLength" 77#define BCRYPT_HASH_LENGTH L"HashDigestLength" 78#define BCRYPT_HASH_OID_LIST L"HashOIDList" 79#define BCRYPT_PADDING_SCHEMES L"PaddingSchemes" 80#define BCRYPT_SIGNATURE_LENGTH L"SignatureLength" 81#define BCRYPT_HASH_BLOCK_LENGTH L"HashBlockLength" 82#define BCRYPT_AUTH_TAG_LENGTH L"AuthTagLength" 83#define BCRYPT_PRIMITIVE_TYPE L"PrimitiveType" 84#define BCRYPT_IS_KEYED_HASH L"IsKeyedHash" 85 86#ifdef __cplusplus 87extern "C" 88{ 89#endif 90 91 WINPR_API NTSTATUS BCryptOpenAlgorithmProvider(BCRYPT_ALG_HANDLE* phAlgorithm, LPCWSTR pszAlgId, 92 LPCWSTR pszImplementation, ULONG dwFlags); 93 94 WINPR_API NTSTATUS BCryptCloseAlgorithmProvider(BCRYPT_ALG_HANDLE hAlgorithm, ULONG dwFlags); 95 96 WINPR_API NTSTATUS BCryptGetProperty(BCRYPT_HANDLE hObject, LPCWSTR pszProperty, 97 PUCHAR pbOutput, ULONG cbOutput, ULONG* pcbResult, 98 ULONG dwFlags); 99 100 WINPR_API NTSTATUS BCryptCreateHash(BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_HASH_HANDLE* phHash, 101 PUCHAR pbHashObject, ULONG cbHashObject, PUCHAR pbSecret, 102 ULONG cbSecret, ULONG dwFlags); 103 104 WINPR_API NTSTATUS BCryptDestroyHash(BCRYPT_HASH_HANDLE hHash); 105 106 WINPR_API NTSTATUS BCryptHashData(BCRYPT_HASH_HANDLE hHash, PUCHAR pbInput, ULONG cbInput, 107 ULONG dwFlags); 108 109 WINPR_API NTSTATUS BCryptFinishHash(BCRYPT_HASH_HANDLE hHash, PUCHAR pbOutput, ULONG cbOutput, 110 ULONG dwFlags); 111 112 WINPR_API NTSTATUS BCryptGenRandom(BCRYPT_ALG_HANDLE hAlgorithm, PUCHAR pbBuffer, 113 ULONG cbBuffer, ULONG dwFlags); 114 115 WINPR_API NTSTATUS BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE hAlgorithm, 116 BCRYPT_KEY_HANDLE* phKey, PUCHAR pbKeyObject, 117 ULONG cbKeyObject, PUCHAR pbSecret, 118 ULONG cbSecret, ULONG dwFlags); 119 120 WINPR_API NTSTATUS BCryptGenerateKeyPair(BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE* phKey, 121 ULONG dwLength, ULONG dwFlags); 122 123 WINPR_API NTSTATUS BCryptImportKey(BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE hImportKey, 124 LPCWSTR pszBlobType, BCRYPT_KEY_HANDLE* phKey, 125 PUCHAR pbKeyObject, ULONG cbKeyObject, PUCHAR pbInput, 126 ULONG cbInput, ULONG dwFlags); 127 128 WINPR_API NTSTATUS BCryptDestroyKey(BCRYPT_KEY_HANDLE hKey); 129 130 WINPR_API NTSTATUS BCryptEncrypt(BCRYPT_KEY_HANDLE hKey, PUCHAR pbInput, ULONG cbInput, 131 VOID* pPaddingInfo, PUCHAR pbIV, ULONG cbIV, PUCHAR pbOutput, 132 ULONG cbOutput, ULONG* pcbResult, ULONG dwFlags); 133 134 WINPR_API NTSTATUS BCryptDecrypt(BCRYPT_KEY_HANDLE hKey, PUCHAR pbInput, ULONG cbInput, 135 VOID* pPaddingInfo, PUCHAR pbIV, ULONG cbIV, PUCHAR pbOutput, 136 ULONG cbOutput, ULONG* pcbResult, ULONG dwFlags); 137 138#ifdef __cplusplus 139} 140#endif 141#endif /* WINPR_BCRYPT_MEMORY_H */