diff --git a/PInvoke/Cryptography/BCrypt/BCrypt.cs b/PInvoke/Cryptography/BCrypt/BCrypt.cs index 378241c7..5e3c51df 100644 --- a/PInvoke/Cryptography/BCrypt/BCrypt.cs +++ b/PInvoke/Cryptography/BCrypt/BCrypt.cs @@ -8989,6 +8989,37 @@ namespace Vanara.PInvoke public IntPtr DangerousGetHandle() => handle; } + /// + /// + /// The BCRYPT_KEY_LENGTHS_STRUCT structure defines the range of key sizes that are supported by the provider. This structure + /// is used with the BCRYPT_KEY_LENGTHS property. + /// + /// + /// This structure is also used with the BCRYPT_AUTH_TAG_LENGTH property to contain the minimum, maximum, and increment size + /// of an authentication tag. + /// + /// + /// + /// The key sizes are given in a range that is inclusive of the minimum and maximum values and are separated by the increment. For + /// example, if the minimum key size is 8 bits, the maximum key size is 16 bits, and the increment is 2 bits, the provider would + /// support key sizes of 8, 10, 12, 14, and 16 bits. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_key_lengths_struct + // typedef struct __BCRYPT_KEY_LENGTHS_STRUCT { ULONG dwMinLength; ULONG dwMaxLength; ULONG dwIncrement; } BCRYPT_KEY_LENGTHS_STRUCT; + [PInvokeData("bcrypt.h", MSDNShortId = "NS:bcrypt.__BCRYPT_KEY_LENGTHS_STRUCT")] + [StructLayout(LayoutKind.Sequential)] + public struct BCRYPT_KEY_LENGTHS_STRUCT + { + /// The minimum length, in bits, of a key. + public uint dwMinLength; + + /// The maximum length, in bits, of a key. + public uint dwMaxLength; + + /// The number of bits that the key size can be incremented between dwMinLength and dwMaxLength. + public uint dwIncrement; + } + /// A BCRYPT_MULTI_HASH_OPERATION structure defines a single operation in a multi-hash operation. // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_bcrypt_multi_hash_operation typedef struct // _BCRYPT_MULTI_HASH_OPERATION { ULONG iHash; BCRYPT_HASH_OPERATION_TYPE hashOperation; PUCHAR pbBuffer; ULONG cbBuffer; } BCRYPT_MULTI_HASH_OPERATION; @@ -9024,6 +9055,28 @@ namespace Vanara.PInvoke public uint cbBuffer; } + /// + /// The BCRYPT_MULTI_OBJECT_LENGTH_STRUCT structure contains information to determine the size of the pbHashObject buffer for + /// the BCryptCreateMultiHash function. + /// + /// + /// The size of the pbHashObject buffer for the BCryptCreateMultiHash function is the following: + /// cbPerObject + (number of hash states) * cbPerElement + /// . + /// + // https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_multi_object_length_struct + // typedef struct _BCRYPT_MULTI_OBJECT_LENGTH_STRUCT { ULONG cbPerObject; ULONG cbPerElement; } BCRYPT_MULTI_OBJECT_LENGTH_STRUCT; + [PInvokeData("bcrypt.h", MSDNShortId = "NS:bcrypt._BCRYPT_MULTI_OBJECT_LENGTH_STRUCT")] + [StructLayout(LayoutKind.Sequential)] + public struct BCRYPT_MULTI_OBJECT_LENGTH_STRUCT + { + /// The number of bytes needed for the object overhead. + public uint cbPerObject; + + /// The number of bytes needed for each element of the object. + public uint cbPerElement; + } + /// /// The BCRYPT_OAEP_PADDING_INFO structure is used to provide options for the Optimal Asymmetric Encryption Padding (OAEP) scheme. /// @@ -9049,6 +9102,57 @@ namespace Vanara.PInvoke public uint cbLabel; } + /// + /// The BCRYPT_OID_LIST structure is used to contain a collection of BCRYPT_OID structures. Use this structure with the + /// BCRYPT_HASH_OID_LIST property to retrieve the list of hashing object identifiers (OIDs) that have been encoded by using + /// Distinguished Encoding Rules (DER) encoding. + /// + /// + /// + /// The first OID in the pOIDs array is used to identify any hashes or signatures created by this algorithm provider. When + /// verifying a hash or signature, all the OIDs in the array are treated as valid. + /// + /// + /// In the Microsoft Primitive Provider implementation, dwOIDCount is 2, so that the pOIDs array contains two members: + /// + /// + /// + /// pOIDs[0] contains a DER-encoded AlgorithmIdentifier with a NULL parameter. + /// + /// + /// pOIDs[1] contains the DER-encoded AlgorithmIdentifier without a NULL parameter. + /// + /// + /// For example, the SHA-1 encoding would be: + /// + /// + /// pOIDs[0] --> 06 05 2b 0e 03 02 1a 05 00 + /// + /// + /// pOIDs[1] --> 06 05 2b 0e 03 02 1a + /// + /// + /// + /// The following snippet describes an AlgorithmIdentifier in Abstract Syntax Notation One (ASN.1) notation. SEQUENCE, + /// OBJECT IDENTIFIER, and ANY are DER encoded. The ANY BLOB is NULL. + /// + /// + /// AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, algorithmParams ANY } + /// + /// + // https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_oid_list + // typedef struct _BCRYPT_OID_LIST { ULONG dwOIDCount; BCRYPT_OID *pOIDs; } BCRYPT_OID_LIST; + [PInvokeData("bcrypt.h", MSDNShortId = "NS:bcrypt._BCRYPT_OID_LIST")] + [StructLayout(LayoutKind.Sequential)] + public struct BCRYPT_OID_LIST + { + /// The number of elements in the pOIDs array. + public uint dwOIDCount; + + /// The address of an array of BCRYPT_OID structures that contains OIDs. + public IntPtr pOIDs; + } + /// The BCRYPT_PKCS1_PADDING_INFO structure is used to provide options for the PKCS #1 padding scheme. // https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_bcrypt_pkcs1_padding_info typedef struct // _BCRYPT_PKCS1_PADDING_INFO { LPCWSTR pszAlgId; } BCRYPT_PKCS1_PADDING_INFO; @@ -9582,7 +9686,7 @@ namespace Vanara.PInvoke /// The list of DER-encoded hashing object identifiers (OIDs). This property is a BCRYPT_OID_LIST structure. This property can /// only be read. /// - // TODO [CorrespondingType(typeof(BCRYPT_OID_LIST))] + [CorrespondingType(typeof(BCRYPT_OID_LIST))] public const string BCRYPT_HASH_OID_LIST = "HashOIDList"; /// Contains the initialization vector (IV) for a key. This property only applies to keys. @@ -9605,7 +9709,7 @@ namespace Vanara.PInvoke /// The key lengths that are supported by the algorithm. This property is a BCRYPT_KEY_LENGTHS_STRUCT structure. This property /// only applies to algorithms. /// - // TODO [CorrespondingType(typeof(BCRYPT_KEY_LENGTHS_STRUCT))] + [CorrespondingType(typeof(BCRYPT_KEY_LENGTHS_STRUCT))] public const string BCRYPT_KEY_LENGTHS = "KeyLengths"; /// This property is not used. The BCRYPT_OBJECT_LENGTH property is used to obtain this information. @@ -9627,7 +9731,7 @@ namespace Vanara.PInvoke /// This property returns a BCRYPT_MULTI_OBJECT_LENGTH_STRUCT, which contains information necessary to calculate the size of an /// object buffer.This property is only supported on operating system versions that support the BCryptCreateMultiHash function. /// - // TODO [CorrespondingType(typeof(BCRYPT_MULTI_OBJECT_LENGTH_STRUCT))] + [CorrespondingType(typeof(BCRYPT_MULTI_OBJECT_LENGTH_STRUCT))] public const string BCRYPT_MULTI_OBJECT_LENGTH = "MultiObjectLength"; ///