struttura BCRYPT_DH_PARAMETER_HEADER (bcrypt.h)

La struttura BCRYPT_DH_PARAMETER_HEADER viene utilizzata per contenere informazioni sull'intestazione dei parametri per una chiave di Diffie-Hellman. Questa struttura viene utilizzata con la proprietà BCRYPT_DH_PARAMETERS nella funzione BCryptSetProperty .

Sintassi

typedef struct _BCRYPT_DH_PARAMETER_HEADER {
  ULONG cbLength;
  ULONG dwMagic;
  ULONG cbKeyLength;
} BCRYPT_DH_PARAMETER_HEADER;

Members

cbLength

Dimensioni totali, in byte, di questa struttura e del buffer che segue immediatamente questa struttura in memoria.

dwMagic

Valore magic per la chiave.

Questo membro deve essere il valore seguente.

BCRYPT_DH_PARAMETERS_MAGIC (0x4d504844)

cbKeyLength

Dimensione, in byte, della chiave a cui si applica questa struttura.

Commenti

Questa struttura viene usata come intestazione per un buffer più grande. Il singolo blocco di memoria è costituito da questa struttura seguita da un buffer di dimensioni cbKeyLength che contiene il numero primo Diffie-Hellman e un altro buffer di dimensioni cbKeyLength che contiene il numero di generatore Diffie-Hellman. Entrambi questi numeri sono in formato big-endian.

Nell'esempio seguente viene illustrato come calcolare le dimensioni necessarie per questo buffer e come compilare i membri di questa struttura.

// In this example, the rgbModulus variable is a byte array that contains the modulus in big-endian byte order. 
// The rgbGenerator variable is a byte array that contains the generator in big-endian byte order.

ULONG cbDHParams = sizeof(BCRYPT_DH_PARAMETER_HEADER) +     (cbKeySize * 2);
PBYTE pbDHParams = (PBYTE)malloc(cbDHParams);
if(!pbDHParams)
{
    status = STATUS_NO_MEMORY;
    goto Cleanup;
}

BCRYPT_DH_PARAMETER_HEADER *pDHParamHeader;
pDHParamHeader = (BCRYPT_DH_PARAMETER_HEADER*)pbDHParams;
pDHParamHeader->cbLength = cbDHParams;
pDHParamHeader->cbKeyLength = cbKeySize;
pDHParamHeader->dwMagic = BCRYPT_DH_PARAMETERS_MAGIC;

// Add the modulus to the parameters.
// The rgbModulus argument is a byte array that contains the modulus.
PBYTE pbTemp = (PBYTE)pbDHParams + sizeof(BCRYPT_DH_PARAMETER_HEADER);
CopyMemory(pbTemp, rgbModulus, pDHParamHeader->cbKeyLength);

// Add the generator to the parameters.
// The rgbGenerator argument is a byte array that contains the generator.
pbTemp += pDHParamHeader->cbKeyLength;
CopyMemory(pbTemp, rgbGenerator, pDHParamHeader->cbKeyLength);


Requisiti

Requisito Valore
Client minimo supportato Windows Vista [solo app desktop]
Server minimo supportato Windows Server 2008 [solo app desktop]
Intestazione bcrypt.h

Vedi anche

BCryptSetProperty

Identificatori di proprietà primitive di crittografia