18c2ecf20Sopenharmony_ci/* b128ops.h - common 128-bit block operations 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. 48c2ecf20Sopenharmony_ci * Copyright (c) 2006, Rik Snel <rsnel@cube.dyndns.org> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Based on Dr Brian Gladman's (GPL'd) work published at 78c2ecf20Sopenharmony_ci * http://fp.gladman.plus.com/cryptography_technology/index.htm 88c2ecf20Sopenharmony_ci * See the original copyright notice below. 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify it 118c2ecf20Sopenharmony_ci * under the terms of the GNU General Public License as published by the Free 128c2ecf20Sopenharmony_ci * Software Foundation; either version 2 of the License, or (at your option) 138c2ecf20Sopenharmony_ci * any later version. 148c2ecf20Sopenharmony_ci */ 158c2ecf20Sopenharmony_ci/* 168c2ecf20Sopenharmony_ci --------------------------------------------------------------------------- 178c2ecf20Sopenharmony_ci Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved. 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci LICENSE TERMS 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci The free distribution and use of this software in both source and binary 228c2ecf20Sopenharmony_ci form is allowed (with or without changes) provided that: 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci 1. distributions of this source code include the above copyright 258c2ecf20Sopenharmony_ci notice, this list of conditions and the following disclaimer; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci 2. distributions in binary form include the above copyright 288c2ecf20Sopenharmony_ci notice, this list of conditions and the following disclaimer 298c2ecf20Sopenharmony_ci in the documentation and/or other associated materials; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci 3. the copyright holder's name is not used to endorse products 328c2ecf20Sopenharmony_ci built using this software without specific written permission. 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci ALTERNATIVELY, provided that this notice is retained in full, this product 358c2ecf20Sopenharmony_ci may be distributed under the terms of the GNU General Public License (GPL), 368c2ecf20Sopenharmony_ci in which case the provisions of the GPL apply INSTEAD OF those given above. 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci DISCLAIMER 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci This software is provided 'as is' with no explicit or implied warranties 418c2ecf20Sopenharmony_ci in respect of its properties, including, but not limited to, correctness 428c2ecf20Sopenharmony_ci and/or fitness for purpose. 438c2ecf20Sopenharmony_ci --------------------------------------------------------------------------- 448c2ecf20Sopenharmony_ci Issue Date: 13/06/2006 458c2ecf20Sopenharmony_ci*/ 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#ifndef _CRYPTO_B128OPS_H 488c2ecf20Sopenharmony_ci#define _CRYPTO_B128OPS_H 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#include <linux/types.h> 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_citypedef struct { 538c2ecf20Sopenharmony_ci u64 a, b; 548c2ecf20Sopenharmony_ci} u128; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_citypedef struct { 578c2ecf20Sopenharmony_ci __be64 a, b; 588c2ecf20Sopenharmony_ci} be128; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_citypedef struct { 618c2ecf20Sopenharmony_ci __le64 b, a; 628c2ecf20Sopenharmony_ci} le128; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cistatic inline void u128_xor(u128 *r, const u128 *p, const u128 *q) 658c2ecf20Sopenharmony_ci{ 668c2ecf20Sopenharmony_ci r->a = p->a ^ q->a; 678c2ecf20Sopenharmony_ci r->b = p->b ^ q->b; 688c2ecf20Sopenharmony_ci} 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistatic inline void be128_xor(be128 *r, const be128 *p, const be128 *q) 718c2ecf20Sopenharmony_ci{ 728c2ecf20Sopenharmony_ci u128_xor((u128 *)r, (u128 *)p, (u128 *)q); 738c2ecf20Sopenharmony_ci} 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cistatic inline void le128_xor(le128 *r, const le128 *p, const le128 *q) 768c2ecf20Sopenharmony_ci{ 778c2ecf20Sopenharmony_ci u128_xor((u128 *)r, (u128 *)p, (u128 *)q); 788c2ecf20Sopenharmony_ci} 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#endif /* _CRYPTO_B128OPS_H */ 81