takashi kadono / Mbed OS Nucleo_446

Dependencies:   ssd1331

Embed: (wiki syntax)

« Back to documentation index

CryptoCell EC Montgomery APIs

Data Structures

struct  CRYS_ECMONT_ScalrMultTempBuff_t
struct  CRYS_ECMONT_TempBuff_t

Enumerations

enum  CRYS_ECMONT_DomainId_t { CRYS_ECMONT_DOMAIN_CURVE_25519, CRYS_ECMONT_DOMAIN_OFF_MODE, CRYS_ECMONT_DOMAIN_LAST = 0x7FFFFFFF }

Functions

CIMPORT_C CRYSError_t CRYS_ECMONT_Scalarmult (uint8_t *pResPoint, size_t *pResPointSize, const uint8_t *pScalar, size_t scalarSize, const uint8_t *pInPoint, size_t inPointSize, CRYS_ECMONT_TempBuff_t *pEcMontTempBuff)
 The function performs EC Montgomery (Curve25519) scalar multiplication: resPoint = scalar * point.
CIMPORT_C CRYSError_t CRYS_ECMONT_ScalarmultBase (uint8_t *pResPoint, size_t *pResPointSize, const uint8_t *pScalar, size_t scalarSize, CRYS_ECMONT_TempBuff_t *pEcMontTempBuff)
 The function performs EC Montgomery (Curve25519) scalar multiplication of base point: res = scalar * base_point.
CIMPORT_C CRYSError_t CRYS_ECMONT_KeyPair (uint8_t *pPublKey, size_t *pPublKeySize, uint8_t *pSecrKey, size_t *pSecrKeySize, void *pRndState, SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, CRYS_ECMONT_TempBuff_t *pEcMontTempBuff)
 The function randomly generates private and public keys for Montgomery Curve25519.
CIMPORT_C CRYSError_t CRYS_ECMONT_SeedKeyPair (uint8_t *pPublKey, size_t *pPublKeySize, uint8_t *pSecrKey, size_t *pSecrKeySize, const uint8_t *pSeed, size_t seedSize, CRYS_ECMONT_TempBuff_t *pEcMontTempBuff)
 The function generates private and public keys for Montgomery algorithms.

Detailed Description

Note:
Implemented algorithms according to Montgomery elliptic curves cryptography, developed by Daniel J.Bernstein etc.

Enumeration Type Documentation

EC Montgomery domains ID-s enumerator.

Enumerator:
CRYS_ECMONT_DOMAIN_CURVE_25519 

EC Curve25519.

CRYS_ECMONT_DOMAIN_OFF_MODE 

EC Montgomery last domain.

CRYS_ECMONT_DOMAIN_LAST 

Reserved.

Definition at line 77 of file crys_ec_mont_api.h.


Function Documentation

CIMPORT_C CRYSError_t CRYS_ECMONT_KeyPair ( uint8_t *  pPublKey,
size_t *  pPublKeySize,
uint8_t *  pSecrKey,
size_t *  pSecrKeySize,
void *  pRndState,
SaSiRndGenerateVectWorkFunc_t  rndGenerateVectFunc,
CRYS_ECMONT_TempBuff_t pEcMontTempBuff 
)

The function randomly generates private and public keys for Montgomery Curve25519.

Note:
  • All byte arrays are in LE order of bytes, i.e. LS byte is on the left most place.
  • LS and MS bits of the Secret key are set according to EC Montgomery scalar mult. algorithm: secrKey[0] &= 248; secrKey[31] &= 127; secrKey[31] |= 64;
