X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=shabea.c;h=62ff6b4a27e72b5af76223f3e8c06f09bd2df6de;hb=33c19d7ea9dafc19b818dd8de984dcf1543d7b37;hp=844788a00defbe64c5a08ae6fb1d5c624e83e9f2;hpb=639b9bea16571c3f3a901cefc4bca48f84b09705;p=avr-crypto-lib.git diff --git a/shabea.c b/shabea.c index 844788a..62ff6b4 100644 --- a/shabea.c +++ b/shabea.c @@ -1,8 +1,26 @@ +/* shabea.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 . +*/ /** * \file shabea.c * \author Daniel Otte * \date 2007-06-07 - * \brief SHABEA - a SHA Based Encrytion Algorithm implementation + * \brief SHABEA - a SHA Based Encryption Algorithm implementation * \par License * GPL * @@ -39,13 +57,12 @@ void memxor(uint8_t * dest, uint8_t * src, uint8_t length){ #define R ((uint8_t*)block+16) void shabea256(void * block, void * key, uint16_t keysize, uint8_t enc, uint8_t rounds){ int8_t r; /**/ - uint8_t *tb; /**/ + uint8_t tb[HALFSIZEB+2+(keysize+7)/8]; /**/ uint16_t kbs; /* bytes used for the key / temporary block */ sha256_hash_t hash; r = (enc?0:(rounds-1)); kbs = (keysize+7)/8; - tb = malloc(HALFSIZEB+2+kbs); memcpy(tb+HALFSIZEB+2, key, kbs); /* copy key to temporary block */ tb[HALFSIZEB+0] = 0; /* set round counter high value to zero */ @@ -63,7 +80,6 @@ void shabea256(void * block, void * key, uint16_t keysize, uint8_t enc, uint8_t memxor(L, hash, HALFSIZE); } } - free(tb); }