Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/sec/se.h
3694 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2019-2026 CTCaer
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef _SE_H_
19
#define _SE_H_
20
21
#include "se_t210.h"
22
#include <utils/types.h>
23
24
void se_rsa_acc_ctrl(u32 rs, u32 flags);
25
void se_key_acc_ctrl(u32 ks, u32 flags);
26
u32 se_key_acc_ctrl_get(u32 ks);
27
28
/*! AES Key Management Functions */
29
void se_aes_key_set(u32 ks, const void *key, u32 size);
30
void se_aes_iv_set(u32 ks, const void *iv, u32 size);
31
void se_aes_key_get(u32 ks, void *key, u32 size);
32
void se_aes_key_clear(u32 ks);
33
void se_aes_iv_clear(u32 ks);
34
int se_aes_unwrap_key(u32 ks_dst, u32 ks_src, const void *seed);
35
void se_aes_ctx_get_keys(u8 *buf, u8 *keys, u32 keysize);
36
/*! Encryption Functions */
37
int se_aes_crypt_ecb(u32 ks, int enc, void *dst, const void *src, u32 size);
38
int se_aes_crypt_cbc(u32 ks, int enc, void *dst, const void *src, u32 size);
39
int se_aes_crypt_ofb(u32 ks, void *dst, const void *src, u32 size);
40
int se_aes_crypt_ctr(u32 ks, void *dst, const void *src, u32 size, void *ctr);
41
int se_aes_crypt_xts_sec(u32 tweak_ks, u32 crypt_ks, int enc, u64 sec, void *dst, void *src, u32 secsize);
42
int se_aes_crypt_xts_sec_nx(u32 tweak_ks, u32 crypt_ks, int enc, u64 sec, u8 *tweak, bool regen_tweak, u32 tweak_exp, void *dst, void *src, u32 sec_size);
43
int se_aes_crypt_xts(u32 tweak_ks, u32 crypt_ks, int enc, u64 sec, void *dst, void *src, u32 secsize, u32 num_secs);
44
/*! Hashing Functions */
45
int se_sha_hash_256_async(void *hash, const void *src, u32 size);
46
int se_sha_hash_256_oneshot(void *hash, const void *src, u32 size);
47
int se_sha_hash_256_partial_start(void *hash, const void *src, u32 size, bool is_oneshot);
48
int se_sha_hash_256_partial_update(void *hash, const void *src, u32 size, bool is_oneshot);
49
int se_sha_hash_256_partial_end(void *hash, u64 total_size, const void *src, u32 src_size, bool is_oneshot);
50
int se_sha_hash_256_finalize(void *hash);
51
int se_aes_hash_cmac(u32 ks, void *hash, const void *src, u32 size);
52
/*! Random Functions */
53
int se_rng_pseudo(void *dst, u32 size);
54
55
#endif
56
57