forked from wolfSSL/wolfssl
add cavium ciphers to SSL, and example client
This commit is contained in:
@@ -2827,6 +2827,8 @@ static void AesCaviumCbcEncrypt(Aes* aes, byte* out, const byte* in,
|
||||
CYASSL_MSG("Bad Cavium Aes Encrypt");
|
||||
}
|
||||
length -= CYASSL_MAX_16BIT;
|
||||
offset += CYASSL_MAX_16BIT;
|
||||
XMEMCPY(aes->reg, out + offset - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
|
||||
}
|
||||
if (length) {
|
||||
word16 slen = (word16)length;
|
||||
@@ -2836,6 +2838,7 @@ static void AesCaviumCbcEncrypt(Aes* aes, byte* out, const byte* in,
|
||||
aes->devId) != 0) {
|
||||
CYASSL_MSG("Bad Cavium Aes Encrypt");
|
||||
}
|
||||
XMEMCPY(aes->reg, out + offset+length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2843,23 +2846,31 @@ static void AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in,
|
||||
word32 length)
|
||||
{
|
||||
word32 requestId;
|
||||
word offset = 0;
|
||||
|
||||
while (length > CYASSL_MAX_16BIT) {
|
||||
word16 slen = (word16)CYASSL_MAX_16BIT;
|
||||
XMEMCPY(aes->tmp, in + offset + slen - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
|
||||
if (CspDecryptAes(CAVIUM_BLOCKING, aes->contextHandle, CAVIUM_NO_UPDATE,
|
||||
aes->type, slen, (byte*)in, out, (byte*)aes->reg,
|
||||
(byte*)aes->key, &requestId, aes->devId) != 0) {
|
||||
aes->type, slen, (byte*)in + offset, out + offset,
|
||||
(byte*)aes->reg, (byte*)aes->key, &requestId,
|
||||
aes->devId) != 0) {
|
||||
CYASSL_MSG("Bad Cavium Aes Decrypt");
|
||||
}
|
||||
length -= CYASSL_MAX_16BIT;
|
||||
offset += CYASSL_MAX_16BIT;
|
||||
XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
|
||||
}
|
||||
if (length) {
|
||||
word16 slen = (word16)length;
|
||||
XMEMCPY(aes->tmp, in + offset + slen - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
|
||||
if (CspDecryptAes(CAVIUM_BLOCKING, aes->contextHandle, CAVIUM_NO_UPDATE,
|
||||
aes->type, slen, (byte*)in, out, (byte*)aes->reg,
|
||||
(byte*)aes->key, &requestId, aes->devId) != 0) {
|
||||
aes->type, slen, (byte*)in + offset, out + offset,
|
||||
(byte*)aes->reg, (byte*)aes->key, &requestId,
|
||||
aes->devId) != 0) {
|
||||
CYASSL_MSG("Bad Cavium Aes Decrypt");
|
||||
}
|
||||
XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ static void Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
|
||||
|
||||
while (length > CYASSL_MAX_16BIT) {
|
||||
word16 slen = (word16)CYASSL_MAX_16BIT;
|
||||
if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_NO_UPDATE,
|
||||
if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_UPDATE,
|
||||
slen, (byte*)in + offset, out + offset, &requestId,
|
||||
arc4->devId) != 0) {
|
||||
CYASSL_MSG("Bad Cavium Arc4 Encrypt");
|
||||
@@ -158,7 +158,7 @@ static void Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
|
||||
}
|
||||
if (length) {
|
||||
word16 slen = (word16)length;
|
||||
if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_NO_UPDATE,
|
||||
if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_UPDATE,
|
||||
slen, (byte*)in + offset, out + offset, &requestId,
|
||||
arc4->devId) != 0) {
|
||||
CYASSL_MSG("Bad Cavium Arc4 Encrypt");
|
||||
|
||||
@@ -817,7 +817,7 @@ static void Des3_CaviumCbcEncrypt(Des3* des3, byte* out, const byte* in,
|
||||
{
|
||||
word offset = 0;
|
||||
word32 requestId;
|
||||
|
||||
|
||||
while (length > CYASSL_MAX_16BIT) {
|
||||
word16 slen = (word16)CYASSL_MAX_16BIT;
|
||||
if (CspEncrypt3Des(CAVIUM_BLOCKING, des3->contextHandle,
|
||||
@@ -827,6 +827,8 @@ static void Des3_CaviumCbcEncrypt(Des3* des3, byte* out, const byte* in,
|
||||
CYASSL_MSG("Bad Cavium 3DES Cbc Encrypt");
|
||||
}
|
||||
length -= CYASSL_MAX_16BIT;
|
||||
offset += CYASSL_MAX_16BIT;
|
||||
XMEMCPY(des3->reg, out + offset - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
|
||||
}
|
||||
if (length) {
|
||||
word16 slen = (word16)length;
|
||||
@@ -837,6 +839,7 @@ static void Des3_CaviumCbcEncrypt(Des3* des3, byte* out, const byte* in,
|
||||
&requestId, des3->devId) != 0) {
|
||||
CYASSL_MSG("Bad Cavium 3DES Cbc Encrypt");
|
||||
}
|
||||
XMEMCPY(des3->reg, out+offset+length - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -844,25 +847,31 @@ static void Des3_CaviumCbcDecrypt(Des3* des3, byte* out, const byte* in,
|
||||
word32 length)
|
||||
{
|
||||
word32 requestId;
|
||||
word offset = 0;
|
||||
|
||||
while (length > CYASSL_MAX_16BIT) {
|
||||
word16 slen = (word16)CYASSL_MAX_16BIT;
|
||||
XMEMCPY(des3->tmp, in + offset + slen - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
|
||||
if (CspDecrypt3Des(CAVIUM_BLOCKING, des3->contextHandle,
|
||||
CAVIUM_NO_UPDATE, slen, (byte*)in, out,
|
||||
CAVIUM_NO_UPDATE, slen, (byte*)in+offset, out+offset,
|
||||
(byte*)des3->reg, (byte*)des3->key[0], &requestId,
|
||||
des3->devId) != 0) {
|
||||
CYASSL_MSG("Bad Cavium 3Des Decrypt");
|
||||
}
|
||||
length -= CYASSL_MAX_16BIT;
|
||||
offset += CYASSL_MAX_16BIT;
|
||||
XMEMCPY(des3->reg, des3->tmp, DES_BLOCK_SIZE);
|
||||
}
|
||||
if (length) {
|
||||
word16 slen = (word16)length;
|
||||
XMEMCPY(des3->tmp, in + offset + slen - DES_BLOCK_SIZE,DES_BLOCK_SIZE);
|
||||
if (CspDecrypt3Des(CAVIUM_BLOCKING, des3->contextHandle,
|
||||
CAVIUM_NO_UPDATE, slen, (byte*)in, out,
|
||||
CAVIUM_NO_UPDATE, slen, (byte*)in+offset, out+offset,
|
||||
(byte*)des3->reg, (byte*)des3->key[0], &requestId,
|
||||
des3->devId) != 0) {
|
||||
CYASSL_MSG("Bad Cavium 3Des Decrypt");
|
||||
}
|
||||
XMEMCPY(des3->reg, des3->tmp, DES_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -277,6 +277,10 @@ void CTaoCryptErrorString(int error, char* buffer)
|
||||
XSTRNCPY(buffer, "AES-CCM Authentication check fail", max);
|
||||
break;
|
||||
|
||||
case CAVIUM_INIT_E:
|
||||
XSTRNCPY(buffer, "Cavium Init type error", max);
|
||||
break;
|
||||
|
||||
default:
|
||||
XSTRNCPY(buffer, "unknown error number", max);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user