From: Martin Willi Date: Fri, 27 Mar 2015 09:25:01 +0000 (+0100) Subject: crypt-burn: Add a encryption buffer command line argument X-Git-Tag: 5.3.1dr1~17^2~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3935d812b72da7fc85d8b05c8190a45beac625ac;p=thirdparty%2Fstrongswan.git crypt-burn: Add a encryption buffer command line argument --- diff --git a/scripts/crypt_burn.c b/scripts/crypt_burn.c index 138fcb2b3a..092306c138 100644 --- a/scripts/crypt_burn.c +++ b/scripts/crypt_burn.c @@ -16,7 +16,7 @@ #include #include -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 !\n", argv[0]); + fprintf(stderr, "usage: %s [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: