addressed review comments

This commit is contained in:
Hideki Miyazaki
2019-09-17 10:42:33 +09:00
parent a6b2d1621b
commit 63d61c490d
8 changed files with 45 additions and 22 deletions

View File

@@ -71,11 +71,12 @@
/* TSIP TLS specific definitions */
#if !defined(WOLFSSL_RENESAS_TSIP)
#define OPENSSL_EXTRA
#define WOLFSSL_GENSEED_FORTEST /* Wardning: define your own seed gen */
#define WOLFSSL_GENSEED_FORTEST /* Warning: define your own seed gen */
#else
#if defined(WOLFSSL_RENESAS_RX65N)
/* In the case of Static RSA and AES-CBC use */
/* In the case of Static RSA and AES-CBC use */
#define HAVE_AES_CBC
/* TSIP ver 1.0.6 or lower supports only static RSA as Public-key cryptography. */
#define WOLFSSL_STATIC_RSA
/* for disabling TSIP CRYPT and TSIP TLS */
/* #define NO_RENESAS_TSIP_CRYPT */

View File

@@ -28,8 +28,8 @@
#include "wolfssl/certs_test.h"
#include "key_data.h"
#define SIMPLE_TLSSEVER_IP "192.168.1.45"
#define SIMPLE_TLSSERVER_PORT "11111"
#define SIMPLE_TLSSEVER_IP "192.168.1.45"
#define SIMPLE_TLSSERVER_PORT "11111"
ER t4_tcp_callback(ID cepid, FN fncd , VP p_parblk);
uint32_t g_encrypted_root_public_key[140];
@@ -41,8 +41,10 @@ static int my_IORecv(WOLFSSL* ssl, char* buff, int sz, void* ctx)
int ret;
ID cepid;
if(ctx != NULL)cepid = *(ID *)ctx;
else return WOLFSSL_CBIO_ERR_GENERAL;
if(ctx != NULL)
cepid = *(ID *)ctx;
else
return WOLFSSL_CBIO_ERR_GENERAL;
ret = tcp_rcv_dat(cepid, buff, sz, TMO_FEVR);
if(ret > 0)return ret;
@@ -54,8 +56,10 @@ static int my_IOSend(WOLFSSL* ssl, char* buff, int sz, void* ctx)
int ret;
ID cepid;
if(ctx != NULL)cepid = *(ID *)ctx;
else return WOLFSSL_CBIO_ERR_GENERAL;
if(ctx != NULL)
cepid = *(ID *)ctx;
else
return WOLFSSL_CBIO_ERR_GENERAL;
ret = tcp_snd_dat(cepid, buff, sz, TMO_FEVR);
if(ret == sz)return ret;

View File

@@ -35,12 +35,16 @@ static int my_IORecv(WOLFSSL* ssl, char* buff, int sz, void* ctx)
int ret;
ID cepid;
if(ctx != NULL)cepid = *(ID *)ctx;
else return WOLFSSL_CBIO_ERR_GENERAL;
if(ctx != NULL)
cepid = *(ID *)ctx;
else
return WOLFSSL_CBIO_ERR_GENERAL;
ret = tcp_rcv_dat(cepid, buff, sz, TMO_FEVR);
if(ret == sz)return ret;
else return WOLFSSL_CBIO_ERR_GENERAL;
if(ret == sz)
return ret;
else
return WOLFSSL_CBIO_ERR_GENERAL;
}
static int my_IOSend(WOLFSSL* ssl, char* buff, int sz, void* ctx)
@@ -48,12 +52,16 @@ static int my_IOSend(WOLFSSL* ssl, char* buff, int sz, void* ctx)
int ret;
ID cepid;
if(ctx != NULL)cepid = *(ID *)ctx;
else return WOLFSSL_CBIO_ERR_GENERAL;
if(ctx != NULL)
cepid = *(ID *)ctx;
else
return WOLFSSL_CBIO_ERR_GENERAL;
ret = tcp_snd_dat(cepid, buff, sz, TMO_FEVR);
if(ret == sz)return ret;
else return WOLFSSL_CBIO_ERR_GENERAL;
if(ret == sz)
return ret;
else
return WOLFSSL_CBIO_ERR_GENERAL;
}

View File

@@ -391,16 +391,22 @@ int tsip_generateSeesionKey(struct WOLFSSL *ssl)
if (enc->aes == NULL)
enc->aes = (Aes*)XMALLOC(sizeof(Aes), ssl->heap,
DYNAMIC_TYPE_CIPHER);
if (enc->aes == NULL)
if (enc->aes == NULL)
return MEMORY_E;
XMEMSET(enc->aes, 0, sizeof(Aes));
}
if (dec) {
if (dec->aes == NULL)
dec->aes = (Aes*)XMALLOC(sizeof(Aes), ssl->heap,
DYNAMIC_TYPE_CIPHER);
if (dec->aes == NULL)
if (dec->aes == NULL) {
if (enc) {
XFREE(enc->aes, NULL, DYNAMIC_TYPE_CIPHER);
}
return MEMORY_E;
}
XMEMSET(dec->aes, 0, sizeof(Aes));
}
/* copy key index into aes */

View File

@@ -2209,7 +2209,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
if (sz < len) {
len = sz;
}
/* retun 4 words randum number*/
/* retun 4 words random number*/
ret = R_TSIP_GenerateRandomNumber(buffer);
if(ret == TSIP_SUCCESS) {
XMEMCPY(output, &buffer, len);

View File

@@ -119,6 +119,9 @@ int wolfCrypt_Init(void)
ret = tsip_Open( );
if( ret != TSIP_SUCCESS ) {
WOLFSSL_MSG("RENESAS TSIP Open failed");
/* not return 1 since WOLFSSL_SUCCESS=1*/
ret = -1;/* FATAL ERROR */
return ret;
}
#endif

View File

@@ -2087,8 +2087,8 @@ typedef struct Keys {
byte keyUpdateRespond:1; /* KeyUpdate is to be responded to. */
#endif
#ifdef WOLFSSL_RENESAS_TSIP_TLS
byte tsip_client_write_MAC_secret[TSIP_TLS_HMAC_KEY_INDEX_WORDSIZE];
byte tsip_server_write_MAC_secret[TSIP_TLS_HMAC_KEY_INDEX_WORDSIZE];
byte tsip_client_write_MAC_secret[TSIP_TLS_HMAC_KEY_INDEX_WORDSIZE];
byte tsip_server_write_MAC_secret[TSIP_TLS_HMAC_KEY_INDEX_WORDSIZE];
#endif
} Keys;
@@ -3441,7 +3441,7 @@ typedef struct Arrays {
byte masterSecret[SECRET_LEN];
#if defined(WOLFSSL_RENESAS_TSIP_TLS) && \
!defined(NO_WOLFSSL_RENESAS_TSIP_TLS_SESSION)
byte tsip_masterSecret[80];
byte tsip_masterSecret[TSIP_TLS_MASTERSECRET_SIZE];
#endif
#ifdef WOLFSSL_DTLS
byte cookie[MAX_COOKIE_LEN];

View File

@@ -273,6 +273,7 @@
#if defined(WOLFSSL_RENESAS_TSIP)
#define TSIP_TLS_HMAC_KEY_INDEX_WORDSIZE 64
#define TSIP_TLS_MASTERSECRET_SIZE 80 /* 20 words */
#if !defined(NO_RENESAS_TSIP_CRYPT) && defined(WOLFSSL_RENESAS_RX65N)
#define WOLFSSL_RENESAS_TSIP_CRYPT
#define WOLFSSL_RENESAS_TSIP_TLS