#include "memxor.h"
#include "cubehash.h"
+#include "cubehash_rotates.h"
#include <string.h>
#include <stdint.h>
-static uint32_t rol32(uint32_t a, uint8_t r){
- return (a<<r)|(a>>(32-r));
-}
/*
• Add x_0jklm into x_1jklm modulo 232 , for each (j, k, l, m).
• Rotate x_0jklm upwards by 7 bits, for each (j, k, l, m).
uint32_t t;
for(i=0; i<16; ++i){
ctx->a[i+16] += ctx->a[i];
- }
- for(i=0; i<16; ++i){
- ctx->a[i] = rol32(ctx->a[i], 7);
+ ctx->a[i] = rotate7left(ctx->a[i]);
}
for(i=0; i<8; ++i){
t = ctx->a[i];
}
for(i=0; i<16; ++i){
ctx->a[i+16] += ctx->a[i];
- }
- for(i=0; i<16; ++i){
- ctx->a[i] = rol32(ctx->a[i], 11);
+ ctx->a[i] = rotate11left(ctx->a[i]);
}
for(i=0; i<4; ++i){
t = ctx->a[i];
--- /dev/null
+/* cubehash_rotates.S */
+/*
+ This file is part of the ARM-Crypto-Lib.
+ Copyright (C) 2006-2010 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 <http://www.gnu.org/licenses/>.
+*/
+
+.global rotate7left
+rotate7left:
+ mov r0, r25
+ mov r25, r24
+ mov r24, r23
+ mov r23, r22
+ mov r22, r0
+ ror r0
+ ror r25
+ ror r24
+ ror r23
+ ror r22
+ ret
+
+.global rotate11left
+rotate11left:
+ mov r0, r25
+ mov r25, r24
+ mov r24, r23
+ mov r23, r22
+ mov r22, r0
+ rol r0
+ rol r23
+ rol r24
+ rol r25
+ rol r22
+ rol r0
+ rol r23
+ rol r24
+ rol r25
+ rol r22
+ rol r0
+ rol r23
+ rol r24
+ rol r25
+ rol r22
+ ret
+
--- /dev/null
+/* cubehash_rotates.h */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2010 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 <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef CUBEHASH_ROTATES_H_
+#define CUBEHASH_ROTATES_H_
+
+#include <stdint.h>
+
+uint32_t rotate7left(uint32_t a);
+uint32_t rotate11left(uint32_t a);
+
+#endif /* CUBEHASH_ROTATES_H_ */
0xf1, 0xd0, 0x21, 0x78,
};
-uint64_t rotl64(uint64_t a, uint8_t r){
- return (a<<r)|(a>>(64-r));
-}
-
static uint8_t r[5][5] PROGMEM = {
{ ROT_CODE( 0), ROT_CODE(36), ROT_CODE( 3), ROT_CODE(41), ROT_CODE(18) },
{ ROT_CODE( 1), ROT_CODE(44), ROT_CODE(10), ROT_CODE(45), ROT_CODE( 2) },
HASHES += $(ALGO_NAME)
$(ALGO_NAME)_DIR := cubehash/
-$(ALGO_NAME)_OBJ := cubehash.o memxor.o
+$(ALGO_NAME)_OBJ := cubehash.o cubehash_rotates.o memxor.o
$(ALGO_NAME)_TEST_BIN := main-cubehash-test.o hfal_cubehash.o $(CLI_STD) $(HFAL_STD)
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance