1 /**********************************************************************
2 Copyright(c) 2011-2015 Intel Corporation All rights reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
13 * Neither the name of Intel Corporation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 **********************************************************************/
33 #if __WORDSIZE == 64 || _WIN64 || __x86_64__
34 # define notbit0 0xfefefefefefefefeULL
35 # define bit7 0x8080808080808080ULL
36 # define gf8poly 0x1d1d1d1d1d1d1d1dULL
38 # define notbit0 0xfefefefeUL
39 # define bit7 0x80808080UL
40 # define gf8poly 0x1d1d1d1dUL
43 int pq_gen_base(int vects
, int len
, void **array
)
46 unsigned long p
, q
, s
;
47 unsigned long **src
= (unsigned long **)array
;
48 int blocks
= len
/ sizeof(long);
50 for (i
= 0; i
< blocks
; i
++) {
51 q
= p
= src
[vects
- 3][i
];
53 for (j
= vects
- 4; j
>= 0; j
--) {
55 q
= s
^ (((q
<< 1) & notbit0
) ^ // shift each byte
56 ((((q
& bit7
) << 1) - ((q
& bit7
) >> 7)) // mask out bytes
57 & gf8poly
)); // apply poly
60 src
[vects
- 2][i
] = p
; // second to last pointer is p
61 src
[vects
- 1][i
] = q
; // last pointer is q
66 int pq_check_base(int vects
, int len
, void **array
)
69 unsigned char p
, q
, s
;
70 unsigned char **src
= (unsigned char **)array
;
72 for (i
= 0; i
< len
; i
++) {
73 q
= p
= src
[vects
- 3][i
];
75 for (j
= vects
- 4; j
>= 0; j
--) {
80 q
= s
^ ((q
<< 1) ^ ((q
& 0x80) ? 0x1d : 0));
83 if (src
[vects
- 2][i
] != p
) // second to last pointer is p
85 if (src
[vects
- 1][i
] != q
) // last pointer is q
91 int xor_gen_base(int vects
, int len
, void **array
)
95 unsigned char **src
= (unsigned char **)array
;
97 for (i
= 0; i
< len
; i
++) {
99 for (j
= 1; j
< vects
- 1; j
++)
102 src
[vects
- 1][i
] = parity
; // last pointer is dest
109 int xor_check_base(int vects
, int len
, void **array
)
113 unsigned char parity
;
114 unsigned char **src
= (unsigned char **)array
;
116 for (i
= 0; i
< len
; i
++) {
118 for (j
= 0; j
< vects
; j
++)
137 struct slver pq_gen_base_slver_0001012a
;
138 struct slver pq_gen_base_slver
= { 0x012a, 0x01, 0x00 };
140 struct slver xor_gen_base_slver_0001012b
;
141 struct slver xor_gen_base_slver
= { 0x012b, 0x01, 0x00 };
143 struct slver pq_check_base_slver_0001012c
;
144 struct slver pq_check_base_slver
= { 0x012c, 0x01, 0x00 };
146 struct slver xor_check_base_slver_0001012d
;
147 struct slver xor_check_base_slver
= { 0x012d, 0x01, 0x00 };