Debian Codegraph @

cipher/poly1305-s390x.S

raw
1 /* poly1305-s390x.S - zSeries implementation of Poly1305
2 *
3 * Copyright (C) 2020 Jussi Kivilinna <[email protected]>
4 *
5 * This file is part of Libgcrypt.
6 *
7 * Libgcrypt is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * Libgcrypt is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include <config.h>
22 #if defined (__s390x__) && __GNUC__ >= 4 && __ARCH__ >= 9
23 #if defined(HAVE_GCC_INLINE_ASM_S390X)
24
25 #include "asm-poly1305-s390x.h"
26
27 .text
28
29 .balign 16
30 .globl _gcry_poly1305_s390x_blocks1
31 ELF(.type _gcry_poly1305_s390x_blocks1,@function;)
32
33 _gcry_poly1305_s390x_blocks1:
34 /* input:
35 * %r2: poly1305-state
36 * %r3: src
37 * %r4: len
38 * %r5: high_pad
39 */
40 CFI_STARTPROC();
41
42 stmg %r6, %r14, 6 * 8(%r15);
43
44 lgr POLY_RSTATE, %r2;
45 lgr POLY_RSRC, %r3;
46 srlg %r0, %r4, 4;
47
48 cgije %r5, 0, .Lpoly_high0;
49
50 POLY1305_LOAD_STATE();
51
52 .balign 4
53 .Lpoly_loop_high1:
54 POLY1305_BLOCK_PART1(0 * 16);
55 INC_POLY1305_SRC(1 * 16);
56 .Lpoly_block_part2:
57 POLY1305_BLOCK_PART2();
58 POLY1305_BLOCK_PART3();
59 POLY1305_BLOCK_PART4();
60 POLY1305_BLOCK_PART5();
61 POLY1305_BLOCK_PART6();
62 POLY1305_BLOCK_PART7();
63 POLY1305_BLOCK_PART8();
64
65 brctg %r0, .Lpoly_loop_high1;
66
67 .balign 4
68 .Lpoly_done:
69 POLY1305_STORE_STATE();
70
71 lmg %r6, %r14, 6 * 8(%r15);
72 xgr %r2, %r2;
73 br %r14;
74
75 .balign 4
76 .Lpoly_high0:
77 lghi %r0, 1;
78 POLY1305_LOAD_STATE();
79 POLY1305_BLOCK_PART1_HB(0 * 16, 0);
80 j .Lpoly_block_part2;
81
82 CFI_ENDPROC();
83 ELF(.size _gcry_poly1305_s390x_blocks1,
84 .-_gcry_poly1305_s390x_blocks1;)
85
86 #endif /*HAVE_GCC_INLINE_ASM_S390X*/
87 #endif /*__s390x__*/