My Project
Loading...
Searching...
No Matches
renesas-tsip-crypt.h
1/* renesas-tsip-crypt.h
2 *
3 * Copyright (C) 2006-2020 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL.
6 *
7 * wolfSSL is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * wolfSSL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 */
21#ifndef __RENESAS_TSIP_CRYPT_H__
22#define __RENESAS_TSIP_CRYPT_H__
23
24#if defined(WOLFSSL_RENESAS_TSIP_IAREWRX)
25 #include "r_bsp/mcu/all/r_rx_compiler.h"
26 #include "r_bsp/platform.h"
27#else
28 #include "platform.h"
29#endif
30
31#include "r_tsip_rx_if.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38typedef enum {
39 tsip_Key_SESSION = 1,
40 tsip_Key_AES128 = 2,
41 tsip_Key_AES256 = 3,
42 tsip_Key_RSA1024 = 4,
43 tsip_Key_RSA2048 = 5,
44 tsip_Key_tls_Rsa2048 = 6,
45 tsip_Key_unknown = -1,
46} wolfssl_TSIP_KEY_IV;
47
48enum {
49 l_TLS_RSA_WITH_AES_128_CBC_SHA = 0x2F,
50 l_TLS_RSA_WITH_AES_128_CBC_SHA256 = 0x3c,
51 l_TLS_RSA_WITH_AES_256_CBC_SHA = 0x35,
52 l_TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x3d,
53};
54
55typedef struct
56{
57 uint8_t *encrypted_session_key;
58 uint8_t *iv;
59 uint8_t *encrypted_user_tls_key;
60 tsip_tls_ca_certification_public_key_index_t user_rsa2048_tls_pubindex;
62
63struct WOLFSSL;
64
65int tsip_Open( );
66void tsip_Close( );
67int tsip_hw_lock();
68void tsip_hw_unlock( void );
69int tsip_usable(const struct WOLFSSL *ssl);
70void tsip_inform_sflash_signedcacert(const byte *ps_flash,
71 const byte *psigned_ca_cert, word32 len);
72void tsip_inform_cert_sign(const byte *sign);
73/* set / get key */
74void tsip_inform_user_keys(byte *encrypted_session_key, byte *iv,
75 byte *encrypted_user_tls_key);
76
77byte tsip_rootCAverified( );
78byte tsip_checkCA(word32 cmIdx);
79int tsip_tls_RootCertVerify(const byte *cert , word32 cert_len,
80 word32 key_n_start, word32 key_n_len,
81 word32 key_e_start, word32 key_e_len,
82 word32 cm_row);
83int tsip_tls_CertVerify(const byte *cert, word32 certSz,
84 const byte *signature, word32 sigSz,
85 word32 key_n_start, word32 key_n_len,
86 word32 key_e_start, word32 key_e_len,
87 byte *tsip_encRsaKeyIdx);
88void tsip_inform_key_position(const word32 key_n_start, const word32 key_n_len,
89 const word32 key_e_start, const word32 key_e_len);
90int tsip_generatePremasterSecret(byte *premaster, word32 preSz);
91int tsip_generateEncryptPreMasterSecret(struct WOLFSSL *ssl, byte *out,
92 word32 *outSz);
93int tsip_generateMasterSecret(const byte *pre, const byte *cr,const byte *sr,
94 byte *ms);
95int tsip_generateSeesionKey(struct WOLFSSL *ssl);
96int tsip_Sha256Hmac(const struct WOLFSSL *ssl, const byte *myInner,
97 word32 innerSz, const byte *in, word32 sz, byte *digest,
98 word32 verify);
99int tsip_Sha1Hmac(const struct WOLFSSL *ssl, const byte *myInner,
100 word32 innerSz, const byte *in, word32 sz, byte *digest,
101 word32 verify);
102
103#if (!defined(NO_SHA) || !defined(NO_SHA256)) && \
104 !defined(NO_WOLFSSL_RENESAS_TSIP_CRYPT_HASH)
105
106typedef enum {
107 TSIP_SHA1 = 0,
108 TSIP_SHA256 = 1,
109} TSIP_SHA_TYPE;
110
111typedef struct {
112 byte* msg;
113 void* heap;
114 word32 used;
115 word32 len;
116 word32 sha_type;
118
119/* RAW hash function APIs are not implemented with TSIP */
120#define WOLFSSL_NO_HASH_RAW
121
123
124#if !defined(NO_SHA256)
126#endif
127
128#endif /* NO_SHA */
129
130#if defined(WOLFSSL_RENESAS_TSIP_TLS_AES_CRYPT)
131typedef struct {
132 tsip_aes_key_index_t tsip_keyIdx;
133 word32 keySize;
135
136 struct Aes;
137 int wc_tsip_AesCbcEncrypt(struct Aes* aes, byte* out, const byte* in,
138 word32 sz);
139 int wc_tsip_AesCbcDecrypt(struct Aes* aes, byte* out, const byte* in,
140 word32 sz);
141
142#endif /* WOLFSSL_RENESAS_TSIP_TLS_AES */
143
144#if defined(WOLFSSL_RENESAS_TSIP_CRYPT_DEBUG)
145byte *ret2err(word32 ret);
146
147#endif
148
149#ifdef __cplusplus
150}
151#endif
152
153#endif /* __RENESAS_TSIP_CRYPT_H__ */
Definition aes.h:149
Definition renesas-tsip-crypt.h:131
Definition internal.h:3849
Definition renesas-tsip-crypt.h:56
Definition sha256.h:132
Definition wolfcaam_sha.h:68
Definition renesas-tsip-crypt.h:111