linux/crypto/gf128mul.c
<<
2.1" /spapti /formti a 2.1" href="../linux+v3 v7/crypto/gf128mul.c">2.1" img src="../.static/gfx/right.png" alt=">>">2. /spapti2. spap class="lxr_search">2.1"2.1" input typvalhidden" namvalnavtarget" ion val">2.1" input typvaltext" namvalsearch" idalsearch">2.1" buttopttypvalsubmit">Search2.1" Prefsi /a>2. /spapti1" /divti1" form ac2. input typvalhidden" namvalajax_lookup" idalajax_lookup" ion val">21" /formti21" div class="headingbottom">i div idalfile_contents"t
   1 /a> spap class="comment">/* gf128mul.c - GF(2^128) multiplica    2 /a> spap class="comment"> * /spapti   3 /a> spap class="comment"> * Copyright (c) 2003, Dr Briap Gladman, Worcester, UK. /spapti   4 /a> spap class="comment"> * Copyright (c) 2006, Rik Snel <rsnel@cube.dyndns.org> /spapti   5 /a> spap class="comment"> * /spapti   6 /a> spap class="comment"> * Based on Dr Briap Gladman's (GPL'd) work published at /spapti   7 /a> spap class="comment"> * http://gladman.plushost.co.uk/oldsite/cryptography_technology/index.php /spapti   8 /a> spap class="comment"> * See the original copyright notice below. /spapti   9 /a> spap class="comment"> * /spapti  .17.a> spap class="comment"> * This program is free software; you cap redistribute it and/or modify it /spapti  11 /a> spap class="comment"> * under the terms of the GNU General Public License as published by the Free /spapti  12 /a> spap class="comment"> * Software Founda   13 /a> spap class="comment"> * any later vers  14 /a> spap class="comment"> */ /spapti  15 /a>i  16 /a> spap class="comment">/* /spapti  17 /a> spap class="comment"> --------------------------------------------------------------------------- /spapti  18 /a> spap class="comment"> Copyright (c) 2003, Dr Briap Gladman, Worcester, UK.   All rights reserved. /spapti  19 /a>i  217.a> spap class="comment"> LICENSE TERMS /spapti  21 /a>i  22 /a> spap class="comment"> The free distribut  23 /a> spap class="comment"> form is allowed (with or without changes) provided that: /spapti  24 /a>i  25 /a> spap class="comment">   1. distribut  26 /a> spap class="comment">      notice, this list of condit  27 /a>i  28 /a> spap class="comment">   2. distribut  29 /a> spap class="comment">      notice, this list of condit  317.a> spap class="comment">      in the documentat  31 /a>i  32 /a> spap class="comment">   3. the copyright holder's namv is not used to endorse products /spapti  33 /a> spap class="comment">      built using this software without specific written permiss  34 /a>i  35 /a> spap class="comment"> ALTERNATIVELY, provided that this notice is retained in full, this product /spapti  36 /a> spap class="comment"> may be distributed under the terms of the GNU General Public License (GPL), /spapti  37 /a> spap class="comment"> in which case the provis  38 /a>i  39 /a> spap class="comment"> DISCLAIMER /spapti  40 /a>i  41 /a> spap class="comment"> This software is provided 'as is' with no explicit or implied warranties /spapti  42 /a> spap class="comment"> ip respect of its properties, including, but not limited to, correctness /spapti  43 /a> spap class="comment"> and/or fitness for purpose. /spapti  44 /a> spap class="comment"> --------------------------------------------------------------------------- /spapti  45 /a> spap class="comment"> Issue 31/01/2006 /spapti  46 /a>i  47 /a> spap class="comment"> This file provides fast multiplica   48 /a> spap class="comment"> cryptographic authentica   49 /a> spap class="comment">*/ /spapti  50 /a>i  51 /a>#include <crypto/gf128mul.h /a>>i  52 /a>#include <linux/kernel.h /a>>i  53 /a>#include <linux/module.h /a>>i  54 /a>#include <linux/slab.h /a>>i  55 /a>i  56 /a>#define  a href="+code=gf128mul_dat" class="sref">gf128mul_dat /a>( a href="+code=q" class="sref">q /a>) { \i  57 /a>         a href="+code=q" class="sref">q /a>(0x00),  a href="+code=q" class="sref">q /a>(0x01),  a href="+code=q" class="sref">q /a>(0x02),  a href="+code=q" class="sref">q /a>(0x03),  a href="+code=q" class="sref">q /a>(0x04),  a href="+code=q" class="sref">q /a>(0x05),  a href="+code=q" class="sref">q /a>(0x06),  a href="+code=q" class="sref">q /a>(0x07),\i  58 /a>         a href="+code=q" class="sref">q /a>(0x08),  a href="+code=q" class="sref">q /a>(0x09),  a href="+code=q" class="sref">q /a>(0x0a),  a href="+code=q" class="sref">q /a>(0x0b),  a href="+code=q" class="sref">q /a>(0x0c),  a href="+code=q" class="sref">q /a>(0x0d),  a href="+code=q" class="sref">q /a>(0x0e),  a href="+code=q" class="sref">q /a>(0x0f),\i  59 /a>         a href="+code=q" class="sref">q /a>(0x10),  a href="+code=q" class="sref">q /a>(0x11),  a href="+code=q" class="sref">q /a>(0x12),  a href="+code=q" class="sref">q /a>(0x13),  a href="+code=q" class="sref">q /a>(0x14),  a href="+code=q" class="sref">q /a>(0x15),  a href="+code=q" class="sref">q /a>(0x16),  a href="+code=q" class="sref">q /a>(0x17),\i  60 /a>         a href="+code=q" class="sref">q /a>(0x18),  a href="+code=q" class="sref">q /a>(0x19),  a href="+code=q" class="sref">q /a>(0x1a),  a href="+code=q" class="sref">q /a>(0x1b),  a href="+code=q" class="sref">q /a>(0x1c),  a href="+code=q" class="sref">q /a>(0x1d),  a href="+code=q" class="sref">q /a>(0x1e),  a href="+code=q" class="sref">q /a>(0x1f),\i  61 /a>         a href="+code=q" class="sref">q /a>(0x20),  a href="+code=q" class="sref">q /a>(0x21),  a href="+code=q" class="sref">q /a>(0x22),  a href="+code=q" class="sref">q /a>(0x23),  a href="+code=q" class="sref">q /a>(0x24),  a href="+code=q" class="sref">q /a>(0x25),  a href="+code=q" class="sref">q /a>(0x26),  a href="+code=q" class="sref">q /a>(0x27),\i  62 /a>         a href="+code=q" class="sref">q /a>(0x28),  a href="+code=q" class="sref">q /a>(0x29),  a href="+code=q" class="sref">q /a>(0x2a),  a href="+code=q" class="sref">q /a>(0x2b),  a href="+code=q" class="sref">q /a>(0x2c),  a href="+code=q" class="sref">q /a>(0x2d),  a href="+code=q" class="sref">q /a>(0x2e),  a href="+code=q" class="sref">q /a>(0x2f),\i  63 /a>         a href="+code=q" class="sref">q /a>(0x30),  a href="+code=q" class="sref">q /a>(0x31),  a href="+code=q" class="sref">q /a>(0x32),  a href="+code=q" class="sref">q /a>(0x33),  a href="+code=q" class="sref">q /a>(0x34),  a href="+code=q" class="sref">q /a>(0x35),  a href="+code=q" class="sref">q /a>(0x36),  a href="+code=q" class="sref">q /a>(0x37),\i  64 /a>         a href="+code=q" class="sref">q /a>(0x38),  a href="+code=q" class="sref">q /a>(0x39),  a href="+code=q" class="sref">q /a>(0x3a),  a href="+code=q" class="sref">q /a>(0x3b),  a href="+code=q" class="sref">q /a>(0x3c),  a href="+code=q" class="sref">q /a>(0x3d),  a href="+code=q" class="sref">q /a>(0x3e),  a href="+code=q" class="sref">q /a>(0x3f),\i  65 /a>         a href="+code=q" class="sref">q /a>(0x40),  a href="+code=q" class="sref">q /a>(0x41),  a href="+code=q" class="sref">q /a>(0x42),  a href="+code=q" class="sref">q /a>(0x43),  a href="+code=q" class="sref">q /a>(0x44),  a href="+code=q" class="sref">q /a>(0x45),  a href="+code=q" class="sref">q /a>(0x46),  a href="+code=q" class="sref">q /a>(0x47),\i  66 /a>         a href="+code=q" class="sref">q /a>(0x48),  a href="+code=q" class="sref">q /a>(0x49),  a href="+code=q" class="sref">q /a>(0x4a),  a href="+code=q" class="sref">q /a>(0x4b),  a href="+code=q" class="sref">q /a>(0x4c),  a href="+code=q" class="sref">q /a>(0x4d),  a href="+code=q" class="sref">q /a>(0x4e),  a href="+code=q" class="sref">q /a>(0x4f),\i  67 /a>         a href="+code=q" class="sref">q /a>(0x50),  a href="+code=q" class="sref">q /a>(0x51),  a href="+code=q" class="sref">q /a>(0x52),  a href="+code=q" class="sref">q /a>(0x53),  a href="+code=q" class="sref">q /a>(0x54),  a href="+code=q" class="sref">q /a>(0x55),  a href="+code=q" class="sref">q /a>(0x56),  a href="+code=q" class="sref">q /a>(0x57),\i  68 /a>         a href="+code=q" class="sref">q /a>(0x58),  a href="+code=q" class="sref">q /a>(0x59),  a href="+code=q" class="sref">q /a>(0x5a),  a href="+code=q" class="sref">q /a>(0x5b),  a href="+code=q" class="sref">q /a>(0x5c),  a href="+code=q" class="sref">q /a>(0x5d),  a href="+code=q" class="sref">q /a>(0x5e),  a href="+code=q" class="sref">q /a>(0x5f),\i  69 /a>         a href="+code=q" class="sref">q /a>(0x60),  a href="+code=q" class="sref">q /a>(0x61),  a href="+code=q" class="sref">q /a>(0x62),  a href="+code=q" class="sref">q /a>(0x63),  a href="+code=q" class="sref">q /a>(0x64),  a href="+code=q" class="sref">q /a>(0x65),  a href="+code=q" class="sref">q /a>(0x66),  a href="+code=q" class="sref">q /a>(0x67),\i  70 /a>         a href="+code=q" class="sref">q /a>(0x68),  a href="+code=q" class="sref">q /a>(0x69),  a href="+code=q" class="sref">q /a>(0x6a),  a href="+code=q" class="sref">q /a>(0x6b),  a href="+code=q" class="sref">q /a>(0x6c),  a href="+code=q" class="sref">q /a>(0x6d),  a href="+code=q" class="sref">q /a>(0x6e),  a href="+code=q" class="sref">q /a>(0x6f),\i  71 /a>         a href="+code=q" class="sref">q /a>(0x70),  a href="+code=q" class="sref">q /a>(0x71),  a href="+code=q" class="sref">q /a>(0x72),  a href="+code=q" class="sref">q /a>(0x73),  a href="+code=q" class="sref">q /a>(0x74),  a href="+code=q" class="sref">q /a>(0x75),  a href="+code=q" class="sref">q /a>(0x76),  a href="+code=q" class="sref">q /a>(0x77),\i  72 /a>         a href="+code=q" class="sref">q /a>(0x78),  a href="+code=q" class="sref">q /a>(0x79),  a href="+code=q" class="sref">q /a>(0x7a),  a href="+code=q" class="sref">q /a>(0x7b),  a href="+code=q" class="sref">q /a>(0x7c),  a href="+code=q" class="sref">q /a>(0x7d),  a href="+code=q" class="sref">q /a>(0x7e),  a href="+code=q" class="sref">q /a>(0x7f),\i  73 /a>         a href="+code=q" class="sref">q /a>(0x80),  a href="+code=q" class="sref">q /a>(0x81),  a href="+code=q" class="sref">q /a>(0x82),  a href="+code=q" class="sref">q /a>(0x83),  a href="+code=q" class="sref">q /a>(0x84),  a href="+code=q" class="sref">q /a>(0x85),  a href="+code=q" class="sref">q /a>(0x86),  a href="+code=q" class="sref">q /a>(0x87),\i  74 /a>         a href="+code=q" class="sref">q /a>(0x88),  a href="+code=q" class="sref">q /a>(0x89),  a href="+code=q" class="sref">q /a>(0x8a),  a href="+code=q" class="sref">q /a>(0x8b),  a href="+code=q" class="sref">q /a>(0x8c),  a href="+code=q" class="sref">q /a>(0x8d),  a href="+code=q" class="sref">q /a>(0x8e),  a href="+code=q" class="sref">q /a>(0x8f),\i  75 /a>         a href="+code=q" class="sref">q /a>(0x90),  a href="+code=q" class="sref">q /a>(0x91),  a href="+code=q" class="sref">q /a>(0x92),  a href="+code=q" class="sref">q /a>(0x93),  a href="+code=q" class="sref">q /a>(0x94),  a href="+code=q" class="sref">q /a>(0x95),  a href="+code=q" class="sref">q /a>(0x96),  a href="+code=q" class="sref">q /a>(0x97),\i  76 /a>         a href="+code=q" class="sref">q /a>(0x98),  a href="+code=q" class="sref">q /a>(0x99),  a href="+code=q" class="sref">q /a>(0x9a),  a href="+code=q" class="sref">q /a>(0x9b),  a href="+code=q" class="sref">q /a>(0x9c),  a href="+code=q" class="sref">q /a>(0x9d),  a href="+code=q" class="sref">q /a>(0x9e),  a href="+code=q" class="sref">q /a>(0x9f),\i  77 /a>         a href="+code=q" class="sref">q /a>(0xa0),  a href="+code=q" class="sref">q /a>(0xa1),  a href="+code=q" class="sref">q /a>(0xa2),  a href="+code=q" class="sref">q /a>(0xa3),  a href="+code=q" class="sref">q /a>(0xa4),  a href="+code=q" class="sref">q /a>(0xa5),  a href="+code=q" class="sref">q /a>(0xa6),  a href="+code=q" class="sref">q /a>(0xa7),\i  78 /a>         a href="+code=q" class="sref">q /a>(0xa8),  a href="+code=q" class="sref">q /a>(0xa9),  a href="+code=q" class="sref">q /a>(0xaa),  a href="+code=q" class="sref">q /a>(0xab),  a href="+code=q" class="sref">q /a>(0xac),  a href="+code=q" class="sref">q /a>(0xad),  a href="+code=q" class="sref">q /a>(0xae),  a href="+code=q" class="sref">q /a>(0xaf),\i  79 /a>         a href="+code=q" class="sref">q /a>(0xb0),  a href="+code=q" class="sref">q /a>(0xb1),  a href="+code=q" class="sref">q /a>(0xb2),  a href="+code=q" class="sref">q /a>(0xb3),  a href="+code=q" class="sref">q /a>(0xb4),  a href="+code=q" class="sref">q /a>(0xb5),  a href="+code=q" class="sref">q /a>(0xb6),  a href="+code=q" class="sref">q /a>(0xb7),\i  80 /a>         a href="+code=q" class="sref">q /a>(0xb8),  a href="+code=q" class="sref">q /a>(0xb9),  a href="+code=q" class="sref">q /a>(0xba),  a href="+code=q" class="sref">q /a>(0xbb),  a href="+code=q" class="sref">q /a>(0xbc),  a href="+code=q" class="sref">q /a>(0xbd),  a href="+code=q" class="sref">q /a>(0xbe),  a href="+code=q" class="sref">q /a>(0xbf),\i  81 /a>         a href="+code=q" class="sref">q /a>(0xc0),  a href="+code=q" class="sref">q /a>(0xc1),  a href="+code=q" class="sref">q /a>(0xc2),  a href="+code=q" class="sref">q /a>(0xc3),  a href="+code=q" class="sref">q /a>(0xc4),  a href="+code=q" class="sref">q /a>(0xc5),  a href="+code=q" class="sref">q /a>(0xc6),  a href="+code=q" class="sref">q /a>(0xc7),\i  82 /a>         a href="+code=q" class="sref">q /a>(0xc8),  a href="+code=q" class="sref">q /a>(0xc9),  a href="+code=q" class="sref">q /a>(0xca),  a href="+code=q" class="sref">q /a>(0xcb),  a href="+code=q" class="sref">q /a>(0xcc),  a href="+code=q" class="sref">q /a>(0xcd),  a href="+code=q" class="sref">q /a>(0xce),  a href="+code=q" class="sref">q /a>(0xcf),\i  83 /a>         a href="+code=q" class="sref">q /a>(0xd0),  a href="+code=q" class="sref">q /a>(0xd1),  a href="+code=q" class="sref">q /a>(0xd2),  a href="+code=q" class="sref">q /a>(0xd3),  a href="+code=q" class="sref">q /a>(0xd4),  a href="+code=q" class="sref">q /a>(0xd5),  a href="+code=q" class="sref">q /a>(0xd6),  a href="+code=q" class="sref">q /a>(0xd7),\i  84 /a>         a href="+code=q" class="sref">q /a>(0xd8),  a href="+code=q" class="sref">q /a>(0xd9),  a href="+code=q" class="sref">q /a>(0xda),  a href="+code=q" class="sref">q /a>(0xdb),  a href="+code=q" class="sref">q /a>(0xdc),  a href="+code=q" class="sref">q /a>(0xdd),  a href="+code=q" class="sref">q /a>(0xde),  a href="+code=q" class="sref">q /a>(0xdf),\i  85 /a>         a href="+code=q" class="sref">q /a>(0xe0),  a href="+code=q" class="sref">q /a>(0xe1),  a href="+code=q" class="sref">q /a>(0xe2),  a href="+code=q" class="sref">q /a>(0xe3),  a href="+code=q" class="sref">q /a>(0xe4),  a href="+code=q" class="sref">q /a>(0xe5),  a href="+code=q" class="sref">q /a>(0xe6),  a href="+code=q" class="sref">q /a>(0xe7),\i  86 /a>         a href="+code=q" class="sref">q /a>(0xe8),  a href="+code=q" class="sref">q /a>(0xe9),  a href="+code=q" class="sref">q /a>(0xea),  a href="+code=q" class="sref">q /a>(0xeb),  a href="+code=q" class="sref">q /a>(0xec),  a href="+code=q" class="sref">q /a>(0xed),  a href="+code=q" class="sref">q /a>(0xee),  a href="+code=q" class="sref">q /a>(0xef),\i  87 /a>         a href="+code=q" class="sref">q /a>(0xf0),  a href="+code=q" class="sref">q /a>(0xf1),  a href="+code=q" class="sref">q /a>(0xf2),  a href="+code=q" class="sref">q /a>(0xf3),  a href="+code=q" class="sref">q /a>(0xf4),  a href="+code=q" class="sref">q /a>(0xf5),  a href="+code=q" class="sref">q /a>(0xf6),  a href="+code=q" class="sref">q /a>(0xf7),\i  88 /a>         a href="+code=q" class="sref">q /a>(0xf8),  a href="+code=q" class="sref">q /a>(0xf9),  a href="+code=q" class="sref">q /a>(0xfa),  a href="+code=q" class="sref">q /a>(0xfb),  a href="+code=q" class="sref">q /a>(0xfc),  a href="+code=q" class="sref">q /a>(0xfd),  a href="+code=q" class="sref">q /a>(0xfe),  a href="+code=q" class="sref">q /a>(0xff) \i  89 /a>}i  90 /a>i  91 /a> spap class="comment">/*      Given the ion v itip 0..255 as the byte overflow when a field element /spapti  92 /a> spap class="comment">   tip GHASH is multiplied by x^8, this func  93 /a> spap class="comment">    are generated in the lo 16-bit word of the field ion v by applying the /spapti  94 /a> spap class="comment">    modular polynomial. The ion vs lo_byte and hi_byte are returned via the /spapti  95 /a> spap class="comment">    macro xp_fun(lo_byte, hi_byte) so that the ion vs cap be assembled into /spapti  96 /a> spap class="comment">    memory as required by a suitable definit  97 /a> spap class="comment">    the table above /spapti  98 /a> spap class="comment">*/ /spapti  99 /a>i 100 /a>#define  a href="+code=xx" class="sref">xx /a>( a href="+code=p" class="sref">p /a>,  a href="+code=q" class="sref">q /a>)        0x##p##qi 101 /a>i 102 /a>#define  a href="+code=xda_bbe" class="sref">xda_bbe /a>( a href="+code=i" class="sref">i /a>) ( \i 103 /a>        ( a href="+code=i" class="sref">i /a> & 0x80 ?  a href="+code=xx" class="sref">xx /a>(43, 80) : 0) ^ ( a href="+code=i" class="sref">i /a> & 0x40 ?  a href="+code=xx" class="sref">xx /a>(21,  a href="+code=c0" class="sref">c0 /a>) : 0) ^ \i 104 /a>        ( a href="+code=i" class="sref">i /a> & 0x20 ?  a href="+code=xx" class="sref">xx /a>(10,  a href="+code=e0" class="sref">e0 /a>) : 0) ^ ( a href="+code=i" class="sref">i /a> & 0x10 ?  a href="+code=xx" class="sref">xx /a>(08, 70) : 0) ^ \i 105 /a>        ( a href="+code=i" class="sref">i /a> & 0x08 ?  a href="+code=xx" class="sref">xx /a>(04, 38) : 0) ^ ( a href="+code=i" class="sref">i /a> & 0x04 ?  a href="+code=xx" class="sref">xx /a>(02, 1c) : 0) ^ \i 106 /a>        ( a href="+code=i" class="sref">i /a> & 0x02 ?  a href="+code=xx" class="sref">xx /a>(01, 0e) : 0) ^ ( a href="+code=i" class="sref">i /a> & 0x01 ?  a href="+code=xx" class="sref">xx /a>(00, 87) : 0) \i 107 /a>)i 108 /a>i 109 /a>#define  a href="+code=xda_lle" class="sref">xda_lle /a>( a href="+code=i" class="sref">i /a>) ( \i 110 /a>        ( a href="+code=i" class="sref">i /a> & 0x80 ?  a href="+code=xx" class="sref">xx /a>( a href="+code=e1" class="sref">e1 /a>, 00) : 0) ^ ( a href="+code=i" class="sref">i /a> & 0x40 ?  a href="+code=xx" class="sref">xx /a>(70, 80) : 0) ^ \i 111 /a>        ( a href="+code=i" class="sref">i /a> & 0x20 ?  a href="+code=xx" class="sref">xx /a>(38, 40) : 0) ^ ( a href="+code=i" class="sref">i /a> & 0x10 ?  a href="+code=xx" class="sref">xx /a>(1c, 20) : 0) ^ \i 112 /a>        ( a href="+code=i" class="sref">i /a> & 0x08 ?  a href="+code=xx" class="sref">xx /a>(0e, 10) : 0) ^ ( a href="+code=i" class="sref">i /a> & 0x04 ?  a href="+code=xx" class="sref">xx /a>(07, 08) : 0) ^ \i 113 /a>        ( a href="+code=i" class="sref">i /a> & 0x02 ?  a href="+code=xx" class="sref">xx /a>(03, 84) : 0) ^ ( a href="+code=i" class="sref">i /a> & 0x01 ?  a href="+code=xx" class="sref">xx /a>(01,  a href="+code=c2" class="sref">c2 /a>) : 0) \i 114 /a>)i 115 /a>i 116 /a>static const  a href="+code=u16" class="sref">u16 /a>  a href="+code=gf128mul_table_lle" class="sref">gf128mul_table_lle /a>[256] =  a href="+code=gf128mul_dat" class="sref">gf128mul_dat /a>( a href="+code=xda_lle" class="sref">xda_lle /a>);i 117 /a>static const  a href="+code=u16" class="sref">u16 /a>  a href="+code=gf128mul_table_bbe" class="sref">gf128mul_table_bbe /a>[256] =  a href="+code=gf128mul_dat" class="sref">gf128mul_dat /a>( a href="+code=xda_bbe" class="sref">xda_bbe /a>);i 118 /a>i 119 /a> spap class="comment">/* Thesetfunc 1217.a> spap class="comment"> * in the polynomial field representat 121 /a> spap class="comment"> * to gain speed but compensates for machine endianess and hence works /spapti 122 /a> spap class="comment"> * correctly on both styles of machine. /spapti 123 /a> spap class="comment"> */ /spapti 124 /a>i 125 /a>static void  a href="+code=gf128mul_x_lle" class="sref">gf128mul_x_lle /a>( a href="+code=be128" class="sref">be128 /a> * a href="+code=r" class="sref">r /a>, const  a href="+code=be128" class="sref">be128 /a> * a href="+code=x" class="sref">x /a>)i 126 /a>{i 127 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=a" class="sref">a /a> =  a href="+code=be64_to_cpu" class="sref">be64_to_cpu /a>( a href="+code=x" class="sref">x /a>-> a href="+code=a" class="sref">a /a>);i 128 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=b" class="sref">b /a> =  a href="+code=be64_to_cpu" class="sref">be64_to_cpu /a>( a href="+code=x" class="sref">x /a>-> a href="+code=b" class="sref">b /a>);i 129 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=_tt" class="sref">_tt /a> =  a href="+code=gf128mul_table_lle" class="sref">gf128mul_table_lle /a>[( a href="+code=b" class="sref">b /a> << 7) & 0xff];i 130 /a>i 131 /a>         a href="+code=r" class="sref">r /a>-> a href="+code=b" class="sref">b /a> =  a href="+code=cpu_to_be64" class="sref">cpu_to_be64 /a>(( a href="+code=b" class="sref">b /a> >> 1) | ( a href="+code=a" class="sref">a /a> << 63));i 132 /a>         a href="+code=r" class="sref">r /a>-> a href="+code=a" class="sref">a /a> =  a href="+code=cpu_to_be64" class="sref">cpu_to_be64 /a>(( a href="+code=a" class="sref">a /a> >> 1) ^ ( a href="+code=_tt" class="sref">_tt /a> << 48));i 133 /a>}i 134 /a>i 135 /a>static void  a href="+code=gf128mul_x_bbe" class="sref">gf128mul_x_bbe /a>( a href="+code=be128" class="sref">be128 /a> * a href="+code=r" class="sref">r /a>, const  a href="+code=be128" class="sref">be128 /a> * a href="+code=x" class="sref">x /a>)i 136 /a>{i 137 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=a" class="sref">a /a> =  a href="+code=be64_to_cpu" class="sref">be64_to_cpu /a>( a href="+code=x" class="sref">x /a>-> a href="+code=a" class="sref">a /a>);i 138 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=b" class="sref">b /a> =  a href="+code=be64_to_cpu" class="sref">be64_to_cpu /a>( a href="+code=x" class="sref">x /a>-> a href="+code=b" class="sref">b /a>);i 139 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=_tt" class="sref">_tt /a> =  a href="+code=gf128mul_table_bbe" class="sref">gf128mul_table_bbe /a>[ a href="+code=a" class="sref">a /a> >> 63];i 140 /a>i 141 /a>         a href="+code=r" class="sref">r /a>-> a href="+code=a" class="sref">a /a> =  a href="+code=cpu_to_be64" class="sref">cpu_to_be64 /a>(( a href="+code=a" class="sref">a /a> << 1) | ( a href="+code=b" class="sref">b /a> >> 63));i 142 /a>         a href="+code=r" class="sref">r /a>-> a href="+code=b" class="sref">b /a> =  a href="+code=cpu_to_be64" class="sref">cpu_to_be64 /a>(( a href="+code=b" class="sref">b /a> << 1) ^  a href="+code=_tt" class="sref">_tt /a>);i 143 /a>}i 144 /a>i 145 /a>void  a href="+code=gf128mul_x_ble" class="sref">gf128mul_x_ble /a>( a href="+code=be128" class="sref">be128 /a> * a href="+code=r" class="sref">r /a>, const  a href="+code=be128" class="sref">be128 /a> * a href="+code=x" class="sref">x /a>)i 146 /a>{i 147 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=a" class="sref">a /a> =  a href="+code=le64_to_cpu" class="sref">le64_to_cpu /a>( a href="+code=x" class="sref">x /a>-> a href="+code=a" class="sref">a /a>);i 148 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=b" class="sref">b /a> =  a href="+code=le64_to_cpu" class="sref">le64_to_cpu /a>( a href="+code=x" class="sref">x /a>-> a href="+code=b" class="sref">b /a>);i 149 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=_tt" class="sref">_tt /a> =  a href="+code=gf128mul_table_bbe" class="sref">gf128mul_table_bbe /a>[ a href="+code=b" class="sref">b /a> >> 63];i 150 /a>i 151 /a>         a href="+code=r" class="sref">r /a>-> a href="+code=a" class="sref">a /a> =  a href="+code=cpu_to_le64" class="sref">cpu_to_le64 /a>(( a href="+code=a" class="sref">a /a> << 1) ^  a href="+code=_tt" class="sref">_tt /a>);i 152 /a>         a href="+code=r" class="sref">r /a>-> a href="+code=b" class="sref">b /a> =  a href="+code=cpu_to_le64" class="sref">cpu_to_le64 /a>(( a href="+code=b" class="sref">b /a> << 1) | ( a href="+code=a" class="sref">a /a> >> 63));i 153 /a>}i 154 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=gf128mul_x_ble" class="sref">gf128mul_x_ble /a>);i 155 /a>i 156 /a>static void  a href="+code=gf128mul_x8_lle" class="sref">gf128mul_x8_lle /a>( a href="+code=be128" class="sref">be128 /a> * a href="+code=x" class="sref">x /a>)i 157 /a>{i 158 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=a" class="sref">a /a> =  a href="+code=be64_to_cpu" class="sref">be64_to_cpu /a>( a href="+code=x" class="sref">x /a>-> a href="+code=a" class="sref">a /a>);i 159 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=b" class="sref">b /a> =  a href="+code=be64_to_cpu" class="sref">be64_to_cpu /a>( a href="+code=x" class="sref">x /a>-> a href="+code=b" class="sref">b /a>);i 160 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=_tt" class="sref">_tt /a> =  a href="+code=gf128mul_table_lle" class="sref">gf128mul_table_lle /a>[ a href="+code=b" class="sref">b /a> & 0xff];i 161 /a>i 162 /a>         a href="+code=x" class="sref">x /a>-> a href="+code=b" class="sref">b /a> =  a href="+code=cpu_to_be64" class="sref">cpu_to_be64 /a>(( a href="+code=b" class="sref">b /a> >> 8) | ( a href="+code=a" class="sref">a /a> << 56));i 163 /a>         a href="+code=x" class="sref">x /a>-> a href="+code=a" class="sref">a /a> =  a href="+code=cpu_to_be64" class="sref">cpu_to_be64 /a>(( a href="+code=a" class="sref">a /a> >> 8) ^ ( a href="+code=_tt" class="sref">_tt /a> << 48));i 164 /a>}i 165 /a>i 166 /a>static void  a href="+code=gf128mul_x8_bbe" class="sref">gf128mul_x8_bbe /a>( a href="+code=be128" class="sref">be128 /a> * a href="+code=x" class="sref">x /a>)i 167 /a>{i 168 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=a" class="sref">a /a> =  a href="+code=be64_to_cpu" class="sref">be64_to_cpu /a>( a href="+code=x" class="sref">x /a>-> a href="+code=a" class="sref">a /a>);i 169 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=b" class="sref">b /a> =  a href="+code=be64_to_cpu" class="sref">be64_to_cpu /a>( a href="+code=x" class="sref">x /a>-> a href="+code=b" class="sref">b /a>);i 170 /a>         a href="+code=u64" class="sref">u64 /a>  a href="+code=_tt" class="sref">_tt /a> =  a href="+code=gf128mul_table_bbe" class="sref">gf128mul_table_bbe /a>[ a href="+code=a" class="sref">a /a> >> 56];i 171 /a>i 172 /a>         a href="+code=x" class="sref">x /a>-> a href="+code=a" class="sref">a /a> =  a href="+code=cpu_to_be64" class="sref">cpu_to_be64 /a>(( a href="+code=a" class="sref">a /a> << 8) | ( a href="+code=b" class="sref">b /a> >> 56));i 173 /a>         a href="+code=x" class="sref">x /a>-> a href="+code=b" class="sref">b /a> =  a href="+code=cpu_to_be64" class="sref">cpu_to_be64 /a>(( a href="+code=b" class="sref">b /a> << 8) ^  a href="+code=_tt" class="sref">_tt /a>);i 174 /a>}i 175 /a>i 176 /a>void  a href="+code=gf128mul_lle" class="sref">gf128mul_lle /a>( a href="+code=be128" class="sref">be128 /a> * a href="+code=r" class="sref">r /a>, const  a href="+code=be128" class="sref">be128 /a> * a href="+code=b" class="sref">b /a>)i 177 /a>{i 178 /a>         a href="+code=be128" class="sref">be128 /a>  a href="+code=p" class="sref">p /a>[8];i 179 /a>        int  a href="+code=i" class="sref">i /a>;i 180 /a>i 181 /a>         a href="+code=p" class="sref">p /a>[0] = * a href="+code=r" class="sref">r /a>;i 182 /a>        for ( a href="+code=i" class="sref">i /a> = 0;  a href="+code=i" class="sref">i /a> < 7; ++ a href="+code=i" class="sref">i /a>)i 183 /a>                 a href="+code=gf128mul_x_lle" class="sref">gf128mul_x_lle /a>(& a href="+code=p" class="sref">p /a>[ a href="+code=i" class="sref">i /a> + 1], & a href="+code=p" class="sref">p /a>[ a href="+code=i" class="sref">i /a>]);i 184 /a>i 185 /a>         a href="+code=memset" class="sref">memset /a>( a href="+code=r" class="sref">r /a>, 0, sizeof(* a href="+code=r" class="sref">r /a>));i 186 /a>        for ( a href="+code=i" class="sref">i /a> = 0;;) {i 187 /a>                 a href="+code=u8" class="sref">u8 /a>  a href="+code=ch" class="sref">ch /a> = (( a href="+code=u8" class="sref">u8 /a> *) a href="+code=b" class="sref">b /a>)[15 -  a href="+code=i" class="sref">i /a>];i 188 /a>i 189 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x80)i 190 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[0]);i 191 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x40)i 192 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[1]);i 193 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x20)i 194 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[2]);i 195 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x10)i 196 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[3]);i 197 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x08)i 198 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[4]);i 199 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x04)i 200 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[5]);i 201 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x02)i 202 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[6]);i 203 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x01)i 204 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[7]);i 205 /a>i 206 /a>                if (++ a href="+code=i" class="sref">i /a> >= 16)i 207 /a>                        break;i 208 /a>i 209 /a>                 a href="+code=gf128mul_x8_lle" class="sref">gf128mul_x8_lle /a>( a href="+code=r" class="sref">r /a>);i 210 /a>        }i 211 /a>}i 212 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=gf128mul_lle" class="sref">gf128mul_lle /a>);i 213 /a>i 214 /a>void  a href="+code=gf128mul_bbe" class="sref">gf128mul_bbe /a>( a href="+code=be128" class="sref">be128 /a> * a href="+code=r" class="sref">r /a>, const  a href="+code=be128" class="sref">be128 /a> * a href="+code=b" class="sref">b /a>)i 215 /a>{i 216 /a>         a href="+code=be128" class="sref">be128 /a>  a href="+code=p" class="sref">p /a>[8];i 217 /a>        int  a href="+code=i" class="sref">i /a>;i 218 /a>i 219 /a>         a href="+code=p" class="sref">p /a>[0] = * a href="+code=r" class="sref">r /a>;i 220 /a>        for ( a href="+code=i" class="sref">i /a> = 0;  a href="+code=i" class="sref">i /a> < 7; ++ a href="+code=i" class="sref">i /a>)i 221 /a>                 a href="+code=gf128mul_x_bbe" class="sref">gf128mul_x_bbe /a>(& a href="+code=p" class="sref">p /a>[ a href="+code=i" class="sref">i /a> + 1], & a href="+code=p" class="sref">p /a>[ a href="+code=i" class="sref">i /a>]);i 222 /a>i 223 /a>         a href="+code=memset" class="sref">memset /a>( a href="+code=r" class="sref">r /a>, 0, sizeof(* a href="+code=r" class="sref">r /a>));i 224 /a>        for ( a href="+code=i" class="sref">i /a> = 0;;) {i 225 /a>                 a href="+code=u8" class="sref">u8 /a>  a href="+code=ch" class="sref">ch /a> = (( a href="+code=u8" class="sref">u8 /a> *) a href="+code=b" class="sref">b /a>)[ a href="+code=i" class="sref">i /a>];i 226 /a>i 227 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x80)i 228 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[7]);i 229 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x40)i 230 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[6]);i 231 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x20)i 232 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[5]);i 233 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x10)i 234 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[4]);i 235 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x08)i 236 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[3]);i 237 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x04)i 238 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[2]);i 239 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x02)i 240 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[1]);i 241 /a>                if ( a href="+code=ch" class="sref">ch /a> & 0x01)i 242 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=p" class="sref">p /a>[0]);i 243 /a>i 244 /a>                if (++ a href="+code=i" class="sref">i /a> >= 16)i 245 /a>                        break;i 246 /a>i 247 /a>                 a href="+code=gf128mul_x8_bbe" class="sref">gf128mul_x8_bbe /a>( a href="+code=r" class="sref">r /a>);i 248 /a>        }i 249 /a>}i 250 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=gf128mul_bbe" class="sref">gf128mul_bbe /a>);i 251 /a>i 252 /a> spap class="comment">/*      This vers 253 /a> spap class="comment">    A 16 byte buffer has to be multiplied by a 16 byte key /spapti 254 /a> spap class="comment">    ion v in GF(128).  If we consider a GF(128) ion v in /spapti 255 /a> spap class="comment">    the buffer's lowest byte, we cap construct a table of /spapti 256 /a> spap class="comment">    the 256 16 byte ion vs that result from the 256 ion vs /spapti 257 /a> spap class="comment">    of this byte.  This requires 4096 bytes. But we also /spapti 258 /a> spap class="comment">    need tables for each of the 16 higher bytes in the /spapti 259 /a> spap class="comment">    buffer as well, which makes 64 kbytes in total. /spapti 2617.a> spap class="comment">*/ /spapti 261 /a> spap class="comment">/* addit 262 /a> spap class="comment"> * t[0][BYTE] contains g*BYTE /spapti 263 /a> spap class="comment"> * t[1][BYTE] contains g*x^8*BYTE /spapti 264 /a> spap class="comment"> *  .. /spapti 265 /a> spap class="comment"> * t[15][BYTE] contains g*x^120*BYTE */ /spapti 266 /a>struct  a href="+code=gf128mul_64k" class="sref">gf128mul_64k /a> * a href="+code=gf128mul_init_64k_lle" class="sref">gf128mul_init_64k_lle /a>(const  a href="+code=be128" class="sref">be128 /a> * a href="+code=g" class="sref">g /a>)i 267 /a>{i 268 /a>        struct  a href="+code=gf128mul_64k" class="sref">gf128mul_64k /a> * a href="+code=t" class="sref">t /a>;i 269 /a>        int  a href="+code=i" class="sref">i /a>,  a href="+code=j" class="sref">j /a>,  a href="+code=k" class="sref">k /a>;i 270 /a>i 271 /a>         a href="+code=t" class="sref">t /a> =  a href="+code=kzalloc" class="sref">kzalloc /a>(sizeof(* a href="+code=t" class="sref">t /a>),  a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL /a>);i 272 /a>        if (! a href="+code=t" class="sref">t /a>)i 273 /a>                goto  a href="+code=out" class="sref">out /a>;i 274 /a>i 275 /a>        for ( a href="+code=i" class="sref">i /a> = 0;  a href="+code=i" class="sref">i /a> < 16;  a href="+code=i" class="sref">i /a>++) {i 276 /a>                 a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>] =  a href="+code=kzalloc" class="sref">kzalloc /a>(sizeof(* a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]),  a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL /a>);i 277 /a>                if (! a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]) {i 278 /a>                         a href="+code=gf128mul_free_64k" class="sref">gf128mul_free_64k /a>( a href="+code=t" class="sref">t /a>);i 279 /a>                         a href="+code=t" class="sref">t /a> =  a href="+code=NULL" class="sref">NULL /a>;i 280 /a>                        goto  a href="+code=out" class="sref">out /a>;i 281 /a>                }i 282 /a>        }i 283 /a>i 284 /a>         a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[0]-> a href="+code=t" class="sref">t /a>[128] = * a href="+code=g" class="sref">g /a>;i 285 /a>        for ( a href="+code=j" class="sref">j /a> = 64;  a href="+code=j" class="sref">j /a> > 0;  a href="+code=j" class="sref">j /a> >>= 1)i 286 /a>                 a href="+code=gf128mul_x_lle" class="sref">gf128mul_x_lle /a>(& a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[0]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>], & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[0]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a> +  a href="+code=j" class="sref">j /a>]);i 287 /a>i 288 /a>        for ( a href="+code=i" class="sref">i /a> = 0;;) {i 289 /a>                for ( a href="+code=j" class="sref">j /a> = 2;  a href="+code=j" class="sref">j /a> < 256;  a href="+code=j" class="sref">j /a> +=  a href="+code=j" class="sref">j /a>)i 290 /a>                        for ( a href="+code=k" class="sref">k /a> = 1;  a href="+code=k" class="sref">k /a> <  a href="+code=j" class="sref">j /a>; ++ a href="+code=k" class="sref">k /a>)i 291 /a>                                 a href="+code=be128_xor" class="sref">be128_xor /a>(& a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a> +  a href="+code=k" class="sref">k /a>],i 292 /a>                                          & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>], & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]-> a href="+code=t" class="sref">t /a>[ a href="+code=k" class="sref">k /a>]);i 293 /a>i 294 /a>                if (++ a href="+code=i" class="sref">i /a> >= 16)i 295 /a>                        break;i 296 /a>i 297 /a>                for ( a href="+code=j" class="sref">j /a> = 128;  a href="+code=j" class="sref">j /a> > 0;  a href="+code=j" class="sref">j /a> >>= 1) {i 298 /a>                         a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>] =  a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a> - 1]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>];i 299 /a>                         a href="+code=gf128mul_x8_lle" class="sref">gf128mul_x8_lle /a>(& a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>]);i 300 /a>                }i 301 /a>        }i 302 /a>i 303 /a> a href="+code=out" class="sref">out /a>:i 304 /a>        return  a href="+code=t" class="sref">t /a>;i 305 /a>}i 306 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=gf128mul_init_64k_lle" class="sref">gf128mul_init_64k_lle /a>);i 307 /a>i 308 /a>struct  a href="+code=gf128mul_64k" class="sref">gf128mul_64k /a> * a href="+code=gf128mul_init_64k_bbe" class="sref">gf128mul_init_64k_bbe /a>(const  a href="+code=be128" class="sref">be128 /a> * a href="+code=g" class="sref">g /a>)i 309 /a>{i 310 /a>        struct  a href="+code=gf128mul_64k" class="sref">gf128mul_64k /a> * a href="+code=t" class="sref">t /a>;i 311 /a>        int  a href="+code=i" class="sref">i /a>,  a href="+code=j" class="sref">j /a>,  a href="+code=k" class="sref">k /a>;i 312 /a>i 313 /a>         a href="+code=t" class="sref">t /a> =  a href="+code=kzalloc" class="sref">kzalloc /a>(sizeof(* a href="+code=t" class="sref">t /a>),  a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL /a>);i 314 /a>        if (! a href="+code=t" class="sref">t /a>)i 315 /a>                goto  a href="+code=out" class="sref">out /a>;i 316 /a>i 317 /a>        for ( a href="+code=i" class="sref">i /a> = 0;  a href="+code=i" class="sref">i /a> < 16;  a href="+code=i" class="sref">i /a>++) {i 318 /a>                 a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>] =  a href="+code=kzalloc" class="sref">kzalloc /a>(sizeof(* a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]),  a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL /a>);i 319 /a>                if (! a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]) {i 320 /a>                         a href="+code=gf128mul_free_64k" class="sref">gf128mul_free_64k /a>( a href="+code=t" class="sref">t /a>);i 321 /a>                         a href="+code=t" class="sref">t /a> =  a href="+code=NULL" class="sref">NULL /a>;i 322 /a>                        goto  a href="+code=out" class="sref">out /a>;i 323 /a>                }i 324 /a>        }i 325 /a>i 326 /a>         a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[0]-> a href="+code=t" class="sref">t /a>[1] = * a href="+code=g" class="sref">g /a>;i 327 /a>        for ( a href="+code=j" class="sref">j /a> = 1;  a href="+code=j" class="sref">j /a> <= 64;  a href="+code=j" class="sref">j /a> <<= 1)i 328 /a>                 a href="+code=gf128mul_x_bbe" class="sref">gf128mul_x_bbe /a>(& a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[0]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a> +  a href="+code=j" class="sref">j /a>], & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[0]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>]);i 329 /a>i 330 /a>        for ( a href="+code=i" class="sref">i /a> = 0;;) {i 331 /a>                for ( a href="+code=j" class="sref">j /a> = 2;  a href="+code=j" class="sref">j /a> < 256;  a href="+code=j" class="sref">j /a> +=  a href="+code=j" class="sref">j /a>)i 332 /a>                        for ( a href="+code=k" class="sref">k /a> = 1;  a href="+code=k" class="sref">k /a> <  a href="+code=j" class="sref">j /a>; ++ a href="+code=k" class="sref">k /a>)i 333 /a>                                 a href="+code=be128_xor" class="sref">be128_xor /a>(& a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a> +  a href="+code=k" class="sref">k /a>],i 334 /a>                                          & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>], & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]-> a href="+code=t" class="sref">t /a>[ a href="+code=k" class="sref">k /a>]);i 335 /a>i 336 /a>                if (++ a href="+code=i" class="sref">i /a> >= 16)i 337 /a>                        break;i 338 /a>i 339 /a>                for ( a href="+code=j" class="sref">j /a> = 128;  a href="+code=j" class="sref">j /a> > 0;  a href="+code=j" class="sref">j /a> >>= 1) {i 340 /a>                         a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>] =  a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a> - 1]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>];i 341 /a>                         a href="+code=gf128mul_x8_bbe" class="sref">gf128mul_x8_bbe /a>(& a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>]);i 342 /a>                }i 343 /a>        }i 344 /a>i 345 /a> a href="+code=out" class="sref">out /a>:i 346 /a>        return  a href="+code=t" class="sref">t /a>;i 347 /a>}i 348 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=gf128mul_init_64k_bbe" class="sref">gf128mul_init_64k_bbe /a>);i 349 /a>i 350 /a>void  a href="+code=gf128mul_free_64k" class="sref">gf128mul_free_64k /a>(struct  a href="+code=gf128mul_64k" class="sref">gf128mul_64k /a> * a href="+code=t" class="sref">t /a>)i 351 /a>{i 352 /a>        int  a href="+code=i" class="sref">i /a>;i 353 /a>i 354 /a>        for ( a href="+code=i" class="sref">i /a> = 0;  a href="+code=i" class="sref">i /a> < 16;  a href="+code=i" class="sref">i /a>++)i 355 /a>                 a href="+code=kfree" class="sref">kfree /a>( a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]);i 356 /a>         a href="+code=kfree" class="sref">kfree /a>( a href="+code=t" class="sref">t /a>);i 357 /a>}i 358 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=gf128mul_free_64k" class="sref">gf128mul_free_64k /a>);i 359 /a>i 360 /a>void  a href="+code=gf128mul_64k_lle" class="sref">gf128mul_64k_lle /a>( a href="+code=be128" class="sref">be128 /a> * a href="+code=a" class="sref">a /a>, struct  a href="+code=gf128mul_64k" class="sref">gf128mul_64k /a> * a href="+code=t" class="sref">t /a>)i 361 /a>{i 362 /a>         a href="+code=u8" class="sref">u8 /a> * a href="+code=ap" class="sref">ap /a> = ( a href="+code=u8" class="sref">u8 /a> *) a href="+code=a" class="sref">a /a>;i 363 /a>         a href="+code=be128" class="sref">be128 /a>  a href="+code=r" class="sref">r /a>[1];i 364 /a>        int  a href="+code=i" class="sref">i /a>;i 365 /a>i 366 /a>        * a href="+code=r" class="sref">r /a> =  a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[0]-> a href="+code=t" class="sref">t /a>[ a href="+code=ap" class="sref">ap /a>[0]];i 367 /a>        for ( a href="+code=i" class="sref">i /a> = 1;  a href="+code=i" class="sref">i /a> < 16; ++ a href="+code=i" class="sref">i /a>)i 368 /a>                 a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]-> a href="+code=t" class="sref">t /a>[ a href="+code=ap" class="sref">ap /a>[ a href="+code=i" class="sref">i /a>]]);i 369 /a>        * a href="+code=a" class="sref">a /a> = * a href="+code=r" class="sref">r /a>;i 370 /a>}i 371 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=gf128mul_64k_lle" class="sref">gf128mul_64k_lle /a>);i 372 /a>i 373 /a>void  a href="+code=gf128mul_64k_bbe" class="sref">gf128mul_64k_bbe /a>( a href="+code=be128" class="sref">be128 /a> * a href="+code=a" class="sref">a /a>, struct  a href="+code=gf128mul_64k" class="sref">gf128mul_64k /a> * a href="+code=t" class="sref">t /a>)i 374 /a>{i 375 /a>         a href="+code=u8" class="sref">u8 /a> * a href="+code=ap" class="sref">ap /a> = ( a href="+code=u8" class="sref">u8 /a> *) a href="+code=a" class="sref">a /a>;i 376 /a>         a href="+code=be128" class="sref">be128 /a>  a href="+code=r" class="sref">r /a>[1];i 377 /a>        int  a href="+code=i" class="sref">i /a>;i 378 /a>i 379 /a>        * a href="+code=r" class="sref">r /a> =  a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[0]-> a href="+code=t" class="sref">t /a>[ a href="+code=ap" class="sref">ap /a>[15]];i 380 /a>        for ( a href="+code=i" class="sref">i /a> = 1;  a href="+code=i" class="sref">i /a> < 16; ++ a href="+code=i" class="sref">i /a>)i 381 /a>                 a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=i" class="sref">i /a>]-> a href="+code=t" class="sref">t /a>[ a href="+code=ap" class="sref">ap /a>[15 -  a href="+code=i" class="sref">i /a>]]);i 382 /a>        * a href="+code=a" class="sref">a /a> = * a href="+code=r" class="sref">r /a>;i 383 /a>}i 384 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=gf128mul_64k_bbe" class="sref">gf128mul_64k_bbe /a>);i 385 /a>i 386 /a> spap class="comment">/*      This vers 387 /a> spap class="comment">    A 16 byte buffer has to be multiplied by a 16 byte key /spapti 388 /a> spap class="comment">    ion v in GF(128).  If we consider a GF(128) ion v in a /spapti 389 /a> spap class="comment">    single byte, we cap construct a table of the 256 16 byte /spapti 3917.a> spap class="comment">    ion vs that result from the 256 ion vs of this byte. /spapti 391 /a> spap class="comment">    This requires 4096 bytes. If we take the highest byte in /spapti 392 /a> spap class="comment">    the buffer and use this table to get the result, we then /spapti 393 /a> spap class="comment">    have to multiply by x^120 to get the fipal ion v. For the /spapti 394 /a> spap class="comment">    next highest byte the result has to be multiplied by x^112 /spapti 395 /a> spap class="comment">    and so on. But we cap do this by accumulating the result /spapti 396 /a> spap class="comment">    in an accumulator starting with the result for the top /spapti 397 /a> spap class="comment">    byte.  We repeatedly multiply the accumulator ion v by /spapti 398 /a> spap class="comment">    x^8 and then add in (i.e. xor) the 16 bytes of the next /spapti 399 /a> spap class="comment">    lower byte in the buffer, stopping when we reach the /spapti 4017.a> spap class="comment">    lowest byte. This requires a 4096 byte table. /spapti 401 /a> spap class="comment">*/ /spapti 402 /a>struct  a href="+code=gf128mul_4k" class="sref">gf128mul_4k /a> * a href="+code=gf128mul_init_4k_lle" class="sref">gf128mul_init_4k_lle /a>(const  a href="+code=be128" class="sref">be128 /a> * a href="+code=g" class="sref">g /a>)i 403 /a>{i 404 /a>        struct  a href="+code=gf128mul_4k" class="sref">gf128mul_4k /a> * a href="+code=t" class="sref">t /a>;i 405 /a>        int  a href="+code=j" class="sref">j /a>,  a href="+code=k" class="sref">k /a>;i 406 /a>i 407 /a>         a href="+code=t" class="sref">t /a> =  a href="+code=kzalloc" class="sref">kzalloc /a>(sizeof(* a href="+code=t" class="sref">t /a>),  a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL /a>);i 408 /a>        if (! a href="+code=t" class="sref">t /a>)i 409 /a>                goto  a href="+code=out" class="sref">out /a>;i 410 /a>i 411 /a>         a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[128] = * a href="+code=g" class="sref">g /a>;i 412 /a>        for ( a href="+code=j" class="sref">j /a> = 64;  a href="+code=j" class="sref">j /a> > 0;  a href="+code=j" class="sref">j /a> >>= 1)i 413 /a>                 a href="+code=gf128mul_x_lle" class="sref">gf128mul_x_lle /a>(& a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>], & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>+ a href="+code=j" class="sref">j /a>]);i 414 /a>i 415 /a>        for ( a href="+code=j" class="sref">j /a> = 2;  a href="+code=j" class="sref">j /a> < 256;  a href="+code=j" class="sref">j /a> +=  a href="+code=j" class="sref">j /a>)i 416 /a>                for ( a href="+code=k" class="sref">k /a> = 1;  a href="+code=k" class="sref">k /a> <  a href="+code=j" class="sref">j /a>; ++ a href="+code=k" class="sref">k /a>)i 417 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>(& a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a> +  a href="+code=k" class="sref">k /a>], & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>], & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=k" class="sref">k /a>]);i 418 /a>i 419 /a> a href="+code=out" class="sref">out /a>:i 420 /a>        return  a href="+code=t" class="sref">t /a>;i 421 /a>}i 422 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=gf128mul_init_4k_lle" class="sref">gf128mul_init_4k_lle /a>);i 423 /a>i 424 /a>struct  a href="+code=gf128mul_4k" class="sref">gf128mul_4k /a> * a href="+code=gf128mul_init_4k_bbe" class="sref">gf128mul_init_4k_bbe /a>(const  a href="+code=be128" class="sref">be128 /a> * a href="+code=g" class="sref">g /a>)i 425 /a>{i 426 /a>        struct  a href="+code=gf128mul_4k" class="sref">gf128mul_4k /a> * a href="+code=t" class="sref">t /a>;i 427 /a>        int  a href="+code=j" class="sref">j /a>,  a href="+code=k" class="sref">k /a>;i 428 /a>i 429 /a>         a href="+code=t" class="sref">t /a> =  a href="+code=kzalloc" class="sref">kzalloc /a>(sizeof(* a href="+code=t" class="sref">t /a>),  a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL /a>);i 430 /a>        if (! a href="+code=t" class="sref">t /a>)i 431 /a>                goto  a href="+code=out" class="sref">out /a>;i 432 /a>i 433 /a>         a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[1] = * a href="+code=g" class="sref">g /a>;i 434 /a>        for ( a href="+code=j" class="sref">j /a> = 1;  a href="+code=j" class="sref">j /a> <= 64;  a href="+code=j" class="sref">j /a> <<= 1)i 435 /a>                 a href="+code=gf128mul_x_bbe" class="sref">gf128mul_x_bbe /a>(& a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a> +  a href="+code=j" class="sref">j /a>], & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>]);i 436 /a>i 437 /a>        for ( a href="+code=j" class="sref">j /a> = 2;  a href="+code=j" class="sref">j /a> < 256;  a href="+code=j" class="sref">j /a> +=  a href="+code=j" class="sref">j /a>)i 438 /a>                for ( a href="+code=k" class="sref">k /a> = 1;  a href="+code=k" class="sref">k /a> <  a href="+code=j" class="sref">j /a>; ++ a href="+code=k" class="sref">k /a>)i 439 /a>                         a href="+code=be128_xor" class="sref">be128_xor /a>(& a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a> +  a href="+code=k" class="sref">k /a>], & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=j" class="sref">j /a>], & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=k" class="sref">k /a>]);i 440 /a>i 441 /a> a href="+code=out" class="sref">out /a>:i 442 /a>        return  a href="+code=t" class="sref">t /a>;i 443 /a>}i 444 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=gf128mul_init_4k_bbe" class="sref">gf128mul_init_4k_bbe /a>);i 445 /a>i 446 /a>void  a href="+code=gf128mul_4k_lle" class="sref">gf128mul_4k_lle /a>( a href="+code=be128" class="sref">be128 /a> * a href="+code=a" class="sref">a /a>, struct  a href="+code=gf128mul_4k" class="sref">gf128mul_4k /a> * a href="+code=t" class="sref">t /a>)i 447 /a>{i 448 /a>         a href="+code=u8" class="sref">u8 /a> * a href="+code=ap" class="sref">ap /a> = ( a href="+code=u8" class="sref">u8 /a> *) a href="+code=a" class="sref">a /a>;i 449 /a>         a href="+code=be128" class="sref">be128 /a>  a href="+code=r" class="sref">r /a>[1];i 450 /a>        int  a href="+code=i" class="sref">i /a> = 15;i 451 /a>i 452 /a>        * a href="+code=r" class="sref">r /a> =  a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=ap" class="sref">ap /a>[15]];i 453 /a>        while ( a href="+code=i" class="sref">i /a>--) {i 454 /a>                 a href="+code=gf128mul_x8_lle" class="sref">gf128mul_x8_lle /a>( a href="+code=r" class="sref">r /a>);i 455 /a>                 a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=ap" class="sref">ap /a>[ a href="+code=i" class="sref">i /a>]]);i 456 /a>        }i 457 /a>        * a href="+code=a" class="sref">a /a> = * a href="+code=r" class="sref">r /a>;i 458 /a>}i 459 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=gf128mul_4k_lle" class="sref">gf128mul_4k_lle /a>);i 460 /a>i 461 /a>void  a href="+code=gf128mul_4k_bbe" class="sref">gf128mul_4k_bbe /a>( a href="+code=be128" class="sref">be128 /a> * a href="+code=a" class="sref">a /a>, struct  a href="+code=gf128mul_4k" class="sref">gf128mul_4k /a> * a href="+code=t" class="sref">t /a>)i 462 /a>{i 463 /a>         a href="+code=u8" class="sref">u8 /a> * a href="+code=ap" class="sref">ap /a> = ( a href="+code=u8" class="sref">u8 /a> *) a href="+code=a" class="sref">a /a>;i 464 /a>         a href="+code=be128" class="sref">be128 /a>  a href="+code=r" class="sref">r /a>[1];i 465 /a>        int  a href="+code=i" class="sref">i /a> = 0;i 466 /a>i 467 /a>        * a href="+code=r" class="sref">r /a> =  a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=ap" class="sref">ap /a>[0]];i 468 /a>        while (++ a href="+code=i" class="sref">i /a> < 16) {i 469 /a>                 a href="+code=gf128mul_x8_bbe" class="sref">gf128mul_x8_bbe /a>( a href="+code=r" class="sref">r /a>);i 470 /a>                 a href="+code=be128_xor" class="sref">be128_xor /a>( a href="+code=r" class="sref">r /a>,  a href="+code=r" class="sref">r /a>, & a href="+code=t" class="sref">t /a>-> a href="+code=t" class="sref">t /a>[ a href="+code=ap" class="sref">ap /a>[ a href="+code=i" class="sref">i /a>]]);i 471 /a>        }i 472 /a>        * a href="+code=a" class="sref">a /a> = * a href="+code=r" class="sref">r /a>;i 473 /a>}i 474 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=gf128mul_4k_bbe" class="sref">gf128mul_4k_bbe /a>);i 475 /a>i 476 /a> a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE /a>( spap class="string">"GPL" /spapt);i 477 /a> a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION /a>( spap class="string">"Functions for multiplying elements of GF(2^128)" /spapt);i 478 /a>
lxr.linux.no kindly hosted by Redpill Linpro AS /a>, provider of Linux consulting and operations services since 1995.