SemiDrive SSDK Appication Program Interface PTG3.0
pke.h File Reference
#include "eccp_curve.h"
#include "register_base_addr.h"
#include "sdrv_crypto_utility.h"

Go to the source code of this file.

Detailed Description

Macro Definition Documentation

◆ C25519_BYTE_LEN

#define C25519_BYTE_LEN   (256 / 8)

◆ C25519_WORD_LEN

#define C25519_WORD_LEN   (256 / 32)

◆ ECCP_MAX_BIT_LEN

#define ECCP_MAX_BIT_LEN   (521)

◆ ECCP_MAX_BYTE_LEN

#define ECCP_MAX_BYTE_LEN   (GET_BYTE_LEN(ECCP_MAX_BIT_LEN))

◆ ECCP_MAX_WORD_LEN

#define ECCP_MAX_WORD_LEN   (GET_WORD_LEN(ECCP_MAX_BIT_LEN))

◆ ECCP_POINT_DOUBLE

#define ECCP_POINT_DOUBLE

◆ Ed25519_BYTE_LEN

#define Ed25519_BYTE_LEN   C25519_BYTE_LEN

◆ Ed25519_WORD_LEN

#define Ed25519_WORD_LEN   C25519_WORD_LEN

◆ MAX_RSA_BIT_LEN

#define MAX_RSA_BIT_LEN   (MAX_RSA_WORD_LEN << 5)

◆ MAX_RSA_WORD_LEN

#define MAX_RSA_WORD_LEN   OPERAND_MAX_WORD_LEN

◆ MICROCODE_C25519_PMUL

#define MICROCODE_C25519_PMUL   (0x38)

◆ MICROCODE_Ed25519_PADD

#define MICROCODE_Ed25519_PADD   (0x34)

◆ MICROCODE_Ed25519_PMUL

#define MICROCODE_Ed25519_PMUL   (0x30)

◆ MICROCODE_INTADD

#define MICROCODE_INTADD   (0x40)

◆ MICROCODE_INTMUL

#define MICROCODE_INTMUL   (0x2C)

◆ MICROCODE_INTSUB

#define MICROCODE_INTSUB   (0x44)

◆ MICROCODE_MGMR_PRE_H

#define MICROCODE_MGMR_PRE_H   (0x28)

◆ MICROCODE_MGMR_PRE_H_MM

#define MICROCODE_MGMR_PRE_H_MM   (0x4C)

◆ MICROCODE_MGMR_PRE_N0

#define MICROCODE_MGMR_PRE_N0   (0x50)

◆ MICROCODE_MODADD

#define MICROCODE_MODADD   (0x20)

◆ MICROCODE_MODEXP

#define MICROCODE_MODEXP   (0x14)

◆ MICROCODE_MODEXP_MGMR_LADDER

#define MICROCODE_MODEXP_MGMR_LADDER   (0x5C)

◆ MICROCODE_MODEXP_WITH_PUBKEY

#define MICROCODE_MODEXP_WITH_PUBKEY   (0x58)

◆ MICROCODE_MODINV

#define MICROCODE_MODINV   (0x1C)

◆ MICROCODE_MODMUL

#define MICROCODE_MODMUL   (0x18)

◆ MICROCODE_MODRES

#define MICROCODE_MODRES   (0x3C)

◆ MICROCODE_MODSUB

#define MICROCODE_MODSUB   (0x24)

◆ MICROCODE_PADD

#define MICROCODE_PADD   (0x08)

◆ MICROCODE_PDBL

#define MICROCODE_PDBL   (0x04)

◆ MICROCODE_PMUL

#define MICROCODE_PMUL   (0x10)

◆ MICROCODE_PMUL_SEC

#define MICROCODE_PMUL_SEC   (0x54)

◆ MICROCODE_PMULF

#define MICROCODE_PMULF   (0x48)

◆ MICROCODE_PVER

