VirtualBox

source: vbox/trunk/src/libs/openssl-1.1.0g/crypto/idea/idea_lcl.h@ 69881

Last change on this file since 69881 was 69881, checked in by vboxsync, 7 years ago

Update OpenSSL to 1.1.0g.
bugref:8070: src/libs maintenance

  • Property svn:eol-style set to native
File size: 5.1 KB
Line 
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
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
8 */
9
10/*
11 * The new form of this macro (check if the a*b == 0) was suggested by Colin
12 * Plumb <[email protected]>
13 */
14/* Removal of the inner if from from Wei Dai 24/4/96 */
15#define idea_mul(r,a,b,ul) \
16ul=(unsigned long)a*b; \
17if (ul != 0) \
18 { \
19 r=(ul&0xffff)-(ul>>16); \
20 r-=((r)>>16); \
21 } \
22else \
23 r=(-(int)a-b+1); /* assuming a or b is 0 and in range */
24
25/*
26 * 7/12/95 - Many thanks to Rhys Weatherley <[email protected]> for
27 * pointing out that I was assuming little endian byte order for all
28 * quantities what idea actually used bigendian. No where in the spec does
29 * it mention this, it is all in terms of 16 bit numbers and even the example
30 * does not use byte streams for the input example :-(. If you byte swap each
31 * pair of input, keys and iv, the functions would produce the output as the
32 * old version :-(.
33 */
34
35/* NOTE - c is not incremented as per n2l */
36#define n2ln(c,l1,l2,n) { \
37 c+=n; \
38 l1=l2=0; \
39 switch (n) { \
40 case 8: l2 =((unsigned long)(*(--(c)))) ; \
41 /* fall thru */ \
42 case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
43 /* fall thru */ \
44 case 6: l2|=((unsigned long)(*(--(c))))<<16; \
45 /* fall thru */ \
46 case 5: l2|=((unsigned long)(*(--(c))))<<24; \
47 /* fall thru */ \
48 case 4: l1 =((unsigned long)(*(--(c)))) ; \
49 /* fall thru */ \
50 case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
51 /* fall thru */ \
52 case 2: l1|=((unsigned long)(*(--(c))))<<16; \
53 /* fall thru */ \
54 case 1: l1|=((unsigned long)(*(--(c))))<<24; \
55 } \
56 }
57
58/* NOTE - c is not incremented as per l2n */
59#define l2nn(l1,l2,c,n) { \
60 c+=n; \
61 switch (n) { \
62 case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
63 /* fall thru */ \
64 case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
65 /* fall thru */ \
66 case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
67 /* fall thru */ \
68 case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
69 /* fall thru */ \
70 case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
71 /* fall thru */ \
72 case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
73 /* fall thru */ \
74 case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
75 /* fall thru */ \
76 case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
77 } \
78 }
79
80#undef n2l
81#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
82 l|=((unsigned long)(*((c)++)))<<16L, \
83 l|=((unsigned long)(*((c)++)))<< 8L, \
84 l|=((unsigned long)(*((c)++))))
85
86#undef l2n
87#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
88 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
89 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
90 *((c)++)=(unsigned char)(((l) )&0xff))
91
92#undef s2n
93#define s2n(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
94 *((c)++)=(unsigned char)(((l)>> 8L)&0xff))
95
96#undef n2s
97#define n2s(c,l) (l =((IDEA_INT)(*((c)++)))<< 8L, \
98 l|=((IDEA_INT)(*((c)++))) )
99
100
101#define E_IDEA(num) \
102 x1&=0xffff; \
103 idea_mul(x1,x1,*p,ul); p++; \
104 x2+= *(p++); \
105 x3+= *(p++); \
106 x4&=0xffff; \
107 idea_mul(x4,x4,*p,ul); p++; \
108 t0=(x1^x3)&0xffff; \
109 idea_mul(t0,t0,*p,ul); p++; \
110 t1=(t0+(x2^x4))&0xffff; \
111 idea_mul(t1,t1,*p,ul); p++; \
112 t0+=t1; \
113 x1^=t1; \
114 x4^=t0; \
115 ul=x2^t0; /* do the swap to x3 */ \
116 x2=x3^t1; \
117 x3=ul;
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette