polyval-generic.c (f3c923a09c4c4f5861b1ed53cf75673992a6ba68) | polyval-generic.c (34f7f6c3011276313383099156be287ac745bcea) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * POLYVAL: hash function for HCTR2. 4 * 5 * Copyright (c) 2007 Nokia Siemens Networks - Mikko Herranen <mh1@iki.fi> 6 * Copyright (c) 2009 Intel Corp. 7 * Author: Huang Ying <ying.huang@intel.com> 8 * Copyright 2021 Google LLC --- 62 unchanged lines hidden (view full) --- 71{ 72 u64 a = get_unaligned((const u64 *)&src[0]); 73 u64 b = get_unaligned((const u64 *)&src[8]); 74 75 put_unaligned(swab64(a), (u64 *)&dst[8]); 76 put_unaligned(swab64(b), (u64 *)&dst[0]); 77} 78 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * POLYVAL: hash function for HCTR2. 4 * 5 * Copyright (c) 2007 Nokia Siemens Networks - Mikko Herranen <mh1@iki.fi> 6 * Copyright (c) 2009 Intel Corp. 7 * Author: Huang Ying <ying.huang@intel.com> 8 * Copyright 2021 Google LLC --- 62 unchanged lines hidden (view full) --- 71{ 72 u64 a = get_unaligned((const u64 *)&src[0]); 73 u64 b = get_unaligned((const u64 *)&src[8]); 74 75 put_unaligned(swab64(a), (u64 *)&dst[8]); 76 put_unaligned(swab64(b), (u64 *)&dst[0]); 77} 78 |
79/* 80 * Performs multiplication in the POLYVAL field using the GHASH field as a 81 * subroutine. This function is used as a fallback for hardware accelerated 82 * implementations when simd registers are unavailable. 83 * 84 * Note: This function is not used for polyval-generic, instead we use the 4k 85 * lookup table implementation for finite field multiplication. 86 */ 87void polyval_mul_non4k(u8 *op1, const u8 *op2) 88{ 89 be128 a, b; 90 91 // Assume one argument is in Montgomery form and one is not. 92 copy_and_reverse((u8 *)&a, op1); 93 copy_and_reverse((u8 *)&b, op2); 94 gf128mul_x_lle(&a, &a); 95 gf128mul_lle(&a, &b); 96 copy_and_reverse(op1, (u8 *)&a); 97} 98EXPORT_SYMBOL_GPL(polyval_mul_non4k); 99 100/* 101 * Perform a POLYVAL update using non4k multiplication. This function is used 102 * as a fallback for hardware accelerated implementations when simd registers 103 * are unavailable. 104 * 105 * Note: This function is not used for polyval-generic, instead we use the 4k 106 * lookup table implementation of finite field multiplication. 107 */ 108void polyval_update_non4k(const u8 *key, const u8 *in, 109 size_t nblocks, u8 *accumulator) 110{ 111 while (nblocks--) { 112 crypto_xor(accumulator, in, POLYVAL_BLOCK_SIZE); 113 polyval_mul_non4k(accumulator, key); 114 in += POLYVAL_BLOCK_SIZE; 115 } 116} 117EXPORT_SYMBOL_GPL(polyval_update_non4k); 118 |
|
79static int polyval_setkey(struct crypto_shash *tfm, 80 const u8 *key, unsigned int keylen) 81{ 82 struct polyval_tfm_ctx *ctx = crypto_shash_ctx(tfm); 83 be128 k; 84 85 if (keylen != POLYVAL_BLOCK_SIZE) 86 return -EINVAL; --- 119 unchanged lines hidden --- | 119static int polyval_setkey(struct crypto_shash *tfm, 120 const u8 *key, unsigned int keylen) 121{ 122 struct polyval_tfm_ctx *ctx = crypto_shash_ctx(tfm); 123 be128 k; 124 125 if (keylen != POLYVAL_BLOCK_SIZE) 126 return -EINVAL; --- 119 unchanged lines hidden --- |