Mistake on this page?
Report an issue in GitHub or email us
Data Structures | Macros | Typedefs | Functions
CryptoCell DH Key Generation APIs

Data Structures

struct  CRYS_DHKGData_t
 
struct  CRYS_DHKG_CheckTemp_t
 

Macros

#define CRYS_DH_SEED_MIN_SIZE_IN_BYTES   CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES
 
#define CRYS_DH_SEED_MIN_SIZE_IN_BITS   (CRYS_DH_SEED_MIN_SIZE_IN_BYTES * 8)
 
#define DH_X942_PRIME_MOD_MIN_VAL   1024
 
#define DH_X942_PRIME_MOD_MAX_VAL   2048
 
#define DH_X942_PGEN_COUNTER_CONST   4096
 
#define DH_X942_HASH_SIZE_BITS   160
 
#define DH_MAX_RATIO_MODULO_TO_ORDER   4
 

Typedefs

typedef struct CRYS_DHKGData_t CRYS_DHKGData_t
 
typedef struct CRYS_DHKG_CheckTemp_t CRYS_DHKG_CheckTemp_t
 

Functions

CRYSError_t CRYS_DH_CreateDomainParams (void *rndState_ptr, SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, uint32_t modPsizeBits, uint32_t orderQsizeBits, uint32_t seedSizeBits, uint8_t *modP_ptr, uint8_t *orderQ_ptr, uint8_t *generatorG_ptr, uint32_t *generGsizeBytes_ptr, uint8_t *factorJ_ptr, uint32_t *JsizeBytes_ptr, uint8_t *seedS_ptr, int8_t generateSeed, uint32_t *pgenCounter_ptr, CRYS_DHKGData_t *DHKGbuff_ptr)
 This function generates DH domain parameters in Galois prime field according to standard [ANS X9.42]. It receives the required sizes (in bits) of the modulus, the generator's order, and the seed, and then generates the prime modulus and the generator according to given sizes. If generateSeed argument is set to 1, the function generates and outputs the random seed. Otherwise (if set to 0), the seed has to be passed as an input argument. According to implementation the seed should be not greate, than (2^seedSizeBits - 2^32). The seed and some additional parameters, generated by the function (factorJ, pgenCounter), are used for checking that all domain parameters are generated according to the standard and not forged. More...
 
CRYSError_t CRYS_DH_CheckDomainParams (void *rndState_ptr, SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, uint8_t *modP_ptr, uint32_t modPsizeBytes, uint8_t *orderQ_ptr, uint32_t orderQsizeBytes, uint8_t *generatorG_ptr, uint32_t generatorSizeBytes, uint8_t *seedS_ptr, uint32_t seedSizeBits, uint32_t pgenCounter, CRYS_DHKG_CheckTemp_t *checkTempBuff_ptr)
 This function receives DH domain parameters, seed and prime generation counter and then verifies that the domain was created according to the standard [ANS X9.42]. According to implementation, the value of the user passed seed should be not greate, than (2^seedSizeBits - 2^32), otherwise an error is returned. More...
 

Detailed Description

Macro Definition Documentation

#define CRYS_DH_SEED_MIN_SIZE_IN_BITS   (CRYS_DH_SEED_MIN_SIZE_IN_BYTES * 8)

Minimal size of DH seed in bits.

Definition at line 61 of file crys_dh_kg.h.

#define CRYS_DH_SEED_MIN_SIZE_IN_BYTES   CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES

Minimal size of DH seed in bytes.

Definition at line 59 of file crys_dh_kg.h.

#define DH_MAX_RATIO_MODULO_TO_ORDER   4

Maximal allowed ratio between modulus and generator order sizes (by implementation)

Definition at line 109 of file crys_dh_kg.h.

#define DH_X942_HASH_SIZE_BITS   160

HASH size in bits for X942 - 160.

Definition at line 107 of file crys_dh_kg.h.

#define DH_X942_PGEN_COUNTER_CONST   4096

PGeneration counter for X942 - 4096.

Definition at line 105 of file crys_dh_kg.h.

#define DH_X942_PRIME_MOD_MAX_VAL   2048

Maximal modulus size for X942 - 2048.

Definition at line 103 of file crys_dh_kg.h.

#define DH_X942_PRIME_MOD_MIN_VAL   1024

DH Domain generation values definitions

Minimal modulus size for X942 - 1024.

Definition at line 101 of file crys_dh_kg.h.

Typedef Documentation

Temporary buffer structure .

Temporary data buffer structure for domain parameters generation in DH.

Function Documentation

CRYSError_t CRYS_DH_CheckDomainParams ( void *  rndState_ptr,
SaSiRndGenerateVectWorkFunc_t  rndGenerateVectFunc,
uint8_t *  modP_ptr,
uint32_t  modPsizeBytes,
uint8_t *  orderQ_ptr,
uint32_t  orderQsizeBytes,
uint8_t *  generatorG_ptr,
uint32_t  generatorSizeBytes,
uint8_t *  seedS_ptr,
uint32_t  seedSizeBits,
uint32_t  pgenCounter,
CRYS_DHKG_CheckTemp_t checkTempBuff_ptr 
)

