Fix: PEM_read_bio_PrivateKey with no-ui / no-stdio
[openssl.git] / crypto / rc2 / rc2_locl.h
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 #undef c2l
11 #define c2l(c,l)        (l =((unsigned long)(*((c)++)))    , \
12                          l|=((unsigned long)(*((c)++)))<< 8L, \
13                          l|=((unsigned long)(*((c)++)))<<16L, \
14                          l|=((unsigned long)(*((c)++)))<<24L)
15
16 /* NOTE - c is not incremented as per c2l */
17 #undef c2ln
18 #define c2ln(c,l1,l2,n) { \
19                         c+=n; \
20                         l1=l2=0; \
21                         switch (n) { \
22                         case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
23                         case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
24                         case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
25                         case 5: l2|=((unsigned long)(*(--(c))));     \
26                         case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
27                         case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
28                         case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
29                         case 1: l1|=((unsigned long)(*(--(c))));     \
30                                 } \
31                         }
32
33 #undef l2c
34 #define l2c(l,c)        (*((c)++)=(unsigned char)(((l)     )&0xff), \
35                          *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
36                          *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
37                          *((c)++)=(unsigned char)(((l)>>24L)&0xff))
38
39 /* NOTE - c is not incremented as per l2c */
40 #undef l2cn
41 #define l2cn(l1,l2,c,n) { \
42                         c+=n; \
43                         switch (n) { \
44                         case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
45                         case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
46                         case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
47                         case 5: *(--(c))=(unsigned char)(((l2)     )&0xff); \
48                         case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
49                         case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
50                         case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
51                         case 1: *(--(c))=(unsigned char)(((l1)     )&0xff); \
52                                 } \
53                         }
54
55 /* NOTE - c is not incremented as per n2l */
56 #define n2ln(c,l1,l2,n) { \
57                         c+=n; \
58                         l1=l2=0; \
59                         switch (n) { \
60                         case 8: l2 =((unsigned long)(*(--(c))))    ; \
61                         case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
62                         case 6: l2|=((unsigned long)(*(--(c))))<<16; \
63                         case 5: l2|=((unsigned long)(*(--(c))))<<24; \
64                         case 4: l1 =((unsigned long)(*(--(c))))    ; \
65                         case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
66                         case 2: l1|=((unsigned long)(*(--(c))))<<16; \
67                         case 1: l1|=((unsigned long)(*(--(c))))<<24; \
68                                 } \
69                         }
70
71 /* NOTE - c is not incremented as per l2n */
72 #define l2nn(l1,l2,c,n) { \
73                         c+=n; \
74                         switch (n) { \
75                         case 8: *(--(c))=(unsigned char)(((l2)    )&0xff); \
76                         case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
77                         case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
78                         case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
79                         case 4: *(--(c))=(unsigned char)(((l1)    )&0xff); \
80                         case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
81                         case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
82                         case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
83                                 } \
84                         }
85
86 #undef n2l
87 #define n2l(c,l)        (l =((unsigned long)(*((c)++)))<<24L, \
88                          l|=((unsigned long)(*((c)++)))<<16L, \
89                          l|=((unsigned long)(*((c)++)))<< 8L, \
90                          l|=((unsigned long)(*((c)++))))
91
92 #undef l2n
93 #define l2n(l,c)        (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
94                          *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
95                          *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
96                          *((c)++)=(unsigned char)(((l)     )&0xff))
97
98 #define C_RC2(n) \
99         t=(x0+(x1& ~x3)+(x2&x3)+ *(p0++))&0xffff; \
100         x0=(t<<1)|(t>>15); \
101         t=(x1+(x2& ~x0)+(x3&x0)+ *(p0++))&0xffff; \
102         x1=(t<<2)|(t>>14); \
103         t=(x2+(x3& ~x1)+(x0&x1)+ *(p0++))&0xffff; \
104         x2=(t<<3)|(t>>13); \
105         t=(x3+(x0& ~x2)+(x1&x2)+ *(p0++))&0xffff; \
106         x3=(t<<5)|(t>>11);