#define MICROCODE_PVER   (0x0C)

◆ MIN_RSA_BIT_LEN

#define MIN_RSA_BIT_LEN   (512)

◆ OPERAND_MAX_BIT_LEN

#define OPERAND_MAX_BIT_LEN   (4096)

◆ OPERAND_MAX_WORD_LEN

#define OPERAND_MAX_WORD_LEN   (GET_WORD_LEN(OPERAND_MAX_BIT_LEN))

◆ PKE_A

#define PKE_A (   a,
  step 
)     ((volatile uint32_t *)(PKE_BASE_ADDR + 0x0400 + (a) * (step)))

◆ PKE_B

#define PKE_B (   a,
  step 
)     ((volatile uint32_t *)(PKE_BASE_ADDR + 0x1000 + (a) * (step)))

◆ PKE_CFG

#define PKE_CFG   (*((volatile uint32_t *)(PKE_BASE_ADDR + 0x04)))

◆ PKE_CTRL

#define PKE_CTRL   (*((volatile uint32_t *)(PKE_BASE_ADDR)))

◆ PKE_IMCR

#define PKE_IMCR   (*((volatile uint32_t *)(PKE_BASE_ADDR + 0x10)))

◆ PKE_INT_ENABLE_OFFSET

#define PKE_INT_ENABLE_OFFSET   (8)

◆ PKE_MC_PTR

#define PKE_MC_PTR   (*((volatile uint32_t *)(PKE_BASE_ADDR + 0x08)))

◆ PKE_MISR

#define PKE_MISR   (*((volatile uint32_t *)(PKE_BASE_ADDR + 0x14)))

◆ PKE_RAND_SEED

#define PKE_RAND_SEED   (*((volatile uint32_t *)(PKE_BASE_ADDR + 0x40)))

◆ PKE_RC_A_NONCE

#define PKE_RC_A_NONCE   (*((volatile uint32_t *)(PKE_BASE_ADDR + 0x6C)))

◆ PKE_RC_D_NONCE

#define PKE_RC_D_NONCE   (*((volatile uint32_t *)(PKE_BASE_ADDR + 0x68)))

◆ PKE_RC_EN

#define PKE_RC_EN   (*((volatile uint32_t *)(PKE_BASE_ADDR + 0x60)))

◆ PKE_RC_KEY

#define PKE_RC_KEY   (*((volatile uint32_t *)(PKE_BASE_ADDR + 0x64)))

◆ PKE_RISR

#define PKE_RISR   (*((volatile uint32_t *)(PKE_BASE_ADDR + 0x0C)))

◆ PKE_RT_CODE

#define PKE_RT_CODE   (*((volatile uint32_t *)(PKE_BASE_ADDR + 0x24)))

◆ PKE_SEC

#define PKE_SEC

◆ PKE_START_CALC

#define PKE_START_CALC   (1)

◆ PKE_VERSION

#define PKE_VERSION   (*((volatile uint32_t *)(PKE_BASE_ADDR + 0xFC)))

◆ SUPPORT_C25519

#define SUPPORT_C25519   1

◆ SUPPORT_SM2

#define SUPPORT_SM2   1

Typedef Documentation

◆ KDF_FUNC

typedef void *(* KDF_FUNC) (const void *input, uint32_t bytelen, uint8_t *key, uint32_t keybytelen)

Enumeration Type Documentation

◆ PKE_RET_CODE

Enumerator
PKE_SUCCESS 
PKE_STOP 
PKE_NO_MODINV 
PKE_NOT_ON_CURVE 
PKE_INVALID_MC 
PKE_ZERO_ALL 
PKE_INTEGER_TOO_BIG 
PKE_INVALID_INPUT 
PKE_ERROR 

Function Documentation

◆ eccp_get_pubkey_from_prikey()

uint32_t eccp_get_pubkey_from_prikey ( eccp_curve_t curve,
uint8_t *  prikey,
uint8_t *  pubkey 
)

