Back to home page

OSCL-LXR

 
 

    


0001 /* b128ops.h - common 128-bit block operations
0002  *
0003  * Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.
0004  * Copyright (c) 2006, Rik Snel <rsnel@cube.dyndns.org>
0005  *
0006  * Based on Dr Brian Gladman's (GPL'd) work published at
0007  * http://fp.gladman.plus.com/cryptography_technology/index.htm
0008  * See the original copyright notice below.
0009  *
0010  * This program is free software; you can redistribute it and/or modify it
0011  * under the terms of the GNU General Public License as published by the Free
0012  * Software Foundation; either version 2 of the License, or (at your option)
0013  * any later version.
0014  */
0015 /*
0016  ---------------------------------------------------------------------------
0017  Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.   All rights reserved.
0018 
0019  LICENSE TERMS
0020 
0021  The free distribution and use of this software in both source and binary
0022  form is allowed (with or without changes) provided that:
0023 
0024    1. distributions of this source code include the above copyright
0025       notice, this list of conditions and the following disclaimer;
0026 
0027    2. distributions in binary form include the above copyright
0028       notice, this list of conditions and the following disclaimer
0029       in the documentation and/or other associated materials;
0030 
0031    3. the copyright holder's name is not used to endorse products
0032       built using this software without specific written permission.
0033 
0034  ALTERNATIVELY, provided that this notice is retained in full, this product
0035  may be distributed under the terms of the GNU General Public License (GPL),
0036  in which case the provisions of the GPL apply INSTEAD OF those given above.
0037 
0038  DISCLAIMER
0039 
0040  This software is provided 'as is' with no explicit or implied warranties
0041  in respect of its properties, including, but not limited to, correctness
0042  and/or fitness for purpose.
0043  ---------------------------------------------------------------------------
0044  Issue Date: 13/06/2006
0045 */
0046 
0047 #ifndef _CRYPTO_B128OPS_H
0048 #define _CRYPTO_B128OPS_H
0049 
0050 #include <linux/types.h>
0051 
0052 typedef struct {
0053     u64 a, b;
0054 } u128;
0055 
0056 typedef struct {
0057     __be64 a, b;
0058 } be128;
0059 
0060 typedef struct {
0061     __le64 b, a;
0062 } le128;
0063 
0064 static inline void u128_xor(u128 *r, const u128 *p, const u128 *q)
0065 {
0066     r->a = p->a ^ q->a;
0067     r->b = p->b ^ q->b;
0068 }
0069 
0070 static inline void be128_xor(be128 *r, const be128 *p, const be128 *q)
0071 {
0072     u128_xor((u128 *)r, (u128 *)p, (u128 *)q);
0073 }
0074 
0075 static inline void le128_xor(le128 *r, const le128 *p, const le128 *q)
0076 {
0077     u128_xor((u128 *)r, (u128 *)p, (u128 *)q);
0078 }
0079 
0080 #endif /* _CRYPTO_B128OPS_H */