SemiDrive SSDK Appication Program Interface PTG3.0
sdrv_crypto_utility.h
Go to the documentation of this file.
1
9#ifndef SDRV_UTILITY_H
10#define SDRV_UTILITY_H
11
12#include <debug.h>
13#include <stdint.h>
14#include <sdrv_common.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20#ifndef NULL
21#define NULL ((void *)0)
22#endif
23
24#define GET_MAX_LEN(a, b) (((a) > (b)) ? (a) : (b))
25#define GET_MIN_LEN(a, b) (((a) > (b)) ? (b) : (a))
26#define GET_WORD_LEN(bitLen) (((bitLen) + 31) / 32)
27#define GET_BYTE_LEN(bitLen) (((bitLen) + 7) / 8)
28
29#define CONFIG_OSR_CRYPTO_TEST_CACC 0
30
31#define PKE_PRINT_BUF
32#ifdef PKE_PRINT_BUF
33extern void print_buf_U8(uint8_t buf[], uint32_t byteLen, char name[]);
34extern void print_buf_U32(uint32_t buf[], uint32_t wordLen, char name[]);
35extern void print_BN_buf_U32(uint32_t buf[], uint32_t wordLen, char name[]);
36#endif
37
50
51typedef struct crypto_block {
52 uint8_t *addr; /* Start address of the data (FIFO or contiguous memory) */
53 uint32_t len; /* Length of data expressed in bytes */
55
56void memcpy_(void *dst, void *src, uint32_t size);
57
58void memset_(void *dst, uint8_t value, uint32_t size);
59
60int8_t memcmp_(void *m1, void *m2, uint32_t size);
61
62void uint32_set(uint32_t *a, uint32_t value, uint32_t wordLen);
63
64void uint32_copy(uint32_t *dst, uint32_t *src, uint32_t wordLen);
65
66void uint32_clear(uint32_t *a, uint32_t wordLen);
67
68void uint32_sleep(uint32_t count, uint8_t rand);
69
70void uint32_endian_reverse(uint8_t *in, uint8_t *out, uint32_t wordLen);
71
72void reverse_byte_array(uint8_t *in, uint8_t *out, uint32_t byteLen);
73
74void reverse_word(uint8_t *in, uint8_t *out, uint32_t bytelen);
75
76void reverse_word_array(uint8_t *in, uint32_t *out, uint32_t wordLen);
77
78void uint8_xor(uint8_t *a, uint8_t *b, uint8_t *c, uint32_t byteLen);
79
80uint32_t get_valid_bits(const uint32_t *a, uint32_t wordLen);
81
82uint32_t get_valid_words(uint32_t *a, uint32_t max_words);
83
84uint8_t uint8_bignum_check_zero(uint8_t a[], uint32_t aByteLen);
85
86uint8_t uint32_bignum_check_zero(uint32_t a[], uint32_t aWordLen);
87
88int32_t uint32_bignumcmp(uint32_t *a, uint32_t aWordLen, uint32_t *b,
89 uint32_t bWordLen);
90
91uint32_t uint32_sec_cmp(uint32_t *a, uint32_t *b, uint32_t wordLen,
92 uint8_t rand);
93
94uint32_t get_multiple2_number(uint32_t a[]);
95
96uint32_t big_div2n(uint32_t a[], int32_t aWordLen, uint32_t n);
97
98uint8_t bigint_check_1(uint32_t a[], uint32_t aWordLen);
99
100uint8_t bigint_check_p_1(uint32_t a[], uint32_t p[], uint32_t wordLen);
101
102uint32_t ce_get_current_time(void);
103#ifdef __cplusplus
104}
105#endif
106
107#endif
SemiDrive driver common header file.
@ SDRV_STATUS_GROUP_CRYPTO
Definition: sdrv_common.h:32
@ SDRV_STATUS_OK
Definition: sdrv_common.h:72
#define SDRV_ERROR_STATUS(group, code)
Construct a status code value from a group and code number. All the error statuses are negetive numbe...
Definition: sdrv_common.h:17
void print_buf_U8(uint8_t buf[], uint32_t byteLen, char name[])
uint8_t bigint_check_1(uint32_t a[], uint32_t aWordLen)
struct crypto_block crypto_block_t
void reverse_word_array(uint8_t *in, uint32_t *out, uint32_t wordLen)
uint32_t get_valid_words(uint32_t *a, uint32_t max_words)
void uint8_xor(uint8_t *a, uint8_t *b, uint8_t *c, uint32_t byteLen)
int8_t memcmp_(void *m1, void *m2, uint32_t size)
uint8_t bigint_check_p_1(uint32_t a[], uint32_t p[], uint32_t wordLen)
void reverse_byte_array(uint8_t *in, uint8_t *out, uint32_t byteLen)
sdrv_crypto_error_status
CRYPTO error status return codes.
Definition: sdrv_crypto_utility.h:41
@ CMD_SEIP_SUCCESS
Definition: sdrv_crypto_utility.h:47
@ E_NOT_OK
Definition: sdrv_crypto_utility.h:45
@ E_PARAM_ERROR
Definition: sdrv_crypto_utility.h:46
@ CMD_SEIP_ERROR
Definition: sdrv_crypto_utility.h:48
@ CMD_RETURN_FAIL
Definition: sdrv_crypto_utility.h:43
@ CMD_RETURN_SUCCESS
Definition: sdrv_crypto_utility.h:42
@ E_OK
Definition: sdrv_crypto_utility.h:44
void uint32_endian_reverse(uint8_t *in, uint8_t *out, uint32_t wordLen)
void uint32_sleep(uint32_t count, uint8_t rand)
uint8_t uint32_bignum_check_zero(uint32_t a[], uint32_t aWordLen)
void reverse_word(uint8_t *in, uint8_t *out, uint32_t bytelen)
uint8_t uint8_bignum_check_zero(uint8_t a[], uint32_t aByteLen)
uint32_t big_div2n(uint32_t a[], int32_t aWordLen, uint32_t n)
uint32_t get_multiple2_number(uint32_t a[])
void print_BN_buf_U32(uint32_t buf[], uint32_t wordLen, char name[])
int32_t uint32_bignumcmp(uint32_t *a, uint32_t aWordLen, uint32_t *b, uint32_t bWordLen)
void uint32_copy(uint32_t *dst, uint32_t *src, uint32_t wordLen)
void print_buf_U32(uint32_t buf[], uint32_t wordLen, char name[])
enum sdrv_crypto_error_status sdrv_crypto_error_status_e
CRYPTO error status return codes.
uint32_t uint32_sec_cmp(uint32_t *a, uint32_t *b, uint32_t wordLen, uint8_t rand)
void uint32_clear(uint32_t *a, uint32_t wordLen)
uint32_t get_valid_bits(const uint32_t *a, uint32_t wordLen)
uint32_t ce_get_current_time(void)
void memset_(void *dst, uint8_t value, uint32_t size)
void uint32_set(uint32_t *a, uint32_t value, uint32_t wordLen)
void memcpy_(void *dst, void *src, uint32_t size)
Definition: sdrv_crypto_utility.h:51
uint8_t * addr
Definition: sdrv_crypto_utility.h:52
uint32_t len
Definition: sdrv_crypto_utility.h:53