Skip to content

Commit

Permalink
[#144] Wolf crypto module building, no unit tests yet;
Browse files Browse the repository at this point in the history
  • Loading branch information
jlucas9 committed Sep 7, 2023
1 parent 335422d commit 55c5087
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/crypto/wolfssl/cryptography_interface_wolfssl.template.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// Reference: https://www.wolfssl.com/documentation/manuals/wolfssl/

#include <wolfssl/options.h>
#include <wolfssl/wolfcrypt/aes.h>
#include <wolfssl/wolfcrypt/ecc.h>
#include <wolfssl/wolfcrypt/cmac.h>
Expand Down Expand Up @@ -402,20 +403,11 @@ static int32_t cryptography_aead_encrypt(uint8_t* data_out, size_t len_data_out,
switch (*ecs)
{
case CRYPTO_CIPHER_AES256_GCM:
status = wc_AesGcmEncryptInit(&enc, key, len_key, iv, iv_len);
if (status == 0)
{
wc_AesGcmEncryptUpdate(&enc, data_out, data_in, len_data_in, aad, aad_len);
}
status = wc_AesGcmSetKey(&enc, key, len_key);
if (status == 0)
{
wc_AesGcmEncryptFinal(&enc, mac, mac_size);
status = wc_AesGcmEncrypt(&enc, data_out, data_in, len_data_in, iv, iv_len, mac, mac_size, aad, aad_len);
}
//status = wc_AesGcmSetKey(&enc, key, len_key);
//if (status == 0)
//{
// status = wc_AesGcmEncrypt(enc, data_out, data_in, len_data_in, iv, iv_len, mac, mac_size, NULL, 0);
//}
break;

case CRYPTO_CIPHER_AES256_CCM:
Expand Down Expand Up @@ -499,7 +491,7 @@ static int32_t cryptography_aead_decrypt(uint8_t* data_out, size_t len_data_out,
status = wc_AesGcmSetKey(&enc, key, len_key);
if (status == 0)
{
status = wc_AesGcmDecrypt(enc, data_out, data_in, len_data_in, iv, iv_len, mac, mac_size, NULL, 0);
status = wc_AesGcmDecrypt(&enc, data_out, data_in, len_data_in, iv, iv_len, mac, mac_size, NULL, 0);
}
break;

Expand Down
13 changes: 13 additions & 0 deletions support/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,16 @@ RUN apt-get update -y \
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install pycryptodome

# WolfSSL
FROM cl0 AS cl1
RUN cd /tmp \
&& git clone https://github.com/wolfSSL/wolfssl.git \
&& cd /tmp/wolfssl \
&& git checkout v5.6.0-stable

RUN mkdir /tmp/wolfssl/build \
&& cd /tmp/wolfssl/build \
&& cmake -DCMAKE_C_FLAGS="-DWOLFSSL_AESGCM_STREAM" .. \
&& make install \
&& rm -rf /tmp/wolfssl

0 comments on commit 55c5087

Please sign in to comment.