增加所有文件
This commit is contained in:
48
drivers/include/crypto/cacc/pke/ecdh.h
Normal file
48
drivers/include/crypto/cacc/pke/ecdh.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
*
|
||||
*Copyright (c) 2021-2029 Semidrive Incorporated. All rights reserved.
|
||||
*Software License Agreement
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef ECDH_H
|
||||
#define ECDH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <eccp_curve.h>
|
||||
#include <pke.h>
|
||||
|
||||
/*ECDH return code*/
|
||||
enum ECDH_RET_CODE {
|
||||
ECDH_SUCCESS = PKE_SUCCESS,
|
||||
ECDH_POINTOR_NULL = PKE_SUCCESS + 0x60,
|
||||
ECDH_INVALID_INPUT,
|
||||
};
|
||||
|
||||
uint32_t ecdh_compute_key(eccp_curve_t *curve, uint8_t *local_prikey,
|
||||
uint8_t *peer_pubkey, uint8_t *key,
|
||||
uint32_t keyByteLen, KDF_FUNC kdf);
|
||||
|
||||
#ifdef PKE_SEC
|
||||
|
||||
#define ECDH_SEC
|
||||
#ifdef ECDH_SEC
|
||||
|
||||
enum ECDH_RET_CODE_S { ECDH_SUCCESS_S = 0x8B9BC1E1, ECDH_ERROR_S = 0xCBC192A3 };
|
||||
|
||||
uint32_t ecdh_compute_key_s(eccp_curve_t *curve, uint8_t *local_prikey,
|
||||
uint8_t *peer_pubkey, uint8_t *key,
|
||||
uint32_t keyByteLen, KDF_FUNC kdf);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
57
drivers/include/crypto/cacc/pke/ecdsa.h
Normal file
57
drivers/include/crypto/cacc/pke/ecdsa.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
*
|
||||
*Copyright (c) 2021-2029 Semidrive Incorporated. All rights reserved.
|
||||
*Software License Agreement
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef ECDSA_H
|
||||
#define ECDSA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <pke.h>
|
||||
|
||||
/*ECDSA return code*/
|
||||
enum ECDSA_RET_CODE {
|
||||
ECDSA_SUCCESS = PKE_SUCCESS,
|
||||
ECDSA_POINTOR_NULL = PKE_SUCCESS + 0x50,
|
||||
ECDSA_INVALID_INPUT,
|
||||
ECDSA_ZERO_ALL,
|
||||
ECDSA_INTEGER_TOO_BIG,
|
||||
ECDSA_VERIFY_FAILED,
|
||||
};
|
||||
|
||||
uint32_t ecdsa_sign(eccp_curve_t *curve, uint8_t *E, uint32_t EByteLen,
|
||||
uint8_t *rand_k, uint8_t *priKey, uint8_t *signature);
|
||||
|
||||
uint32_t ecdsa_verify(eccp_curve_t *curve, uint8_t *E, uint32_t EByteLen,
|
||||
uint8_t *pubKey, uint8_t *signature);
|
||||
|
||||
#ifdef PKE_SEC
|
||||
|
||||
#define ECDSA_SEC
|
||||
#ifdef ECDSA_SEC
|
||||
|
||||
enum ECDSA_RET_CODE_S {
|
||||
ECDSA_SUCCESS_S = 0x7D5FEB14,
|
||||
ECDSA_ERROR_S = 0xB4C0BC5A
|
||||
};
|
||||
|
||||
uint32_t ecdsa_sign_s(eccp_curve_t *curve, uint8_t *E, uint32_t EByteLen,
|
||||
uint8_t *rand_k, uint8_t *priKey, uint8_t *signature);
|
||||
|
||||
uint32_t ecdsa_verify_s(eccp_curve_t *curve, uint8_t *E, uint32_t EByteLen,
|
||||
uint8_t *pubKey, uint8_t *signature);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
51
drivers/include/crypto/cacc/pke/ed25519.h
Normal file
51
drivers/include/crypto/cacc/pke/ed25519.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
*
|
||||
*Copyright (c) 2021-2029 Semidrive Incorporated. All rights reserved.
|
||||
*Software License Agreement
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef ED25519_H
|
||||
#define ED25519_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <pke.h>
|
||||
|
||||
extern const edward_curve_t ed25519[1];
|
||||
|
||||
/*Ed25519 mode*/
|
||||
typedef enum {
|
||||
Ed25519_DEFAULT = 0,
|
||||
Ed25519_CTX,
|
||||
Ed25519_PH,
|
||||
} Ed25519_MODE;
|
||||
|
||||
/*Ed25519 return code*/
|
||||
enum {
|
||||
EdDSA_SUCCESS = PKE_SUCCESS,
|
||||
EdDSA_POINTOR_NULL = PKE_SUCCESS + 0x80,
|
||||
EdDSA_INVALID_INPUT,
|
||||
EdDSA_VERIFY_FAIL,
|
||||
};
|
||||
|
||||
uint32_t ed25519_get_pubkey_from_prikey(uint8_t prikey[32], uint8_t pubkey[32]);
|
||||
|
||||
uint32_t ed25519_getkey(uint8_t prikey[32], uint8_t pubkey[32]);
|
||||
|
||||
uint32_t ed25519_sign(Ed25519_MODE mode, uint8_t prikey[32], uint8_t pubkey[32],
|
||||
uint8_t *ctx, uint8_t ctxByteLen, uint8_t *M,
|
||||
uint32_t MByteLen, uint8_t RS[64]);
|
||||
|
||||
uint32_t ed25519_verify(Ed25519_MODE mode, uint8_t pubkey[32], uint8_t *ctx,
|
||||
uint8_t ctxByteLen, uint8_t *M, uint32_t MByteLen,
|
||||
uint8_t RS[64]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
63
drivers/include/crypto/cacc/pke/rsa.h
Normal file
63
drivers/include/crypto/cacc/pke/rsa.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
*
|
||||
*Copyright (c) 2021-2029 Semidrive Incorporated. All rights reserved.
|
||||
*Software License Agreement
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef RSA_H
|
||||
#define RSA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <pke.h>
|
||||
|
||||
/*RSA return code*/
|
||||
enum RSA_RET_CODE {
|
||||
RSA_SUCCESS = PKE_SUCCESS,
|
||||
RSA_BUFFER_NULL = PKE_SUCCESS + 0x30,
|
||||
RSA_INPUT_TOO_LONG,
|
||||
RSA_INPUT_INVALID,
|
||||
};
|
||||
|
||||
uint32_t RSA_ModExp(uint32_t *a, uint32_t *e, uint32_t *n, uint32_t *out,
|
||||
uint32_t eBitLen, uint32_t nBitLen);
|
||||
|
||||
uint32_t RSA_CRTModExp(uint32_t *a, uint32_t *p, uint32_t *q, uint32_t *dp,
|
||||
uint32_t *dq, uint32_t *u, uint32_t *out,
|
||||
uint32_t nBitLen);
|
||||
|
||||
uint32_t RSA_GetKey(uint32_t *e, uint32_t *d, uint32_t *n, uint32_t eBitLen,
|
||||
uint32_t nBitLen);
|
||||
|
||||
uint32_t RSA_GetCRTKey(uint32_t *e, uint32_t *p, uint32_t *q, uint32_t *dp,
|
||||
uint32_t *dq, uint32_t *u, uint32_t *n, uint32_t eBitLen,
|
||||
uint32_t nBitLen);
|
||||
|
||||
#ifdef PKE_SEC
|
||||
|
||||
#define RSA_SEC
|
||||
#ifdef RSA_SEC
|
||||
|
||||
/*RSA SEC return code*/
|
||||
enum RSA_RET_CODE_S { RSA_SUCCESS_S = 0x3AEBA318, RSA_ERROR_S = 0x45DF3DAE };
|
||||
|
||||
uint32_t RSA_ModExp_with_pub(uint32_t *a, uint32_t *e, uint32_t *d, uint32_t *n,
|
||||
uint32_t *out, uint32_t eBitLen, uint32_t nBitLen);
|
||||
|
||||
uint32_t RSA_CRTModExp_with_pub(uint32_t *a, uint32_t *p, uint32_t *q,
|
||||
uint32_t *dp, uint32_t *dq, uint32_t *u,
|
||||
uint32_t *e, uint32_t *out, uint32_t eBitLen,
|
||||
uint32_t nBitLen);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
79
drivers/include/crypto/cacc/pke/sm2.h
Normal file
79
drivers/include/crypto/cacc/pke/sm2.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
*
|
||||
*Copyright (c) 2021-2029 Semidrive Incorporated. All rights reserved.
|
||||
*Software License Agreement
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef SM2_H
|
||||
#define SM2_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <pke.h>
|
||||
|
||||
#include "sm2_basic.h"
|
||||
|
||||
/*only available for PKE_HP*/
|
||||
#define SM2_HIGH_SPEED
|
||||
|
||||
/*some sm2 length*/
|
||||
#define SM2_BIT_LEN (256)
|
||||
#define SM2_BYTE_LEN (32)
|
||||
#define SM2_WORD_LEN (8)
|
||||
#define SM3_DIGEST_BYTE_LEN SM2_BYTE_LEN
|
||||
#define SM2_MAX_ID_BYTE_LEN (1 << 13)
|
||||
|
||||
uint32_t sm2_sign(uint8_t E[32], uint8_t rand_k[32], uint8_t priKey[32],
|
||||
uint8_t signature[64]);
|
||||
|
||||
uint32_t sm2_verify(uint8_t E[32], uint8_t pubKey[65], uint8_t signature[64]);
|
||||
|
||||
uint32_t sm2_encrypt(uint8_t *M, uint32_t MByteLen, uint8_t rand_k[32],
|
||||
uint8_t pubKey[65], sm2_cipher_order_e order, uint8_t *C,
|
||||
uint32_t *CByteLen);
|
||||
|
||||
uint32_t sm2_decrypt(uint8_t *C, uint32_t CByteLen, uint8_t priKey[32],
|
||||
sm2_cipher_order_e order, uint8_t *M, uint32_t *MByteLen);
|
||||
|
||||
uint32_t sm2_exchangekey(sm2_exchange_role_e role, uint8_t *dA, uint8_t *PB,
|
||||
uint8_t *rA, uint8_t *RA, uint8_t *RB, uint8_t *ZA,
|
||||
uint8_t *ZB, uint32_t kByteLen, uint8_t *KA,
|
||||
uint8_t *S1, uint8_t *SA);
|
||||
|
||||
#ifdef PKE_SEC
|
||||
|
||||
#define SM2_SEC
|
||||
#ifdef SM2_SEC
|
||||
|
||||
enum SM2_RET_CODE_S { SM2_SUCCESS_S = 0x3E2FDB1A, SM2_ERROR_S = 0xCBAD735E };
|
||||
|
||||
uint32_t sm2_sign_s(uint8_t E[32], uint8_t rand_k[32], uint8_t priKey[32],
|
||||
uint8_t signature[64]);
|
||||
|
||||
uint32_t sm2_verify_s(uint8_t E[32], uint8_t pubKey[65], uint8_t signature[64]);
|
||||
|
||||
uint32_t sm2_encrypt_s(uint8_t *M, uint32_t MByteLen, uint8_t rand_k[32],
|
||||
uint8_t pubKey[65], sm2_cipher_order_e order, uint8_t *C,
|
||||
uint32_t *CByteLen);
|
||||
|
||||
uint32_t sm2_decrypt_s(uint8_t *C, uint32_t CByteLen, uint8_t priKey[32],
|
||||
sm2_cipher_order_e order, uint8_t *M,
|
||||
uint32_t *MByteLen);
|
||||
|
||||
uint32_t sm2_exchangekey_s(sm2_exchange_role_e role, uint8_t *dA, uint8_t *PB,
|
||||
uint8_t *rA, uint8_t *RA, uint8_t *RB, uint8_t *ZA,
|
||||
uint8_t *ZB, uint32_t kByteLen, uint8_t *KA,
|
||||
uint8_t *S1, uint8_t *SA);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
80
drivers/include/crypto/cacc/pke/sm2_basic.h
Normal file
80
drivers/include/crypto/cacc/pke/sm2_basic.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
*
|
||||
*Copyright (c) 2021-2029 Semidrive Incorporated. All rights reserved.
|
||||
*Software License Agreement
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef SM2_BASIC_H
|
||||
#define SM2_BASIC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <pke.h>
|
||||
|
||||
/*only available for PKE_HP*/
|
||||
#define SM2_HIGH_SPEED
|
||||
|
||||
/*some sm2 length*/
|
||||
#define SM2_BIT_LEN (256)
|
||||
#define SM2_BYTE_LEN (32)
|
||||
#define SM2_WORD_LEN (8)
|
||||
#define SM3_DIGEST_BYTE_LEN SM2_BYTE_LEN
|
||||
#define SM2_MAX_ID_BYTE_LEN (1 << 13)
|
||||
|
||||
/*SM2 error code*/
|
||||
enum SM2_RET_CODE {
|
||||
SM2_SUCCESS = 0,
|
||||
SM2_BUFFER_NULL = PKE_SUCCESS + 0x40,
|
||||
SM2_NOT_ON_CURVE,
|
||||
SM2_EXCHANGE_ROLE_INVALID,
|
||||
SM2_INPUT_INVALID,
|
||||
SM2_ZERO_ALL,
|
||||
SM2_INTEGER_TOO_BIG,
|
||||
SM2_VERIFY_FAILED,
|
||||
SM2_DECRYPT_VERIFY_FAILED
|
||||
};
|
||||
|
||||
/*SM2 key exchange role*/
|
||||
typedef enum {
|
||||
SM2_ROLE_SPONSOR = 0,
|
||||
SM2_ROLE_RESPONSOR,
|
||||
SM2_ROLE_MAX
|
||||
} sm2_exchange_role_e;
|
||||
|
||||
/* SM2 ciphertext order*/
|
||||
typedef enum {
|
||||
SM2_C1C3C2 = 0,
|
||||
SM2_C1C2C3,
|
||||
} sm2_cipher_order_e;
|
||||
|
||||
extern const uint32_t sm2p256v1_Gx[8];
|
||||
extern const uint32_t sm2p256v1_Gy[8];
|
||||
extern const uint32_t sm2p256v1_n[8];
|
||||
extern const uint32_t sm2p256v1_n_h[8];
|
||||
extern const uint32_t sm2p256v1_n_1[8];
|
||||
|
||||
extern const eccp_curve_t sm2_curve[1];
|
||||
|
||||
uint32_t sm2_getZ(uint8_t *ID, uint32_t byteLenofID, uint8_t pubKey[65],
|
||||
uint8_t Z[32]);
|
||||
|
||||
uint32_t sm2_getE(uint8_t *M, uint32_t byteLen, uint8_t Z[32], uint8_t E[32]);
|
||||
|
||||
uint32_t sm2_get_pubkey_from_prikey(uint8_t priKey[32], uint8_t pubKey[65]);
|
||||
|
||||
uint32_t sm2_getkey(uint8_t priKey[32], uint8_t pubKey[65]);
|
||||
|
||||
uint32_t sm2_kdf_with_xor(uint8_t *in, uint32_t inByteLen, uint8_t *m,
|
||||
uint8_t *k, uint32_t kByteLen);
|
||||
|
||||
void uint32_BigNum_Add_One(uint32_t *a, uint32_t wordLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
127
drivers/include/crypto/cacc/pke/sm9.h
Normal file
127
drivers/include/crypto/cacc/pke/sm9.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
*
|
||||
*Copyright (c) 2021-2029 Semidrive Incorporated. All rights reserved.
|
||||
*Software License Agreement
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef SM9_H
|
||||
#define SM9_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <pke.h>
|
||||
#include <trng.h>
|
||||
|
||||
#define SM9_MAX_ID_BYTE_LEN (1 << 13)
|
||||
#define SM9_MAX_MSG_BYTE_LEN (0xFFFFFF9F)
|
||||
#define SM9_MAX_ENC_K2_BYTE_LEN (0x40)
|
||||
#define SM9_POINT_NOT_COMPRESSED (0x04)
|
||||
|
||||
/*SM9 error code*/
|
||||
enum SM9_RET_CODE {
|
||||
SM9_SUCCESS = 0,
|
||||
SM9_BUFFER_NULL = 0x50,
|
||||
SM9_NOT_ON_CURVE,
|
||||
SM9_EXCHANGE_ROLE_INVALID,
|
||||
SM9_INPUT_INVALID,
|
||||
SM9_ZERO_ALL,
|
||||
SM9_INTEGER_TOO_BIG,
|
||||
SM9_VERIFY_FAILED,
|
||||
SM9_IN_OUT_SAME_BUFFER,
|
||||
SM9_DECRY_VERIFY_FAILED
|
||||
};
|
||||
|
||||
/*SM9 encryption type choice*/
|
||||
typedef enum {
|
||||
SM9_ENC_KDF_STREAM_CIPHER = 0,
|
||||
SM9_ENC_KDF_BLOCK_CIPHER
|
||||
} sm9_enc_type_e;
|
||||
|
||||
/*available when choose SM9_ENC_KDF_BLOCK_CIPHER*/
|
||||
typedef enum {
|
||||
SM9_ENC_NO_PADDING = 0,
|
||||
SM9_ENC_PKCS7_PADDING,
|
||||
SM9_ENC_MAX_PADDING
|
||||
} sm9_enc_padding_e;
|
||||
|
||||
/*SM9 key exchange role*/
|
||||
typedef enum { SM9_ROLE_SPONSOR = 0, SM9_ROLE_RESPONSOR } sm9_exchange_role_e;
|
||||
|
||||
uint32_t sm9_sign_gen_mastPubKey_from_mastPriKey(uint8_t ks[32],
|
||||
uint8_t Ppub_s[128]);
|
||||
|
||||
uint32_t sm9_sign_gen_mastKeyPair(uint8_t ks[32], uint8_t Ppub_s[128]);
|
||||
|
||||
uint32_t sm9_sign_gen_userPriKey(const uint8_t *IDA, uint32_t IDA_byteLen,
|
||||
uint8_t hid, uint8_t ks[32], uint8_t dsA[64]);
|
||||
|
||||
uint32_t sm9_sign(const uint8_t *M, uint32_t MByteLen,
|
||||
const uint8_t Ppub_s[128], const uint8_t dsA[64],
|
||||
uint8_t r[32], uint8_t h[32], uint8_t S[65]);
|
||||
|
||||
uint32_t sm9_verify(const uint8_t *M, uint32_t MByteLen, const uint8_t *IDA,
|
||||
uint32_t IDA_byteLen, uint8_t hid,
|
||||
const uint8_t Ppub_s[128], const uint8_t h[32],
|
||||
const uint8_t S[65]);
|
||||
|
||||
uint32_t sm9_enc_gen_mastPubKey_from_mastPriKey(uint8_t ke[32],
|
||||
uint8_t Ppub_e[64]);
|
||||
|
||||
uint32_t sm9_enc_gen_mastKeyPair(uint8_t ke[32], uint8_t Ppub_e[64]);
|
||||
|
||||
uint32_t sm9_enc_gen_userPriKey(const uint8_t *IDB, uint32_t IDB_byteLen,
|
||||
uint8_t hid, uint8_t ke[32], uint8_t deB[128]);
|
||||
|
||||
uint32_t sm9_wrap_key(const uint8_t *IDB, uint32_t IDB_byteLen, uint8_t hid,
|
||||
const uint8_t Ppub_e[64], uint8_t r[32], uint8_t C[64],
|
||||
uint32_t KByteLen, uint8_t *K);
|
||||
|
||||
uint32_t sm9_unwrap_key(const uint8_t *IDB, uint32_t IDB_byteLen,
|
||||
const uint8_t deB[128], const uint8_t C[64],
|
||||
uint32_t KByteLen, uint8_t *K);
|
||||
|
||||
uint32_t sm9_enc(const uint8_t *IDB, uint32_t IDB_byteLen, uint8_t hid,
|
||||
const uint8_t *M, uint32_t MByteLen, const uint8_t Ppub_e[64],
|
||||
uint8_t r[32], sm9_enc_type_e enc_type,
|
||||
sm9_enc_padding_e padding_type, uint32_t K2ByteLen, uint8_t *C,
|
||||
uint32_t *CByteLen);
|
||||
|
||||
uint32_t sm9_dec(const uint8_t *IDB, uint32_t IDB_byteLen, const uint8_t *C,
|
||||
uint32_t CByteLen, const uint8_t deB[128],
|
||||
sm9_enc_type_e enc_type, sm9_enc_padding_e padding_type,
|
||||
uint32_t K2ByteLen, uint8_t *M, uint32_t *MByteLen);
|
||||
|
||||
uint32_t sm9_exckey_gen_mastPubKey_from_mastPriKey(uint8_t ke[32],
|
||||
uint8_t Ppub_e[64]);
|
||||
|
||||
uint32_t sm9_exckey_gen_mastKeyPair(uint8_t ke[32], uint8_t Ppub_e[64]);
|
||||
|
||||
uint32_t sm9_exckey_gen_userPriKey(const uint8_t *IDA, uint32_t IDA_byteLen,
|
||||
uint8_t hid, uint8_t ke[32],
|
||||
uint8_t deA[128]);
|
||||
|
||||
uint32_t sm9_exckey_gen_tmpPubKey_from_tmpPriKey(
|
||||
const uint8_t *IDB, uint32_t IDB_byteLen, uint8_t hid,
|
||||
const uint8_t Ppub_e[64], uint8_t rA[32], uint8_t RA[64]);
|
||||
|
||||
uint32_t sm9_exckey_gen_tmpKeyPair(const uint8_t *IDB, uint32_t IDB_byteLen,
|
||||
uint8_t hid, const uint8_t Ppub_e[64],
|
||||
uint8_t rA[32], uint8_t RA[64]);
|
||||
|
||||
uint32_t sm9_exchangekey(sm9_exchange_role_e role, const uint8_t *IDA,
|
||||
uint32_t IDA_byteLen, const uint8_t *IDB,
|
||||
uint32_t IDB_byteLen, const uint8_t Ppub_e[64],
|
||||
const uint8_t deA[128], const uint8_t rA[32],
|
||||
const uint8_t RA[64], const uint8_t RB[64],
|
||||
uint32_t kByteLen, uint8_t *KA, uint8_t S1[32],
|
||||
uint8_t SA[32]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
41
drivers/include/crypto/cacc/pke/x25519.h
Normal file
41
drivers/include/crypto/cacc/pke/x25519.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
*
|
||||
*Copyright (c) 2021-2029 Semidrive Incorporated. All rights reserved.
|
||||
*Software License Agreement
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef X25519_H
|
||||
#define X25519_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <pke.h>
|
||||
|
||||
extern const mont_curve_t c25519[1];
|
||||
|
||||
/*X25519 return code*/
|
||||
enum {
|
||||
X25519_SUCCESS = PKE_SUCCESS,
|
||||
X25519_POINTER_NULL = PKE_SUCCESS + 0x70,
|
||||
X25519_ZERO_ALL,
|
||||
X25519_INVALID_INPUT,
|
||||
X25519_INVALID_OUTPUT,
|
||||
};
|
||||
|
||||
uint32_t x25519_get_pubkey_from_prikey(uint8_t prikey[32], uint8_t pubkey[32]);
|
||||
|
||||
uint32_t x25519_getkey(uint8_t prikey[32], uint8_t pubkey[32]);
|
||||
|
||||
uint32_t x25519_compute_key(uint8_t local_prikey[32], uint8_t peer_pubkey[32],
|
||||
uint8_t *key, uint32_t keyByteLen, KDF_FUNC kdf);
|
||||
|
||||
void x25519_decode_scalar(uint8_t *k, uint8_t *out, uint32_t bytes);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user