◆ eccp_getkey()

uint32_t eccp_getkey ( eccp_curve_t curve,
uint8_t *  prikey,
uint8_t *  pubkey 
)

◆ eccp_pointAdd()

uint32_t eccp_pointAdd ( eccp_curve_t curve,
uint32_t *  P1x,
uint32_t *  P1y,
uint32_t *  P2x,
uint32_t *  P2y,
uint32_t *  Qx,
uint32_t *  Qy 
)

◆ eccp_pointDouble()

uint32_t eccp_pointDouble ( eccp_curve_t curve,
uint32_t *  Px,
uint32_t *  Py,
uint32_t *  Qx,
uint32_t *  Qy 
)

◆ eccp_pointMul()

uint32_t eccp_pointMul ( eccp_curve_t curve,
uint32_t *  k,
uint32_t *  Px,
uint32_t *  Py,
uint32_t *  Qx,
uint32_t *  Qy 
)

◆ eccp_pointMul_base()

uint32_t eccp_pointMul_base ( eccp_curve_t curve,
uint32_t *  k,
uint32_t *  Qx,
uint32_t *  Qy 
)

◆ eccp_pointMul_sec()

uint32_t eccp_pointMul_sec ( eccp_curve_t curve,
uint32_t *  k,
uint32_t *  Px,
uint32_t *  Py,
uint32_t *  Qx,
uint32_t *  Qy 
)

◆ eccp_pointMul_Shamir()

uint32_t eccp_pointMul_Shamir ( eccp_curve_t curve,
uint32_t *  k1,
uint32_t *  P1x,
uint32_t *  P1y,
uint32_t *  k2,
uint32_t *  P2x,
uint32_t *  P2y,
uint32_t *  Qx,
uint32_t *  Qy 
)

◆ eccp_pointMul_Shamir_safe()

uint32_t eccp_pointMul_Shamir_safe ( eccp_curve_t curve,
uint32_t *  k1,
uint32_t *  P1x,
uint32_t *  P1y,
uint32_t *  k2,
uint32_t *  P2x,
uint32_t *  P2y,
uint32_t *  Qx,
uint32_t *  Qy 
)

◆ eccp_pointVerify()

uint32_t eccp_pointVerify ( eccp_curve_t curve,
uint32_t *  Px,
uint32_t *  Py 
)

◆ ed25519_decode_point()

uint32_t ed25519_decode_point ( edward_curve_t curve,
uint8_t  in_y[32],
uint8_t  out_x[32],
uint8_t  out_y[32] 
)

◆ ed25519_pointAdd()

uint32_t ed25519_pointAdd ( edward_curve_t curve,
uint32_t *  P1x,
uint32_t *  P1y,
uint32_t *  P2x,
uint32_t *  P2y,
uint32_t *  Qx,
uint32_t *  Qy 
)

◆ ed25519_pointMul()

uint32_t ed25519_pointMul ( edward_curve_t curve,
uint32_t *  k,
uint32_t *  Px,
uint32_t *  Py,
uint32_t *  Qx,
uint32_t *  Qy 
)

◆ pke_add()

uint32_t pke_add ( const uint32_t *  a,
const uint32_t *  b,
uint32_t *  out,
uint32_t  wordlen 
)

◆ pke_check_rt_code()

uint32_t pke_check_rt_code ( void  )

◆ pke_clear_interrupt()

void pke_clear_interrupt ( void  )

◆ pke_get_operand_bytes()

uint32_t pke_get_operand_bytes ( void  )

◆ pke_get_version()

uint32_t pke_get_version ( void  )

◆ pke_load_operand()

void pke_load_operand ( uint32_t *  baseaddr,
uint32_t *  data,
uint32_t  wordlen 
)

◆ pke_load_pre_calc_mont()

void pke_load_pre_calc_mont ( uint32_t *  H,
uint32_t  wordlen 
)

