b128ops.h 2.4 KB

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