|
@@ -239,7 +239,7 @@ WOLFSSL_API int tsip_use_PrivateKey_buffer_crypt(TsipUserCtx *uc,
|
|
|
/* Obsolete function. Use tsip_use_PrivateKey_buffer instead.
|
|
|
* Set client encrypted private key data.
|
|
|
* parameters:
|
|
|
- * key Renesas Secure Flash Programmer generated key.
|
|
|
+ * key Renesas Secure Flash Programmer generated key.
|
|
|
* keyType 0: RSA 2048bit, 1: RSA 4096bit, 2 ECC P256
|
|
|
* return 0 on success, others on failure.
|
|
|
*/
|
|
@@ -253,7 +253,7 @@ WOLFSSL_API int tsip_set_clientPrivateKeyEnc(const byte* encKey, int keyType)
|
|
|
g_user_key_info.encrypted_user_private_key = (uint8_t*)encKey;
|
|
|
g_user_key_info.encrypted_user_private_key_type = keyType;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
WOLFSSL_LEAVE("tsip_set_clientPrivateKeyEnc", ret);
|
|
|
return ret;
|
|
|
}
|
|
@@ -299,7 +299,7 @@ WOLFSSL_LOCAL int tsip_TlsCleanup(struct WOLFSSL* ssl)
|
|
|
|
|
|
/* free stored messages */
|
|
|
tsipFlushMessages(ssl);
|
|
|
-
|
|
|
+
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
@@ -322,12 +322,12 @@ WOLFSSL_LOCAL int tsip_Tls13GenEccKeyPair(WOLFSSL* ssl, KeyShareEntry* kse)
|
|
|
TsipUserCtx* tuc = NULL;
|
|
|
|
|
|
WOLFSSL_ENTER("tsip_Tls13GenEccKeyPair");
|
|
|
-
|
|
|
+
|
|
|
if (ssl == NULL || kse == NULL)
|
|
|
ret = BAD_FUNC_ARG;
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR) {
|
|
|
isTLS13 = 1;
|
|
|
}
|
|
@@ -383,7 +383,7 @@ WOLFSSL_LOCAL int tsip_Tls13GenEccKeyPair(WOLFSSL* ssl, KeyShareEntry* kse)
|
|
|
ecckey = (ecc_key*)kse->key;
|
|
|
ret = wc_ecc_set_curve(ecckey, kse->keyLen, curveId);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
kse->pubKey[0] = ECC_POINT_UNCOMP;
|
|
|
|
|
|
/* generate ecc key pair with TSIP */
|
|
@@ -428,9 +428,9 @@ WOLFSSL_LOCAL int tsip_Tls13GenEccKeyPair(WOLFSSL* ssl, KeyShareEntry* kse)
|
|
|
#if defined(WOLFSSL_TLS13)
|
|
|
/* generate shared secret(pre-master secret)
|
|
|
* get peer's raw ECDHE public key from KeyShareEntry.
|
|
|
- * The pre-master secret generated by TSIP is stored into
|
|
|
+ * The pre-master secret generated by TSIP is stored into
|
|
|
* TsipUserCtx.sharedSecret13Idx as TSIP specific format.
|
|
|
- *
|
|
|
+ *
|
|
|
* return 0 on success, CRYPTOCB_UNAVAILABLE when tsip can not handle and is
|
|
|
* expecting to fallback to S/W, other negative values on error.
|
|
|
*/
|
|
@@ -448,7 +448,7 @@ WOLFSSL_LOCAL int tsip_Tls13GenSharedSecret(struct WOLFSSL* ssl,
|
|
|
ret = BAD_FUNC_ARG;
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR) {
|
|
|
isTLS13 = 1;
|
|
|
}
|
|
@@ -468,7 +468,7 @@ WOLFSSL_LOCAL int tsip_Tls13GenSharedSecret(struct WOLFSSL* ssl,
|
|
|
|
|
|
if (ret == 0) {
|
|
|
/* get user context for TSIP */
|
|
|
- tuc = ssl->RenesasUserCtx;
|
|
|
+ tuc = ssl->RenesasUserCtx;
|
|
|
if (tuc == NULL) {
|
|
|
WOLFSSL_MSG("TsipUserCtx hasn't been set to ssl.");
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
@@ -530,7 +530,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveEarlySecret(struct WOLFSSL* ssl)
|
|
|
|
|
|
if (ret == 0) {
|
|
|
/* get user context for TSIP */
|
|
|
- tuc = ssl->RenesasUserCtx;
|
|
|
+ tuc = ssl->RenesasUserCtx;
|
|
|
if (tuc == NULL) {
|
|
|
WOLFSSL_MSG("TsipUserCtx hasn't been set to ssl.");
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
@@ -539,7 +539,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveEarlySecret(struct WOLFSSL* ssl)
|
|
|
tuc->EarlySecret_set = 1;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
WOLFSSL_LEAVE("tsip_Tls13DeriveEarlySecret", ret);
|
|
|
return ret;
|
|
|
}
|
|
@@ -552,7 +552,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveEarlySecret(struct WOLFSSL* ssl)
|
|
|
* get pre-master secret stored in TsipUserCtx.sharedSecret13Idx.
|
|
|
* Derived handshake secret is stored into TsipUserCtx.handshakeSecret13Idx
|
|
|
* as tsip specific format.
|
|
|
- *
|
|
|
+ *
|
|
|
* return 0 on success, CRYPTOCB_UNAVAILABLE when tsip can not handle and is
|
|
|
* expecting to fallback to S/W, other negative values on error.
|
|
|
*/
|
|
@@ -568,7 +568,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveHandshakeSecret(struct WOLFSSL* ssl)
|
|
|
ret = BAD_FUNC_ARG;
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR) {
|
|
|
isTLS13 = 1;
|
|
|
}
|
|
@@ -580,7 +580,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveHandshakeSecret(struct WOLFSSL* ssl)
|
|
|
|
|
|
if (ret == 0) {
|
|
|
/* get user context for TSIP */
|
|
|
- tuc = ssl->RenesasUserCtx;
|
|
|
+ tuc = ssl->RenesasUserCtx;
|
|
|
if (tuc == NULL) {
|
|
|
WOLFSSL_MSG("TsipUserCtx hasn't been set to ssl.");
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
@@ -597,7 +597,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveHandshakeSecret(struct WOLFSSL* ssl)
|
|
|
|
|
|
if (ret == 0) {
|
|
|
if ((ret = tsip_hw_lock()) == 0) {
|
|
|
-
|
|
|
+
|
|
|
tuc->HandshakeSecret_set = 0;
|
|
|
|
|
|
err = R_TSIP_Tls13GenerateHandshakeSecret(
|
|
@@ -640,7 +640,7 @@ static int tsipTls13DeriveClientHandshakeKeys(struct WOLFSSL* ssl)
|
|
|
ret = BAD_FUNC_ARG;
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR) {
|
|
|
isTLS13 = 1;
|
|
|
}
|
|
@@ -651,7 +651,7 @@ static int tsipTls13DeriveClientHandshakeKeys(struct WOLFSSL* ssl)
|
|
|
|
|
|
if (ret == 0) {
|
|
|
/* get user context for TSIP */
|
|
|
- tuc = ssl->RenesasUserCtx;
|
|
|
+ tuc = ssl->RenesasUserCtx;
|
|
|
if (tuc == NULL) {
|
|
|
WOLFSSL_MSG("TsipUserCtx hasn't been set to ssl.");
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
@@ -673,9 +673,9 @@ static int tsipTls13DeriveClientHandshakeKeys(struct WOLFSSL* ssl)
|
|
|
|
|
|
if (ret == 0) {
|
|
|
if ((ret = tsip_hw_lock()) == 0) {
|
|
|
-
|
|
|
+
|
|
|
tuc->HandshakeClientTrafficKey_set = 0;
|
|
|
-
|
|
|
+
|
|
|
err = R_TSIP_Tls13GenerateClientHandshakeTrafficKey(
|
|
|
&(tuc->handle13),
|
|
|
TSIP_TLS13_MODE_FULL_HANDSHAKE,
|
|
@@ -687,7 +687,7 @@ static int tsipTls13DeriveClientHandshakeKeys(struct WOLFSSL* ssl)
|
|
|
if (err != TSIP_SUCCESS) {
|
|
|
WOLFSSL_MSG(
|
|
|
"R_TSIP_Tls13GenerateClientHandshakeTrafficKey error");
|
|
|
- ret = WC_HW_E;
|
|
|
+ ret = WC_HW_E;
|
|
|
}
|
|
|
|
|
|
/* key derivation succeeded */
|
|
@@ -724,7 +724,7 @@ static int tsipTls13DeriveServerHandshakeKeys(struct WOLFSSL* ssl)
|
|
|
ret = BAD_FUNC_ARG;
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR) {
|
|
|
isTLS13 = 1;
|
|
|
}
|
|
@@ -735,7 +735,7 @@ static int tsipTls13DeriveServerHandshakeKeys(struct WOLFSSL* ssl)
|
|
|
|
|
|
if (ret == 0) {
|
|
|
/* get user context for TSIP */
|
|
|
- tuc = ssl->RenesasUserCtx;
|
|
|
+ tuc = ssl->RenesasUserCtx;
|
|
|
if (tuc == NULL) {
|
|
|
WOLFSSL_MSG("TsipUserCtx hasn't been set to ssl.");
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
@@ -757,7 +757,7 @@ static int tsipTls13DeriveServerHandshakeKeys(struct WOLFSSL* ssl)
|
|
|
|
|
|
if (ret == 0) {
|
|
|
if ((ret = tsip_hw_lock()) == 0) {
|
|
|
-
|
|
|
+
|
|
|
tuc->HandshakeServerTrafficKey_set = 0;
|
|
|
|
|
|
err = R_TSIP_Tls13GenerateServerHandshakeTrafficKey(
|
|
@@ -773,7 +773,7 @@ static int tsipTls13DeriveServerHandshakeKeys(struct WOLFSSL* ssl)
|
|
|
"R_TSIP_Tls13GenerateServerHandshakeTrafficKey error");
|
|
|
ret = WC_HW_E;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/* key derivation succeeded */
|
|
|
if (ret == 0) {
|
|
|
tuc->HandshakeServerTrafficKey_set = 1;
|
|
@@ -808,7 +808,7 @@ static int tsipTls13DeriveTrafficKeys(struct WOLFSSL* ssl)
|
|
|
ret = BAD_FUNC_ARG;
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR) {
|
|
|
isTLS13 = 1;
|
|
|
}
|
|
@@ -819,7 +819,7 @@ static int tsipTls13DeriveTrafficKeys(struct WOLFSSL* ssl)
|
|
|
|
|
|
if (ret == 0) {
|
|
|
/* get user context for TSIP */
|
|
|
- tuc = ssl->RenesasUserCtx;
|
|
|
+ tuc = ssl->RenesasUserCtx;
|
|
|
if (tuc == NULL) {
|
|
|
WOLFSSL_MSG("TsipUserCtx hasn't been set to ssl.");
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
@@ -841,7 +841,7 @@ static int tsipTls13DeriveTrafficKeys(struct WOLFSSL* ssl)
|
|
|
|
|
|
if (ret == 0) {
|
|
|
if ((ret = tsip_hw_lock()) == 0) {
|
|
|
-
|
|
|
+
|
|
|
tuc->ServerTrafficSecret_set = 0;
|
|
|
tuc->ClientTrafficSecret_set = 0;
|
|
|
tuc->ServerWriteTrafficKey_set = 0;
|
|
@@ -862,7 +862,7 @@ static int tsipTls13DeriveTrafficKeys(struct WOLFSSL* ssl)
|
|
|
"R_TSIP_Tls13GenerateApplicationTrafficKey error");
|
|
|
ret = WC_HW_E;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/* key derivation succeeded */
|
|
|
if (ret == 0) {
|
|
|
tuc->ServerTrafficSecret_set = 1;
|
|
@@ -899,7 +899,7 @@ static int tsipTls13UpdateClientTrafficKeys(struct WOLFSSL* ssl)
|
|
|
ret = BAD_FUNC_ARG;
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR) {
|
|
|
isTLS13 = 1;
|
|
|
}
|
|
@@ -910,7 +910,7 @@ static int tsipTls13UpdateClientTrafficKeys(struct WOLFSSL* ssl)
|
|
|
|
|
|
if (ret == 0) {
|
|
|
/* get user context for TSIP */
|
|
|
- tuc = ssl->RenesasUserCtx;
|
|
|
+ tuc = ssl->RenesasUserCtx;
|
|
|
if (tuc == NULL) {
|
|
|
WOLFSSL_MSG("TsipUserCtx hasn't been set to ssl.");
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
@@ -971,7 +971,7 @@ static int tsipTls13UpdateServerTrafficKeys(struct WOLFSSL* ssl)
|
|
|
ret = BAD_FUNC_ARG;
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR) {
|
|
|
isTLS13 = 1;
|
|
|
}
|
|
@@ -982,7 +982,7 @@ static int tsipTls13UpdateServerTrafficKeys(struct WOLFSSL* ssl)
|
|
|
|
|
|
if (ret == 0) {
|
|
|
/* get user context for TSIP */
|
|
|
- tuc = ssl->RenesasUserCtx;
|
|
|
+ tuc = ssl->RenesasUserCtx;
|
|
|
if (tuc == NULL) {
|
|
|
WOLFSSL_MSG("TsipUserCtx hasn't been set to ssl.");
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
@@ -1042,7 +1042,7 @@ static int tsipTls13UpdateServerTrafficKeys(struct WOLFSSL* ssl)
|
|
|
* side ENCRYPT_SIDE_ONLY: when only encryption secret needs to be derived.
|
|
|
* DECRYPT_SIDE_ONLY: when only decryption secret needs to be derived.
|
|
|
* ENCRYPT_AND_DECRYPT_SIDE: when both secret needs to be derived.
|
|
|
- *
|
|
|
+ *
|
|
|
* returns 0 on success, CRYPTOCB_UNAVAILABLE when tsip can not handle and is
|
|
|
* expecting to fallback to S/W, other negative values on error.
|
|
|
*/
|
|
@@ -1142,7 +1142,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveMasterSecret(struct WOLFSSL* ssl)
|
|
|
ret = BAD_FUNC_ARG;
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR) {
|
|
|
isTLS13 = 1;
|
|
|
}
|
|
@@ -1152,7 +1152,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveMasterSecret(struct WOLFSSL* ssl)
|
|
|
}
|
|
|
if (ret == 0) {
|
|
|
/* get user context for TSIP */
|
|
|
- tuc = ssl->RenesasUserCtx;
|
|
|
+ tuc = ssl->RenesasUserCtx;
|
|
|
if (tuc == NULL) {
|
|
|
WOLFSSL_MSG("TsipUserCtx hasn't been set to ssl.");
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
@@ -1160,7 +1160,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveMasterSecret(struct WOLFSSL* ssl)
|
|
|
}
|
|
|
if (ret == 0) {
|
|
|
/* make sure handshake secret and verify data has been set by TSIP */
|
|
|
- if (!tuc->HandshakeSecret_set ||
|
|
|
+ if (!tuc->HandshakeSecret_set ||
|
|
|
!tuc->HandshakeVerifiedData_set) {
|
|
|
WOLFSSL_MSG("TSIP wasn't involved in the key-exchange.");
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
@@ -1168,7 +1168,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveMasterSecret(struct WOLFSSL* ssl)
|
|
|
}
|
|
|
if (ret == 0) {
|
|
|
if ((ret = tsip_hw_lock()) == 0) {
|
|
|
-
|
|
|
+
|
|
|
tuc->MasterSecret_set = 0;
|
|
|
|
|
|
err = R_TSIP_Tls13GenerateMasterSecret(
|
|
@@ -1183,7 +1183,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveMasterSecret(struct WOLFSSL* ssl)
|
|
|
"R_TSIP_Tls13GenerateMasterSecret( error");
|
|
|
ret = WC_HW_E;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (ret == 0) {
|
|
|
tuc->MasterSecret_set = 1;
|
|
|
}
|
|
@@ -1206,7 +1206,7 @@ WOLFSSL_LOCAL int tsip_Tls13DeriveMasterSecret(struct WOLFSSL* ssl)
|
|
|
/* verify handshake
|
|
|
* ssl WOLFSSL object
|
|
|
* hash buffer holding decrypted finished message content from server.
|
|
|
- *
|
|
|
+ *
|
|
|
*/
|
|
|
static int tsipTls13VerifyHandshake(struct WOLFSSL* ssl,
|
|
|
const byte* hash)/*finished message*/
|
|
@@ -1223,7 +1223,7 @@ static int tsipTls13VerifyHandshake(struct WOLFSSL* ssl,
|
|
|
ret = BAD_FUNC_ARG;
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR) {
|
|
|
isTLS13 = 1;
|
|
|
}
|
|
@@ -1234,7 +1234,7 @@ static int tsipTls13VerifyHandshake(struct WOLFSSL* ssl,
|
|
|
|
|
|
if (ret == 0) {
|
|
|
/* get user context for TSIP */
|
|
|
- tuc = ssl->RenesasUserCtx;
|
|
|
+ tuc = ssl->RenesasUserCtx;
|
|
|
if (tuc == NULL) {
|
|
|
WOLFSSL_MSG("TsipUserCtx hasn't been set to ssl.");
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
@@ -1255,7 +1255,7 @@ static int tsipTls13VerifyHandshake(struct WOLFSSL* ssl,
|
|
|
|
|
|
if (ret == 0) {
|
|
|
if ((ret = tsip_hw_lock()) == 0) {
|
|
|
-
|
|
|
+
|
|
|
tuc->HandshakeVerifiedData_set = 0;
|
|
|
|
|
|
err = R_TSIP_Tls13ServerHandshakeVerification(
|
|
@@ -1271,7 +1271,7 @@ static int tsipTls13VerifyHandshake(struct WOLFSSL* ssl,
|
|
|
}
|
|
|
else if (err != TSIP_SUCCESS) {
|
|
|
WOLFSSL_MSG("R_TSIP_Tls13ServerHandshakeVerification error");
|
|
|
- ret = WC_HW_E;
|
|
|
+ ret = WC_HW_E;
|
|
|
}
|
|
|
if (ret == 0) {
|
|
|
WOLFSSL_MSG("Verified handshake");
|
|
@@ -1294,9 +1294,9 @@ static int tsipTls13VerifyHandshake(struct WOLFSSL* ssl,
|
|
|
|
|
|
#if defined(WOLFSSL_TLS13)
|
|
|
/* handles finished message from server.
|
|
|
- * verify hmac in the message. Also output verify data to
|
|
|
+ * verify hmac in the message. Also output verify data to
|
|
|
* TsipUserCtx.verifyDataIdx, which is used for deriving master secret.
|
|
|
- *
|
|
|
+ *
|
|
|
* ssl WOLFSSL object
|
|
|
* input the buffer holding decrypted finished message, type and padding
|
|
|
* inOutIdx On entry, the index into the message content of Finished.
|
|
@@ -1348,7 +1348,7 @@ WOLFSSL_LOCAL int tsip_Tls13HandleFinished(
|
|
|
* inSz The size of the handshake message (including message header).
|
|
|
* type The real content type being put after the message data.
|
|
|
* hashOutput Whether to hash the unencrypted record data.
|
|
|
- * returns the size of the record including header, CRYPTOCB_UNAVAILABLE
|
|
|
+ * returns the size of the record including header, CRYPTOCB_UNAVAILABLE
|
|
|
* when tsip can not handle and is expecting to fallback to S/W,
|
|
|
* other negative values on error.
|
|
|
*/
|
|
@@ -1365,7 +1365,7 @@ WOLFSSL_LOCAL int tsip_Tls13BuildMessage(struct WOLFSSL* ssl,
|
|
|
int isTLS13 = 0;
|
|
|
RecordLayerHeader* rl = NULL;
|
|
|
(void)outSz;
|
|
|
-
|
|
|
+
|
|
|
WOLFSSL_ENTER("tsip_Tls13BuildMessage");
|
|
|
|
|
|
if (ssl == NULL || output == NULL || input == NULL) {
|
|
@@ -1373,7 +1373,7 @@ WOLFSSL_LOCAL int tsip_Tls13BuildMessage(struct WOLFSSL* ssl,
|
|
|
}
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR) {
|
|
|
isTLS13 = 1;
|
|
|
}
|
|
@@ -1421,7 +1421,7 @@ WOLFSSL_LOCAL int tsip_Tls13BuildMessage(struct WOLFSSL* ssl,
|
|
|
/* The real record content type goes at the end of the data. */
|
|
|
output[RECORD_HEADER_SZ + inSz] = (byte)type;
|
|
|
|
|
|
- ret = tsip_Tls13AesEncrypt(ssl,
|
|
|
+ ret = tsip_Tls13AesEncrypt(ssl,
|
|
|
output + RECORD_HEADER_SZ, /* output */
|
|
|
output + RECORD_HEADER_SZ, /* plain message */
|
|
|
inSz + 1); /* plain data size(= inSz + 1 for type) */
|
|
@@ -1440,7 +1440,7 @@ WOLFSSL_LOCAL int tsip_Tls13BuildMessage(struct WOLFSSL* ssl,
|
|
|
|
|
|
#if defined(WOLFSSL_TLS13)
|
|
|
/* Send finished message to the server.
|
|
|
- *
|
|
|
+ *
|
|
|
* ssl WOLFSSL object
|
|
|
* output buffer to output packet, including packet header and finished message
|
|
|
* outSz buffer size of output
|
|
@@ -1466,7 +1466,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendFinished(
|
|
|
if (ssl == NULL || output == NULL || input == NULL || outSz == 0) {
|
|
|
ret = BAD_FUNC_ARG;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (ret == 0) {
|
|
|
finishedSz = ssl->specs.hash_size;
|
|
|
|
|
@@ -1485,7 +1485,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendFinished(
|
|
|
output, outSz,
|
|
|
input, headerSz + finishedSz,
|
|
|
handshake, hashOut);
|
|
|
-
|
|
|
+
|
|
|
if (recordSz > 0) {
|
|
|
ssl->options.clientState = CLIENT_FINISHED_COMPLETE;
|
|
|
ssl->options.handShakeState = HANDSHAKE_DONE;
|
|
@@ -1515,7 +1515,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendFinished(
|
|
|
* return 0 on success, CRYPTOCB_UNAVAILABLE when TSIP can not handle,
|
|
|
* other negative values on error.
|
|
|
*/
|
|
|
-WOLFSSL_LOCAL int tsip_Tls13CertificateVerify(struct WOLFSSL* ssl,
|
|
|
+WOLFSSL_LOCAL int tsip_Tls13CertificateVerify(struct WOLFSSL* ssl,
|
|
|
const byte* input, word32* inOutIdx,
|
|
|
word32 totalSz)
|
|
|
{
|
|
@@ -1528,7 +1528,7 @@ WOLFSSL_LOCAL int tsip_Tls13CertificateVerify(struct WOLFSSL* ssl,
|
|
|
e_tsip_err_t err = TSIP_SUCCESS;
|
|
|
TsipUserCtx* tuc = NULL;
|
|
|
e_tsip_tls13_signature_scheme_type_t sig_scheme;
|
|
|
-
|
|
|
+
|
|
|
WOLFSSL_ENTER("tsip_Tls13CertificateVerify");
|
|
|
|
|
|
|
|
@@ -1576,7 +1576,7 @@ WOLFSSL_LOCAL int tsip_Tls13CertificateVerify(struct WOLFSSL* ssl,
|
|
|
|
|
|
if (ret == 0) {
|
|
|
/* get user context for TSIP */
|
|
|
- tuc = ssl->RenesasUserCtx;
|
|
|
+ tuc = ssl->RenesasUserCtx;
|
|
|
if (tuc == NULL) {
|
|
|
WOLFSSL_MSG("TsipUserCtx is not set to ssl.");
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
@@ -1596,7 +1596,7 @@ WOLFSSL_LOCAL int tsip_Tls13CertificateVerify(struct WOLFSSL* ssl,
|
|
|
|
|
|
idx = 0;
|
|
|
ForceZero(sigData, sizeof(tuc->sigDataCertVerify));
|
|
|
- XMEMSET(sigData, TSIP_SIGNING_DATA_PREFIX_BYTE,
|
|
|
+ XMEMSET(sigData, TSIP_SIGNING_DATA_PREFIX_BYTE,
|
|
|
TSIP_SIGNING_DATA_PREFIX_SZ);
|
|
|
|
|
|
idx += TSIP_SIGNING_DATA_PREFIX_SZ;
|
|
@@ -1605,7 +1605,7 @@ WOLFSSL_LOCAL int tsip_Tls13CertificateVerify(struct WOLFSSL* ssl,
|
|
|
idx += TSIP_CERT_VFY_LABEL_SZ;
|
|
|
ret = tsip_GetMessageSha256(ssl, &sigData[idx], &messageSz);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (ret == 0) {
|
|
|
|
|
|
if ((ret = tsip_hw_lock()) == 0) {
|
|
@@ -1617,7 +1617,7 @@ WOLFSSL_LOCAL int tsip_Tls13CertificateVerify(struct WOLFSSL* ssl,
|
|
|
totalSz);
|
|
|
|
|
|
if (err == TSIP_SUCCESS) {
|
|
|
-
|
|
|
+
|
|
|
*inOutIdx += totalSz;
|
|
|
*inOutIdx += ssl->keys.padSz;
|
|
|
ssl->options.peerAuthGood = 1;
|
|
@@ -1650,17 +1650,17 @@ WOLFSSL_LOCAL int tsip_Tls13CertificateVerify(struct WOLFSSL* ssl,
|
|
|
/* Send the TLS v1.3 CertificateVerify message. A part of the message is
|
|
|
* processed by TSIP for acceleration.
|
|
|
*
|
|
|
- * Prior to this function call, the appropriate key-pair should be set via
|
|
|
- * tsip_use_PrivateKey_buffer_TLS and tsip_use_PublicKey_buffer_TLS APIs.
|
|
|
- * Those key pair can be generated by the tool named
|
|
|
+ * Prior to this function call, the appropriate key-pair should be set via
|
|
|
+ * tsip_use_PrivateKey_buffer_TLS and tsip_use_PublicKey_buffer_TLS APIs.
|
|
|
+ * Those key pair can be generated by the tool named
|
|
|
* "Renesas secure flash programmer".
|
|
|
* When RSA certificate is used, both public and private keys should be set.
|
|
|
* The public key is used for self-verify the generated certificateVerify
|
|
|
* message. When ECC certificate is used, the self-verify will be performed only
|
|
|
* WOLFSSL_CHECK_SIG_FAULTS is defined.
|
|
|
- *
|
|
|
- * Returns 0 on success, CRYPTOCB_UNAVAILABLE when the required key is not
|
|
|
- * provided or unsupported algo is specified and otherwise failure.
|
|
|
+ *
|
|
|
+ * Returns 0 on success, CRYPTOCB_UNAVAILABLE when the required key is not
|
|
|
+ * provided or unsupported algo is specified and otherwise failure.
|
|
|
*/
|
|
|
WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl)
|
|
|
{
|
|
@@ -1693,7 +1693,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl)
|
|
|
}
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR)
|
|
|
isTLS13 = 1;
|
|
|
|
|
@@ -1702,7 +1702,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl)
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (ret == 0) {
|
|
|
/* get user context for TSIP */
|
|
|
tuc = ssl->RenesasUserCtx;
|
|
@@ -1712,10 +1712,10 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl)
|
|
|
}
|
|
|
|
|
|
if (ret == 0) {
|
|
|
- #if !defined(NO_RSA)
|
|
|
+ #if !defined(NO_RSA)
|
|
|
if (ssl->options.haveRSA)
|
|
|
isRsa = 1;
|
|
|
- else
|
|
|
+ else
|
|
|
#endif
|
|
|
#ifdef HAVE_ECC
|
|
|
if (ssl->options.haveECC)
|
|
@@ -1746,7 +1746,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (ret == 0) {
|
|
|
+ if (ret == 0) {
|
|
|
/* get message hash */
|
|
|
ForceZero(hash, sizeof(hash));
|
|
|
ret = tsip_GetMessageSha256(ssl, hash, (int*)&hashSz);
|
|
@@ -1777,7 +1777,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl)
|
|
|
TSIP_TLS13_SIGNATURE_SCHEME_RSA_PSS_RSAE_SHA256,
|
|
|
hash,
|
|
|
message + HANDSHAKE_HEADER_SZ,
|
|
|
- &messageSz);
|
|
|
+ &messageSz);
|
|
|
}
|
|
|
else {
|
|
|
err = R_TSIP_Tls13CertificateVerifyGenerate(
|
|
@@ -1785,7 +1785,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl)
|
|
|
TSIP_TLS13_SIGNATURE_SCHEME_ECDSA_SECP256R1_SHA256,
|
|
|
hash,
|
|
|
message + HANDSHAKE_HEADER_SZ,
|
|
|
- &messageSz);
|
|
|
+ &messageSz);
|
|
|
}
|
|
|
if (err != TSIP_SUCCESS) {
|
|
|
WOLFSSL_MSG("failed to make certificate verify message");
|
|
@@ -1816,7 +1816,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl)
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
-#if defined(WOLFSSL_CHECK_SIG_FAULTS)
|
|
|
+#if defined(WOLFSSL_CHECK_SIG_FAULTS)
|
|
|
if (!tuc->ClientEccP256PubKey_set) {
|
|
|
ret = NO_PRIVATE_KEY;
|
|
|
}
|
|
@@ -1829,7 +1829,7 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl)
|
|
|
|
|
|
idx = 0;
|
|
|
ForceZero(sigData, sizeof(tuc->sigDataCertVerify));
|
|
|
- XMEMSET(sigData, TSIP_SIGNING_DATA_PREFIX_BYTE,
|
|
|
+ XMEMSET(sigData, TSIP_SIGNING_DATA_PREFIX_BYTE,
|
|
|
TSIP_SIGNING_DATA_PREFIX_SZ);
|
|
|
|
|
|
idx += TSIP_SIGNING_DATA_PREFIX_SZ;
|
|
@@ -1842,9 +1842,9 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl)
|
|
|
if (ret == 0) {
|
|
|
/* extract signature data from generated CertificateVerify message */
|
|
|
if (!isRsa) {
|
|
|
-#if defined(WOLFSSL_CHECK_SIG_FAULTS)
|
|
|
- idx = 4;
|
|
|
- derSig = message +
|
|
|
+#if defined(WOLFSSL_CHECK_SIG_FAULTS)
|
|
|
+ idx = 4;
|
|
|
+ derSig = message +
|
|
|
HANDSHAKE_HEADER_SZ + HASH_SIG_SIZE + VERIFY_HEADER;
|
|
|
if (derSig[idx] == 0x00)
|
|
|
idx++;
|
|
@@ -1907,8 +1907,8 @@ WOLFSSL_LOCAL int tsip_Tls13SendCertVerify(WOLFSSL* ssl)
|
|
|
((HandShakeHeader*)message)->type = certificate_verify;
|
|
|
|
|
|
c32to24(messageSz, ((HandShakeHeader*)message)->length);
|
|
|
-
|
|
|
- recordSz = tsip_Tls13BuildMessage(ssl, output, 0, message,
|
|
|
+
|
|
|
+ recordSz = tsip_Tls13BuildMessage(ssl, output, 0, message,
|
|
|
messageSz + HANDSHAKE_HEADER_SZ,
|
|
|
handshake, 1);
|
|
|
|
|
@@ -2114,8 +2114,8 @@ int wc_tsip_RsaVerify(
|
|
|
* key buffer holding peer's public key (NOT used in this function)
|
|
|
* keySz public key size((NOT used in this function))
|
|
|
* result address of the variable to output result
|
|
|
- * ctx context
|
|
|
- * return 0 on success, CRYPTOCB_UNAVAILABLE in case TSIP cannot handle
|
|
|
+ * ctx context
|
|
|
+ * return 0 on success, CRYPTOCB_UNAVAILABLE in case TSIP cannot handle
|
|
|
*/
|
|
|
int wc_tsip_EccVerify(
|
|
|
WOLFSSL* ssl,
|
|
@@ -2138,8 +2138,8 @@ int wc_tsip_EccVerify(
|
|
|
return CRYPTOCB_UNAVAILABLE;
|
|
|
}
|
|
|
|
|
|
- /* in TLS1.3 */
|
|
|
- if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
+ /* in TLS1.3 */
|
|
|
+ if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
ssl->version.minor == TLSv1_3_MINOR) {
|
|
|
WOLFSSL_LEAVE("wc_tsip_EccVerify", CRYPTOCB_UNAVAILABLE);
|
|
|
return CRYPTOCB_UNAVAILABLE;
|
|
@@ -2261,7 +2261,7 @@ WOLFSSL_API void tsip_set_callbacks(WOLFSSL_CTX* ctx)
|
|
|
#endif /* !WOLFSSL_NO_TLS12 && !WOLFSSL_AEAD_ONLY */
|
|
|
wolfSSL_CTX_SetEccSharedSecretCb(ctx, NULL);
|
|
|
/* Set ssl-> options.sendVerify to SEND_CERT by the following two
|
|
|
- * registrations. This will allow the client certificate to be sent to
|
|
|
+ * registrations. This will allow the client certificate to be sent to
|
|
|
* the server even if the private key is empty. The two callbacks do
|
|
|
* virtually nothing.
|
|
|
*/
|
|
@@ -2307,7 +2307,7 @@ WOLFSSL_API int tsip_set_callback_ctx(WOLFSSL* ssl, void* user_ctx)
|
|
|
wolfSSL_SetRsaSignCtx(ssl, user_ctx);
|
|
|
wolfSSL_SetGenPreMasterCtx(ssl, user_ctx);
|
|
|
wolfSSL_SetEccSharedSecretCtx(ssl, NULL);
|
|
|
-#if !defined(WOLFSSL_NO_TLS12) && !defined(WOLFSSL_AEAD_ONLY)
|
|
|
+#if !defined(WOLFSSL_NO_TLS12) && !defined(WOLFSSL_AEAD_ONLY)
|
|
|
wolfSSL_SetVerifyMacCtx(ssl, user_ctx);
|
|
|
#endif /* !WOLFSSL_NO_TLS12 && !WOLFSSL_AEAD_ONLY */
|
|
|
/* set up crypt callback */
|
|
@@ -2367,7 +2367,7 @@ static int tsipImportPrivateKey(TsipUserCtx* tuc, int keyType)
|
|
|
if (encPrivKey == NULL || provisioning_key == NULL || iv == NULL) {
|
|
|
WOLFSSL_MSG("Missing some key materials used for import" );
|
|
|
return CRYPTOCB_UNAVAILABLE;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
if (ret == 0) {
|
|
|
if (keyType != tuc->wrappedKeyType) {
|
|
@@ -2381,7 +2381,7 @@ static int tsipImportPrivateKey(TsipUserCtx* tuc, int keyType)
|
|
|
|
|
|
#if !defined(NO_RSA)
|
|
|
case TSIP_KEY_TYPE_RSA2048:
|
|
|
-
|
|
|
+
|
|
|
tuc->ClientRsa2048PrivKey_set = 0;
|
|
|
err = R_TSIP_GenerateRsa2048PrivateKeyIndex(
|
|
|
provisioning_key, iv, (uint8_t*)encPrivKey,
|
|
@@ -2396,7 +2396,7 @@ static int tsipImportPrivateKey(TsipUserCtx* tuc, int keyType)
|
|
|
#endif
|
|
|
|
|
|
case TSIP_KEY_TYPE_RSA4096:
|
|
|
- /* not supported as of TSIPv1.15 */
|
|
|
+ /* not supported as of TSIPv1.15 */
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
|
break;
|
|
|
|
|
@@ -2458,7 +2458,7 @@ WOLFSSL_LOCAL int tsipImportPublicKey(TsipUserCtx* tuc, int keyType)
|
|
|
if (encPubKey == NULL || provisioning_key == NULL || iv == NULL) {
|
|
|
WOLFSSL_MSG("Missing some key materials used for import" );
|
|
|
return CRYPTOCB_UNAVAILABLE;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
if (ret == 0) {
|
|
|
if (keyType != tuc->wrappedKeyType) {
|
|
@@ -2469,7 +2469,7 @@ WOLFSSL_LOCAL int tsipImportPublicKey(TsipUserCtx* tuc, int keyType)
|
|
|
|
|
|
if ((ret = tsip_hw_lock()) == 0) {
|
|
|
switch(keyType) {
|
|
|
-
|
|
|
+
|
|
|
#if !defined(NO_RSA)
|
|
|
case TSIP_KEY_TYPE_RSA2048:
|
|
|
#if defined(WOLFSSL_RENESAS_TSIP_TLS)
|
|
@@ -2479,10 +2479,10 @@ WOLFSSL_LOCAL int tsipImportPublicKey(TsipUserCtx* tuc, int keyType)
|
|
|
XFREE(tuc->rsa2048pub_keyIdx, NULL,
|
|
|
DYNAMIC_TYPE_RSA_BUFFER);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
tuc->rsa2048pub_keyIdx =
|
|
|
(tsip_rsa2048_public_key_index_t*)XMALLOC(
|
|
|
- sizeof(tsip_rsa2048_public_key_index_t), NULL,
|
|
|
+ sizeof(tsip_rsa2048_public_key_index_t), NULL,
|
|
|
DYNAMIC_TYPE_RSA_BUFFER);
|
|
|
if (tuc->rsa2048pub_keyIdx == NULL) {
|
|
|
return MEMORY_E;
|
|
@@ -2508,14 +2508,14 @@ WOLFSSL_LOCAL int tsipImportPublicKey(TsipUserCtx* tuc, int keyType)
|
|
|
}
|
|
|
break;
|
|
|
#endif
|
|
|
-
|
|
|
+
|
|
|
#if !defined(NO_RSA)
|
|
|
case TSIP_KEY_TYPE_RSA4096:
|
|
|
- /* not supported as of TSIPv1.15 */
|
|
|
+ /* not supported as of TSIPv1.15 */
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
|
break;
|
|
|
#endif
|
|
|
-
|
|
|
+
|
|
|
#if defined(HAVE_ECC) && \
|
|
|
defined(WOLFSSL_RENESAS_TSIP_TLS)
|
|
|
case TSIP_KEY_TYPE_ECDSAP256:
|
|
@@ -3101,7 +3101,7 @@ int wc_tsip_generateVerifyData(
|
|
|
WOLFSSL_LEAVE("tsip_generateVerifyData", BAD_FUNC_ARG);
|
|
|
return BAD_FUNC_ARG;
|
|
|
}
|
|
|
- if (XSTRNCMP((const char*)side, (const char*)kTlsServerFinStr,
|
|
|
+ if (XSTRNCMP((const char*)side, (const char*)kTlsServerFinStr,
|
|
|
FINISHED_LABEL_SZ) == 0) {
|
|
|
l_side = R_TSIP_TLS_GENERATE_SERVER_VERIFY;
|
|
|
}
|
|
@@ -3667,14 +3667,14 @@ WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|
|
|
|
|
WOLFSSL_ENTER("tsip_SignRsaPkcs");
|
|
|
|
|
|
- if (info == NULL || tuc == NULL
|
|
|
+ if (info == NULL || tuc == NULL
|
|
|
#ifndef WOLFSSL_RENESAS_TSIP_CRYPTONLY
|
|
|
|| tuc->ssl == NULL
|
|
|
#endif
|
|
|
) {
|
|
|
ret = BAD_FUNC_ARG;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
#ifdef WOLFSSL_RENESAS_TSIP_TLS
|
|
|
if (ret == 0) {
|
|
|
ssl = tuc->ssl;
|
|
@@ -3690,7 +3690,7 @@ WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|
|
ret = tsipImportPrivateKey(tuc, tuc->wrappedKeyType);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if (ret == 0) {
|
|
|
if (ssl->options.hashAlgo == md5_mac)
|
|
|
tsip_hash_type = R_TSIP_RSA_HASH_MD5;
|
|
@@ -3703,7 +3703,7 @@ WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|
|
}
|
|
|
#else
|
|
|
(void)ssl;
|
|
|
-
|
|
|
+
|
|
|
if (ret == 0) {
|
|
|
if (tuc->sing_hash_type == md5_mac)
|
|
|
tsip_hash_type = R_TSIP_RSA_HASH_MD5;
|
|
@@ -3714,7 +3714,7 @@ WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|
|
else
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
switch (tuc->wrappedKeyType) {
|
|
|
case TSIP_KEY_TYPE_RSA1024:
|
|
|
if (tuc->keyflgs_crypt.bits.rsapri1024_key_set != 1)
|
|
@@ -3735,9 +3735,9 @@ WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
#endif
|
|
|
-
|
|
|
+
|
|
|
if (ret == 0) {
|
|
|
#ifdef WOLFSSL_RENESAS_TSIP_TLS
|
|
|
hashData.pdata = (uint8_t*)ssl->buffers.digest.buffer;
|
|
@@ -3762,7 +3762,7 @@ WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|
|
tsip_hash_type);
|
|
|
|
|
|
if (err != TSIP_SUCCESS) {
|
|
|
- ret = WC_HW_E;
|
|
|
+ ret = WC_HW_E;
|
|
|
}
|
|
|
break;
|
|
|
#endif
|
|
@@ -3779,7 +3779,7 @@ WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|
|
tsip_hash_type);
|
|
|
|
|
|
if (err != TSIP_SUCCESS) {
|
|
|
- ret = WC_HW_E;
|
|
|
+ ret = WC_HW_E;
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -3807,7 +3807,7 @@ WOLFSSL_LOCAL int tsip_SignRsaPkcs(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|
|
|
|
|
#if !defined(NO_RSA) && defined(WOLFSSL_RENESAS_TSIP_TLS)
|
|
|
WOLFSSL_LOCAL int tsip_VerifyRsaPkcsCb(
|
|
|
- WOLFSSL* ssl,
|
|
|
+ WOLFSSL* ssl,
|
|
|
unsigned char* sig, unsigned int sigSz,
|
|
|
unsigned char** out,
|
|
|
const unsigned char* keyDer, unsigned int keySz,
|
|
@@ -3842,7 +3842,7 @@ WOLFSSL_LOCAL int tsip_VerifyRsaPkcsCb(
|
|
|
/* import public key_index from wrapped key */
|
|
|
ret = tsipImportPublicKey(tuc, tuc->wrappedKeyType);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (ret == 0) {
|
|
|
if (ssl->options.hashAlgo == md5_mac)
|
|
|
tsip_hash_type = R_TSIP_RSA_HASH_MD5;
|
|
@@ -3852,7 +3852,7 @@ WOLFSSL_LOCAL int tsip_VerifyRsaPkcsCb(
|
|
|
tsip_hash_type = R_TSIP_RSA_HASH_SHA256;
|
|
|
else {
|
|
|
ret = CRYPTOCB_UNAVAILABLE;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (ret == 0) {
|
|
@@ -3863,7 +3863,7 @@ WOLFSSL_LOCAL int tsip_VerifyRsaPkcsCb(
|
|
|
if ((ret = tsip_hw_lock()) == 0) {
|
|
|
|
|
|
switch (tuc->wrappedKeyType) {
|
|
|
-
|
|
|
+
|
|
|
case TSIP_KEY_TYPE_RSA2048:
|
|
|
sigData.data_length = 256;
|
|
|
err = R_TSIP_RsassaPkcs2048SignatureVerification(
|
|
@@ -3904,7 +3904,7 @@ WOLFSSL_LOCAL int tsip_VerifyRsaPkcsCb(
|
|
|
|
|
|
#if defined(HAVE_ECC) && defined(WOLFSSL_RENESAS_TSIP_TLS)
|
|
|
/* Perform signing with the client's ECC private key on hash value of messages
|
|
|
- * exchanged with server.
|
|
|
+ * exchanged with server.
|
|
|
*
|
|
|
* parameters
|
|
|
* info->pk.eccsign.in : the buffer holding hash value of messages
|
|
@@ -3951,33 +3951,33 @@ WOLFSSL_LOCAL int tsip_SignEcdsa(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|
|
/* import private key_index from wrapped key */
|
|
|
ret = tsipImportPrivateKey(tuc, tuc->wrappedKeyType);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (ret == 0) {
|
|
|
hashData.pdata = (uint8_t*)info->pk.eccsign.in;
|
|
|
hashData.data_type = 1;
|
|
|
sigData.pdata = (uint8_t*)info->pk.eccsign.out;
|
|
|
sigData.data_length = 0; /* signature size will be returned here */
|
|
|
|
|
|
- if ((ret = tsip_hw_lock()) == 0) {
|
|
|
+ if ((ret = tsip_hw_lock()) == 0) {
|
|
|
switch (tuc->wrappedKeyType) {
|
|
|
|
|
|
#if defined(HAVE_ECC)
|
|
|
case TSIP_KEY_TYPE_ECDSAP256:
|
|
|
offsetForWork = R_TSIP_ECDSA_DATA_BYTE_SIZE + 32;
|
|
|
- if (*(info->pk.eccsign.outlen) <
|
|
|
+ if (*(info->pk.eccsign.outlen) <
|
|
|
R_TSIP_ECDSA_DATA_BYTE_SIZE + offsetForWork) {
|
|
|
ret = BUFFER_E;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- sigData.pdata = (uint8_t*)info->pk.eccsign.out +
|
|
|
+ sigData.pdata = (uint8_t*)info->pk.eccsign.out +
|
|
|
offsetForWork;
|
|
|
err = R_TSIP_EcdsaP256SignatureGenerate(
|
|
|
&hashData, &sigData,
|
|
|
&tuc->EcdsaP256PrivateKeyIdx);
|
|
|
if (err != TSIP_SUCCESS) {
|
|
|
ret = WC_HW_E;
|
|
|
- break;
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
out = info->pk.eccsign.out;
|
|
@@ -3991,7 +3991,7 @@ WOLFSSL_LOCAL int tsip_SignEcdsa(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|
|
/* encode ASN sequence */
|
|
|
out[idx++] = ASN_SEQUENCE | ASN_CONSTRUCTED;
|
|
|
out[idx++] = sz;
|
|
|
-
|
|
|
+
|
|
|
/* copy r part */
|
|
|
out[idx++] = ASN_INTEGER;
|
|
|
out[idx++] = rSz;
|
|
@@ -4006,7 +4006,7 @@ WOLFSSL_LOCAL int tsip_SignEcdsa(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|
|
if (sSz > R_TSIP_ECDSA_DATA_BYTE_SIZE / 2)
|
|
|
out[idx++] = 0x00;
|
|
|
XMEMCPY(&out[idx], sig, R_TSIP_ECDSA_DATA_BYTE_SIZE / 2);
|
|
|
-
|
|
|
+
|
|
|
/* out size */
|
|
|
*(info->pk.eccsign.outlen) = ASN_TAG_SZ + 1 + sz;
|
|
|
break;
|
|
@@ -4047,20 +4047,22 @@ WOLFSSL_LOCAL int tsip_SignEcdsa(wc_CryptoInfo* info, TsipUserCtx* tuc)
|
|
|
|
|
|
#ifdef WOLFSSL_RENESAS_TSIP_CRYPT_DEBUG
|
|
|
|
|
|
-/* err
|
|
|
- * e_tsip_err
|
|
|
+#if 0
|
|
|
+ /* this is here for documentation purposes. */
|
|
|
+ enum e_tsip_err {
|
|
|
TSIP_SUCCESS = 0,
|
|
|
- TSIP_ERR_SELF_CHECK1, // Self-check 1 fail or TSIP function internal err.
|
|
|
- TSIP_ERR_RESOURCE_CONFLICT, // A resource conflict occurred.
|
|
|
- TSIP_ERR_SELF_CHECK2, // Self-check 2 fail.
|
|
|
- TSIP_ERR_KEY_SET, // setting the invalid key.
|
|
|
- TSIP_ERR_AUTHENTICATION, // Authentication failed.
|
|
|
- TSIP_ERR_CALLBACK_UNREGIST, // Callback function is not registered.
|
|
|
- TSIP_ERR_PARAMETER, // Illegal Input data.
|
|
|
- TSIP_ERR_PROHIBIT_FUNCTION, // An invalid function call occurred.
|
|
|
- * TSIP_RESUME_FIRMWARE_GENERATE_MAC,
|
|
|
- // There is a continuation of R_TSIP_GenerateFirmwareMAC.
|
|
|
-*/
|
|
|
+ TSIP_ERR_SELF_CHECK1, /* Self-check 1 fail or TSIP function internal err. */
|
|
|
+ TSIP_ERR_RESOURCE_CONFLICT, /* A resource conflict occurred. */
|
|
|
+ TSIP_ERR_SELF_CHECK2, /* Self-check 2 fail. */
|
|
|
+ TSIP_ERR_KEY_SET, /* setting the invalid key. */
|
|
|
+ TSIP_ERR_AUTHENTICATION, /* Authentication failed. */
|
|
|
+ TSIP_ERR_CALLBACK_UNREGIST, /* Callback function is not registered. */
|
|
|
+ TSIP_ERR_PARAMETER, /* Illegal Input data. */
|
|
|
+ TSIP_ERR_PROHIBIT_FUNCTION, /* An invalid function call occurred. */
|
|
|
+ TSIP_RESUME_FIRMWARE_GENERATE_MAC
|
|
|
+ /* There is a continuation of R_TSIP_GenerateFirmwareMAC. */
|
|
|
+ };
|
|
|
+#endif
|
|
|
|
|
|
static void hexdump(const uint8_t* in, uint32_t len)
|
|
|
{
|