◆ pke_mod()

uint32_t pke_mod ( uint32_t *  a,
uint32_t  awordlen,
uint32_t *  b,
uint32_t *  b_h,
uint32_t  bwordlen,
uint32_t *  c 
)

◆ pke_modadd()

uint32_t pke_modadd ( const uint32_t *  modulus,
const uint32_t *  a,
const uint32_t *  b,
uint32_t *  out,
uint32_t  wordlen 
)

◆ pke_modexp()

uint32_t pke_modexp ( const uint32_t *  modulus,
const uint32_t *  exponent,
const uint32_t *  base,
uint32_t *  out,
uint32_t  mod_wordlen,
uint32_t  exp_wordlen 
)

◆ pke_modexp_ladder()

uint32_t pke_modexp_ladder ( const uint32_t *  modulus,
const uint32_t *  exponent,
const uint32_t *  base,
uint32_t *  out,
uint32_t  mod_wordlen,
uint32_t  exp_wordlen 
)

◆ pke_modexp_with_pub()

uint32_t pke_modexp_with_pub ( const uint32_t *  modulus,
const uint32_t *  exponent,
const uint32_t *  pub,
const uint32_t *  base,
uint32_t *  out,
uint32_t  mod_wordlen,
uint32_t  exp_wordlen,
uint32_t  pub_wordlen 
)

◆ pke_modinv()

uint32_t pke_modinv ( const uint32_t *  modulus,
const uint32_t *  a,
uint32_t *  ainv,
uint32_t  modwordlen,
uint32_t  awordlen 
)

◆ pke_modmul()

uint32_t pke_modmul ( const uint32_t *  modulus,
const uint32_t *  a,
const uint32_t *  b,
uint32_t *  out,
uint32_t  wordlen 
)

◆ pke_modmul_internal()

uint32_t pke_modmul_internal ( const uint32_t *  modulus,
const uint32_t *  a,
const uint32_t *  b,
uint32_t *  out,
uint32_t  wordlen 
)

◆ pke_modsub()

uint32_t pke_modsub ( const uint32_t *  modulus,
const uint32_t *  a,
const uint32_t *  b,
uint32_t *  out,
uint32_t  wordlen 
)

◆ pke_mul()

uint32_t pke_mul ( const uint32_t *  a,
const uint32_t *  b,
uint32_t *  out,
uint32_t  ab_wordLen 
)

◆ pke_mul_internal()

uint32_t pke_mul_internal ( const uint32_t *  a,
const uint32_t *  b,
uint32_t *  out,
uint32_t  a_wordlen,
uint32_t  b_wordlen,
uint32_t  out_wordlen 
)

◆ pke_pre_calc_mont()

uint32_t pke_pre_calc_mont ( const uint32_t *  modulus,
uint32_t  bitlen,
uint32_t *  H 
)

◆ pke_pre_calc_mont_no_output()

uint32_t pke_pre_calc_mont_no_output ( const uint32_t *  modulus,
uint32_t  wordlen 
)

◆ pke_sec_init()

uint32_t pke_sec_init ( void  )

◆ pke_sec_uninit()

uint32_t pke_sec_uninit ( void  )

◆ pke_set_microcode()

void pke_set_microcode ( uint32_t  addr)

◆ pke_set_operand_width()

void pke_set_operand_width ( uint32_t  bitlen)

◆ pke_start()

void pke_start ( void  )

◆ pke_sub()

uint32_t pke_sub ( const uint32_t *  a,
const uint32_t *  b,
uint32_t *  out,
uint32_t  wordlen 
)

◆ pke_wait_till_done()

void pke_wait_till_done ( void  )

◆ x25519_pointMul()

uint32_t x25519_pointMul ( mont_curve_t curve,
uint32_t *  k,
uint32_t *  Pu,
uint32_t *  Qu 
)

Variable Documentation

◆ ed25519

const edward_curve_t ed25519[1]
extern