]> pd.if.org Git - zpackage/blob - libtomcrypt/src/mac/pmac/pmac_shift_xor.c
49d48f981fcd091c11000a0f83b7f2e14ac3e41c
[zpackage] / libtomcrypt / src / mac / pmac / pmac_shift_xor.c
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
2  *
3  * LibTomCrypt is a library that provides various cryptographic
4  * algorithms in a highly modular and flexible manner.
5  *
6  * The library is free for all purposes without any express
7  * guarantee it works.
8  */
9 #include "tomcrypt.h"
10
11 /**
12    @file pmac_shift_xor.c
13    PMAC implementation, internal function, by Tom St Denis
14 */
15
16 #ifdef LTC_PMAC
17
18 /**
19   Internal function.  Performs the state update (adding correct multiple)
20   @param pmac   The PMAC state.
21 */
22 void pmac_shift_xor(pmac_state *pmac)
23 {
24    int x, y;
25    y = pmac_ntz(pmac->block_index++);
26 #ifdef LTC_FAST
27    for (x = 0; x < pmac->block_len; x += sizeof(LTC_FAST_TYPE)) {
28        *(LTC_FAST_TYPE_PTR_CAST((unsigned char *)pmac->Li + x)) ^=
29        *(LTC_FAST_TYPE_PTR_CAST((unsigned char *)pmac->Ls[y] + x));
30    }
31 #else
32    for (x = 0; x < pmac->block_len; x++) {
33        pmac->Li[x] ^= pmac->Ls[y][x];
34    }
35 #endif
36 }
37
38 #endif
39
40 /* ref:         $Format:%D$ */
41 /* git commit:  $Format:%H$ */
42 /* commit time: $Format:%ai$ */