summaryrefslogtreecommitdiff
path: root/cesar/cp/secu/src
diff options
context:
space:
mode:
authorlaranjeiro2009-06-15 13:04:16 +0000
committerlaranjeiro2009-06-15 13:04:16 +0000
commit1cad1f444a2f085e3031c6efdf29e5b0b9b8615e (patch)
tree83fd30ffbfe1342414970d2a1135dd2517d93f5f /cesar/cp/secu/src
parent5c4119fe62c6ea3373b79961dd4ecd47781bc8cb (diff)
*cp/secu:
* Added the checkpoint function call on the AES cbc encrypt and decrypt function, when the loop variable is modulo CP_SECU_CHECKPOINT_ITERATION. * Use the define in the pbkdf1 function. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@4791 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp/secu/src')
-rw-r--r--cesar/cp/secu/src/pbkdf1.c2
-rw-r--r--cesar/cp/secu/src/secu.c23
2 files changed, 20 insertions, 5 deletions
diff --git a/cesar/cp/secu/src/pbkdf1.c b/cesar/cp/secu/src/pbkdf1.c
index e99ece2125..3615e6dd40 100644
--- a/cesar/cp/secu/src/pbkdf1.c
+++ b/cesar/cp/secu/src/pbkdf1.c
@@ -58,7 +58,7 @@ secu_pbkdf1 (cp_t *ctx, const u8 input[], const uint input_length,
uint i;
for (i = 1; i < it_count; i++)
{
- if ((i % 10) == 0)
+ if ((i % CP_SECU_CHECKPOINT_ITERATION) == 0)
cp_sta_core_checkpoint (ctx);
cp_secu_sha256 (sha_output, CP_SECU_SHA256_SIZE, sha_output);
}
diff --git a/cesar/cp/secu/src/secu.c b/cesar/cp/secu/src/secu.c
index e8257692a7..17b3cd2e4c 100644
--- a/cesar/cp/secu/src/secu.c
+++ b/cesar/cp/secu/src/secu.c
@@ -16,6 +16,7 @@
#include "lib/bitstream.h"
#include "cp/defs.h"
+#include "cp/sta/core/core.h"
#include "cp/secu/defs.h"
#include "cp/secu/secu.h"
#include "cp/secu/pbkdf1.h"
@@ -207,7 +208,7 @@ cp_secu_generate_hash (cp_t *ctx, const u32 seed, u8 *hash,
}
void
-cp_secu_aes_cbc_encrypt (cp_secu_aes_t *ctx, u32 iv[4],
+cp_secu_aes_cbc_encrypt (cp_t *ctx, cp_secu_aes_t *aes_ctx, u32 iv[4],
const u32 *input, u32 *output, int length)
{
/* Based on the Real AES CBC function, this one only work with word
@@ -215,12 +216,15 @@ cp_secu_aes_cbc_encrypt (cp_secu_aes_t *ctx, u32 iv[4],
int i;
int len;
u32 wb[4];
+ uint loop;
dbg_assert (ctx);
+ dbg_assert (aes_ctx);
dbg_assert (iv);
dbg_assert (input);
dbg_assert (output);
+ loop = 0;
while (length > 0)
{
len = (length > 16) ? 128 : length * 8;
@@ -231,7 +235,10 @@ cp_secu_aes_cbc_encrypt (cp_secu_aes_t *ctx, u32 iv[4],
len -= 32;
}
- cp_secu_aes_encrypt (ctx, wb, wb);
+ if (loop % CP_SECU_CHECKPOINT_ITERATION == 0)
+ cp_sta_core_checkpoint (ctx);
+
+ cp_secu_aes_encrypt (aes_ctx, wb, wb);
len = (length > 16) ? 128 : length * 8;
for (i = 0; len; i++)
@@ -244,23 +251,27 @@ cp_secu_aes_cbc_encrypt (cp_secu_aes_t *ctx, u32 iv[4],
input += 4;
output += 4;
length -= 16;
+ loop ++;
}
}
void
-cp_secu_aes_cbc_decrypt (cp_secu_aes_t *ctx, u32 iv[4],
+cp_secu_aes_cbc_decrypt (cp_t *ctx, cp_secu_aes_t *aes_ctx, u32 iv[4],
const u32 *input, u32 *output, int length)
{
int i;
u32 temp[4];
u32 wb[4];
int len;
+ uint loop;
dbg_assert (ctx);
+ dbg_assert (aes_ctx);
dbg_assert (iv);
dbg_assert (input);
dbg_assert (output);
+ loop = 0;
while (length > 0)
{
len = (length > 16) ? 128 : length * 8;
@@ -272,7 +283,10 @@ cp_secu_aes_cbc_decrypt (cp_secu_aes_t *ctx, u32 iv[4],
len -= 32;
}
- cp_secu_aes_decrypt (ctx, wb, wb);
+ if ((loop % CP_SECU_CHECKPOINT_ITERATION) == 0)
+ cp_sta_core_checkpoint (ctx);
+
+ cp_secu_aes_decrypt (aes_ctx, wb, wb);
for (i = 0; i < 4; i++)
wb[i] ^= iv[i];
@@ -290,6 +304,7 @@ cp_secu_aes_cbc_decrypt (cp_secu_aes_t *ctx, u32 iv[4],
input += 4;
output += 4;
length -= 16;
+ loop ++;
}
}