^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* b128ops.h - common 128-bit block operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2006, Rik Snel <rsnel@cube.dyndns.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Based on Dr Brian Gladman's (GPL'd) work published at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * http://fp.gladman.plus.com/cryptography_technology/index.htm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * See the original copyright notice below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * This program is free software; you can redistribute it and/or modify it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * under the terms of the GNU General Public License as published by the Free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Software Foundation; either version 2 of the License, or (at your option)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) LICENSE TERMS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) The free distribution and use of this software in both source and binary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) form is allowed (with or without changes) provided that:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 1. distributions of this source code include the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) notice, this list of conditions and the following disclaimer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 2. distributions in binary form include the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) notice, this list of conditions and the following disclaimer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) in the documentation and/or other associated materials;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 3. the copyright holder's name is not used to endorse products
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) built using this software without specific written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) ALTERNATIVELY, provided that this notice is retained in full, this product
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) may be distributed under the terms of the GNU General Public License (GPL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) in which case the provisions of the GPL apply INSTEAD OF those given above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) DISCLAIMER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) This software is provided 'as is' with no explicit or implied warranties
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) in respect of its properties, including, but not limited to, correctness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) and/or fitness for purpose.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) Issue Date: 13/06/2006
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #ifndef _CRYPTO_B128OPS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define _CRYPTO_B128OPS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) u64 a, b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) } u128;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) __be64 a, b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) } be128;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) __le64 b, a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) } le128;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static inline void u128_xor(u128 *r, const u128 *p, const u128 *q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) r->a = p->a ^ q->a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) r->b = p->b ^ q->b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static inline void be128_xor(be128 *r, const be128 *p, const be128 *q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) u128_xor((u128 *)r, (u128 *)p, (u128 *)q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) static inline void le128_xor(le128 *r, const le128 *p, const le128 *q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) u128_xor((u128 *)r, (u128 *)p, (u128 *)q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #endif /* _CRYPTO_B128OPS_H */