aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2015-03-27 10:25:01 +0100
committerMartin Willi <martin@revosec.ch>2015-04-15 11:35:25 +0200
commit3935d812b72da7fc85d8b05c8190a45beac625ac (patch)
tree9ee3310e4981579ce632e025a9610cc072718f36
parent466d560a336ba0f6e736394af743d3a434c3ab78 (diff)
downloadstrongswan-3935d812b72da7fc85d8b05c8190a45beac625ac.tar.bz2
strongswan-3935d812b72da7fc85d8b05c8190a45beac625ac.tar.xz
crypt-burn: Add a encryption buffer command line argument
-rw-r--r--scripts/crypt_burn.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/scripts/crypt_burn.c b/scripts/crypt_burn.c
index 138fcb2b3..092306c13 100644
--- a/scripts/crypt_burn.c
+++ b/scripts/crypt_burn.c
@@ -16,7 +16,7 @@
#include <stdio.h>
#include <library.h>
-static int burn_crypter(const proposal_token_t *token, u_int limit)
+static int burn_crypter(const proposal_token_t *token, u_int limit, u_int len)
{
chunk_t iv, key, data;
crypter_t *crypter;
@@ -34,7 +34,7 @@ static int burn_crypter(const proposal_token_t *token, u_int limit)
iv = chunk_alloc(crypter->get_iv_size(crypter));
memset(iv.ptr, 0xFF, iv.len);
- data = chunk_alloc(round_up(1024, crypter->get_block_size(crypter)));
+ data = chunk_alloc(round_up(len, crypter->get_block_size(crypter)));
memset(data.ptr, 0xDD, data.len);
key = chunk_alloc(crypter->get_key_size(crypter));
memset(key.ptr, 0xAA, key.len);
@@ -68,7 +68,7 @@ static int burn_crypter(const proposal_token_t *token, u_int limit)
return ok;
}
-static bool burn_aead(const proposal_token_t *token, u_int limit)
+static bool burn_aead(const proposal_token_t *token, u_int limit, u_int len)
{
chunk_t iv, key, data, dataicv, assoc;
aead_t *aead;
@@ -86,7 +86,7 @@ static bool burn_aead(const proposal_token_t *token, u_int limit)
iv = chunk_alloc(aead->get_iv_size(aead));
memset(iv.ptr, 0xFF, iv.len);
- dataicv = chunk_alloc(round_up(1024, aead->get_block_size(aead)) +
+ dataicv = chunk_alloc(round_up(len, aead->get_block_size(aead)) +
aead->get_icv_size(aead));
data = chunk_create(dataicv.ptr, dataicv.len - aead->get_icv_size(aead));
memset(data.ptr, 0xDD, data.len);
@@ -127,7 +127,7 @@ static bool burn_aead(const proposal_token_t *token, u_int limit)
int main(int argc, char *argv[])
{
const proposal_token_t *token;
- int limit = 0;
+ u_int limit = 0, len = 1024;
bool ok;
library_init(NULL, "crypt_burn");
@@ -138,12 +138,17 @@ int main(int argc, char *argv[])
if (argc < 2)
{
- fprintf(stderr, "usage: %s <algorithm>!\n", argv[0]);
+ fprintf(stderr, "usage: %s <algorithm> [buflen=%u] [rounds=%u]\n",
+ argv[0], len, limit);
return 1;
}
if (argc > 2)
{
- limit = atoi(argv[2]);
+ len = atoi(argv[2]);
+ }
+ if (argc > 3)
+ {
+ limit = atoi(argv[3]);
}
token = lib->proposal->get_token(lib->proposal, argv[1]);
@@ -158,11 +163,11 @@ int main(int argc, char *argv[])
case ENCRYPTION_ALGORITHM:
if (encryption_algorithm_is_aead(token->algorithm))
{
- ok = burn_aead(token, limit);
+ ok = burn_aead(token, limit, len);
}
else
{
- ok = burn_crypter(token, limit);
+ ok = burn_crypter(token, limit, len);
}
break;
default: