2 * Accelerated GHASH implementation with Intel PCLMULQDQ-NI
3 * instructions. This file contains accelerated part of ghash
4 * implementation. More information about PCLMULQDQ can be found at:
6 * http://software.intel.com/en-us/articles/carry-less-multiplication-and-its-usage-for-computing-the-gcm-mode/
8 * Copyright (c) 2009 Intel Corp.
9 * Author: Huang Ying <ying.huang@intel.com>
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License version 2 as published
16 * by the Free Software Foundation.
19 #include <linux/linkage.h>
21 #include <asm/frame.h>
23 .section .rodata.cst16.bswap_mask, "aM", @progbits, 16
26 .octa 0x000102030405060708090a0b0c0d0e0f
39 * __clmul_gf128mul_ble: internal ABI
42 * SHASH: operand2, hash_key << 1 mod poly
44 * DATA: operand1 * operand2 mod poly
52 pshufd $0b01001110, DATA, T2
53 pshufd $0b01001110, SHASH, T3
57 PCLMULQDQ 0x00 SHASH DATA # DATA = a0 * b0
58 PCLMULQDQ 0x11 SHASH T1 # T1 = a1 * b1
59 PCLMULQDQ 0x00 T3 T2 # T2 = (a1 + a0) * (b1 + b0)
61 pxor T1, T2 # T2 = a0 * b1 + a1 * b0
67 pxor T2, T1 # <T1:DATA> is result of
68 # carry-less multiplication
70 # first phase of the reduction
83 # second phase of the reduction
93 ENDPROC(__clmul_gf128mul_ble)
95 /* void clmul_ghash_mul(char *dst, const u128 *shash) */
96 ENTRY(clmul_ghash_mul)
100 movaps .Lbswap_mask, BSWAP
101 PSHUFB_XMM BSWAP DATA
102 call __clmul_gf128mul_ble
103 PSHUFB_XMM BSWAP DATA
107 ENDPROC(clmul_ghash_mul)
110 * void clmul_ghash_update(char *dst, const char *src, unsigned int srclen,
111 * const u128 *shash);
113 ENTRY(clmul_ghash_update)
116 jb .Lupdate_just_ret # check length
117 movaps .Lbswap_mask, BSWAP
120 PSHUFB_XMM BSWAP DATA
126 call __clmul_gf128mul_ble
131 PSHUFB_XMM BSWAP DATA
136 ENDPROC(clmul_ghash_update)