|
WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
|
#include "crypto_pke_struct.h"

函数 | |
| td_s32 | ed_ecfp_mul_naf (const drv_pke_ecc_curve *ecc, const drv_pke_data *k, const drv_pke_ecc_point *p, const drv_pke_ecc_point *r CIPHER_CHECK_WORD) |
| R = k * G, point multiplication. | |
| td_s32 | ed_ecfp_mul_naf_cal (td_u32 work_len, const drv_pke_data *k) |
| R = k * G, point multiplication. ed inner function, while the G is the default point G(gx, gy). And before call this function, the curve init parameters should have been set into PKE DRAM. | |
| td_s32 | point_mul_compress (const drv_pke_data *k, const drv_pke_ecc_point *u, const drv_pke_data *p, const drv_pke_ecc_point *r) |
| R = k * u, point multiplication with point compress. | |
| td_s32 | ed_secret_to_public (const drv_pke_ecc_curve *ecc, const drv_pke_data *priv_key, const drv_pke_ecc_point *pub_key) |
| Qu = d * G, get public key from private key. | |
| td_s32 | sha512_modq (const drv_pke_data *q, const drv_pke_data *in1, const drv_pke_data *in2, const drv_pke_data *in3, const drv_pke_data *out) |
| calculate the sha512 result of three segment buffer and modulo the result by q. | |
| td_s32 | ed_ecfn_sign_s (const drv_pke_data *sk, const drv_pke_data *r, const drv_pke_data *h, const drv_pke_data *n, const drv_pke_data *s) |
| multi-multiplication to calculate the signature s. s = (r + h * sk) mod n. | |
| td_s32 | ed_mul_sub (const drv_pke_ecc_curve *ecc, const drv_pke_data *s, const drv_pke_data *h, const drv_pke_ecc_point *a, const drv_pke_ecc_point *r) |
| calculate sB - hA for ed verify. the result is in ed_addr_cx, ed_addr_cy and ed_addr_cz, which is in Jacobin coordinate. | |
| td_s32 | secret_expand (const td_u8 *secret, td_u8 *a, td_u8 *prefix, const td_u32 len) |
| private key expand function. from 32 byte private key get 64 byte output. (a, prefix) = sha512(secret). | |
| td_s32 | point_decompress (const drv_pke_data *enc_pkey, const drv_pke_data *p, const drv_pke_ecc_point *pkey) |
| point decompress, from little endian data get real point by curve equation. | |
| td_s32 ed_ecfn_sign_s | ( | const drv_pke_data * | sk, |
| const drv_pke_data * | r, | ||
| const drv_pke_data * | h, | ||
| const drv_pke_data * | n, | ||
| const drv_pke_data * | s | ||
| ) |
multi-multiplication to calculate the signature s. s = (r + h * sk) mod n.
| sk | the first 32 bytes of the decoded private key. |
| r | the result of sha512 modulo L, r = sha512(prefix || msg) mod n. |
| h | the result of sha512 modulo L, h = sha512(R || A || msg) mod n. R and A is the encoded rG and pubkey. |
| n | the group order of G. |
| s | the signature result. |
| td_s32 ed_ecfp_mul_naf | ( | const drv_pke_ecc_curve * | ecc, |
| const drv_pke_data * | k, | ||
| const drv_pke_ecc_point * | p, | ||
| const drv_pke_ecc_point *r | CIPHER_CHECK_WORD | ||
| ) |
R = k * G, point multiplication.
Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2022-2022. All rights reserved. Description: ed25519 related functions head file.
Create: 2022-10-31
| ecc | input ecc curve param. |
| k | the scalar. |
| p | the input point. |
| r | the output point. |
| CIPHER_CHECK_WORD | ifdef SEC_ENHANCE, the value is XOR result of parameters, otherwise it doesn't exist. |
| td_s32 ed_ecfp_mul_naf_cal | ( | td_u32 | work_len, |
| const drv_pke_data * | k | ||
| ) |
R = k * G, point multiplication. ed inner function, while the G is the default point G(gx, gy). And before call this function, the curve init parameters should have been set into PKE DRAM.
| work_len | work_len = align_len / ALIGNED_TO_WORK_LEN_IN_BYTE. |
| k | the scalar. |
| td_s32 ed_mul_sub | ( | const drv_pke_ecc_curve * | ecc, |
| const drv_pke_data * | s, | ||
| const drv_pke_data * | h, | ||
| const drv_pke_ecc_point * | a, | ||
| const drv_pke_ecc_point * | r | ||
| ) |
calculate sB - hA for ed verify. the result is in ed_addr_cx, ed_addr_cy and ed_addr_cz, which is in Jacobin coordinate.
| ecc | the input ed curve parameters. |
| s | the decoded signature value. |
| h | the result of sha512 modulo L, h = sha512(R || A || msg) mod n. R and A is the encoded rG and pubkey. |
| a | the decoded public key. |
| r | the output result. |
| td_s32 ed_secret_to_public | ( | const drv_pke_ecc_curve * | ecc, |
| const drv_pke_data * | priv_key, | ||
| const drv_pke_ecc_point * | pub_key | ||
| ) |
Qu = d * G, get public key from private key.
| ecc | the curve parameter. |
| priv_key | the input private key. |
| pub_key | the output public key. |
| td_s32 point_decompress | ( | const drv_pke_data * | enc_pkey, |
| const drv_pke_data * | p, | ||
| const drv_pke_ecc_point * | pkey | ||
| ) |
point decompress, from little endian data get real point by curve equation.
| enc_pkey | the encoded point value. |
| p | the module. |
| pkey | the the decoded point. |
| td_s32 point_mul_compress | ( | const drv_pke_data * | k, |
| const drv_pke_ecc_point * | u, | ||
| const drv_pke_data * | p, | ||
| const drv_pke_ecc_point * | r | ||
| ) |
R = k * u, point multiplication with point compress.
| k | the scalar. |
| u | the input point. |
| p | the modulur. |
| r | the output point. |
private key expand function. from 32 byte private key get 64 byte output. (a, prefix) = sha512(secret).
| secret | the input private key. |
| a | the first 32 byte of the sha512(secret). |
| prefix | the last 32 byte of the sha512(secret). |
| len | the byte length of the input private key. |
| td_s32 sha512_modq | ( | const drv_pke_data * | q, |
| const drv_pke_data * | in1, | ||
| const drv_pke_data * | in2, | ||
| const drv_pke_data * | in3, | ||
| const drv_pke_data * | out | ||
| ) |
calculate the sha512 result of three segment buffer and modulo the result by q.
| q | the modulus. |
| in1 | the first segment. |
| in2 | the second segment. |
| in3 | the third segment. |
| out | the result. |