lin
2025-02-18 59b6413ea46963124667e54dd4348d204bcf94d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * Declare the function interface of SUNXI SS process.
 *
 * Copyright (C) 2014 Allwinner.
 *
 * Mintow <duanmintao@allwinnertech.com>
 *
 * This file is licensed under the terms of the GNU General Public
 * License version 2.  This program is licensed "as is" without any
 * warranty of any kind, whether express or implied.
 */
 
#ifndef _SUNXI_SECURITY_SYSTEM_PROC_H_
#define _SUNXI_SECURITY_SYSTEM_PROC_H_
 
#include <crypto/aes.h>
#include <crypto/sha.h>
#include <crypto/algapi.h>
#include <linux/scatterlist.h>
 
/* Inner functions declaration, defined in vx/sunxi_ss_proc.c */
 
int ss_aes_key_valid(struct crypto_ablkcipher *tfm, int len);
int ss_aes_one_req(sunxi_ss_t *sss, struct ablkcipher_request *req);
 
#ifdef SS_GCM_MODE_ENABLE
int ss_aead_crypt(struct aead_request *req, int dir, int method, int mode);
int ss_aead_one_req(sunxi_ss_t *sss, struct aead_request *req);
#endif
 
#ifdef SS_DRBG_MODE_ENABLE
int ss_drbg_get_random(struct crypto_rng *tfm, const u8 *src, u32 slen,
               u8 *rdata, u32 dlen, u32 mode);
int ss_drbg_sha1_get_random(struct crypto_rng *tfm, const u8 *src,
               unsigned int slen, u8 *dst, unsigned int dlen);
int ss_drbg_sha256_get_random(struct crypto_rng *tfm, const u8 *src,
               unsigned int slen, u8 *dst, unsigned int dlen);
int ss_drbg_sha512_get_random(struct crypto_rng *tfm, const u8 *src,
               unsigned int slen, u8 *dst, unsigned int dlen);
#endif
 
int ss_rng_get_random(struct crypto_rng *tfm, u8 *rdata, u32 dlen, u32 trng);
 
u32 ss_hash_start(ss_hash_ctx_t *ctx,
       ss_aes_req_ctx_t *req_ctx, u32 len, u32 last);
 
irqreturn_t sunxi_ss_irq_handler(int irq, void *dev_id);
 
/* defined in sunxi_ss_proc_comm.c */
 
void ss_print_hex(char *_data, int _len, void *_addr);
#ifdef SS_SCATTER_ENABLE
void ss_print_task_info(ce_task_desc_t *task);
#endif
int ss_sg_cnt(struct scatterlist *sg, int total);
 
int ss_prng_get_random(struct crypto_rng *tfm, const u8 *src, unsigned int slen,
       u8 *dst, unsigned int dlen);
#ifdef SS_TRNG_ENABLE
int ss_trng_get_random(struct crypto_rng *tfm, const u8 *src, unsigned int slen,
       u8 *dst, unsigned int dlen);
#endif
#ifdef SS_TRNG_POSTPROCESS_ENABLE
void ss_trng_postprocess(u8 *out, u32 outlen, u8 *in, u32 inlen);
#endif
 
int ss_aes_crypt(struct ablkcipher_request *req, int dir, int method, int mode);
 
void ss_hash_swap(char *data, int len);
int ss_hash_blk_size(int type);
void ss_hash_padding_sg_prepare(struct scatterlist *last, int total);
int ss_hash_update(struct ahash_request *req);
int ss_hash_final(struct ahash_request *req);
int ss_hash_finup(struct ahash_request *req);
int ss_hash_digest(struct ahash_request *req);
 
#endif /* end of _SUNXI_SECURITY_SYSTEM_PROC_H_ */