]>
Commit | Line | Data |
---|---|---|
b1322259 RS |
1 | /* |
2 | * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. | |
d02b48c6 | 3 | * |
8b00b7b8 | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
b1322259 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 | ||
11e4b79a | 10 | #ifndef HEADER_BF_LOCL_H |
0f113f3e | 11 | # define HEADER_BF_LOCL_H |
dc193c9c | 12 | # include <openssl/opensslconf.h> |
d02b48c6 RE |
13 | |
14 | /* NOTE - c is not incremented as per n2l */ | |
0f113f3e MC |
15 | # define n2ln(c,l1,l2,n) { \ |
16 | c+=n; \ | |
17 | l1=l2=0; \ | |
18 | switch (n) { \ | |
19 | case 8: l2 =((unsigned long)(*(--(c)))) ; \ | |
018fcbec | 20 | /* fall thru */ \ |
0f113f3e | 21 | case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ |
018fcbec | 22 | /* fall thru */ \ |
0f113f3e | 23 | case 6: l2|=((unsigned long)(*(--(c))))<<16; \ |
018fcbec | 24 | /* fall thru */ \ |
0f113f3e | 25 | case 5: l2|=((unsigned long)(*(--(c))))<<24; \ |
018fcbec | 26 | /* fall thru */ \ |
0f113f3e | 27 | case 4: l1 =((unsigned long)(*(--(c)))) ; \ |
018fcbec | 28 | /* fall thru */ \ |
0f113f3e | 29 | case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ |
018fcbec | 30 | /* fall thru */ \ |
0f113f3e | 31 | case 2: l1|=((unsigned long)(*(--(c))))<<16; \ |
018fcbec | 32 | /* fall thru */ \ |
0f113f3e MC |
33 | case 1: l1|=((unsigned long)(*(--(c))))<<24; \ |
34 | } \ | |
35 | } | |
d02b48c6 RE |
36 | |
37 | /* NOTE - c is not incremented as per l2n */ | |
0f113f3e MC |
38 | # define l2nn(l1,l2,c,n) { \ |
39 | c+=n; \ | |
40 | switch (n) { \ | |
41 | case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ | |
018fcbec | 42 | /* fall thru */ \ |
0f113f3e | 43 | case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ |
018fcbec | 44 | /* fall thru */ \ |
0f113f3e | 45 | case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ |
018fcbec | 46 | /* fall thru */ \ |
0f113f3e | 47 | case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ |
018fcbec | 48 | /* fall thru */ \ |
0f113f3e | 49 | case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ |
018fcbec | 50 | /* fall thru */ \ |
0f113f3e | 51 | case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ |
018fcbec | 52 | /* fall thru */ \ |
0f113f3e | 53 | case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ |
018fcbec | 54 | /* fall thru */ \ |
0f113f3e MC |
55 | case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ |
56 | } \ | |
57 | } | |
58 | ||
59 | # undef n2l | |
60 | # define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ | |
d02b48c6 RE |
61 | l|=((unsigned long)(*((c)++)))<<16L, \ |
62 | l|=((unsigned long)(*((c)++)))<< 8L, \ | |
63 | l|=((unsigned long)(*((c)++)))) | |
64 | ||
0f113f3e MC |
65 | # undef l2n |
66 | # define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ | |
d02b48c6 RE |
67 | *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ |
68 | *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ | |
69 | *((c)++)=(unsigned char)(((l) )&0xff)) | |
70 | ||
0f113f3e MC |
71 | /* |
72 | * This is actually a big endian algorithm, the most significant byte is used | |
73 | * to lookup array 0 | |
74 | */ | |
d02b48c6 | 75 | |
3e9e810f | 76 | # define BF_ENC(LL,R,S,P) ( \ |
0f113f3e | 77 | LL^=P, \ |
3e9e810f RS |
78 | LL^=((( S[ ((R>>24)&0xff)] + \ |
79 | S[0x0100+((R>>16)&0xff)])^ \ | |
80 | S[0x0200+((R>> 8)&0xff)])+ \ | |
81 | S[0x0300+((R )&0xff)])&0xffffffffU \ | |
0f113f3e | 82 | ) |
8e10f2b3 UM |
83 | |
84 | #endif |