This module contains APIs to program and use the ASYMMETRIC CRYPTOGRAPHY.
Files | |
file | asym_crypt.h |
This file contains the prototype of ASYMMETRIC CRYPTOGRAPHY driver APIs. | |
Data Structures | |
struct | AsymCrypt_RSAPubkey |
RSA public key. All values are in biginteger format (size followed by word value array, least significant word first) More... | |
struct | AsymCrypt_RSAPrivkey |
RSA private key. All values are in biginteger format (size followed by word value array, least significant word first) More... | |
struct | AsymCrypt_ECPoint |
EC Point, also the public key. More... | |
struct | AsymCrypt_ECPrimeCurveP |
EC prime curve parameters. More... | |
struct | AsymCrypt_ECDSASig |
ECDSA signature. More... | |
struct | AsymCrypt_EddsaPoint |
Point on Eddsa Elliptical Curve. More... | |
struct | AsymCrypt_EdCurveParam |
Structure to hold Edward Curve Eddsa parameters. More... | |
struct | AsymCrypt_EddsaSig |
Eddsa EDDSA signature. More... | |
struct | AsymCrypt_EddsaKey |
Eddsa EDDSA Private key - Public key pair in uint8 array form. More... | |
Functions | |
AsymCrypt_Handle | AsymCrypt_open (uint32_t index) |
Function to Open AsymCrypt instance, enable AsymCrypt engine, Initialize clocks. More... | |
AsymCrypt_Return_t | AsymCrypt_close (AsymCrypt_Handle handle) |
Function to close a AsymCrypt module specified by the AsymCrypt handle. More... | |
AsymCrypt_Return_t | AsymCrypt_RSAPrivate (AsymCrypt_Handle handle, const uint32_t m[RSA_MAX_LENGTH], const struct AsymCrypt_RSAPrivkey *k, uint32_t result[RSA_MAX_LENGTH]) |
This Function performs Decryption or Signing operations. More... | |
AsymCrypt_Return_t | AsymCrypt_RSAPublic (AsymCrypt_Handle handle, const uint32_t m[RSA_MAX_LENGTH], const struct AsymCrypt_RSAPubkey *k, uint32_t result[RSA_MAX_LENGTH]) |
This Function performs Encryption or Verification operations. More... | |
AsymCrypt_Return_t | AsymCrypt_RSAKeyGenPrivate (AsymCrypt_Handle handle, struct AsymCrypt_RSAPrivkey *k, uint32_t keybitsize) |
This Function performs Encryption or Verification operations. More... | |
AsymCrypt_Return_t | AsymCrypt_RSAKeyGenPublic (AsymCrypt_Handle handle, const struct AsymCrypt_RSAPrivkey *privKey, struct AsymCrypt_RSAPubkey *pubKey, uint32_t keybitsize) |
This Function performs Encryption or Verification operations. More... | |
AsymCrypt_Return_t | AsymCrypt_ECDSASign (AsymCrypt_Handle handle, const struct AsymCrypt_ECPrimeCurveP *cp, const uint32_t priv[ECDSA_MAX_LENGTH], const uint32_t k[ECDSA_MAX_LENGTH], const uint32_t h[ECDSA_MAX_LENGTH], struct AsymCrypt_ECDSASig *sig) |
ECDSA sign primitive function. More... | |
AsymCrypt_Return_t | AsymCrypt_ECDSAVerify (AsymCrypt_Handle handle, const struct AsymCrypt_ECPrimeCurveP *cp, const struct AsymCrypt_ECPoint *pub, const struct AsymCrypt_ECDSASig *sig, const uint32_t h[ECDSA_MAX_LENGTH]) |
ECDSA verify primitive function. More... | |
AsymCrypt_Return_t | AsymCrypt_ECDSAKeyGenPrivate (AsymCrypt_Handle handle, const struct AsymCrypt_ECPrimeCurveP *cp, uint32_t priv[ECDSA_MAX_LENGTH]) |
ECDSA KeyGen Private Key function. More... | |
AsymCrypt_Return_t | AsymCrypt_ECDSAKeyGenPublic (AsymCrypt_Handle handle, const struct AsymCrypt_ECPrimeCurveP *cp, struct AsymCrypt_ECPoint *pub, const uint32_t priv[ECDSA_MAX_LENGTH]) |
ECDSA KeyGen Public Key function. More... | |
AsymCrypt_Return_t | AsymCrypt_EddsaGetPubKey (AsymCrypt_Handle handle, AsymCrypt_ExecuteShaCallback shaCbFxn, uint8_t privKey[EDDSA_MAX_KEY_LEN], uint8_t pubKey[EDDSA_MAX_KEY_LEN], AsymCrypt_EdCurveType_t input_curve) |
ECDSA KeyGen Public Key function. More... | |
AsymCrypt_Return_t | AsymCrypt_EddsaSign (AsymCrypt_Handle handle, AsymCrypt_ExecuteShaCallback shaCbFxn, const struct AsymCrypt_EddsaKey *key, const uint8_t *ptrData, const uint32_t dataSizeByte, struct AsymCrypt_EddsaSig *sig, AsymCrypt_EdCurveType_t input_curve) |
EDDSA Signing primitive function. More... | |
AsymCrypt_Return_t | AsymCrypt_EddsaVerify (AsymCrypt_Handle handle, AsymCrypt_ExecuteShaCallback shaCbFxn, const uint8_t pubKey[EDDSA_MAX_KEY_LEN], const uint8_t *ptrData, const uint32_t dataSizeByte, const struct AsymCrypt_EddsaSig *sig, AsymCrypt_EdCurveType_t input_curve) |
ECDSA verify primitive function. More... | |
AsymCrypt_Return_t | AsymCrypt_EcdhGenSharedSecret (AsymCrypt_Handle handle, const struct AsymCrypt_ECPrimeCurveP *cp, const uint32_t priv[ECDSA_MAX_LENGTH], const struct AsymCrypt_ECPoint *pubKey, struct AsymCrypt_ECPoint *ecShSecret) |
ECDSA verify primitive function. More... | |
Typedefs | |
typedef void * | AsymCrypt_Handle |
Handle to the AsymCrypt driver. More... | |
typedef AsymCrypt_Return_t(* | AsymCrypt_ExecuteShaCallback) (uint8_t *in_addr, uint32_t length, uint8_t *sha_addr) |
This callback implemented to configure a SHA for EDDSA algorithms. More... | |
Enumerations | |
enum | AsymCrypt_Return_t { ASYM_CRYPT_RETURN_SUCCESS = 0xCEF6A572U, ASYM_CRYPT_RETURN_FAILURE = 0xD20341DDU } |
ASYM CRYPTO Driver Error code. More... | |
enum | AsymCrypt_EdCurveType_t { ASYM_CRYPT_CURVE_TYPE_EDDSA_25519 = 0xBE2479A0U, ASYM_CRYPT_CURVE_TYPE_EDDSA_448 = 0x57138CAFU } |
ASYM EDDSA Curve Type. More... | |
Macros | |
#define | RSA_MAX_LENGTH (130U) |
#define | ECDSA_MAX_LENGTH (18U) |
#define | EC_PARAM_MAXLEN (68U) |
#define | ASYM_CRYPT_LEN(bytelen) (((bytelen) / 4U) + 1U) |
#define | RSA_KEY_E_MAXLEN (8U) |
#define | RSA_KEY_N_MAXLEN (520U) |
#define | RSA_KEY_PQ_MAXLEN ((RSA_KEY_N_MAXLEN / 2U) + 4U) |
#define | RSA_SIG_MAXLEN RSA_KEY_N_MAXLEN |
#define | EDDSA_MAX_KEY_LEN (57U) |
#define | EDDSA_ED25519_KEY_LEN (32U) |
#define | EDDSA_ED448_KEY_LEN (57U) |
#define | EDDSA_ED25519_HASH_LEN (64U) |
#define | EDDSA_ED448_HASH_LEN (114U) |
#define RSA_MAX_LENGTH (130U) |
Max size of AsymCrypt Data in words - for RSA
#define ECDSA_MAX_LENGTH (18U) |
Max size of AsymCrypt Data in words - for ECDSA
#define EC_PARAM_MAXLEN (68U) |
Maximum length of a AsymCrypt data used in EC crypto in bytes, enough to accommodate 521-bit prime curves
#define ASYM_CRYPT_LEN | ( | bytelen | ) | (((bytelen) / 4U) + 1U) |
Length of a data array in words
#define RSA_KEY_E_MAXLEN (8U) |
RSA KEY E maximun length
#define RSA_KEY_N_MAXLEN (520U) |
RSA KEY N maximun length
#define RSA_KEY_PQ_MAXLEN ((RSA_KEY_N_MAXLEN / 2U) + 4U) |
RSA KEY PQ maximun length
#define RSA_SIG_MAXLEN RSA_KEY_N_MAXLEN |
RSA KEY SIG maximun length
#define EDDSA_MAX_KEY_LEN (57U) |
Eddsa Key length in Bytes
#define EDDSA_ED25519_KEY_LEN (32U) |
Ed25519 Key length in Bytes
#define EDDSA_ED448_KEY_LEN (57U) |
Ed448 Key length in Bytes
#define EDDSA_ED25519_HASH_LEN (64U) |
Ed25519 Hash length in Bytes
#define EDDSA_ED448_HASH_LEN (114U) |
Ed448 Hash length in Bytes
typedef void* AsymCrypt_Handle |
Handle to the AsymCrypt driver.
typedef AsymCrypt_Return_t(* AsymCrypt_ExecuteShaCallback) (uint8_t *in_addr, uint32_t length, uint8_t *sha_addr) |
This callback implemented to configure a SHA for EDDSA algorithms.
in_addr | [IN] Source address for Input SHA value |
length | [IN] Length of the input data. |
sha_addr | [IN] Address at which SHA value is available. |
enum AsymCrypt_Return_t |
AsymCrypt_Handle AsymCrypt_open | ( | uint32_t | index | ) |
Function to Open AsymCrypt instance, enable AsymCrypt engine, Initialize clocks.
AsymCrypt_Return_t AsymCrypt_close | ( | AsymCrypt_Handle | handle | ) |
Function to close a AsymCrypt module specified by the AsymCrypt handle.
handle | AsymCrypt_Handle returned from AsymCrypt_open() |
AsymCrypt_Return_t AsymCrypt_RSAPrivate | ( | AsymCrypt_Handle | handle, |
const uint32_t | m[RSA_MAX_LENGTH], | ||
const struct AsymCrypt_RSAPrivkey * | k, | ||
uint32_t | result[RSA_MAX_LENGTH] | ||
) |
This Function performs Decryption or Signing operations.
handle | AsymCrypt_Handle returned from AsymCrypt_open() |
m | m value in bigint format. |
k | RSA private key |
result | Result of the operation in bigint format. caller must allocate memory size of (2 * sizeof(p)) for the result. |
AsymCrypt_Return_t AsymCrypt_RSAPublic | ( | AsymCrypt_Handle | handle, |
const uint32_t | m[RSA_MAX_LENGTH], | ||
const struct AsymCrypt_RSAPubkey * | k, | ||
uint32_t | result[RSA_MAX_LENGTH] | ||
) |
This Function performs Encryption or Verification operations.
handle | AsymCrypt_Handle returned from AsymCrypt_open() |
m | m value in bigint format. |
k | RSA public key |
result | Result of the operation in bigint format. caller must allocate the same memory as s and n for this array. |
AsymCrypt_Return_t AsymCrypt_RSAKeyGenPrivate | ( | AsymCrypt_Handle | handle, |
struct AsymCrypt_RSAPrivkey * | k, | ||
uint32_t | keybitsize | ||
) |
This Function performs Encryption or Verification operations.
handle | AsymCrypt_Handle returned from AsymCrypt_open() |
k | RSA private key |
keybitsize | Result of the operation in bigint format. caller must allocate the same memory as s and n for this array. |
AsymCrypt_Return_t AsymCrypt_RSAKeyGenPublic | ( | AsymCrypt_Handle | handle, |
const struct AsymCrypt_RSAPrivkey * | privKey, | ||
struct AsymCrypt_RSAPubkey * | pubKey, | ||
uint32_t | keybitsize | ||
) |
This Function performs Encryption or Verification operations.
handle | AsymCrypt_Handle returned from AsymCrypt_open() |
privKey | RSA private key |
pubKey | RSA public key |
keybitsize | Result of the operation in bigint format. caller must allocate the same memory as s and n for this array. |
AsymCrypt_Return_t AsymCrypt_ECDSASign | ( | AsymCrypt_Handle | handle, |
const struct AsymCrypt_ECPrimeCurveP * | cp, | ||
const uint32_t | priv[ECDSA_MAX_LENGTH], | ||
const uint32_t | k[ECDSA_MAX_LENGTH], | ||
const uint32_t | h[ECDSA_MAX_LENGTH], | ||
struct AsymCrypt_ECDSASig * | sig | ||
) |
ECDSA sign primitive function.
handle | AsymCrypt_Handle returned from AsymCrypt_open() |
cp | EC curve parameters |
priv | EC private key |
k | Random number for each signing |
h | Hash value of message to sign in bigint format |
sig | ECDSA Signature - 'r' and 's' values |
AsymCrypt_Return_t AsymCrypt_ECDSAVerify | ( | AsymCrypt_Handle | handle, |
const struct AsymCrypt_ECPrimeCurveP * | cp, | ||
const struct AsymCrypt_ECPoint * | pub, | ||
const struct AsymCrypt_ECDSASig * | sig, | ||
const uint32_t | h[ECDSA_MAX_LENGTH] | ||
) |
ECDSA verify primitive function.
handle | AsymCrypt_Handle returned from AsymCrypt_open() |
cp | EC curve parameters |
pub | EC Public key |
sig | ECDSA Signature - 'r' & 's' value in bigint format |
h | Hash value of message to verify in bigint format |
AsymCrypt_Return_t AsymCrypt_ECDSAKeyGenPrivate | ( | AsymCrypt_Handle | handle, |
const struct AsymCrypt_ECPrimeCurveP * | cp, | ||
uint32_t | priv[ECDSA_MAX_LENGTH] | ||
) |
ECDSA KeyGen Private Key function.
handle | AsymCrypt_Handle returned from AsymCrypt_open() |
cp | EC curve parameters |
priv | EC Generated Private Key |
AsymCrypt_Return_t AsymCrypt_ECDSAKeyGenPublic | ( | AsymCrypt_Handle | handle, |
const struct AsymCrypt_ECPrimeCurveP * | cp, | ||
struct AsymCrypt_ECPoint * | pub, | ||
const uint32_t | priv[ECDSA_MAX_LENGTH] | ||
) |
ECDSA KeyGen Public Key function.
handle | AsymCrypt_Handle returned from AsymCrypt_open() |
cp | EC curve parameters |
priv | EC Private Key as input |
pub | EC Generated Private Key |
AsymCrypt_Return_t AsymCrypt_EddsaGetPubKey | ( | AsymCrypt_Handle | handle, |
AsymCrypt_ExecuteShaCallback | shaCbFxn, | ||
uint8_t | privKey[EDDSA_MAX_KEY_LEN], | ||
uint8_t | pubKey[EDDSA_MAX_KEY_LEN], | ||
AsymCrypt_EdCurveType_t | input_curve | ||
) |
ECDSA KeyGen Public Key function.
handle | AsymCrypt_Handle returned from AsymCrypt_open() |
shaCbFxn | [in] SHA Callback Function |
privKey | [in] Private Key Function |
pubKey | [out] Public Key Function |
input_curve | [in] input_curve |
AsymCrypt_Return_t AsymCrypt_EddsaSign | ( | AsymCrypt_Handle | handle, |
AsymCrypt_ExecuteShaCallback | shaCbFxn, | ||
const struct AsymCrypt_EddsaKey * | key, | ||
const uint8_t * | ptrData, | ||
const uint32_t | dataSizeByte, | ||
struct AsymCrypt_EddsaSig * | sig, | ||
AsymCrypt_EdCurveType_t | input_curve | ||
) |
EDDSA Signing primitive function.
handle | AsymCrypt_Handle returned from AsymCrypt_open() |
shaCbFxn | SHA Callback Function |
key | EDDSA Private/Public key pair |
ptrData | Input Pointer to Data |
dataSizeByte | Data Size in Bytes |
sig | Output Pointer to Signature |
input_curve | Input Curve |
AsymCrypt_Return_t AsymCrypt_EddsaVerify | ( | AsymCrypt_Handle | handle, |
AsymCrypt_ExecuteShaCallback | shaCbFxn, | ||
const uint8_t | pubKey[EDDSA_MAX_KEY_LEN], | ||
const uint8_t * | ptrData, | ||
const uint32_t | dataSizeByte, | ||
const struct AsymCrypt_EddsaSig * | sig, | ||
AsymCrypt_EdCurveType_t | input_curve | ||
) |
ECDSA verify primitive function.
handle | AsymCrypt_Handle returned from AsymCrypt_open() |
shaCbFxn | SHA Callback Function |
pubKey | EDDSA Public key |
ptrData | Input Pointer to Data |
dataSizeByte | Data Size in Bytes |
sig | Input Pointer to Signature |
input_curve | Input Curve |
AsymCrypt_Return_t AsymCrypt_EcdhGenSharedSecret | ( | AsymCrypt_Handle | handle, |
const struct AsymCrypt_ECPrimeCurveP * | cp, | ||
const uint32_t | priv[ECDSA_MAX_LENGTH], | ||
const struct AsymCrypt_ECPoint * | pubKey, | ||
struct AsymCrypt_ECPoint * | ecShSecret | ||
) |
ECDSA verify primitive function.
handle | [in] AsymCrypt_Handle returned from AsymCrypt_open() |
cp | [in] EC curve parameters |
priv | [in] EC Private key |
pubKey | [in] EC Public key |
ecShSecret | [out] EC Shared Secret key |