]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/idea/idea_local.h
crypto/*: Fix various typos, repeated words, align some spelling to LDP.
[thirdparty/openssl.git] / crypto / idea / idea_local.h
CommitLineData
2039c421
RS
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
0f113f3e 3 *
aa2d9a76 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
2039c421
RS
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
d02b48c6
RE
8 */
9
d02b48c6
RE
10#define idea_mul(r,a,b,ul) \
11ul=(unsigned long)a*b; \
12if (ul != 0) \
0f113f3e
MC
13 { \
14 r=(ul&0xffff)-(ul>>16); \
15 r-=((r)>>16); \
16 } \
d02b48c6 17else \
0f113f3e 18 r=(-(int)a-b+1); /* assuming a or b is 0 and in range */
d02b48c6 19
d02b48c6 20/* NOTE - c is not incremented as per n2l */
0f113f3e
MC
21#define n2ln(c,l1,l2,n) { \
22 c+=n; \
23 l1=l2=0; \
24 switch (n) { \
25 case 8: l2 =((unsigned long)(*(--(c)))) ; \
2c54276e 26 /* fall through */ \
0f113f3e 27 case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
2c54276e 28 /* fall through */ \
0f113f3e 29 case 6: l2|=((unsigned long)(*(--(c))))<<16; \
2c54276e 30 /* fall through */ \
0f113f3e 31 case 5: l2|=((unsigned long)(*(--(c))))<<24; \
2c54276e 32 /* fall through */ \
0f113f3e 33 case 4: l1 =((unsigned long)(*(--(c)))) ; \
2c54276e 34 /* fall through */ \
0f113f3e 35 case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
2c54276e 36 /* fall through */ \
0f113f3e 37 case 2: l1|=((unsigned long)(*(--(c))))<<16; \
2c54276e 38 /* fall through */ \
0f113f3e
MC
39 case 1: l1|=((unsigned long)(*(--(c))))<<24; \
40 } \
41 }
d02b48c6
RE
42
43/* NOTE - c is not incremented as per l2n */
0f113f3e
MC
44#define l2nn(l1,l2,c,n) { \
45 c+=n; \
46 switch (n) { \
47 case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
2c54276e 48 /* fall through */ \
0f113f3e 49 case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
2c54276e 50 /* fall through */ \
0f113f3e 51 case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
2c54276e 52 /* fall through */ \
0f113f3e 53 case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
2c54276e 54 /* fall through */ \
0f113f3e 55 case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
2c54276e 56 /* fall through */ \
0f113f3e 57 case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
2c54276e 58 /* fall through */ \
0f113f3e 59 case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
2c54276e 60 /* fall through */ \
0f113f3e
MC
61 case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
62 } \
63 }
d02b48c6
RE
64
65#undef n2l
66#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
67 l|=((unsigned long)(*((c)++)))<<16L, \
68 l|=((unsigned long)(*((c)++)))<< 8L, \
69 l|=((unsigned long)(*((c)++))))
70
71#undef l2n
72#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
73 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
74 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
75 *((c)++)=(unsigned char)(((l) )&0xff))
76
77#undef s2n
0f113f3e
MC
78#define s2n(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
79 *((c)++)=(unsigned char)(((l)>> 8L)&0xff))
d02b48c6
RE
80
81#undef n2s
0f113f3e
MC
82#define n2s(c,l) (l =((IDEA_INT)(*((c)++)))<< 8L, \
83 l|=((IDEA_INT)(*((c)++))) )
d02b48c6 84
58964a49
RE
85
86#define E_IDEA(num) \
0f113f3e
MC
87 x1&=0xffff; \
88 idea_mul(x1,x1,*p,ul); p++; \
89 x2+= *(p++); \
90 x3+= *(p++); \
91 x4&=0xffff; \
92 idea_mul(x4,x4,*p,ul); p++; \
93 t0=(x1^x3)&0xffff; \
94 idea_mul(t0,t0,*p,ul); p++; \
95 t1=(t0+(x2^x4))&0xffff; \
96 idea_mul(t1,t1,*p,ul); p++; \
97 t0+=t1; \
98 x1^=t1; \
99 x4^=t0; \
100 ul=x2^t0; /* do the swap to x3 */ \
101 x2=x3^t1; \
102 x3=ul;