diff options
Diffstat (limited to 'scripts/crypt_burn.c')
-rw-r--r-- | scripts/crypt_burn.c | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/scripts/crypt_burn.c b/scripts/crypt_burn.c index 5c41b191b..449364a1a 100644 --- a/scripts/crypt_burn.c +++ b/scripts/crypt_burn.c @@ -1,7 +1,20 @@ +/* + * Copyright (C) 2010 Martin Willi + * Copyright (C) 2010 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ #include <stdio.h> #include <library.h> -#include <crypto/proposal/proposal_keywords.h> int main(int argc, char *argv[]) { @@ -33,7 +46,7 @@ int main(int argc, char *argv[]) limit = atoi(argv[2]); } - token = proposal_get_token(argv[1], strlen(argv[1])); + token = lib->proposal->get_token(lib->proposal, argv[1]); if (!token) { fprintf(stderr, "algorithm '%s' unknown!\n", argv[1]); @@ -56,10 +69,14 @@ int main(int argc, char *argv[]) } while (TRUE) { - aead->encrypt(aead, + if (!aead->encrypt(aead, chunk_create(buffer, sizeof(buffer) - aead->get_icv_size(aead)), chunk_from_thing(assoc), - chunk_create(iv, aead->get_iv_size(aead)), NULL); + chunk_create(iv, aead->get_iv_size(aead)), NULL)) + { + fprintf(stderr, "aead encryption failed!\n"); + return 1; + } if (!aead->decrypt(aead, chunk_create(buffer, sizeof(buffer)), chunk_from_thing(assoc), chunk_create(iv, aead->get_iv_size(aead)), NULL)) @@ -86,12 +103,18 @@ int main(int argc, char *argv[]) while (i--) { - crypter->encrypt(crypter, - chunk_create(buffer, sizeof(buffer) / bs * bs), - chunk_create(iv, crypter->get_iv_size(crypter)), NULL); - crypter->decrypt(crypter, - chunk_create(buffer, sizeof(buffer) / bs * bs), - chunk_create(iv, crypter->get_iv_size(crypter)), NULL); + if (!crypter->encrypt(crypter, + chunk_create(buffer, sizeof(buffer) / bs * bs), + chunk_create(iv, crypter->get_iv_size(crypter)), NULL)) + { + continue; + } + if (!crypter->decrypt(crypter, + chunk_create(buffer, sizeof(buffer) / bs * bs), + chunk_create(iv, crypter->get_iv_size(crypter)), NULL)) + { + continue; + } if (limit && ++i == limit) { break; |