X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=nessie_bc_test.c;h=f9a91e547a8f82f745e9f9df73201d0da8245e50;hb=96ebafd201c9e8441c7677577b24aa402c1defc6;hp=11deea73aadf0d18da56a5f811c0fe76190e6c13;hpb=2aee09dcaf731b4086e7cdb865ee77b2715ce751;p=avr-crypto-lib.git diff --git a/nessie_bc_test.c b/nessie_bc_test.c index 11deea7..f9a91e5 100644 --- a/nessie_bc_test.c +++ b/nessie_bc_test.c @@ -1,3 +1,21 @@ +/* nessie_bc_test.c */ +/* + This file is part of the Crypto-avr-lib/microcrypt-lib. + Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + + 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 3 of the License, or + (at your option) any later version. + + 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. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ /** * * author: Daniel Otte @@ -32,13 +50,15 @@ void nessie_bc_enc(uint8_t* key, uint8_t* pt){ /* single test */ nessie_print_item("key", key, (nessie_bc_ctx.keysize_b+7)/8); nessie_bc_ctx.cipher_genctx(key, nessie_bc_ctx.keysize_b, ctx); + memcpy(buffer, pt, nessie_bc_ctx.blocksize_B); nessie_print_item("plain", buffer, nessie_bc_ctx.blocksize_B); nessie_bc_ctx.cipher_enc(buffer, ctx); nessie_print_item("cipher", buffer, nessie_bc_ctx.blocksize_B); - nessie_bc_ctx.cipher_dec(buffer, ctx); - nessie_print_item("decrypted", buffer, nessie_bc_ctx.blocksize_B); - + if(nessie_bc_ctx.cipher_dec){ + nessie_bc_ctx.cipher_dec(buffer, ctx); + nessie_print_item("decrypted", buffer, nessie_bc_ctx.blocksize_B); + } /* 100 times test */ memcpy(buffer, pt, nessie_bc_ctx.blocksize_B); for(i=0; i<100; ++i){ @@ -136,6 +156,8 @@ void nessie_bc_run(void){ } nessie_bc_enc(key, buffer); /* half done ;-) */ + if(nessie_bc_ctx.cipher_dec==NULL) + return; /* test set 5 */ set=5; nessie_print_setheader(set);