X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=bmw%2Fbmw_small.c;fp=bmw%2Fbmw_small.c;h=aefd592d2212eff728d2d8c749d5249495f1ca8b;hb=d32eba56ce10ea6b9eff123b50d9842673b38f2b;hp=0000000000000000000000000000000000000000;hpb=8f855d283a31a468ea014774c4723a8b77b81644;p=avr-crypto-lib.git diff --git a/bmw/bmw_small.c b/bmw/bmw_small.c new file mode 100644 index 0000000..aefd592 --- /dev/null +++ b/bmw/bmw_small.c @@ -0,0 +1,461 @@ +/* bmw_small.c */ +/* + This file is part of the AVR-Crypto-Lib. + Copyright (C) 2009 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 . +*/ +/* + * \file bmw_small.c + * \author Daniel Otte + * \email daniel.otte@rub.de + * \date 2009-04-27 + * \license GPLv3 or later + * + */ + +#include +#include +#include +#include "bmw_small.h" + + +#define SHL32(a,n) ((a)<<(n)) +#define SHR32(a,n) ((a)>>(n)) +#define ROTL32(a,n) (((a)<<(n))|((a)>>(32-(n)))) +#define ROTR32(a,n) (((a)>>(n))|((a)<<(32-(n)))) + +#define BUG24 0 +#define F0_HACK 1 + +#define DEBUG 0 +#if DEBUG + #include "cli.h" + + void ctx_dump(const bmw_small_ctx_t* ctx){ + uint8_t i; + cli_putstr_P(PSTR("\r\n==== ctx dump ====")); + for(i=0; i<16;++i){ + cli_putstr_P(PSTR("\r\n h[")); + cli_hexdump(&i, 1); + cli_putstr_P(PSTR("] = ")); + cli_hexdump_rev(&(ctx->h[i]), 4); + } + cli_putstr_P(PSTR("\r\n counter = ")); + cli_hexdump(&(ctx->counter), 4); + } + + void dump_x(const uint32_t* q, uint8_t elements, char x){ + uint8_t i; + cli_putstr_P(PSTR("\r\n==== ")); + cli_putc(x); + cli_putstr_P(PSTR(" dump ====")); + for(i=0; i