This function receives DH domain parameters, seed and prime generation counter and then verifies that the domain was created according to the standard [ANS X9.42]. According to implementation, the value of the user passed seed should be not greate, than (2^seedSizeBits - 2^32), otherwise an error is returned.

Note
All buffer parameters should be in Big-Endian form. For more detailed description of the parameters see CRYS_DH_CreateDomainParams.
Returns
CRYS_OK on success.
A non-zero value on failure as defined crys_dh_error.h, crys_rnd_error.h or crys_hash_error.h.
Parameters
[in,out]rndState_ptrPointer to the RND state.
[in,out]rndGenerateVectFuncPointer to the RND Generate vector function pointer.
[in]modP_ptrPointer to the modulus (Prime).
[in]modPsizeBytesSize of the modulus (Prime) in bytes.
[in]orderQ_ptrPointer to the order Q of generator. The size of the buffer for output generated value must be no less than the order size.
[in]orderQsizeBytesSize of the Generator's order in bytes.
[in]generatorG_ptrPointer to the generator of the multiplicative subgroup in GF(P).
[in]generatorSizeBytesSize of the generator in bytes.
[in]seedS_ptrRandom seed used for prime generation.
[in]seedSizeBitsSeed size in bits.
[in]pgenCounterCounter of prime generation attempts.
[in]checkTempBuff_ptrTemporary buffer for internal calculations.
CRYSError_t CRYS_DH_CreateDomainParams ( void *  rndState_ptr,
SaSiRndGenerateVectWorkFunc_t  rndGenerateVectFunc,
uint32_t  modPsizeBits,
uint32_t  orderQsizeBits,
uint32_t  seedSizeBits,
uint8_t *  modP_ptr,
uint8_t *  orderQ_ptr,
uint8_t *  generatorG_ptr,
uint32_t *  generGsizeBytes_ptr,
uint8_t *  factorJ_ptr,
uint32_t *  JsizeBytes_ptr,
uint8_t *  seedS_ptr,
int8_t  generateSeed,
uint32_t *  pgenCounter_ptr,
CRYS_DHKGData_t DHKGbuff_ptr 
)

This function generates DH domain parameters in Galois prime field according to standard [ANS X9.42]. It receives the required sizes (in bits) of the modulus, the generator's order, and the seed, and then generates the prime modulus and the generator according to given sizes. If generateSeed argument is set to 1, the function generates and outputs the random seed. Otherwise (if set to 0), the seed has to be passed as an input argument. According to implementation the seed should be not greate, than (2^seedSizeBits - 2^32). The seed and some additional parameters, generated by the function (factorJ, pgenCounter), are used for checking that all domain parameters are generated according to the standard and not forged.

Note
All buffer parameters should be in Big-Endian form.
Returns
CRYS_OK on success.
A non-zero value on failure as defined crys_dh_error.h, crys_rnd_error.h or crys_hash_error.h.
Parameters
[in,out]rndState_ptrPointer to the RND state structure.
[in]rndGenerateVectFuncPointer to a random vector generation function.
[in]modPsizeBitsSize of the modulus (Prime) in bits equal 256*n, where n >= 4. FIPS 186-4 defines sizes 1024 and 2048 bit.
[in]orderQsizeBitsSize of the Generator's order in bits. FIPS 186-4 defines orderQSizeBits = 160 for modulus 1024 bit and 224 or 256 bit for modPSizeBits = 2048. We not recommend sizes > 256 and returns an error if orderQSizeBits > modPSizeBits/4
[in]seedSizeBitsSeed size in bits. Requirements: modPSizeBits >= seedSizeBits >= orderQSizeBits (the first is required by our implementation).
[out]modP_ptrPointer to the modulus (prime) buffer. The size of the buffer for output generated value must be no less than given modulus size.
[out]orderQ_ptrPointer to the order Q of generator. The size of the buffer for output generated value must be no less than the given order size.
[out]generatorG_ptrPointer to the generator of multiplicative subgroup in GF(P). If the user does not need this output, then both the pointer and the buffer size must be set to 0.
[in,out]generGsizeBytes_ptrPointer to the one word buffer for outputting the generator's size. The passed size (if needed) must be not less than modulus size and the function returns the actual size of the generator.
[out]factorJ_ptrPointer to the buffer for integer factor J. If NULL, the function does not output this parameter (in this case JsizeBytes_ptr also must be set to NULL, else the function returns an error).
[in,out]JsizeBytes_ptrPointer to the size of integer factor J. If NULL, the function does not output this parameter.
[in,out]seedS_ptrRandom seed used for prime generation. The size of the buffer must be at least the seed size.
[in]generateSeedFlag, defining whether the seed should be generated randomly by the function (1) or is passed by the user (0).
[out]pgenCounter_ptrPointer to counter of tries to generate the primes. If NULL, the function does not output this parameter.
[out]DHKGbuff_ptrThe temp buffer of defined structure for internal calculations.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.