初始提交
This commit is contained in:
172
export/inc/crypto/iot_crypto_aes_api.h
Executable file
172
export/inc/crypto/iot_crypto_aes_api.h
Executable file
@@ -0,0 +1,172 @@
|
||||
/****************************************************************************
|
||||
|
||||
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
||||
|
||||
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
||||
be copied by any method or incorporated into another program without
|
||||
the express written consent of Aerospace C.Power. This Information or any portion
|
||||
thereof remains the property of Aerospace C.Power. The Information contained herein
|
||||
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
||||
liability for its use in any way and conveys no license or title under
|
||||
any patent or copyright and makes no representation or warranty that this
|
||||
Information is free from patent or copyright infringement.
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef IOT_CRYPTO_AES_API_H
|
||||
#define IOT_CRYPTO_AES_API_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "iot_crypto_error_api.h"
|
||||
|
||||
/** \defgroup CRYPTO_APIs CRYPTO APIs
|
||||
*/
|
||||
|
||||
#define IOT_AES_ENCRYPT 1
|
||||
#define IOT_AES_DECRYPT 0
|
||||
|
||||
/** @addtogroup CRYPTO_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_aes_setkey_enc() - set AES enc key
|
||||
* @param tm: time zone param
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_aes_setkey_enc(const uint8_t *key, uint32_t keybits);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_aes_setkey_dec() - set AES dec key
|
||||
* @param key: key buffer
|
||||
* @param keybits: key length
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_aes_setkey_dec(const uint8_t *key, uint32_t keybits);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_aes_ecb() - AES ECB
|
||||
* @param mode: 1->enc mode, 0->dec mode
|
||||
* @param len: buffer len
|
||||
* @param input: input buffer
|
||||
* @param output: output buffer
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_aes_ecb(uint8_t mode, uint32_t len,
|
||||
const uint8_t *input, uint8_t *output);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_aes_cbc() - AES CBC
|
||||
* @param mode: 1->enc mode, 0->dec mode
|
||||
* @param len: buffer len
|
||||
* @param len: iv buffer
|
||||
* @param input: input buffer
|
||||
* @param output: output buffer
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_aes_cbc(uint8_t mode, uint32_t len, uint8_t *iv,
|
||||
const uint8_t *input, uint8_t *output);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_aes_ctr() - AES CTR
|
||||
* @param len: buffer len
|
||||
* @param nc_off offset in the current stream_block
|
||||
* @param nonce_counter 128-bit nonce and counter.
|
||||
* @param stream_block saved stream-block for resuming.
|
||||
* @param input: input buffer
|
||||
* @param output: output buffer
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_aes_ctr( int len, size_t *nc_off, uint8_t *nonce_counter,
|
||||
uint8_t *stream_block, const uint8_t *input, uint8_t *output);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_aes_ecb_with_key() - set aes key and AES ECB calculation
|
||||
* @param key: key buffer
|
||||
* @param keybits: key length
|
||||
* @param mode: 1->enc mode, 0->dec mode
|
||||
* @param len: buffer len
|
||||
* @param input: input buffer
|
||||
* @param output: output buffer
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_aes_ecb_with_key(const uint8_t *key, uint32_t keybits,
|
||||
uint8_t mode, uint32_t len, const uint8_t *input, uint8_t *output);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_aes_cbc_with_key() - set aes key and AES CBC calculation
|
||||
* @param key: key buffer
|
||||
* @param keybits: key bit length
|
||||
* @param mode: 1->enc mode, 0->dec mode
|
||||
* @param len: buffer len
|
||||
* @param in_iv: input iv buffer
|
||||
* @param input: input buffer
|
||||
* @param output: output buffer
|
||||
* @param out_iv: output iv buffer
|
||||
* @param round: round count
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_aes_cbc_with_key(const uint8_t *key, uint32_t keybits,
|
||||
uint8_t mode, uint32_t len, uint8_t *in_iv, const uint8_t *input,
|
||||
uint8_t *output, uint8_t *out_iv, uint32_t round);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_aes_ctr_with_key() - set aes key and AES CTR calculation
|
||||
* @param key: key buffer
|
||||
* @param keybits: key length
|
||||
* @param len: buffer len
|
||||
* @param nc_off offset in the current stream_block
|
||||
* @param nonce_counter 128-bit nonce and counter.
|
||||
* @param stream_block saved stream-block for resuming.
|
||||
* @param input: input buffer
|
||||
* @param output: output buffer
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_aes_ctr_with_key(const uint8_t *key, uint32_t keybits,
|
||||
int len, size_t *nc_off, uint8_t *nonce_counter, uint8_t *stream_block,
|
||||
const uint8_t *input, uint8_t *output);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_aes_gcm
|
||||
*
|
||||
* @param is_enc: 1 - encrypt, 0 - decrypt
|
||||
* @param key: key buffer
|
||||
* @param keybits: key bit number
|
||||
* @param input: for encrypt, this is plaintext
|
||||
* for decrypt, this is chipertext
|
||||
* @param input_len: input text byte length
|
||||
* @param iv: input iv buffer
|
||||
* @param iv_len: iv byte length
|
||||
* @param add: add buffer
|
||||
* @param add_len: add byte length
|
||||
* @param output: for encrypt, this is chipertext
|
||||
* for decrypt, this is plaintext
|
||||
* @param tag: output tag buffer
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_aes_gcm(uint8_t is_enc, uint8_t *key,
|
||||
uint32_t keybits, uint8_t *input, uint32_t input_len, uint8_t *iv,
|
||||
uint32_t iv_len, uint8_t *add, uint32_t add_len, uint8_t *output,
|
||||
uint8_t *tag);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //IOT_CRYPTO_AES_API_H
|
248
export/inc/crypto/iot_crypto_dsa_api.h
Normal file
248
export/inc/crypto/iot_crypto_dsa_api.h
Normal file
@@ -0,0 +1,248 @@
|
||||
/****************************************************************************
|
||||
|
||||
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
||||
|
||||
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
||||
be copied by any method or incorporated into another program without
|
||||
the express written consent of Aerospace C.Power. This Information or any portion
|
||||
thereof remains the property of Aerospace C.Power. The Information contained herein
|
||||
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
||||
liability for its use in any way and conveys no license or title under
|
||||
any patent or copyright and makes no representation or warranty that this
|
||||
Information is free from patent or copyright infringement.
|
||||
|
||||
****************************************************************************/
|
||||
#ifndef IOT_CRYPTO_DSA_API_H
|
||||
#define IOT_CRYPTO_DSA_API_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "iot_crypto_error_api.h"
|
||||
|
||||
/* define ECDSA elliptic curve type */
|
||||
typedef enum {
|
||||
ecdsa_ecp_bp256r1 = 0x0,
|
||||
} ecdsa_ecp_t;
|
||||
|
||||
#define G_SIZE_INBYTES (32)
|
||||
#define SM3_RESULT_SIZE (32)
|
||||
|
||||
typedef struct _sm2_exchange_info_t{
|
||||
uint32_t keylen;
|
||||
uint8_t za[SM3_RESULT_SIZE];
|
||||
uint8_t zb[SM3_RESULT_SIZE];
|
||||
uint8_t s1[SM3_RESULT_SIZE];
|
||||
uint8_t s2[SM3_RESULT_SIZE];
|
||||
void *sm2_exchange_data;
|
||||
uint8_t *keygen;
|
||||
uint8_t *tmpbuf;
|
||||
}sm2_exchange_info_t;
|
||||
|
||||
typedef struct _ecp_point_t{
|
||||
uint8_t x[G_SIZE_INBYTES];
|
||||
uint8_t y[G_SIZE_INBYTES];
|
||||
}ecp_point_t;
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_ecdsa_gen_keypair() - generate key pair.
|
||||
* @param ecp: curve type, see ecdsa_ecp_t.
|
||||
* @param public_key: returns the generated public key
|
||||
* @param public_key_len: returns the generated public key len
|
||||
* @param pri_key: returns the generated private key
|
||||
* @param pri_key_len: returns the generated private key len
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_ecdsa_gen_keypair(
|
||||
ecdsa_ecp_t ecp, uint8_t *public_key, uint32_t *public_key_len,
|
||||
uint8_t *pri_key, uint32_t *pri_key_len);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_ecdsa_with_sha256_sign() - ESDA signature, message hash
|
||||
* algorithm is SHA256.
|
||||
* @param ecp: curve type, see ecdsa_ecp_t.
|
||||
* @param msg: message to be signed
|
||||
* @param len: message len
|
||||
* @param pri_key: private key
|
||||
* @param pri_key_len: private key len
|
||||
* @param r_buf: return the generated signature information r part
|
||||
* @param r_buf_len: r part len.
|
||||
* @param s_buf: return the generated signature information s part
|
||||
* @param s_buf_len: s part len.
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_ecdsa_with_sha256_sign(ecdsa_ecp_t ecp,
|
||||
const uint8_t *msg, uint32_t len,
|
||||
const uint8_t *pri_key, uint32_t pri_key_len,
|
||||
uint8_t *r_buf, uint32_t *r_buf_len,
|
||||
uint8_t *s_buf, uint32_t *s_buf_len);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_ecdsa_with_sha256_sign_verify() - ESDA signature verify,
|
||||
* message hash algorithm is SHA256.
|
||||
* @param ecp: curve type, see ecdsa_ecp_t.
|
||||
* @param msg: original message to be signed verify
|
||||
* @param len: original message len
|
||||
* @param public_key: pointer public key
|
||||
* @param public_key_len: public key len
|
||||
* @param r_buf: signature info r part for verification
|
||||
* @param r_buf_len: r part len
|
||||
* @param s_buf: signature info s part for verification
|
||||
* @param s_buf_len: s part len
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_ecdsa_with_sha256_sign_verify(ecdsa_ecp_t ecp,
|
||||
const uint8_t *msg, uint32_t len,
|
||||
const uint8_t *public_key, uint32_t public_key_len,
|
||||
const uint8_t *r_buf, uint32_t r_buf_len,
|
||||
const uint8_t *s_buf, uint32_t s_buf_len);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_sign() - signature with pub key and private key
|
||||
* @param r signature r
|
||||
* @param rlen signature r len
|
||||
* @param s signature s
|
||||
* @param slen signature s len
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_sign(uint8_t *message, uint32_t message_size,
|
||||
uint8_t *ID, uint32_t ID_len, uint8_t *public_key, uint32_t public_key_len,
|
||||
uint8_t *r, uint32_t *rlen, uint8_t *s, uint32_t *slen, uint8_t *private_key,
|
||||
uint32_t private_key_len);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_verify() - verify signature
|
||||
* @param r signature r
|
||||
* @param rlen signature r len
|
||||
* @param s signature s
|
||||
* @param slen signature s len
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_verify(uint8_t *message, uint32_t message_size,
|
||||
uint8_t *ID, uint32_t ID_len, uint8_t *public_key, uint32_t public_key_len,
|
||||
uint8_t *r, uint32_t rlen, uint8_t *s, uint32_t slen);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_gen_keypair() - gen keypair include pub key and pri key
|
||||
* @param public_key_len input public_key buf len && output pub_key len
|
||||
* @param private_key_len input private_key buf len && output pri_key len
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_gen_keypair(uint8_t *public_key,
|
||||
uint32_t *public_key_len, uint8_t *private_key, uint32_t *private_key_len);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_gen_share_key() - calc share key by pub key and pri key
|
||||
* @pub_key: public key, Fixed 64 bytes
|
||||
* @pri_key: private key, Fixed 32 bytes
|
||||
* @gen_key: buffer to store generated key
|
||||
* @gen_key_len The size of the gen_key
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_gen_share_key(uint8_t *pub_key, uint8_t *pri_key,
|
||||
uint8_t *gen_key, uint32_t gen_key_len);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_encrypt() - sm2 encrypt
|
||||
* @param message_plain: plain text
|
||||
* @param message_size: plain size
|
||||
* @param cipher_text: buffer to store cipher text
|
||||
* @param ciphertext_len: cipher buffer len
|
||||
* @param pubkey: public key
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_encrypt(uint8_t* message_plain, uint32_t message_size,
|
||||
uint8_t* cipher_text, uint32_t *ciphertext_len, uint8_t *pubkey);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_decrypt() - sm2_decrypt
|
||||
* @param cipher_text: cipher text
|
||||
* @param ciphertext_len: cipher text len
|
||||
* @param message_plain: buffer to store Plain text
|
||||
* @param message_size: plain size
|
||||
* @param prikey: private key
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_decrypt(uint8_t* cipher_text, uint32_t ciphertext_len,
|
||||
uint8_t* message_plain, uint32_t *message_size, uint8_t *prikey);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_exchange_info_init() - sm2_info init
|
||||
* @param pub_key_a: public key A
|
||||
* @param pub_key_a_len: public key A len
|
||||
* @param pub_key_b: public key B
|
||||
* @param pub_key_b_len: public key B len
|
||||
* @param pri_key: private key
|
||||
* @param pri_key_len: private key len
|
||||
* @param key_len_in_bits: generate key len in bits
|
||||
* @param sm2_info: parameter set
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_exchange_info_init(uint8_t *pub_key_a,
|
||||
uint32_t pub_key_a_len,uint8_t *pub_key_b, uint32_t pub_key_b_len,
|
||||
uint8_t *pri_key, uint32_t pri_key_len, uint32_t key_len_in_bits,
|
||||
sm2_exchange_info_t *sm2_info);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_exchange_info_init() - sm2_info deinit
|
||||
* @param sm2_info: parameter set
|
||||
*/
|
||||
void iot_crypto_sm2_exchange_info_deinit(sm2_exchange_info_t *sm2_info);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_exchange_req_step1() - request exchange step1
|
||||
* @param ida: a's id
|
||||
* @param ida_len: a's id len
|
||||
* @param idb: b's id
|
||||
* @param idb_len: b's id len
|
||||
* @param ra: generate ecp point
|
||||
* @param sm2_info: parameter set
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_exchange_req_step1(uint8_t *ida, uint32_t ida_len,
|
||||
uint8_t *idb, uint32_t idb_len, ecp_point_t *ra,
|
||||
sm2_exchange_info_t *sm2_info);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_exchange_req_step2() - request exchange step2
|
||||
* @param rb: response generate info
|
||||
* @param sm2_info: parameter set
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_exchange_req_step2(ecp_point_t *rb,
|
||||
sm2_exchange_info_t *sm2_info);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_exchange_response_step1() - response exchange step1
|
||||
* @param ida: a's id
|
||||
* @param ida_len: a's id len
|
||||
* @param idb: b's id
|
||||
* @param idb_len: b's id len
|
||||
* @param ra: request generate info
|
||||
* @param rb: response generate info
|
||||
* @param sm2_info: parameter set
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_exchange_response_step1(uint8_t *ida, uint32_t ida_len,
|
||||
uint8_t *idb, uint32_t idb_len, ecp_point_t *ra, ecp_point_t *rb,
|
||||
sm2_exchange_info_t *sm2_info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IOT_CRYPTO_DSA_API_H */
|
535
export/inc/crypto/iot_crypto_dsa_async_api.h
Normal file
535
export/inc/crypto/iot_crypto_dsa_async_api.h
Normal file
@@ -0,0 +1,535 @@
|
||||
/****************************************************************************
|
||||
|
||||
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
||||
|
||||
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
||||
be copied by any method or incorporated into another program without
|
||||
the express written consent of Aerospace C.Power. This Information or any portion
|
||||
thereof remains the property of Aerospace C.Power. The Information contained herein
|
||||
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
||||
liability for its use in any way and conveys no license or title under
|
||||
any patent or copyright and makes no representation or warranty that this
|
||||
Information is free from patent or copyright infringement.
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _IOT_CRYPTO_DSA_ASYNC_API_H_
|
||||
#define _IOT_CRYPTO_DSA_ASYNC_API_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "iot_pkt_api.h"
|
||||
#include "iot_crypto_error_api.h"
|
||||
#include "iot_crypto_dsa_api.h"
|
||||
|
||||
/* crypto calculate type */
|
||||
#define IOT_CRYPTO_CALC_TYPE_INVALID 0
|
||||
#define IOT_CRYPTO_CALC_TYPE_SM2_SIGN 1
|
||||
#define IOT_CRYPTO_CALC_TYPE_SM2_VERIFY 2
|
||||
#define IOT_CRYPTO_CALC_TYPE_ECDSA_SHA256_SIGN 3
|
||||
#define IOT_CRYPTO_CALC_TYPE_ECDSA_SHA256_VERIFY 4
|
||||
#define IOT_CRYPTO_CALC_TYPE_SM2_KDF_GEN 5
|
||||
#define IOT_CRYPTO_CALC_TYPE_SM2_KEYPAIR_GEN 6
|
||||
#define IOT_CRYPTO_CALC_TYPE_ECDSA_KEYPAIR_GEN 7
|
||||
#define IOT_CRYPTO_CALC_TYPE_SG_AUTH_SIGN 8
|
||||
#define IOT_CRYPTO_CALC_TYPE_SG_AUTH_VERIRY 9
|
||||
#define IOT_CRYPTO_CALC_TYPE_MAX 10
|
||||
|
||||
/* sg id authentication random calculate type */
|
||||
#define IOT_CRYPTO_SG_RANDOM_SIGN_SM2 0
|
||||
#define IOT_CRYPTO_SG_RANDOM_SIGN_ECC 1
|
||||
#define IOT_CRYPTO_SG_RANDOM_VERIFY_SM2 2
|
||||
#define IOT_CRYPTO_SG_RANDOM_VERIFY_ECC 3
|
||||
|
||||
/* save the pack status and set 1 byte align */
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct _iot_crypto_async_user_info {
|
||||
uint8_t info[40];
|
||||
} iot_crypto_async_user_info_t;
|
||||
|
||||
typedef struct _iot_crypto_async_hdr {
|
||||
/* crypto calculate type, see IOT_CRYPTO_CALC_TYPE_XXX */
|
||||
uint8_t type;
|
||||
/* error code, see CRYPTO_RET_XXX */
|
||||
uint8_t err_code;
|
||||
/* reserved */
|
||||
uint16_t rsvd;
|
||||
/* user information */
|
||||
iot_crypto_async_user_info_t user;
|
||||
} iot_crypto_async_hdr_t;
|
||||
|
||||
typedef struct _iot_crypto_ret_sm2_sign {
|
||||
/* sm2 signature r */
|
||||
uint8_t r[32];
|
||||
/* sm2 signature s */
|
||||
uint8_t s[32];
|
||||
} iot_crypto_ret_sm2_sign_t;
|
||||
|
||||
typedef struct _iot_crypto_ret_ecdsa_sha256_sign {
|
||||
/* ecdsa sha256 signature r */
|
||||
uint8_t r[32];
|
||||
/* ecdsa sha256 signature s */
|
||||
uint8_t s[32];
|
||||
} iot_crypto_ret_ecdsa_sha256_sign_t;
|
||||
|
||||
typedef struct _iot_crypto_ret_sm2_gen_keypair_info_t {
|
||||
uint32_t pub_key_len;
|
||||
uint32_t pri_key_len;
|
||||
uint8_t pub_key[64];
|
||||
uint8_t pri_key[32];
|
||||
} iot_crypto_ret_sm2_gen_keypair_info_t;
|
||||
|
||||
typedef struct _iot_crypto_ret_ecdsa_gen_keypair_info_t {
|
||||
ecdsa_ecp_t ecp;
|
||||
uint32_t pub_key_len;
|
||||
uint32_t pri_key_len;
|
||||
uint8_t pub_key[64];
|
||||
uint8_t pri_key[32];
|
||||
} iot_crypto_ret_ecdsa_gen_keypair_info_t;
|
||||
|
||||
typedef struct _iot_crypto_ret_sm2_kdf_gen {
|
||||
/* sm2 kdf generate key length */
|
||||
uint32_t len;
|
||||
/* sm2 kdf generate key buffer */
|
||||
uint8_t key[0];
|
||||
} iot_crypto_ret_sm2_kdf_gen_t;
|
||||
|
||||
typedef struct _iot_crypto_ret_sg_auth_gen_key {
|
||||
/* indicate key[] buffer length */
|
||||
uint16_t key_len;
|
||||
/* generate key buffer */
|
||||
uint8_t key[0];
|
||||
} iot_crypto_ret_sg_auth_gen_key_t;
|
||||
|
||||
/* sg authentication signature async result */
|
||||
typedef struct _iot_crypto_ret_sg_sign_async {
|
||||
/* asynchronous signature result header */
|
||||
iot_crypto_async_hdr_t async_hdr;
|
||||
union {
|
||||
/* random sm2 signature */
|
||||
iot_crypto_ret_sm2_sign_t sm2_sign;
|
||||
/* random ecdsa sha256 signature */
|
||||
iot_crypto_ret_ecdsa_sha256_sign_t sha256_sign;
|
||||
};
|
||||
/* the key generated by sg authentication */
|
||||
iot_crypto_ret_sg_auth_gen_key_t sg_gen_key;
|
||||
} iot_crypto_ret_sg_sign_async_t;
|
||||
|
||||
/* sg authentication verify async result */
|
||||
typedef struct _iot_crypto_ret_sg_verify_async {
|
||||
/* asynchronous verfiy result header */
|
||||
iot_crypto_async_hdr_t async_hdr;
|
||||
/* the key generated by sg authentication */
|
||||
iot_crypto_ret_sg_auth_gen_key_t sg_gen_key;
|
||||
} iot_crypto_ret_sg_verify_async_t;
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_async_func_t - crypto done callback function
|
||||
*
|
||||
* @param pkt: crypto done data pkt
|
||||
* @retval: none
|
||||
*/
|
||||
typedef void (*iot_crypto_async_done_func_t)(iot_pkt_t *pkt);
|
||||
|
||||
/* restore the pack status */
|
||||
#pragma pack(pop)
|
||||
|
||||
#if IOT_CRYPTO_ASYNC_SUPPORT
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_ecdsa_with_sha256_sign_async() - ESDA signature for async,
|
||||
* message hash algorithm is SHA256.
|
||||
* asynchronous result data map:
|
||||
* iot_crypto_async_hdr_t + iot_crypto_ret_ecdsa_sha256_sign_t
|
||||
* @param ecp: curve type, see ecdsa_ecp_t.
|
||||
* @param msg: message to be signed
|
||||
* @param len: message len
|
||||
* @param pri_key: private key
|
||||
* @param pri_key_len: private key len
|
||||
* @param cb: crypto done callback function
|
||||
* @param user: current crypto user info arguments
|
||||
*
|
||||
* @retval:error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_ecdsa_with_sha256_sign_async(
|
||||
ecdsa_ecp_t ecp, const uint8_t *msg, uint32_t len,
|
||||
const uint8_t *pri_key, uint32_t pri_key_len,
|
||||
iot_crypto_async_done_func_t cb, iot_crypto_async_user_info_t *user);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_ecdsa_with_sha256_verify_async() - ESDA signature verify
|
||||
* for async, message hash algorithm is SHA256.
|
||||
* asynchronous result data map:
|
||||
* iot_crypto_async_hdr_t
|
||||
* @param ecp: curve type, see ecdsa_ecp_t.
|
||||
* @param msg: original message to be signed verify
|
||||
* @param len: original message len
|
||||
* @param public_key: pointer public key
|
||||
* @param public_key_len: public key len
|
||||
* @param r_buf: signature info r part for verification
|
||||
* @param r_buf_len: r part len
|
||||
* @param s_buf: signature info s part for verification
|
||||
* @param s_buf_len: s part len
|
||||
* @param cb: crypto done callback function
|
||||
* @param user: current crypto user info arguments
|
||||
*
|
||||
* @retval:error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_ecdsa_with_sha256_verify_async(
|
||||
ecdsa_ecp_t ecp,
|
||||
const uint8_t *msg, uint32_t len,
|
||||
const uint8_t *public_key, uint32_t public_key_len,
|
||||
const uint8_t *r_buf, uint32_t r_buf_len,
|
||||
const uint8_t *s_buf, uint32_t s_buf_len,
|
||||
iot_crypto_async_done_func_t cb, iot_crypto_async_user_info_t *user);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_sign_async() - sm2 signature for async with pub key and
|
||||
* private key
|
||||
* asynchronous result data map:
|
||||
* iot_crypto_async_hdr_t + iot_crypto_ret_sm2_sign_t
|
||||
* @param message: original message to be signed
|
||||
* @param message_size: original message length
|
||||
* @param id: user id
|
||||
* @param id_len: user id length
|
||||
* @param public_key: pointer public key
|
||||
* @param public_key_len: public key len
|
||||
* @param private_key: pointer private key
|
||||
* @param private_key_len: private length
|
||||
* @param cb: crypto done callback function
|
||||
* @param user: current crypto user info arguments
|
||||
*
|
||||
* @retval:error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_sign_async(uint8_t *message, uint32_t message_size,
|
||||
uint8_t *id, uint32_t id_len, uint8_t *public_key, uint32_t public_key_len,
|
||||
uint8_t *private_key, uint32_t private_key_len,
|
||||
iot_crypto_async_done_func_t cb,
|
||||
iot_crypto_async_user_info_t *user);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_verify_async() - sm2 verify for async with pub key
|
||||
* asynchronous result data map:
|
||||
* iot_crypto_async_hdr_t
|
||||
* @param message: original message to be signed
|
||||
* @param message_size: original message length
|
||||
* @param id: user id
|
||||
* @param id_len: user id length
|
||||
* @param public_key: pointer public key
|
||||
* @param public_key_len: public key len
|
||||
* @param r signature r
|
||||
* @param rlen signature r len
|
||||
* @param s signature s
|
||||
* @param slen signature s len
|
||||
* @param cb: crypto done callback function
|
||||
* @param user: current crypto user info arguments
|
||||
*
|
||||
* @retval:error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_verify_async(uint8_t *message, uint32_t message_size,
|
||||
uint8_t *id, uint32_t id_len, uint8_t *public_key, uint32_t public_key_len,
|
||||
uint8_t *r, uint32_t rlen, uint8_t *s, uint32_t slen,
|
||||
iot_crypto_async_done_func_t cb, iot_crypto_async_user_info_t *user);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_gen_share_key_async() - calc share key by pub key and
|
||||
* private key
|
||||
* asynchronous result data map:
|
||||
* iot_crypto_async_hdr_t + iot_crypto_ret_sm2_kdf_gen_t
|
||||
* @param pub_key: public key, Fixed 64 bytes
|
||||
* @param pri_key: private key, Fixed 32 bytes
|
||||
* @param gen_key_len: the size of the gen_key
|
||||
* @param cb: crypto done callback function
|
||||
* @param user: current crypto user info arguments
|
||||
*
|
||||
* @retval:error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_gen_share_key_async(uint8_t *pub_key, uint8_t *pri_key,
|
||||
uint32_t gen_key_len, iot_crypto_async_done_func_t cb,
|
||||
iot_crypto_async_user_info_t *user);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_gen_keypair_async() - sm2 generate pair key
|
||||
* asynchronous result data map:
|
||||
* iot_crypto_async_hdr_t + iot_crypto_ret_sm2_gen_keypair_info_t
|
||||
* @param cb: crypto done callback function
|
||||
* @param user: current crypto user info arguments
|
||||
*
|
||||
* @retval:error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm2_gen_keypair_async(
|
||||
iot_crypto_async_done_func_t cb, iot_crypto_async_user_info_t *user);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm2_gen_keypair_async() - sm2 generate pair key
|
||||
* asynchronous result data map:
|
||||
* iot_crypto_async_hdr_t + iot_crypto_ret_sm2_gen_keypair_info_t
|
||||
* @param ecp: curve type, see ecdsa_ecp_t
|
||||
* @param cb: crypto done callback function
|
||||
* @param user: current crypto user info arguments
|
||||
*
|
||||
* @retval:error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_ecdsa_gen_keypair_async(ecdsa_ecp_t ecp,
|
||||
iot_crypto_async_done_func_t cb, iot_crypto_async_user_info_t *user);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sg_auth_random_sign_async() - calculate identity
|
||||
* authentication for sg security authentication(random signature).
|
||||
* asynchronous result data map:
|
||||
* iot_crypto_ret_sg_sign_async_t
|
||||
* @param root_pub: root public key
|
||||
* @param root_pub_len: root public key length
|
||||
* @param auth_chip_id: the chip id of the certificate to be authenticated
|
||||
* @param auth_chip_id_len: auth_chip_id data length
|
||||
* @param auth_ecp: the elliptic curve type of the certificate to be
|
||||
* authenticated, see ecdsa_ecp_t.
|
||||
* @param auth_pub: the public key of the certificate to be authenticated
|
||||
* @param auth_pub_len: auth_pub data length
|
||||
* @param auth_sign: the signature of the certificate to be authenticated
|
||||
* @param auth_sign_len: auth_sign data length
|
||||
* @param gen_key_len: generate share key length
|
||||
* @param random_type: indicate random and random_sign means,
|
||||
* see IOT_CRYPTO_SG_RANDOM_SIGN_XXX.
|
||||
* @param random: random data address
|
||||
* @param random_len: random data length
|
||||
* @param local_ecp: the elliptic curve type of the local device certificate
|
||||
* @param local_pub: the public key of the local device certificate
|
||||
* @param local_pub_len: local_pub data length
|
||||
* @param local_pri: the private key of the local device certificate
|
||||
* @param local_pri_len: local_pri data length
|
||||
* @param sm2_id: sm2 user id
|
||||
* @param sm2_id_len: sm2 user id length
|
||||
* @param cb: crypto done callback function
|
||||
* @param user: current crypto user info arguments
|
||||
*
|
||||
* @retval:error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sg_auth_random_sign_async(
|
||||
uint8_t *root_pub, uint32_t root_pub_len,
|
||||
uint8_t *auth_chip_id, uint32_t auth_chip_id_len,
|
||||
ecdsa_ecp_t auth_ecp, uint8_t *auth_pub, uint32_t auth_pub_len,
|
||||
uint8_t *auth_sign, uint32_t auth_sign_len,
|
||||
uint16_t gen_key_len, uint8_t random_type,
|
||||
uint8_t *random, uint32_t random_len,
|
||||
ecdsa_ecp_t local_ecp, uint8_t *local_pub, uint32_t local_pub_len,
|
||||
uint8_t *local_pri, uint32_t local_pri_len,
|
||||
uint8_t *sm2_id, uint8_t sm2_id_len,
|
||||
iot_crypto_async_done_func_t cb,
|
||||
iot_crypto_async_user_info_t *user);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sg_auth_random_verify_async() - calculate identity
|
||||
* authentication for sg security authentication(random verify).
|
||||
* asynchronous result data map:
|
||||
* iot_crypto_ret_sg_verify_async_t
|
||||
* @param root_pub: root public key
|
||||
* @param root_pub_len: root public key length
|
||||
* @param auth_chip_id: the chip id of the certificate to be authenticated
|
||||
* @param auth_chip_id_len: auth_chip_id data length
|
||||
* @param auth_ecp: the elliptic curve type of the certificate to be
|
||||
* authenticated, see ecdsa_ecp_t.
|
||||
* @param auth_pub: the public key of the certificate to be authenticated
|
||||
* @param auth_pub_len: auth_pub data length
|
||||
* @param auth_sign: the signature of the certificate to be authenticated
|
||||
* @param auth_sign_len: auth_sign data length
|
||||
* @param gen_key_len: generate share key length
|
||||
* @param random_type: indicate random and random_sign means,
|
||||
* see /IOT_CRYPTO_SG_RANDOM_VERIFY_XXX.
|
||||
* @param random: random data address
|
||||
* @param random_len: random data length
|
||||
* @param ramdom_sign: signatures data address
|
||||
* @param random_sign_len: ramdom_sign data length
|
||||
* @param local_ecp: the elliptic curve type of the local device certificate
|
||||
* @param local_pub: the public key of the local device certificate
|
||||
* @param local_pub_len: local_pub data length
|
||||
* @param local_pri: the private key of the local device certificate
|
||||
* @param local_pri_len: local_pri data length
|
||||
* @param sm2_id: sm2 user id
|
||||
* @param sm2_id_len: sm2 user id length
|
||||
* @param cb: crypto done callback function
|
||||
* @param user: current crypto user info arguments
|
||||
*
|
||||
* @retval:error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sg_auth_random_verify_async(
|
||||
uint8_t *root_pub, uint32_t root_pub_len,
|
||||
uint8_t *auth_chip_id, uint32_t auth_chip_id_len,
|
||||
ecdsa_ecp_t auth_ecp, uint8_t *auth_pub, uint32_t auth_pub_len,
|
||||
uint8_t *auth_sign, uint32_t auth_sign_len,
|
||||
uint16_t gen_key_len, uint8_t random_verify_type,
|
||||
uint8_t *random, uint32_t random_len,
|
||||
uint8_t *ramdom_sign, uint32_t random_sign_len,
|
||||
ecdsa_ecp_t local_ecp, uint8_t *local_pub, uint32_t local_pub_len,
|
||||
uint8_t *local_pri, uint32_t local_pri_len,
|
||||
uint8_t *sm2_id, uint8_t sm2_id_len,
|
||||
iot_crypto_async_done_func_t cb,
|
||||
iot_crypto_async_user_info_t *user);
|
||||
|
||||
#else /* IOT_CRYPTO_ASYNC_SUPPORT */
|
||||
|
||||
#define iot_crypto_ecdsa_with_sha256_sign_async(ecp, msg, len, pri_key, \
|
||||
pri_key_len, cb, user) \
|
||||
(void)(CRYPTO_RET_NOSUPP); \
|
||||
do { \
|
||||
(void)ecp; \
|
||||
(void)msg; \
|
||||
(void)len; \
|
||||
(void)pri_key; \
|
||||
(void)pri_key_len; \
|
||||
(void)cb; \
|
||||
(void)user; \
|
||||
} while(0)
|
||||
|
||||
#define iot_crypto_ecdsa_with_sha256_verify_async(ecp, msg, len, public_key, \
|
||||
public_key_len, r_buf, r_buf_len, s_buf, s_buf_len, cb, user) \
|
||||
(void)(CRYPTO_RET_NOSUPP); \
|
||||
do { \
|
||||
(void)ecp; \
|
||||
(void)msg; \
|
||||
(void)len; \
|
||||
(void)public_key; \
|
||||
(void)public_key_len; \
|
||||
(void)r_buf; \
|
||||
(void)r_buf_len; \
|
||||
(void)s_buf; \
|
||||
(void)s_buf_len; \
|
||||
(void)cb; \
|
||||
(void)user; \
|
||||
} while(0)
|
||||
|
||||
#define iot_crypto_sm2_sign_async(message, message_size, ID, ID_len, \
|
||||
public_key, public_key_len, private_key, private_key_len, cb, user) \
|
||||
(CRYPTO_RET_NOSUPP); \
|
||||
do { \
|
||||
(void)message; \
|
||||
(void)message_size; \
|
||||
(void)ID; \
|
||||
(void)ID_len; \
|
||||
(void)public_key; \
|
||||
(void)private_key_len; \
|
||||
(void)private_key; \
|
||||
(void)private_key_len; \
|
||||
(void)cb; \
|
||||
(void)user; \
|
||||
} while(0);
|
||||
|
||||
#define iot_crypto_sm2_verify_async(message, message_size, ID, ID_len, \
|
||||
public_key, public_key_len, r, rlen, s, slen, cb, user) \
|
||||
(void)(CRYPTO_RET_NOSUPP); \
|
||||
do { \
|
||||
(void)message; \
|
||||
(void)message_size; \
|
||||
(void)ID; \
|
||||
(void)ID_len; \
|
||||
(void)public_key; \
|
||||
(void)public_key_len; \
|
||||
(void)r; \
|
||||
(void)rlen; \
|
||||
(void)s; \
|
||||
(void)slen; \
|
||||
(void)cb; \
|
||||
(void)user; \
|
||||
} while(0);
|
||||
|
||||
#define iot_crypto_sm2_gen_share_key_async(pub_key, pri_key, gen_key_len, \
|
||||
cb, user) \
|
||||
(void)(CRYPTO_RET_NOSUPP); \
|
||||
do { \
|
||||
(void)pub_key; \
|
||||
(void)pri_key; \
|
||||
(void)gen_key_len; \
|
||||
(void)cb; \
|
||||
(void)user; \
|
||||
} while(0);
|
||||
|
||||
#define iot_crypto_sm2_gen_keypair_async(cb, user) \
|
||||
(void)(CRYPTO_RET_NOSUPP); \
|
||||
do { \
|
||||
(void)cb; \
|
||||
(void)user; \
|
||||
} while(0);
|
||||
|
||||
#define iot_crypto_ecdsa_gen_keypair_async(ecp, cb, user) \
|
||||
(void)(CRYPTO_RET_NOSUPP); \
|
||||
do { \
|
||||
(void)ecp; \
|
||||
(void)cb; \
|
||||
(void)user; \
|
||||
} while(0);
|
||||
|
||||
#define iot_crypto_sg_auth_random_sign_async( \
|
||||
root_pub, root_pub_len, auth_chip_id, auth_chip_id_len, \
|
||||
auth_ecp, auth_pub, auth_pub_len, auth_sign, auth_sign_len, \
|
||||
gen_key_len, random_type, random, random_len, \
|
||||
local_ecp, local_pub, local_pub_len, \
|
||||
local_pri, local_pri_len, sm2_id, sm2_id_len, \
|
||||
cb, user) \
|
||||
(CRYPTO_RET_NOSUPP); \
|
||||
do { \
|
||||
(void)root_pub; \
|
||||
(void)root_pub_len; \
|
||||
(void)auth_chip_id; \
|
||||
(void)auth_chip_id_len; \
|
||||
(void)auth_ecp; \
|
||||
(void)auth_pub; \
|
||||
(void)auth_pub_len; \
|
||||
(void)auth_sign; \
|
||||
(void)auth_sign_len; \
|
||||
(void)gen_key_len; \
|
||||
(void)random_type; \
|
||||
(void)random; \
|
||||
(void)random_len; \
|
||||
(void)local_ecp; \
|
||||
(void)local_pub; \
|
||||
(void)local_pub_len; \
|
||||
(void)local_pri; \
|
||||
(void)local_pri_len; \
|
||||
(void)cb; \
|
||||
(void)user; \
|
||||
} while(0)
|
||||
|
||||
#define iot_crypto_sg_auth_random_verify_async( \
|
||||
root_pub, root_pub_len, auth_chip_id, auth_chip_id_len, \
|
||||
auth_ecp, auth_pub, auth_pub_len, auth_sign, auth_sign_len, \
|
||||
gen_key_len, random_type, random, random_len, \
|
||||
ramdom_sign, random_sign_len, local_ecp, local_pub, local_pub_len, \
|
||||
local_pri, local_pri_len, sm2_id, sm2_id_len, \
|
||||
cb, user) \
|
||||
(CRYPTO_RET_NOSUPP); \
|
||||
do { \
|
||||
(void)root_pub; \
|
||||
(void)root_pub_len; \
|
||||
(void)auth_chip_id; \
|
||||
(void)auth_chip_id_len; \
|
||||
(void)auth_ecp; \
|
||||
(void)auth_pub; \
|
||||
(void)auth_pub_len; \
|
||||
(void)auth_sign; \
|
||||
(void)auth_sign_len; \
|
||||
(void)gen_key_len; \
|
||||
(void)random_type; \
|
||||
(void)random; \
|
||||
(void)random_len; \
|
||||
(void)ramdom_sign; \
|
||||
(void)random_sign_len; \
|
||||
(void)local_ecp; \
|
||||
(void)local_pub; \
|
||||
(void)local_pub_len; \
|
||||
(void)local_pri; \
|
||||
(void)local_pri_len; \
|
||||
(void)cb; \
|
||||
(void)user; \
|
||||
} while(0)
|
||||
|
||||
#endif /* IOT_CRYPTO_ASYNC_SUPPORT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _IOT_CRYPTO_DSA_ASYNC_API_H_ */
|
26
export/inc/crypto/iot_crypto_error_api.h
Normal file
26
export/inc/crypto/iot_crypto_error_api.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/****************************************************************************
|
||||
|
||||
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
||||
|
||||
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
||||
be copied by any method or incorporated into another program without
|
||||
the express written consent of Aerospace C.Power. This Information or any portion
|
||||
thereof remains the property of Aerospace C.Power. The Information contained herein
|
||||
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
||||
liability for its use in any way and conveys no license or title under
|
||||
any patent or copyright and makes no representation or warranty that this
|
||||
Information is free from patent or copyright infringement.
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef IOT_CRYPTO_ERROR_API_H
|
||||
#define IOT_CRYPTO_ERROR_API_H
|
||||
|
||||
/* crypto error type */
|
||||
#define CRYPTO_RET_OK 0
|
||||
#define CRYPTO_RET_INVAL 1
|
||||
#define CRYPTO_RET_CALC_ERR 2
|
||||
#define CRYPTO_RET_NO_MEM 3
|
||||
#define CRYPTO_RET_NOSUPP 4
|
||||
|
||||
#endif //IOT_CRYPTO_ERROR_API_H
|
98
export/inc/crypto/iot_crypto_hash_api.h
Executable file
98
export/inc/crypto/iot_crypto_hash_api.h
Executable file
@@ -0,0 +1,98 @@
|
||||
/****************************************************************************
|
||||
|
||||
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
||||
|
||||
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
||||
be copied by any method or incorporated into another program without
|
||||
the express written consent of Aerospace C.Power. This Information or any portion
|
||||
thereof remains the property of Aerospace C.Power. The Information contained herein
|
||||
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
||||
liability for its use in any way and conveys no license or title under
|
||||
any patent or copyright and makes no representation or warranty that this
|
||||
Information is free from patent or copyright infringement.
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef IOT_CRYPTO_HASH_API_H
|
||||
#define IOT_CRYPTO_HASH_API_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "iot_crypto_error_api.h"
|
||||
|
||||
/** \defgroup CRYPTO_APIs CRYPTO APIs
|
||||
*/
|
||||
|
||||
/** @addtogroup CRYPTO_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sha224() - SHA224
|
||||
* @param input: input buffer
|
||||
* @param ilen: buffer len
|
||||
* @param output: output buffer
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sha224(const uint8_t *input, uint32_t ilen,
|
||||
uint8_t output[28]);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sha256() - SHA256
|
||||
* @param input: input buffer
|
||||
* @param ilen: buffer len
|
||||
* @param output: output buffer
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sha256(const uint8_t *input, uint32_t ilen,
|
||||
uint8_t output[32]);
|
||||
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sha384() - SHA384
|
||||
* @param input: input buffer
|
||||
* @param ilen: buffer len
|
||||
* @param output: output buffer
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sha384( const uint8_t *input, size_t ilen,
|
||||
uint8_t output[48]);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sha512() - SHA512
|
||||
* @param input: input buffer
|
||||
* @param ilen: buffer len
|
||||
* @param output: output buffer
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sha512( const uint8_t *input, size_t ilen,
|
||||
uint8_t output[64]);
|
||||
|
||||
/**
|
||||
* @brief iot_crypto_sm3
|
||||
*
|
||||
* @param indata: input data
|
||||
* @param indata_len: inbuffer len
|
||||
* @param outdata: output data
|
||||
* @param outdata_len: output len
|
||||
*
|
||||
* @retval: error code. see CRYPTO_RET_XXX
|
||||
*/
|
||||
uint32_t iot_crypto_sm3(uint8_t *indata, uint32_t indata_len,
|
||||
uint8_t *outdata, uint32_t outdata_len);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //IOT_CRYPTO_HASH_API_H
|
Reference in New Issue
Block a user