3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * \file shabal192-asm.S
22 * \email daniel.otte@rub.de
24 * \license GPLv3 or later
27 #include "avr-asm-macros.S"
31 .long 0xFD749ED4, 0xB798E530, 0x33904B6F, 0x46BDA85E
32 .long 0x076934B4, 0x454B4058, 0x77F74527, 0xFB4CF465
33 .long 0x62931DA9, 0xE778C8DB, 0x22B3998E, 0xAC15CFB9
35 .long 0x58BCBAC4, 0xEC47A08E, 0xAEE933B2, 0xDFCBC824
36 .long 0xA7944804, 0xBF65BDB0, 0x5A9D4502, 0x59979AF7
37 .long 0xC5CEA54E, 0x4B6B8150, 0x16E71909, 0x7D632319
38 .long 0x930573A0, 0xF34C63D1, 0xCAF914B4, 0xFDD6612C
40 .long 0x61550878, 0x89EF2B75, 0xA1660C46, 0x7EF3855B
41 .long 0x7297B58C, 0x1BC67793, 0x7FB1C723, 0xB66FC640
42 .long 0x1A48B71C, 0xF0976D17, 0x088CE80A, 0xA454EDF3
43 .long 0x1C096BF4, 0xAC76224B, 0x5215781C, 0xCD5D2669
46 /******************************************************************************/
48 void shabal192_init(shabal_ctx_t* ctx){
50 ctx->b = ctx->b_buffer;
51 ctx->c = ctx->c_buffer;
53 for(i=0;i<SHABAL_R;++i){
54 ctx->a[i] = pgm_read_dword(&(shabal192_iv[i]));
57 ctx->b[i] = pgm_read_dword(&(shabal192_iv[SHABAL_R+i]));
60 ctx->c[i] = pgm_read_dword(&(shabal192_iv[SHABAL_R+16+i]));
67 .global shabal192_init
88 ldi r30, lo8(shabal192_iv)
89 ldi r31, hi8(shabal192_iv)
102 /******************************************************************************/
104 * param dest: r24:r25
107 .global shabal192_ctx2hash
114 adiw r30, (16-192/32)*4
122 /******************************************************************************/
124 void shabal192(void* dest, void* msg, uint32_t length_b){
126 shabal192_init(&ctx);
127 while(length_b>=SHABAL_BLOCKSIZE){
128 shabal_nextBlock(&ctx, msg);
129 msg = (uint8_t*)msg+SHABAL_BLOCKSIZE_B;
130 length_b -= SHABAL_BLOCKSIZE;
132 shabal_lastBlock(&ctx, msg, length_b);
133 shabal192_ctx2hash(dest, &ctx);
137 * param dest: r24:r25
139 * param length_b: r18:r21
154 stack_alloc_large 188
155 adiw r30, 1 /* Z points to stack space (ctx) */
171 rcall shabal_nextBlock
183 rcall shabal_lastBlock
186 rcall shabal192_ctx2hash
187 stack_free_large2 188