Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

CryptoCell key build for ECC APIs

CryptoCell key build for ECC APIs
[CryptoCell ECC APIs]

Functions

CIMPORT_C CRYSError_t CRYS_ECPKI_BuildPrivKey (const CRYS_ECPKI_Domain_t *pDomain, const uint8_t *pPrivKeyIn, uint32_t PrivKeySizeInBytes, CRYS_ECPKI_UserPrivKey_t *pUserPrivKey)
 Builds (imports) the user private key structure from an existing private key so that this structure can be used by other EC primitives. This function should be called before using of the private key. Input domain structure must be initialized by EC parameters and auxiliary values, using CRYS_ECPKI_GetDomain or CRYS_ECPKI_SetDomain functions.
CIMPORT_C CRYSError_t _DX_ECPKI_BuildPublKey (const CRYS_ECPKI_Domain_t *pDomain, uint8_t *PublKeyIn_ptr, uint32_t PublKeySizeInBytes, EC_PublKeyCheckMode_t CheckMode, CRYS_ECPKI_UserPublKey_t *pUserPublKey, CRYS_ECPKI_BUILD_TempData_t *pTempBuff)
 Builds a user public key structure from an imported public key, so it can be used by other EC primitives. When operating the EC cryptographic algorithms with imported EC public key, this function should be called before using of the public key.
CIMPORT_C CRYSError_t CRYS_ECPKI_ExportPublKey (CRYS_ECPKI_UserPublKey_t *pUserPublKey, CRYS_ECPKI_PointCompression_t compression, uint8_t *pExternPublKey, uint32_t *pPublKeySizeBytes)
 Converts an existing public key from internal representation to Big-Endian export representation. The function converts the X,Y coordinates of public key EC point to big endianness, and sets the public key as follows:

Function Documentation

CIMPORT_C CRYSError_t _DX_ECPKI_BuildPublKey ( const CRYS_ECPKI_Domain_t pDomain,
uint8_t *  PublKeyIn_ptr,
uint32_t  PublKeySizeInBytes,
EC_PublKeyCheckMode_t  CheckMode,
CRYS_ECPKI_UserPublKey_t pUserPublKey,
CRYS_ECPKI_BUILD_TempData_t pTempBuff 
)

Builds a user public key structure from an imported public key, so it can be used by other EC primitives. When operating the EC cryptographic algorithms with imported EC public key, this function should be called before using of the public key.

Note:
The Incoming public key PublKeyIn structure is big endian bytes array, containing concatenation of PC||X||Y, where:
  • PC - point control single byte, defining the type of point: 0x4 - uncompressed, 06,07 - hybrid, 2,3 - compressed.
  • X,Y - EC point coordinates of public key (y is omitted in compressed form), size of X and Y must be equal to size of EC modulus.

The user may call this function by appropriate macros, according to necessary validation level [SEC1. ECC standard: 3.2, ANS X9.62]:

  • Checking the input pointers and sizes only - CRYS_ECPKI_BuildPublKey.
  • Partially checking of public key - CRYS_ECPKI_BuildPublKeyPartlyCheck.
  • Full checking of public key - CRYS_ECPKI_BuildPublKeyFullCheck.
Note:
Full check mode takes long time and should be used when it is actually needed.
Returns:
CRYS_OK on success.
A non-zero value on failure as defined crys_ecpki_error.h.
Parameters:
[in]pDomainThe EC domain (curve).
[in]PublKeyIn_ptrPointer to the input public key data, in compressed or uncompressed or hybrid form: [PC||X||Y] Big-Endian representation, structured according to [IEEE1363], where:

  • X and Y are the public key's EC point coordinates. In compressed form, Y is omitted.
  • The sizes of X and Y are equal to the size of the EC modulus.
  • PC is a one-byte point control that defines the type of point compression.
[in]PublKeySizeInBytesThe size of public key data (in bytes).
[in]CheckModeThe required level of public key verification (higher verification level means longer verification time):

  • 0 = preliminary validation.
  • 1 = partial validation.
  • 2 = full validation.
[out]pUserPublKeyPointer to the output public key structure. This structure is used as input to the ECPKI cryptographic primitives.
[in]pTempBuffPointer for a temporary buffer required for the build function.
CIMPORT_C CRYSError_t CRYS_ECPKI_BuildPrivKey ( const CRYS_ECPKI_Domain_t pDomain,
const uint8_t *  pPrivKeyIn,
uint32_t  PrivKeySizeInBytes,
CRYS_ECPKI_UserPrivKey_t pUserPrivKey 
)

Builds (imports) the user private key structure from an existing private key so that this structure can be used by other EC primitives. This function should be called before using of the private key. Input domain structure must be initialized by EC parameters and auxiliary values, using CRYS_ECPKI_GetDomain or CRYS_ECPKI_SetDomain functions.

Returns:
CRYS_OK on success.
A non-zero value on failure as defined crys_ecpki_error.h.
Parameters:
[in]pDomainThe EC domain (curve).
[in]pPrivKeyInPointer to private key data.
[in]PrivKeySizeInBytesSize of private key data (in bytes).
[out]pUserPrivKeyPointer to the private key structure. This structure is used as input to the ECPKI cryptographic primitives.
CIMPORT_C CRYSError_t CRYS_ECPKI_ExportPublKey ( CRYS_ECPKI_UserPublKey_t pUserPublKey,
CRYS_ECPKI_PointCompression_t  compression,
uint8_t *  pExternPublKey,
uint32_t *  pPublKeySizeBytes 
)

Converts an existing public key from internal representation to Big-Endian export representation. The function converts the X,Y coordinates of public key EC point to big endianness, and sets the public key as follows:

  • In case "Uncompressed" point: PubKey = PC||X||Y, PC = 0x4 - single byte;
  • In case of "Hybrid" key PC = 0x6.
  • In case of "Compressed" key PC = 0x2.
Note:
Size of output X and Y coordinates is equal to ModSizeInBytes.
Returns:
CRYS_OK on success.
A non-zero value on failure as defined crys_ecpki_error.h.
Parameters:
[in]pUserPublKeyPointer to the input public key structure (in Little-Endian form).
[in]compressionCompression mode: Compressed, Uncompressed or Hybrid.
[out]pExternPublKeyPointer to the exported public key array, in compressed or uncompressed or hybrid form: [PC||X||Y] Big-Endian representation, structured according to [IEEE1363]. In compressed form, Y is omitted.
[in,out]pPublKeySizeBytesPointer used for the input of the user public key buffer size (in bytes), and the output of the size of the converted public key in bytes.