summaryrefslogtreecommitdiff
path: root/cipher/poly1305-s390x.S
blob: 5ba424e4bd239175d8bc45e55ad645ab7467d429 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* poly1305-s390x.S  -  zSeries implementation of Poly1305
 *
 * Copyright (C) 2020 Jussi Kivilinna <jussi.kivilinna@iki.fi>
 *
 * This file is part of Libgcrypt.
 *
 * Libgcrypt is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * Libgcrypt is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#include <config.h>
#if defined (__s390x__) && __GNUC__ >= 4 && __ARCH__ >= 9
#if defined(HAVE_GCC_INLINE_ASM_S390X)

#include "asm-poly1305-s390x.h"

.text

.balign 16
.globl _gcry_poly1305_s390x_blocks1
ELF(.type _gcry_poly1305_s390x_blocks1,@function;)

_gcry_poly1305_s390x_blocks1:
	/* input:
	 *	%r2: poly1305-state
	 *	%r3: src
	 *	%r4: len
	 *	%r5: high_pad
	 */
	CFI_STARTPROC();

	stmg %r6, %r14, 6 * 8(%r15);

	lgr POLY_RSTATE, %r2;
	lgr POLY_RSRC, %r3;
	srlg %r0, %r4, 4;

	cgije %r5, 0, .Lpoly_high0;

	POLY1305_LOAD_STATE();

.balign 4
.Lpoly_loop_high1:
	POLY1305_BLOCK_PART1(0 * 16);
	INC_POLY1305_SRC(1 * 16);
.Lpoly_block_part2:
	POLY1305_BLOCK_PART2();
	POLY1305_BLOCK_PART3();
	POLY1305_BLOCK_PART4();
	POLY1305_BLOCK_PART5();
	POLY1305_BLOCK_PART6();
	POLY1305_BLOCK_PART7();
	POLY1305_BLOCK_PART8();

	brctg %r0, .Lpoly_loop_high1;

.balign 4
.Lpoly_done:
	POLY1305_STORE_STATE();

	lmg %r6, %r14, 6 * 8(%r15);
	xgr %r2, %r2;
	br %r14;

.balign 4
.Lpoly_high0:
	lghi %r0, 1;
	POLY1305_LOAD_STATE();
	POLY1305_BLOCK_PART1_HB(0 * 16, 0);
	j .Lpoly_block_part2;

	CFI_ENDPROC();
ELF(.size _gcry_poly1305_s390x_blocks1,
    .-_gcry_poly1305_s390x_blocks1;)

#endif /*HAVE_GCC_INLINE_ASM_S390X*/
#endif /*__s390x__*/