Returns:
CRYS_OK on success,
A non-zero value on failure as defined crys_ec_mont_edw_error.h or crys_rnd_error.h.
Parameters:
[out]pPublKeyPointer to the public key.
[in,out]pPublKeySizePointer to the size of the public key in bytes. In - the size of the buffer must be at least EC order size (for curve25519 - 32 bytes); Out - the actual size.
[out]pSecrKeyPointer to the secret key, including.
[in,out]pSecrKeySizePointer to the size of buffer for the secret key in bytes - must be at least EC order size (for curve25519 - 32 bytes).
[in,out]pRndStatePointer to the RND state structure.
[in]rndGenerateVectFuncPointer to the random vector generation function.
[in]pEcMontTempBuffPointer to the temp buffer, for internal use.
CIMPORT_C CRYSError_t CRYS_ECMONT_Scalarmult ( uint8_t *  pResPoint,
size_t *  pResPointSize,
const uint8_t *  pScalar,
size_t  scalarSize,
const uint8_t *  pInPoint,
size_t  inPointSize,
CRYS_ECMONT_TempBuff_t pEcMontTempBuff 
)

The function performs EC Montgomery (Curve25519) scalar multiplication: resPoint = scalar * point.

Returns:
CRYS_OK on success,
A non-zero value on failure as defined crys_ec_mont_edw_error.h.
Parameters:
[out]pResPointPointer to the public (secret) key.
[in,out]pResPointSizePointer to the size of the public key in bytes. In - the size of the buffer. must be at least EC modulus size (for curve25519 - 32 bytes). Out - the actual size.
[in]pScalarPointer to the secret (private) key.
[in]scalarSizePointer to the size of the secret key in bytes; must be equal to EC order size (for curve25519 - 32 bytes).
[in]pInPointPointer to the input point (compressed).
[in]inPointSizeSize of the point - must be equal to CRYS_ECMONT_MOD_SIZE_IN_BYTES.
[in]pEcMontTempBuffPointer to temp buffer, for internal use.
CIMPORT_C CRYSError_t CRYS_ECMONT_ScalarmultBase ( uint8_t *  pResPoint,
size_t *  pResPointSize,
const uint8_t *  pScalar,
size_t  scalarSize,
CRYS_ECMONT_TempBuff_t pEcMontTempBuff 
)

The function performs EC Montgomery (Curve25519) scalar multiplication of base point: res = scalar * base_point.

Note: all byte arrays have LE order of bytes, i.e. LS byte is on left most place.

Returns:
CRYS_OK on success,
A non-zero value on failure as defined crys_ec_mont_edw_error.h.
Parameters:
[out]pResPointPointer to the public (secret) key.
[in,out]pResPointSizePointer to the size of the public key in bytes. In - the size of buffer must be at least EC modulus size (for curve25519 - 32 bytes); Out - the actual size.
[in]pScalarPointer to the secret (private) key.
[in]scalarSizePointer to the size of the scalar in bytes - must be equal to EC order size (for curve25519 - 32 bytes).
[in]pEcMontTempBuffPointer to temp buffer, for internal use.
CIMPORT_C CRYSError_t CRYS_ECMONT_SeedKeyPair ( uint8_t *  pPublKey,
size_t *  pPublKeySize,
uint8_t *  pSecrKey,
size_t *  pSecrKeySize,
const uint8_t *  pSeed,
size_t  seedSize,
CRYS_ECMONT_TempBuff_t pEcMontTempBuff 
)

The function generates private and public keys for Montgomery algorithms.

The generation performed using given seed.

Returns:
CRYS_OK on success,
A non-zero value on failure as defined crys_ec_mont_edw_error.h or crys_hash_error.h.
Parameters:
[out]pPublKeyPointer to the public (secret) key.
[in,out]pPublKeySizePointer to the size of the public key in bytes. In - the size of buffer must be at least EC order size (for curve25519 - 32 bytes); Out - the actual size.
[out]pSecrKeyPointer to the secret (private) key.
[in,out]pSecrKeySizePointer to the size of the secret key in bytes In - the size of buffer must be at least EC order size (for curve25519 - 32 bytes); Out - the actual size.
[in]pSeedPointer to the given seed - 32 bytes.
[in]seedSizeSize of the seed in bytes (must be equal to CRYS_ECMONT_SEEDBYTES).
[in]pEcMontTempBuffPointer to a temp buffer, for internal use.