Browse Source

Compilation fixes

pull/392/head
Luca Deri 4 years ago
parent
commit
5a06abc75d
  1. 2
      src/tf.c
  2. 12
      src/transform_aes.c
  3. 12
      src/transform_tf.c

2
src/tf.c

@ -48,7 +48,7 @@ THE SOFTWARE.
#include "tf.h"
#include "portable_endian.h"
const uint8_t RS[4][8] = { { 0x01, 0xA4, 0x55, 0x87, 0x5A, 0x58, 0xDB, 0x9E, },
{ 0xA4, 0x56, 0x82, 0xF3, 0x1E, 0xC6, 0x68, 0xE5, },

12
src/transform_aes.c

@ -30,8 +30,8 @@
#define AES_PREAMBLE_SIZE (AES_BLOCK_SIZE)
// cbc mode is being used with random value prepended to plaintext
// instead of iv so, actual iv is null_iv
const uint8_t null_iv[AES_IV_SIZE] = {0};
// instead of iv so, actual iv is aes_null_iv
const uint8_t aes_null_iv[AES_IV_SIZE] = {0};
typedef struct transop_aes {
aes_context_t *ctx;
@ -98,7 +98,7 @@ static int transop_encode_aes(n2n_trans_op_t * arg,
// to slightly faster code than run-time dependant 'padding'
memset (assembly + idx, 0, AES_BLOCK_SIZE);
aes_cbc_encrypt(outbuf, assembly, padded_len, null_iv, priv->ctx);
aes_cbc_encrypt(outbuf, assembly, padded_len, aes_null_iv, priv->ctx);
if(padding) {
// exchange last two cipher blocks
@ -153,15 +153,15 @@ static int transop_decode_aes(n2n_trans_op_t * arg,
// write new penultimate block from buf
memcpy(assembly + penultimate_block, buf, AES_BLOCK_SIZE);
// regular cbc decryption on the re-arranged ciphertext
aes_cbc_decrypt(assembly, assembly, in_len + AES_BLOCK_SIZE - rest, null_iv, priv->ctx);
aes_cbc_decrypt(assembly, assembly, in_len + AES_BLOCK_SIZE - rest, aes_null_iv, priv->ctx);
// check for expected zero padding and give a warning otherwise
if (memcmp(assembly + in_len, null_iv, AES_BLOCK_SIZE - rest)) {
if (memcmp(assembly + in_len, aes_null_iv, AES_BLOCK_SIZE - rest)) {
traceEvent(TRACE_WARNING, "transop_decode_aes payload decryption failed with unexpected cipher text stealing padding");
return -1;
}
} else {
// regular cbc decryption on multiple block-sized payload
aes_cbc_decrypt(assembly, inbuf, in_len, null_iv, priv->ctx);
aes_cbc_decrypt(assembly, inbuf, in_len, aes_null_iv, priv->ctx);
}
len = in_len - AES_PREAMBLE_SIZE;
memcpy(outbuf,

12
src/transform_tf.c

@ -28,8 +28,8 @@
#define TF_PREAMBLE_SIZE (TF_BLOCK_SIZE)
// cbc mode is being used with random value prepended to plaintext
// instead of iv so, actual iv is null_iv
const uint8_t null_iv[TF_IV_SIZE] = {0};
// instead of iv so, actual iv is tf_null_iv
const uint8_t tf_null_iv[TF_IV_SIZE] = {0};
typedef struct transop_tf {
tf_context_t *ctx;
@ -100,7 +100,7 @@ static int transop_encode_tf(n2n_trans_op_t * arg,
// pad the following bytes with zero, fixed length (TF_BLOCK_SIZE) seems to compile
// to slightly faster code than run-time dependant 'padding'
memset (assembly + idx, 0, TF_BLOCK_SIZE);
tf_cbc_encrypt(outbuf, assembly, padded_len, null_iv, priv->ctx);
tf_cbc_encrypt(outbuf, assembly, padded_len, tf_null_iv, priv->ctx);
if(padding) {
// exchange last two cipher blocks
@ -156,16 +156,16 @@ static int transop_decode_tf(n2n_trans_op_t * arg,
memcpy(assembly + penultimate_block, buf, TF_BLOCK_SIZE);
// regular cbc decryption on the re-arranged ciphertext
tf_cbc_decrypt(assembly, assembly, in_len + TF_BLOCK_SIZE - rest, null_iv, priv->ctx);
tf_cbc_decrypt(assembly, assembly, in_len + TF_BLOCK_SIZE - rest, tf_null_iv, priv->ctx);
// check for expected zero padding and give a warning otherwise
if (memcmp(assembly + in_len, null_iv, TF_BLOCK_SIZE - rest)) {
if (memcmp(assembly + in_len, tf_null_iv, TF_BLOCK_SIZE - rest)) {
traceEvent(TRACE_WARNING, "transop_decode_tf payload decryption failed with unexpected cipher text stealing padding");
return -1;
}
} else {
// regular cbc decryption on multiple block-sized payload
tf_cbc_decrypt(assembly, inbuf, in_len, null_iv, priv->ctx);
tf_cbc_decrypt(assembly, inbuf, in_len, tf_null_iv, priv->ctx);
}
len = in_len - TF_PREAMBLE_SIZE;
memcpy(outbuf,

Loading…
Cancel
Save