mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-23 23:59:22 +00:00
libgcrypt: Import libgcrypt 1.11
We currently use an old version of libgcrypt which results in us having fewer ciphers and missing on many other improvements. Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
a0d4c94ef6
commit
3312af6e07
468 files changed
+210508
-33178
No files matched your search
@@ -1,9 +1,14 @@
|
||||
2011-12-01 Werner Koch <wk@g10code.com>
|
||||
|
||||
NB: ChangeLog files are no longer manually maintained. Starting
|
||||
on December 1st, 2011 we put change information only in the GIT
|
||||
commit log, and generate a top-level ChangeLog file from logs at
|
||||
"make dist". See doc/HACKING for details.
|
||||
NB: ChangeLog files are no longer manually maintained. Starting
|
||||
on December 1st, 2011 we put change information only in the GIT
|
||||
commit log, and generate a top-level ChangeLog file from logs at
|
||||
"make dist". See doc/HACKING for details.
|
||||
|
||||
2011-07-04 Werner Koch <wk@g10code.com>
|
||||
|
||||
* longlong.h (add_ssaaaa) [__arm__]: Do no use asm if thumb code
|
||||
generation is enabled. This is bug#1202. Reported for gpg 1.4.
|
||||
|
||||
2011-03-28 Werner Koch <wk@g10code.com>
|
||||
|
||||
@@ -820,3 +825,7 @@ Mon Feb 16 13:00:27 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||
This file is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
Local Variables:
|
||||
buffer-read-only: t
|
||||
End:
|
||||
@@ -14,8 +14,8 @@
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
# License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
# 1.5 leads to a combinatorial explosion due to all the conditionals
|
||||
# I was not able to build it with 64Megs - 1.6 fixes this.
|
||||
@@ -29,7 +29,7 @@ AM_CFLAGS = $(GPG_ERROR_CFLAGS)
|
||||
AM_ASFLAGS = $(MPI_SFLAGS)
|
||||
AM_CCASFLAGS = $(NOEXECSTACK_FLAGS)
|
||||
|
||||
EXTRA_DIST = Manifest config.links
|
||||
EXTRA_DIST = config.links
|
||||
DISTCLEANFILES = mpi-asm-defs.h \
|
||||
mpih-add1-asm.S mpih-mul1-asm.S mpih-mul2-asm.S mpih-mul3-asm.S \
|
||||
mpih-lshift-asm.S mpih-rshift-asm.S mpih-sub1-asm.S asm-syntax.h \
|
||||
@@ -173,5 +173,11 @@ libmpi_la_SOURCES = longlong.h \
|
||||
mpicoder.c \
|
||||
mpih-div.c \
|
||||
mpih-mul.c \
|
||||
mpiutil.c \
|
||||
ec.c
|
||||
mpih-const-time.c \
|
||||
mpiutil.c \
|
||||
ec.c ec-internal.h ec-ed25519.c ec-nist.c ec-inline.h \
|
||||
ec-hw-s390x.c
|
||||
EXTRA_libmpi_la_SOURCES = \
|
||||
asm-common-aarch64.h \
|
||||
asm-common-amd64.h \
|
||||
asm-common-i386.h
|
||||
@@ -1,41 +0,0 @@
|
||||
# Manifest - checksums of the mpi directory
|
||||
# Copyright 2003 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
Makefile.am
|
||||
config.links
|
||||
longlong.h
|
||||
mpi-add.c
|
||||
mpi-bit.c
|
||||
mpi-cmp.c
|
||||
mpi-div.c
|
||||
mpi-gcd.c
|
||||
mpi-inline.c
|
||||
mpi-inline.h
|
||||
mpi-internal.h
|
||||
mpi-inv.c
|
||||
mpi-mpow.c
|
||||
mpi-mul.c
|
||||
mpi-pow.c
|
||||
mpi-scan.c
|
||||
mpicoder.c
|
||||
mpih-div.c
|
||||
mpih-mul.c
|
||||
mpiutil.c
|
||||
$names$ iQCVAwUAP+LmfDEAnp832S/7AQKZJQQAkR/gQITUM+6Ygy9WAOAO17btyKAlCtGTXp5XSZ+J3X0o/rYneRdSCW89IJvwFRJjAOcFJd52MXs6ZVFF/RQBC8MvJzuQChbEzvihK8o2VgK34YWjU+6XH9sFgRMIgzkHs/51ZZxeQUOPy1XF7TyKB0WE7YBUVisFiRaqB1qGIOs==Z3qB
|
||||
|
||||
+1
@@ -3,3 +3,4 @@ mpih-mul1.S
|
||||
mpih-mul2.S
|
||||
mpih-mul3.S
|
||||
mpih-sub1.S
|
||||
mpi-asm-defs.h
|
||||
@@ -0,0 +1,4 @@
|
||||
/* This file defines some basic constants for the MPI machinery. We
|
||||
* need to define the types on a per-CPU basis, so it is done with
|
||||
* this file here. */
|
||||
#define BYTES_PER_MPI_LIMB (SIZEOF_UNSIGNED_LONG_LONG)
|
||||
@@ -0,0 +1,75 @@
|
||||
/* ARM64 add_n -- Add two limb vectors of the same length > 0 and store
|
||||
* sum in a third limb vector.
|
||||
*
|
||||
* Copyright (C) 2013 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 "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
#include "asm-common-aarch64.h"
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_add_n( mpi_ptr_t res_ptr, x0
|
||||
* mpi_ptr_t s1_ptr, x1
|
||||
* mpi_ptr_t s2_ptr, x2
|
||||
* mpi_size_t size) w3
|
||||
*/
|
||||
|
||||
.text
|
||||
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_add_n)
|
||||
ELF(.type C_SYMBOL_NAME(_gcry_mpih_add_n),%function)
|
||||
.align 4
|
||||
C_SYMBOL_NAME(_gcry_mpih_add_n):
|
||||
CFI_STARTPROC()
|
||||
and w5, w3, #3;
|
||||
adds xzr, xzr, xzr; /* clear carry flag */
|
||||
|
||||
cbz w5, .Large_loop;
|
||||
|
||||
.Loop:
|
||||
ldr x4, [x1], #8;
|
||||
sub w3, w3, #1;
|
||||
ldr x11, [x2], #8;
|
||||
and w5, w3, #3;
|
||||
adcs x4, x4, x11;
|
||||
str x4, [x0], #8;
|
||||
cbz w3, .Lend;
|
||||
cbnz w5, .Loop;
|
||||
|
||||
.Large_loop:
|
||||
ldp x4, x6, [x1], #16;
|
||||
ldp x5, x7, [x2], #16;
|
||||
ldp x8, x10, [x1], #16;
|
||||
ldp x9, x11, [x2], #16;
|
||||
sub w3, w3, #4;
|
||||
adcs x4, x4, x5;
|
||||
adcs x6, x6, x7;
|
||||
adcs x8, x8, x9;
|
||||
adcs x10, x10, x11;
|
||||
stp x4, x6, [x0], #16;
|
||||
stp x8, x10, [x0], #16;
|
||||
cbnz w3, .Large_loop;
|
||||
|
||||
.Lend:
|
||||
adc x0, xzr, xzr;
|
||||
ret_spec_stop;
|
||||
CFI_ENDPROC()
|
||||
ELF(.size C_SYMBOL_NAME(_gcry_mpih_add_n),.-C_SYMBOL_NAME(_gcry_mpih_add_n);)
|
||||
@@ -0,0 +1,100 @@
|
||||
/* ARM64 mul_1 -- Multiply a limb vector with a limb and store the result in
|
||||
* a second limb vector.
|
||||
*
|
||||
* Copyright (C) 2013 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 "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
#include "asm-common-aarch64.h"
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_mul_1( mpi_ptr_t res_ptr, x0
|
||||
* mpi_ptr_t s1_ptr, x1
|
||||
* mpi_size_t s1_size, w2
|
||||
* mpi_limb_t s2_limb) x3
|
||||
*/
|
||||
|
||||
.text
|
||||
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_mul_1)
|
||||
ELF(.type C_SYMBOL_NAME(_gcry_mpih_mul_1),%function)
|
||||
.align 4
|
||||
C_SYMBOL_NAME(_gcry_mpih_mul_1):
|
||||
CFI_STARTPROC()
|
||||
and w5, w2, #3;
|
||||
mov x4, xzr;
|
||||
|
||||
cbz w5, .Large_loop;
|
||||
|
||||
.Loop:
|
||||
ldr x5, [x1], #8;
|
||||
sub w2, w2, #1;
|
||||
mul x9, x5, x3;
|
||||
umulh x10, x5, x3;
|
||||
and w5, w2, #3;
|
||||
adds x4, x4, x9;
|
||||
str x4, [x0], #8;
|
||||
adc x4, x10, xzr;
|
||||
|
||||
cbz w2, .Lend;
|
||||
cbnz w5, .Loop;
|
||||
|
||||
.Large_loop:
|
||||
ldp x5, x6, [x1];
|
||||
sub w2, w2, #4;
|
||||
|
||||
mul x9, x5, x3;
|
||||
ldp x7, x8, [x1, #16];
|
||||
umulh x10, x5, x3;
|
||||
add x1, x1, #32;
|
||||
|
||||
adds x4, x4, x9;
|
||||
str x4, [x0], #8;
|
||||
mul x11, x6, x3;
|
||||
adc x4, x10, xzr;
|
||||
|
||||
umulh x12, x6, x3;
|
||||
|
||||
adds x4, x4, x11;
|
||||
str x4, [x0], #8;
|
||||
mul x13, x7, x3;
|
||||
adc x4, x12, xzr;
|
||||
|
||||
umulh x14, x7, x3;
|
||||
|
||||
adds x4, x4, x13;
|
||||
str x4, [x0], #8;
|
||||
mul x15, x8, x3;
|
||||
adc x4, x14, xzr;
|
||||
|
||||
umulh x16, x8, x3;
|
||||
|
||||
adds x4, x4, x15;
|
||||
str x4, [x0], #8;
|
||||
adc x4, x16, xzr;
|
||||
|
||||
cbnz w2, .Large_loop;
|
||||
|
||||
.Lend:
|
||||
mov x0, x4;
|
||||
ret_spec_stop;
|
||||
CFI_ENDPROC()
|
||||
ELF(.size C_SYMBOL_NAME(_gcry_mpih_mul_1),.-C_SYMBOL_NAME(_gcry_mpih_mul_1);)
|
||||
@@ -0,0 +1,112 @@
|
||||
/* ARM64 mul_2 -- Multiply a limb vector with a limb and add the result to
|
||||
* a second limb vector.
|
||||
*
|
||||
* Copyright (C) 2013 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 "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
#include "asm-common-aarch64.h"
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, x0
|
||||
* mpi_ptr_t s1_ptr, x1
|
||||
* mpi_size_t s1_size, w2
|
||||
* mpi_limb_t s2_limb) x3
|
||||
*/
|
||||
|
||||
.text
|
||||
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_addmul_1)
|
||||
ELF(.type C_SYMBOL_NAME(_gcry_mpih_addmul_1),%function)
|
||||
.align 4
|
||||
C_SYMBOL_NAME(_gcry_mpih_addmul_1):
|
||||
CFI_STARTPROC()
|
||||
and w5, w2, #3;
|
||||
mov x6, xzr;
|
||||
mov x7, xzr;
|
||||
|
||||
cbz w5, .Large_loop;
|
||||
|
||||
.Loop:
|
||||
ldr x5, [x1], #8;
|
||||
|
||||
mul x12, x5, x3;
|
||||
ldr x4, [x0];
|
||||
umulh x13, x5, x3;
|
||||
sub w2, w2, #1;
|
||||
|
||||
adds x12, x12, x4;
|
||||
and w5, w2, #3;
|
||||
adc x13, x13, x7;
|
||||
adds x12, x12, x6;
|
||||
str x12, [x0], #8;
|
||||
adc x6, x7, x13;
|
||||
|
||||
cbz w2, .Lend;
|
||||
cbnz w5, .Loop;
|
||||
|
||||
.Large_loop:
|
||||
ldp x5, x9, [x1], #16;
|
||||
sub w2, w2, #4;
|
||||
ldp x4, x8, [x0];
|
||||
|
||||
mul x12, x5, x3;
|
||||
umulh x13, x5, x3;
|
||||
|
||||
adds x12, x12, x4;
|
||||
mul x14, x9, x3;
|
||||
adc x13, x13, x7;
|
||||
adds x12, x12, x6;
|
||||
umulh x15, x9, x3;
|
||||
str x12, [x0], #8;
|
||||
adc x6, x7, x13;
|
||||
|
||||
adds x14, x14, x8;
|
||||
ldp x5, x9, [x1], #16;
|
||||
adc x15, x15, x7;
|
||||
adds x14, x14, x6;
|
||||
mul x12, x5, x3;
|
||||
str x14, [x0], #8;
|
||||
ldp x4, x8, [x0];
|
||||
umulh x13, x5, x3;
|
||||
adc x6, x7, x15;
|
||||
|
||||
adds x12, x12, x4;
|
||||
mul x14, x9, x3;
|
||||
adc x13, x13, x7;
|
||||
adds x12, x12, x6;
|
||||
umulh x15, x9, x3;
|
||||
str x12, [x0], #8;
|
||||
adc x6, x7, x13;
|
||||
|
||||
adds x14, x14, x8;
|
||||
adc x15, x15, x7;
|
||||
adds x14, x14, x6;
|
||||
str x14, [x0], #8;
|
||||
adc x6, x7, x15;
|
||||
|
||||
cbnz w2, .Large_loop;
|
||||
|
||||
.Lend:
|
||||
mov x0, x6;
|
||||
ret_spec_stop;
|
||||
CFI_ENDPROC()
|
||||
ELF(.size C_SYMBOL_NAME(_gcry_mpih_addmul_1),.-C_SYMBOL_NAME(_gcry_mpih_addmul_1);)
|
||||
@@ -0,0 +1,125 @@
|
||||
/* ARM mul_3 -- Multiply a limb vector with a limb and subtract the result
|
||||
* from a second limb vector.
|
||||
*
|
||||
* Copyright (C) 2013 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 "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
#include "asm-common-aarch64.h"
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_submul_1( mpi_ptr_t res_ptr, x0
|
||||
* mpi_ptr_t s1_ptr, x1
|
||||
* mpi_size_t s1_size, w2
|
||||
* mpi_limb_t s2_limb) x3
|
||||
*/
|
||||
|
||||
.text
|
||||
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_submul_1)
|
||||
ELF(.type C_SYMBOL_NAME(_gcry_mpih_submul_1),%function)
|
||||
.align 4
|
||||
C_SYMBOL_NAME(_gcry_mpih_submul_1):
|
||||
CFI_STARTPROC()
|
||||
and w5, w2, #3;
|
||||
mov x7, xzr;
|
||||
cbz w5, .Large_loop;
|
||||
|
||||
subs xzr, xzr, xzr;
|
||||
|
||||
.Loop:
|
||||
ldr x4, [x1], #8;
|
||||
cinc x7, x7, cc;
|
||||
ldr x5, [x0];
|
||||
sub w2, w2, #1;
|
||||
|
||||
mul x6, x4, x3;
|
||||
subs x5, x5, x7;
|
||||
umulh x4, x4, x3;
|
||||
and w10, w2, #3;
|
||||
|
||||
cset x7, cc;
|
||||
subs x5, x5, x6;
|
||||
add x7, x7, x4;
|
||||
str x5, [x0], #8;
|
||||
|
||||
cbz w2, .Loop_end;
|
||||
cbnz w10, .Loop;
|
||||
|
||||
cinc x7, x7, cc;
|
||||
|
||||
.Large_loop:
|
||||
ldp x4, x8, [x1], #16;
|
||||
sub w2, w2, #4;
|
||||
ldp x5, x9, [x0];
|
||||
|
||||
mul x6, x4, x3;
|
||||
subs x5, x5, x7;
|
||||
umulh x4, x4, x3;
|
||||
|
||||
cset x7, cc;
|
||||
subs x5, x5, x6;
|
||||
mul x6, x8, x3;
|
||||
add x7, x7, x4;
|
||||
str x5, [x0], #8;
|
||||
cinc x7, x7, cc;
|
||||
|
||||
umulh x8, x8, x3;
|
||||
|
||||
subs x9, x9, x7;
|
||||
cset x7, cc;
|
||||
subs x9, x9, x6;
|
||||
ldp x4, x10, [x1], #16;
|
||||
str x9, [x0], #8;
|
||||
add x7, x7, x8;
|
||||
ldp x5, x9, [x0];
|
||||
cinc x7, x7, cc;
|
||||
|
||||
mul x6, x4, x3;
|
||||
subs x5, x5, x7;
|
||||
umulh x4, x4, x3;
|
||||
|
||||
cset x7, cc;
|
||||
subs x5, x5, x6;
|
||||
mul x6, x10, x3;
|
||||
add x7, x7, x4;
|
||||
str x5, [x0], #8;
|
||||
cinc x7, x7, cc;
|
||||
|
||||
umulh x10, x10, x3;
|
||||
|
||||
subs x9, x9, x7;
|
||||
cset x7, cc;
|
||||
subs x9, x9, x6;
|
||||
add x7, x7, x10;
|
||||
str x9, [x0], #8;
|
||||
cinc x7, x7, cc;
|
||||
|
||||
cbnz w2, .Large_loop;
|
||||
|
||||
mov x0, x7;
|
||||
ret_spec_stop;
|
||||
|
||||
.Loop_end:
|
||||
cinc x0, x7, cc;
|
||||
ret_spec_stop;
|
||||
CFI_ENDPROC()
|
||||
ELF(.size C_SYMBOL_NAME(_gcry_mpih_submul_1),.-C_SYMBOL_NAME(_gcry_mpih_submul_1);)
|
||||
@@ -0,0 +1,75 @@
|
||||
/* ARM64 sub_n -- Subtract two limb vectors of the same length > 0 and store
|
||||
* sum in a third limb vector.
|
||||
*
|
||||
* Copyright (C) 2013 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 "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
#include "asm-common-aarch64.h"
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_sub_n( mpi_ptr_t res_ptr, x0
|
||||
* mpi_ptr_t s1_ptr, x1
|
||||
* mpi_ptr_t s2_ptr, x2
|
||||
* mpi_size_t size) w3
|
||||
*/
|
||||
|
||||
.text
|
||||
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_sub_n)
|
||||
ELF(.type C_SYMBOL_NAME(_gcry_mpih_sub_n),%function)
|
||||
.align 4
|
||||
C_SYMBOL_NAME(_gcry_mpih_sub_n):
|
||||
CFI_STARTPROC()
|
||||
and w5, w3, #3;
|
||||
subs xzr, xzr, xzr; /* prepare carry flag for sub */
|
||||
|
||||
cbz w5, .Large_loop;
|
||||
|
||||
.Loop:
|
||||
ldr x4, [x1], #8;
|
||||
sub w3, w3, #1;
|
||||
ldr x11, [x2], #8;
|
||||
and w5, w3, #3;
|
||||
sbcs x4, x4, x11;
|
||||
str x4, [x0], #8;
|
||||
cbz w3, .Lend;
|
||||
cbnz w5, .Loop;
|
||||
|
||||
.Large_loop:
|
||||
ldp x4, x6, [x1], #16;
|
||||
ldp x5, x7, [x2], #16;
|
||||
ldp x8, x10, [x1], #16;
|
||||
ldp x9, x11, [x2], #16;
|
||||
sub w3, w3, #4;
|
||||
sbcs x4, x4, x5;
|
||||
sbcs x6, x6, x7;
|
||||
sbcs x8, x8, x9;
|
||||
sbcs x10, x10, x11;
|
||||
stp x4, x6, [x0], #16;
|
||||
stp x8, x10, [x0], #16;
|
||||
cbnz w3, .Large_loop;
|
||||
|
||||
.Lend:
|
||||
cset x0, cc;
|
||||
ret_spec_stop;
|
||||
CFI_ENDPROC()
|
||||
ELF(.size C_SYMBOL_NAME(_gcry_mpih_sub_n),.-C_SYMBOL_NAME(_gcry_mpih_sub_n);)
|
||||
@@ -5,7 +5,7 @@ RELEVANT OPTIMIZATION ISSUES
|
||||
EV4
|
||||
|
||||
1. This chip has very limited store bandwidth. The on-chip L1 cache is
|
||||
write-through, and a cache line is transfered from the store buffer to the
|
||||
write-through, and a cache line is transferred from the store buffer to the
|
||||
off-chip L2 in as much 15 cycles on most systems. This delay hurts
|
||||
mpn_add_n, mpn_sub_n, mpn_lshift, and mpn_rshift.
|
||||
|
||||
@@ -20,7 +20,7 @@ EV5
|
||||
|
||||
1. The memory bandwidth of this chip seems excellent, both for loads and
|
||||
stores. Even when the working set is larger than the on-chip L1 and L2
|
||||
caches, the perfromance remain almost unaffected.
|
||||
caches, the performance remain almost unaffected.
|
||||
|
||||
2. mulq has a measured latency of 13 cycles and an issue rate of 1 each 8th
|
||||
cycle. umulh has a measured latency of 15 cycles and an issue rate of 1
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
func_abi.h
|
||||
mpih-add1.S
|
||||
mpih-lshift.S
|
||||
mpih-mul1.S
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "asm-common-amd64.h"
|
||||
|
||||
#ifdef USE_MS_ABI
|
||||
/* Store registers and move four first input arguments from MS ABI to
|
||||
* SYSV ABI. */
|
||||
#define FUNC_ENTRY() \
|
||||
CFI_STARTPROC(); \
|
||||
pushq %rsi; \
|
||||
CFI_PUSH(%rsi); \
|
||||
pushq %rdi; \
|
||||
CFI_PUSH(%rdi); \
|
||||
movq %rdx, %rsi; \
|
||||
movq %rcx, %rdi; \
|
||||
movq %r8, %rdx; \
|
||||
movq %r9, %rcx;
|
||||
|
||||
/* Restore registers. */
|
||||
#define FUNC_EXIT() \
|
||||
popq %rdi; \
|
||||
CFI_POP(%rdi); \
|
||||
popq %rsi; \
|
||||
CFI_POP(%rsi); \
|
||||
ret_spec_stop; \
|
||||
CFI_ENDPROC();
|
||||
#else
|
||||
#define FUNC_ENTRY() \
|
||||
CFI_STARTPROC();
|
||||
|
||||
#define FUNC_EXIT() \
|
||||
ret_spec_stop; \
|
||||
CFI_ENDPROC();
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/* This file defines some basic constants for the MPI machinery. We
|
||||
* need to define the types on a per-CPU basis, so it is done with
|
||||
* this file here. */
|
||||
#define BYTES_PER_MPI_LIMB 8
|
||||
#define BYTES_PER_MPI_LIMB (SIZEOF_UNSIGNED_LONG_LONG)
|
||||
@@ -3,6 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1995, 1998,
|
||||
* 2001, 2002, 2006 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2023 Jussi Kivilinna <jussi.kivilinna@iki.fi>
|
||||
*
|
||||
* This file is part of Libgcrypt.
|
||||
*
|
||||
@@ -17,8 +18,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -39,25 +40,80 @@
|
||||
* mpi_ptr_t s2_ptr, rdx
|
||||
* mpi_size_t size) rcx
|
||||
*/
|
||||
|
||||
.text
|
||||
TEXT
|
||||
ALIGN(4)
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_add_n)
|
||||
C_SYMBOL_NAME(_gcry_mpih_add_n:)
|
||||
leaq (%rsi,%rcx,8), %rsi
|
||||
leaq (%rdi,%rcx,8), %rdi
|
||||
leaq (%rdx,%rcx,8), %rdx
|
||||
negq %rcx
|
||||
xorl %eax, %eax /* clear cy */
|
||||
FUNC_ENTRY()
|
||||
movl %ecx, %r9d
|
||||
andl $3, %r9d
|
||||
je .Lprehandle0
|
||||
cmpl $2, %r9d
|
||||
jb .Lprehandle1
|
||||
je .Lprehandle2
|
||||
|
||||
#define FIRST_ADD() \
|
||||
movq (%rsi), %rax; \
|
||||
addq (%rdx), %rax; \
|
||||
movq %rax, (%rdi)
|
||||
|
||||
#define NEXT_ADD(offset) \
|
||||
movq offset(%rsi), %rax; \
|
||||
adcq offset(%rdx), %rax; \
|
||||
movq %rax, offset(%rdi)
|
||||
|
||||
.Lprehandle3:
|
||||
leaq -2(%rcx), %rcx
|
||||
FIRST_ADD();
|
||||
NEXT_ADD(8);
|
||||
NEXT_ADD(16);
|
||||
decq %rcx
|
||||
je .Lend
|
||||
leaq 24(%rsi), %rsi
|
||||
leaq 24(%rdx), %rdx
|
||||
leaq 24(%rdi), %rdi
|
||||
jmp .Loop
|
||||
|
||||
ALIGN(3)
|
||||
.Lprehandle2:
|
||||
leaq -1(%rcx), %rcx
|
||||
FIRST_ADD();
|
||||
NEXT_ADD(8);
|
||||
decq %rcx
|
||||
je .Lend
|
||||
leaq 16(%rsi), %rsi
|
||||
leaq 16(%rdx), %rdx
|
||||
leaq 16(%rdi), %rdi
|
||||
jmp .Loop
|
||||
|
||||
ALIGN(3)
|
||||
.Lprehandle1:
|
||||
FIRST_ADD();
|
||||
decq %rcx
|
||||
je .Lend
|
||||
leaq 8(%rsi), %rsi
|
||||
leaq 8(%rdx), %rdx
|
||||
leaq 8(%rdi), %rdi
|
||||
jmp .Loop
|
||||
|
||||
ALIGN(3)
|
||||
.Lprehandle0:
|
||||
clc /* clear cy */
|
||||
|
||||
ALIGN(4) /* minimal alignment for claimed speed */
|
||||
.Loop: movq (%rsi,%rcx,8), %rax
|
||||
movq (%rdx,%rcx,8), %r10
|
||||
adcq %r10, %rax
|
||||
movq %rax, (%rdi,%rcx,8)
|
||||
incq %rcx
|
||||
.Loop: leaq -3(%rcx), %rcx
|
||||
NEXT_ADD(0);
|
||||
NEXT_ADD(8);
|
||||
NEXT_ADD(16);
|
||||
NEXT_ADD(24);
|
||||
leaq 32(%rsi), %rsi
|
||||
leaq 32(%rdx), %rdx
|
||||
leaq 32(%rdi), %rdi
|
||||
decq %rcx
|
||||
jne .Loop
|
||||
|
||||
movq %rcx, %rax /* zero %rax */
|
||||
adcq %rax, %rax
|
||||
ret
|
||||
|
||||
ALIGN(2)
|
||||
.Lend:
|
||||
movl $0, %eax /* zero %rax */
|
||||
adcl %eax, %eax
|
||||
FUNC_EXIT()
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -39,39 +39,41 @@
|
||||
* unsigned cnt) rcx
|
||||
*/
|
||||
|
||||
.text
|
||||
TEXT
|
||||
ALIGN(4)
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_lshift)
|
||||
C_SYMBOL_NAME(_gcry_mpih_lshift:)
|
||||
movq -8(%rsi,%rdx,8), %mm7
|
||||
movd %ecx, %mm1
|
||||
FUNC_ENTRY()
|
||||
/* Note: %xmm6 and %xmm7 not used for WIN64 ABI compatibility. */
|
||||
movq -8(%rsi,%rdx,8), %xmm4
|
||||
movd %ecx, %xmm1
|
||||
movl $64, %eax
|
||||
subl %ecx, %eax
|
||||
movd %eax, %mm0
|
||||
movq %mm7, %mm3
|
||||
psrlq %mm0, %mm7
|
||||
movd %mm7, %rax
|
||||
movd %eax, %xmm0
|
||||
movdqa %xmm4, %xmm3
|
||||
psrlq %xmm0, %xmm4
|
||||
movq %xmm4, %rax
|
||||
subq $2, %rdx
|
||||
jl .Lendo
|
||||
|
||||
ALIGN(4) /* minimal alignment for claimed speed */
|
||||
.Loop: movq (%rsi,%rdx,8), %mm6
|
||||
movq %mm6, %mm2
|
||||
psrlq %mm0, %mm6
|
||||
psllq %mm1, %mm3
|
||||
por %mm6, %mm3
|
||||
movq %mm3, 8(%rdi,%rdx,8)
|
||||
.Loop: movq (%rsi,%rdx,8), %xmm5
|
||||
movdqa %xmm5, %xmm2
|
||||
psrlq %xmm0, %xmm5
|
||||
psllq %xmm1, %xmm3
|
||||
por %xmm5, %xmm3
|
||||
movq %xmm3, 8(%rdi,%rdx,8)
|
||||
je .Lende
|
||||
movq -8(%rsi,%rdx,8), %mm7
|
||||
movq %mm7, %mm3
|
||||
psrlq %mm0, %mm7
|
||||
psllq %mm1, %mm2
|
||||
por %mm7, %mm2
|
||||
movq %mm2, (%rdi,%rdx,8)
|
||||
movq -8(%rsi,%rdx,8), %xmm4
|
||||
movdqa %xmm4, %xmm3
|
||||
psrlq %xmm0, %xmm4
|
||||
psllq %xmm1, %xmm2
|
||||
por %xmm4, %xmm2
|
||||
movq %xmm2, (%rdi,%rdx,8)
|
||||
subq $2, %rdx
|
||||
jge .Loop
|
||||
|
||||
.Lendo: movq %mm3, %mm2
|
||||
.Lende: psllq %mm1, %mm2
|
||||
movq %mm2, (%rdi)
|
||||
emms
|
||||
ret
|
||||
.Lendo: movdqa %xmm3, %xmm2
|
||||
.Lende: psllq %xmm1, %xmm2
|
||||
movq %xmm2, (%rdi)
|
||||
FUNC_EXIT()
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -40,18 +40,19 @@
|
||||
|
||||
|
||||
TEXT
|
||||
ALIGN(5)
|
||||
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
ALIGN(4)
|
||||
|
||||
GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1)
|
||||
C_SYMBOL_NAME(_gcry_mpih_mul_1:)
|
||||
|
||||
FUNC_ENTRY()
|
||||
movq %rdx, %r11
|
||||
leaq (%rsi,%rdx,8), %rsi
|
||||
leaq (%rdi,%rdx,8), %rdi
|
||||
negq %r11
|
||||
xorl %r8d, %r8d
|
||||
|
||||
ALIGN(4)
|
||||
.Loop: movq (%rsi,%r11,8), %rax
|
||||
mulq %rcx
|
||||
addq %r8, %rax
|
||||
@@ -62,4 +63,4 @@ C_SYMBOL_NAME(_gcry_mpih_mul_1:)
|
||||
jne .Loop
|
||||
|
||||
movq %r8, %rax
|
||||
ret
|
||||
FUNC_EXIT()
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -31,49 +31,6 @@
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_addmul_2( mpi_ptr_t res_ptr, (sp + 4)
|
||||
* mpi_ptr_t s1_ptr, (sp + 8)
|
||||
* mpi_size_t s1_size, (sp + 12)
|
||||
* mpi_limb_t s2_limb) (sp + 16)
|
||||
*/
|
||||
|
||||
/* i80386 addmul_1 -- Multiply a limb vector with a limb and add
|
||||
* the result to a second limb vector.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1998,
|
||||
* 2001, 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (rdi)
|
||||
@@ -82,8 +39,10 @@
|
||||
* mpi_limb_t s2_limb) (rcx)
|
||||
*/
|
||||
TEXT
|
||||
ALIGN(4)
|
||||
GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1)
|
||||
C_SYMBOL_NAME(_gcry_mpih_addmul_1:)
|
||||
FUNC_ENTRY()
|
||||
movq %rdx, %r11
|
||||
leaq (%rsi,%rdx,8), %rsi
|
||||
leaq (%rdi,%rdx,8), %rdi
|
||||
@@ -91,7 +50,7 @@ C_SYMBOL_NAME(_gcry_mpih_addmul_1:)
|
||||
xorl %r8d, %r8d
|
||||
xorl %r10d, %r10d
|
||||
|
||||
ALIGN(3) /* minimal alignment for claimed speed */
|
||||
ALIGN(4) /* minimal alignment for claimed speed */
|
||||
.Loop: movq (%rsi,%r11,8), %rax
|
||||
mulq %rcx
|
||||
addq (%rdi,%r11,8), %rax
|
||||
@@ -104,4 +63,4 @@ C_SYMBOL_NAME(_gcry_mpih_addmul_1:)
|
||||
jne .Loop
|
||||
|
||||
movq %r8, %rax
|
||||
ret
|
||||
FUNC_EXIT()
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -40,16 +40,17 @@
|
||||
* mpi_limb_t s2_limb) (rcx)
|
||||
*/
|
||||
TEXT
|
||||
ALIGN(4)
|
||||
GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1)
|
||||
C_SYMBOL_NAME(_gcry_mpih_submul_1:)
|
||||
|
||||
FUNC_ENTRY()
|
||||
movq %rdx, %r11
|
||||
leaq (%rsi,%r11,8), %rsi
|
||||
leaq (%rdi,%r11,8), %rdi
|
||||
negq %r11
|
||||
xorl %r8d, %r8d
|
||||
|
||||
ALIGN(3) /* minimal alignment for claimed speed */
|
||||
ALIGN(4) /* minimal alignment for claimed speed */
|
||||
.Loop: movq (%rsi,%r11,8), %rax
|
||||
movq (%rdi,%r11,8), %r10
|
||||
mulq %rcx
|
||||
@@ -63,4 +64,4 @@ C_SYMBOL_NAME(_gcry_mpih_submul_1:)
|
||||
jne .Loop
|
||||
|
||||
movq %r8, %rax
|
||||
ret
|
||||
FUNC_EXIT()
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -39,42 +39,44 @@
|
||||
* unsigned cnt) rcx
|
||||
*/
|
||||
|
||||
.text
|
||||
TEXT
|
||||
ALIGN(4)
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_rshift)
|
||||
C_SYMBOL_NAME(_gcry_mpih_rshift:)
|
||||
movq (%rsi), %mm7
|
||||
movd %ecx, %mm1
|
||||
FUNC_ENTRY()
|
||||
/* Note: %xmm6 and %xmm7 not used for WIN64 ABI compatibility. */
|
||||
movq (%rsi), %xmm4
|
||||
movd %ecx, %xmm1
|
||||
movl $64, %eax
|
||||
subl %ecx, %eax
|
||||
movd %eax, %mm0
|
||||
movq %mm7, %mm3
|
||||
psllq %mm0, %mm7
|
||||
movd %mm7, %rax
|
||||
movd %eax, %xmm0
|
||||
movdqa %xmm4, %xmm3
|
||||
psllq %xmm0, %xmm4
|
||||
movq %xmm4, %rax
|
||||
leaq (%rsi,%rdx,8), %rsi
|
||||
leaq (%rdi,%rdx,8), %rdi
|
||||
negq %rdx
|
||||
addq $2, %rdx
|
||||
jg .Lendo
|
||||
|
||||
ALIGN(8) /* minimal alignment for claimed speed */
|
||||
.Loop: movq -8(%rsi,%rdx,8), %mm6
|
||||
movq %mm6, %mm2
|
||||
psllq %mm0, %mm6
|
||||
psrlq %mm1, %mm3
|
||||
por %mm6, %mm3
|
||||
movq %mm3, -16(%rdi,%rdx,8)
|
||||
ALIGN(4) /* minimal alignment for claimed speed */
|
||||
.Loop: movq -8(%rsi,%rdx,8), %xmm5
|
||||
movdqa %xmm5, %xmm2
|
||||
psllq %xmm0, %xmm5
|
||||
psrlq %xmm1, %xmm3
|
||||
por %xmm5, %xmm3
|
||||
movq %xmm3, -16(%rdi,%rdx,8)
|
||||
je .Lende
|
||||
movq (%rsi,%rdx,8), %mm7
|
||||
movq %mm7, %mm3
|
||||
psllq %mm0, %mm7
|
||||
psrlq %mm1, %mm2
|
||||
por %mm7, %mm2
|
||||
movq %mm2, -8(%rdi,%rdx,8)
|
||||
movq (%rsi,%rdx,8), %xmm4
|
||||
movdqa %xmm4, %xmm3
|
||||
psllq %xmm0, %xmm4
|
||||
psrlq %xmm1, %xmm2
|
||||
por %xmm4, %xmm2
|
||||
movq %xmm2, -8(%rdi,%rdx,8)
|
||||
addq $2, %rdx
|
||||
jle .Loop
|
||||
|
||||
.Lendo: movq %mm3, %mm2
|
||||
.Lende: psrlq %mm1, %mm2
|
||||
movq %mm2, -8(%rdi)
|
||||
emms
|
||||
ret
|
||||
.Lendo: movdqa %xmm3, %xmm2
|
||||
.Lende: psrlq %xmm1, %xmm2
|
||||
movq %xmm2, -8(%rdi)
|
||||
FUNC_EXIT()
|
||||
@@ -3,6 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1995, 1998,
|
||||
* 2001, 2002, 2006 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2023 Jussi Kivilinna <jussi.kivilinna@iki.fi>
|
||||
*
|
||||
* This file is part of Libgcrypt.
|
||||
*
|
||||
@@ -17,8 +18,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -39,23 +40,80 @@
|
||||
* mpi_ptr_t s2_ptr, rdx
|
||||
* mpi_size_t size) rcx
|
||||
*/
|
||||
.text
|
||||
TEXT
|
||||
ALIGN(4)
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_sub_n)
|
||||
C_SYMBOL_NAME(_gcry_mpih_sub_n:)
|
||||
leaq (%rsi,%rcx,8), %rsi
|
||||
leaq (%rdi,%rcx,8), %rdi
|
||||
leaq (%rdx,%rcx,8), %rdx
|
||||
negq %rcx
|
||||
xorl %eax, %eax /* clear cy */
|
||||
FUNC_ENTRY()
|
||||
movl %ecx, %r9d
|
||||
andl $3, %r9d
|
||||
je .Lprehandle0
|
||||
cmpl $2, %r9d
|
||||
jb .Lprehandle1
|
||||
je .Lprehandle2
|
||||
|
||||
#define FIRST_SUB() \
|
||||
movq (%rsi), %rax; \
|
||||
subq (%rdx), %rax; \
|
||||
movq %rax, (%rdi)
|
||||
|
||||
#define NEXT_SUB(offset) \
|
||||
movq offset(%rsi), %rax; \
|
||||
sbbq offset(%rdx), %rax; \
|
||||
movq %rax, offset(%rdi)
|
||||
|
||||
.Lprehandle3:
|
||||
leaq -2(%rcx), %rcx
|
||||
FIRST_SUB();
|
||||
NEXT_SUB(8);
|
||||
NEXT_SUB(16);
|
||||
decq %rcx
|
||||
je .Lend
|
||||
leaq 24(%rsi), %rsi
|
||||
leaq 24(%rdx), %rdx
|
||||
leaq 24(%rdi), %rdi
|
||||
jmp .Loop
|
||||
|
||||
ALIGN(3)
|
||||
.Lprehandle2:
|
||||
leaq -1(%rcx), %rcx
|
||||
FIRST_SUB();
|
||||
NEXT_SUB(8);
|
||||
decq %rcx
|
||||
je .Lend
|
||||
leaq 16(%rsi), %rsi
|
||||
leaq 16(%rdx), %rdx
|
||||
leaq 16(%rdi), %rdi
|
||||
jmp .Loop
|
||||
|
||||
ALIGN(3)
|
||||
.Lprehandle1:
|
||||
FIRST_SUB();
|
||||
decq %rcx
|
||||
je .Lend
|
||||
leaq 8(%rsi), %rsi
|
||||
leaq 8(%rdx), %rdx
|
||||
leaq 8(%rdi), %rdi
|
||||
jmp .Loop
|
||||
|
||||
ALIGN(3)
|
||||
.Lprehandle0:
|
||||
clc /* clear cy */
|
||||
|
||||
ALIGN(4) /* minimal alignment for claimed speed */
|
||||
.Loop: movq (%rsi,%rcx,8), %rax
|
||||
movq (%rdx,%rcx,8), %r10
|
||||
sbbq %r10, %rax
|
||||
movq %rax, (%rdi,%rcx,8)
|
||||
incq %rcx
|
||||
.Loop: leaq -3(%rcx), %rcx
|
||||
NEXT_SUB(0);
|
||||
NEXT_SUB(8);
|
||||
NEXT_SUB(16);
|
||||
NEXT_SUB(24);
|
||||
leaq 32(%rsi), %rsi
|
||||
leaq 32(%rdx), %rdx
|
||||
leaq 32(%rdi), %rdi
|
||||
decq %rcx
|
||||
jne .Loop
|
||||
|
||||
movq %rcx, %rax /* zero %rax */
|
||||
adcq %rax, %rax
|
||||
ret
|
||||
ALIGN(2)
|
||||
.Lend:
|
||||
movl $0, %eax /* zero %rax */
|
||||
adcl %eax, %eax
|
||||
FUNC_EXIT()
|
||||
+1
-5
@@ -1,10 +1,6 @@
|
||||
Manifest
|
||||
mpi-asm-defs.h
|
||||
mpih-add1.S
|
||||
mpih-mul1.S
|
||||
mpih-mul2.S
|
||||
mpih-mul3.S
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
mpih-sub1.S
|
||||
README
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/* This file defines some basic constants for the MPI machinery. We
|
||||
* need to define the types on a per-CPU basis, so it is done with
|
||||
* this file here. */
|
||||
#define BYTES_PER_MPI_LIMB (SIZEOF_UNSIGNED_LONG)
|
||||
@@ -0,0 +1,76 @@
|
||||
/* ARM add_n -- Add two limb vectors of the same length > 0 and store
|
||||
* sum in a third limb vector.
|
||||
*
|
||||
* Copyright (C) 2013 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/>.
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library (version 4.2.1).
|
||||
*/
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
.syntax unified
|
||||
.arm
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_add_n( mpi_ptr_t res_ptr, r0
|
||||
* mpi_ptr_t s1_ptr, r1
|
||||
* mpi_ptr_t s2_ptr, r2
|
||||
* mpi_size_t size) r3
|
||||
*/
|
||||
|
||||
.text
|
||||
|
||||
.globl _gcry_mpih_add_n
|
||||
.type _gcry_mpih_add_n,%function
|
||||
_gcry_mpih_add_n:
|
||||
push {r4, r5, r6, r7, r8, r9, r10, lr};
|
||||
cmn r0, #0; /* clear carry flag */
|
||||
|
||||
tst r3, #3;
|
||||
beq .Large_loop;
|
||||
|
||||
.Loop:
|
||||
ldr r4, [r1], #4;
|
||||
sub r3, #1;
|
||||
ldr lr, [r2], #4;
|
||||
adcs r4, lr;
|
||||
tst r3, #3;
|
||||
str r4, [r0], #4;
|
||||
bne .Loop;
|
||||
|
||||
teq r3, #0;
|
||||
beq .Lend;
|
||||
|
||||
.Large_loop:
|
||||
ldm r1!, {r4, r6, r8, r10};
|
||||
ldm r2!, {r5, r7, r9, lr};
|
||||
sub r3, #4;
|
||||
adcs r4, r5;
|
||||
adcs r6, r7;
|
||||
adcs r8, r9;
|
||||
adcs r10, lr;
|
||||
teq r3, #0;
|
||||
stm r0!, {r4, r6, r8, r10};
|
||||
bne .Large_loop;
|
||||
|
||||
.Lend:
|
||||
adc r0, r3, #0;
|
||||
pop {r4, r5, r6, r7, r8, r9, r10, pc};
|
||||
.size _gcry_mpih_add_n,.-_gcry_mpih_add_n;
|
||||
@@ -0,0 +1,80 @@
|
||||
/* ARM mul_1 -- Multiply a limb vector with a limb and store the result in
|
||||
* a second limb vector.
|
||||
*
|
||||
* Copyright (C) 2013 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/>.
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library (version 4.2.1).
|
||||
*/
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
.syntax unified
|
||||
.arm
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_mul_1( mpi_ptr_t res_ptr, r0
|
||||
* mpi_ptr_t s1_ptr, r1
|
||||
* mpi_size_t s1_size, r2
|
||||
* mpi_limb_t s2_limb) r3
|
||||
*/
|
||||
|
||||
.text
|
||||
|
||||
.globl _gcry_mpih_mul_1
|
||||
.type _gcry_mpih_mul_1,%function
|
||||
_gcry_mpih_mul_1:
|
||||
push {r4, r5, r6, r7, r8, r9, r10, r11, lr};
|
||||
mov r4, #0;
|
||||
|
||||
tst r2, #3;
|
||||
beq .Large_loop;
|
||||
|
||||
.Loop:
|
||||
ldr r5, [r1], #4;
|
||||
mov lr, #0;
|
||||
umlal r4, lr, r5, r3;
|
||||
sub r2, #1;
|
||||
str r4, [r0], #4;
|
||||
tst r2, #3;
|
||||
mov r4, lr;
|
||||
bne .Loop;
|
||||
|
||||
teq r2, #0;
|
||||
beq .Lend;
|
||||
|
||||
.Large_loop:
|
||||
ldm r1!, {r5, r6, r7, r8};
|
||||
mov r9, #0;
|
||||
mov r10, #0;
|
||||
umlal r4, r9, r5, r3;
|
||||
mov r11, #0;
|
||||
umlal r9, r10, r6, r3;
|
||||
str r4, [r0], #4;
|
||||
mov r4, #0;
|
||||
umlal r10, r11, r7, r3;
|
||||
subs r2, #4;
|
||||
umlal r11, r4, r8, r3;
|
||||
stm r0!, {r9, r10, r11};
|
||||
bne .Large_loop;
|
||||
|
||||
.Lend:
|
||||
mov r0, r4;
|
||||
pop {r4, r5, r6, r7, r8, r9, r10, r11, pc};
|
||||
.size _gcry_mpih_mul_1,.-_gcry_mpih_mul_1;
|
||||
@@ -0,0 +1,94 @@
|
||||
/* ARM mul_2 -- Multiply a limb vector with a limb and add the result to
|
||||
* a second limb vector.
|
||||
*
|
||||
* Copyright (C) 2013 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/>.
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library (version 4.2.1).
|
||||
*/
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
.syntax unified
|
||||
.arm
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, r0
|
||||
* mpi_ptr_t s1_ptr, r1
|
||||
* mpi_size_t s1_size, r2
|
||||
* mpi_limb_t s2_limb) r3
|
||||
*/
|
||||
|
||||
.text
|
||||
|
||||
.globl _gcry_mpih_addmul_1
|
||||
.type _gcry_mpih_addmul_1,%function
|
||||
_gcry_mpih_addmul_1:
|
||||
push {r4, r5, r6, r8, r10, lr};
|
||||
mov lr, #0;
|
||||
cmn r0, #0; /* clear carry flag */
|
||||
|
||||
tst r2, #3;
|
||||
beq .Large_loop;
|
||||
.Loop:
|
||||
ldr r5, [r1], #4;
|
||||
ldr r4, [r0];
|
||||
sub r2, #1;
|
||||
adcs r4, lr;
|
||||
mov lr, #0;
|
||||
umlal r4, lr, r5, r3;
|
||||
tst r2, #3;
|
||||
str r4, [r0], #4;
|
||||
bne .Loop;
|
||||
|
||||
teq r2, #0;
|
||||
beq .Lend;
|
||||
|
||||
.Large_loop:
|
||||
ldr r5, [r1], #4;
|
||||
ldm r0, {r4, r6, r8, r10};
|
||||
|
||||
sub r2, #4;
|
||||
adcs r4, lr;
|
||||
mov lr, #0;
|
||||
umlal r4, lr, r5, r3;
|
||||
|
||||
ldr r5, [r1], #4;
|
||||
adcs r6, lr;
|
||||
mov lr, #0;
|
||||
umlal r6, lr, r5, r3;
|
||||
|
||||
ldr r5, [r1], #4;
|
||||
adcs r8, lr;
|
||||
mov lr, #0;
|
||||
umlal r8, lr, r5, r3;
|
||||
|
||||
ldr r5, [r1], #4;
|
||||
adcs r10, lr;
|
||||
mov lr, #0;
|
||||
umlal r10, lr, r5, r3;
|
||||
|
||||
teq r2, #0;
|
||||
stm r0!, {r4, r6, r8, r10};
|
||||
bne .Large_loop;
|
||||
|
||||
.Lend:
|
||||
adc r0, lr, #0;
|
||||
pop {r4, r5, r6, r8, r10, pc};
|
||||
.size _gcry_mpih_addmul_1,.-_gcry_mpih_addmul_1;
|
||||
@@ -0,0 +1,100 @@
|
||||
/* ARM mul_3 -- Multiply a limb vector with a limb and subtract the result
|
||||
* from a second limb vector.
|
||||
*
|
||||
* Copyright (C) 2013 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/>.
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library (version 4.2.1).
|
||||
*/
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
.syntax unified
|
||||
.arm
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_submul_1( mpi_ptr_t res_ptr, r0
|
||||
* mpi_ptr_t s1_ptr, r1
|
||||
* mpi_size_t s1_size, r2
|
||||
* mpi_limb_t s2_limb) r3
|
||||
*/
|
||||
|
||||
.text
|
||||
|
||||
.globl _gcry_mpih_submul_1
|
||||
.type _gcry_mpih_submul_1,%function
|
||||
_gcry_mpih_submul_1:
|
||||
push {r4, r5, r6, r8, r9, r10, lr};
|
||||
mov lr, #0;
|
||||
cmp r0, #0; /* prepare carry flag for sbc */
|
||||
|
||||
tst r2, #3;
|
||||
beq .Large_loop;
|
||||
.Loop:
|
||||
ldr r5, [r1], #4;
|
||||
mov r4, lr;
|
||||
mov lr, #0;
|
||||
ldr r6, [r0];
|
||||
umlal r4, lr, r5, r3;
|
||||
sub r2, #1;
|
||||
sbcs r4, r6, r4;
|
||||
tst r2, #3;
|
||||
str r4, [r0], #4;
|
||||
bne .Loop;
|
||||
|
||||
teq r2, #0;
|
||||
beq .Lend;
|
||||
|
||||
.Large_loop:
|
||||
ldr r5, [r1], #4;
|
||||
mov r9, #0;
|
||||
ldr r4, [r0, #0];
|
||||
|
||||
umlal lr, r9, r5, r3;
|
||||
ldr r6, [r0, #4];
|
||||
ldr r5, [r1], #4;
|
||||
sbcs r4, r4, lr;
|
||||
|
||||
mov lr, #0;
|
||||
umlal r9, lr, r5, r3;
|
||||
ldr r8, [r0, #8];
|
||||
ldr r5, [r1], #4;
|
||||
sbcs r6, r6, r9;
|
||||
|
||||
mov r9, #0;
|
||||
umlal lr, r9, r5, r3;
|
||||
ldr r10, [r0, #12];
|
||||
ldr r5, [r1], #4;
|
||||
sbcs r8, r8, lr;
|
||||
|
||||
mov lr, #0;
|
||||
umlal r9, lr, r5, r3;
|
||||
sub r2, #4;
|
||||
sbcs r10, r10, r9;
|
||||
|
||||
teq r2, #0;
|
||||
stm r0!, {r4, r6, r8, r10};
|
||||
bne .Large_loop;
|
||||
|
||||
.Lend:
|
||||
it cc
|
||||
movcc r2, #1;
|
||||
add r0, lr, r2;
|
||||
pop {r4, r5, r6, r8, r9, r10, pc};
|
||||
.size _gcry_mpih_submul_1,.-_gcry_mpih_submul_1;
|
||||
@@ -0,0 +1,77 @@
|
||||
/* ARM sub_n -- Subtract two limb vectors of the same length > 0 and store
|
||||
* sum in a third limb vector.
|
||||
*
|
||||
* Copyright (C) 2013 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/>.
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library (version 4.2.1).
|
||||
*/
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
.syntax unified
|
||||
.arm
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_sub_n( mpi_ptr_t res_ptr, r0
|
||||
* mpi_ptr_t s1_ptr, r1
|
||||
* mpi_ptr_t s2_ptr, r2
|
||||
* mpi_size_t size) r3
|
||||
*/
|
||||
|
||||
.text
|
||||
|
||||
.globl _gcry_mpih_sub_n
|
||||
.type _gcry_mpih_sub_n,%function
|
||||
_gcry_mpih_sub_n:
|
||||
push {r4, r5, r6, r7, r8, r9, r10, lr};
|
||||
cmp r0, #0; /* prepare carry flag for sub */
|
||||
|
||||
tst r3, #3;
|
||||
beq .Large_loop;
|
||||
|
||||
.Loop:
|
||||
ldr r4, [r1], #4;
|
||||
sub r3, #1;
|
||||
ldr lr, [r2], #4;
|
||||
sbcs r4, lr;
|
||||
tst r3, #3;
|
||||
str r4, [r0], #4;
|
||||
bne .Loop;
|
||||
|
||||
teq r3, #0;
|
||||
beq .Lend;
|
||||
|
||||
.Large_loop:
|
||||
ldm r1!, {r4, r6, r8, r10};
|
||||
sub r3, #4;
|
||||
ldm r2!, {r5, r7, r9, lr};
|
||||
sbcs r4, r5;
|
||||
sbcs r6, r7;
|
||||
sbcs r8, r9;
|
||||
sbcs r10, lr;
|
||||
teq r3, #0;
|
||||
stm r0!, {r4, r6, r8, r10};
|
||||
bne .Large_loop;
|
||||
|
||||
.Lend:
|
||||
sbc r0, r3, #0;
|
||||
neg r0, r0;
|
||||
pop {r4, r5, r6, r7, r8, r9, r10, pc};
|
||||
.size _gcry_mpih_sub_n,.-_gcry_mpih_sub_n;
|
||||
@@ -0,0 +1,26 @@
|
||||
/* asm-common-aarch64.h - Common macros for AArch64 assembly
|
||||
*
|
||||
* Copyright (C) 2018 Martin Storsjö <martin@martin.st>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef MPI_ASM_COMMON_AARCH64_H
|
||||
#define MPI_ASM_COMMON_AARCH64_H
|
||||
|
||||
#include "../cipher/asm-common-aarch64.h"
|
||||
|
||||
#endif /* MPI_ASM_COMMON_AARCH64_H */
|
||||
@@ -0,0 +1,26 @@
|
||||
/* asm-common-amd64.h - Common macros for AMD64 assembly
|
||||
*
|
||||
* Copyright (C) 2022 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/>.
|
||||
*/
|
||||
|
||||
#ifndef MPI_ASM_COMMON_AMD64_H
|
||||
#define MPI_ASM_COMMON_AMD64_H
|
||||
|
||||
#include "../cipher/asm-common-amd64.h"
|
||||
|
||||
#endif /* MPI_ASM_COMMON_AMD64_H */
|
||||
@@ -0,0 +1,26 @@
|
||||
/* asm-common-i386.h - Common macros for AMD64 assembly
|
||||
*
|
||||
* Copyright (C) 2023 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/>.
|
||||
*/
|
||||
|
||||
#ifndef MPI_ASM_COMMON_I386_H
|
||||
#define MPI_ASM_COMMON_I386_H
|
||||
|
||||
#include "../cipher/asm-common-i386.h"
|
||||
|
||||
#endif /* MPI_ASM_COMMON_I386_H */
|
||||
@@ -1,5 +1,6 @@
|
||||
# config.links - helper for ../configure -*- mode: sh -*-
|
||||
# Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2012 g10 Code GmbH
|
||||
#
|
||||
# This file is part of Libgcrypt.
|
||||
#
|
||||
@@ -14,15 +15,20 @@
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
# License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
#
|
||||
# sourced by ../configure to get the list of files to link
|
||||
# this should set $mpi_ln_list.
|
||||
# Note: this is called from the above directory.
|
||||
#
|
||||
# Reguired variables:
|
||||
# $ac_cv_sys_symbol_underscore
|
||||
# $gcry_cv_gcc_arm_platform_as_ok
|
||||
|
||||
mpi_sflags=
|
||||
mpi_extra_modules=
|
||||
mpi_cpu_arch=
|
||||
|
||||
test -d ./mpi || mkdir ./mpi
|
||||
|
||||
@@ -37,152 +43,179 @@ mpi_optional_modules=`$AWK '/^#BEGIN_ASM_LIST/,/^#END_ASM_LIST/ {
|
||||
echo '/* created by config.links - do not edit */' >./mpi/asm-syntax.h
|
||||
echo "/* Host: ${host} */" >>./mpi/asm-syntax.h
|
||||
|
||||
if test "$try_asm_modules" = "yes" ; then
|
||||
case "${host}" in
|
||||
powerpc-apple-darwin* | \
|
||||
i[34567]86*-*-openbsd[12]* | \
|
||||
i[34567]86*-*-openbsd3.[0123]*)
|
||||
echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
|
||||
path=""
|
||||
mpi_cpu_arch="x86"
|
||||
;;
|
||||
i[3467]86*-*-openbsd* | \
|
||||
i[3467]86*-*-freebsd*-elf | \
|
||||
i[3467]86*-*-freebsd[3-9]* | \
|
||||
i[3467]86*-*-freebsdelf* | \
|
||||
i[3467]86*-*-netbsd* | \
|
||||
i[3467]86*-*-k*bsd*)
|
||||
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
|
||||
path="i386"
|
||||
;;
|
||||
i586*-*-openbsd* | \
|
||||
i586*-*-freebsd*-elf | \
|
||||
i586*-*-freebsd[3-9]* | \
|
||||
i586*-*-freebsdelf* | \
|
||||
i586*-*-netbsd* | \
|
||||
i586*-*-k*bsd* | \
|
||||
pentium-*-netbsd* | \
|
||||
i[34567]86*-*-openbsd* | \
|
||||
i[34567]86*-*-freebsd*-elf | \
|
||||
i[34567]86*-*-freebsd[3-9]* | \
|
||||
i[34567]86*-*-freebsd[12][0-9]*| \
|
||||
i[34567]86*-*-freebsdelf* | \
|
||||
i[34567]86*-*-netbsd* | \
|
||||
i[34567]86*-*-k*bsd* | \
|
||||
pentium-*-netbsd* | \
|
||||
pentiumpro-*-netbsd*)
|
||||
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
|
||||
path="i586 i386"
|
||||
path="i386"
|
||||
mpi_cpu_arch="x86"
|
||||
;;
|
||||
i[34]86*-*-bsdi4*)
|
||||
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
|
||||
path="i386"
|
||||
mpi_cpu_arch="x86"
|
||||
;;
|
||||
i[3467]86*-*-linuxaout* | \
|
||||
i[3467]86*-*-linuxoldld* | \
|
||||
i[3467]86*-*-*bsd*)
|
||||
i[34567]86*-*-linuxaout* | \
|
||||
i[34567]86*-*-linuxoldld* | \
|
||||
i[34567]86*-*-*bsd*)
|
||||
echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h
|
||||
echo '#define X86_BROKEN_ALIGN' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
|
||||
path="i386"
|
||||
mpi_cpu_arch="x86"
|
||||
;;
|
||||
i586*-*-linuxaout* | \
|
||||
i586*-*-linuxoldld* | \
|
||||
i586*-*-*bsd*)
|
||||
echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h
|
||||
echo '#define X86_BROKEN_ALIGN' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
|
||||
path="i586 i386"
|
||||
;;
|
||||
i[3467]86*-msdosdjgpp* | \
|
||||
i[34]86*-apple-darwin*)
|
||||
i[34567]86*-msdosdjgpp* | \
|
||||
i[34567]86*-apple-darwin*)
|
||||
echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
|
||||
path="i386"
|
||||
mpi_cpu_arch="x86"
|
||||
;;
|
||||
i586*-msdosdjgpp* | \
|
||||
i[567]86*-apple-darwin*)
|
||||
echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
|
||||
path="i586 i386"
|
||||
;;
|
||||
i[3467]86*-*-*)
|
||||
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
|
||||
path="i386"
|
||||
;;
|
||||
i586*-*-* | \
|
||||
pentium-*-* | \
|
||||
i[34567]86*-*-* | \
|
||||
pentium-*-* | \
|
||||
pentiumpro-*-*)
|
||||
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
|
||||
path="i586 i386"
|
||||
path="i386"
|
||||
mpi_cpu_arch="x86"
|
||||
;;
|
||||
x86_64-apple-darwin*)
|
||||
echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/amd64/func_abi.h >>./mpi/asm-syntax.h
|
||||
path="amd64"
|
||||
mpi_cpu_arch="x86"
|
||||
;;
|
||||
x86_64-*mingw32*)
|
||||
echo '#define USE_MS_ABI' >>./mpi/asm-syntax.h
|
||||
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/amd64/func_abi.h >>./mpi/asm-syntax.h
|
||||
path="amd64"
|
||||
mpi_cpu_arch="x86"
|
||||
;;
|
||||
x86_64-*-*)
|
||||
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/amd64/func_abi.h >>./mpi/asm-syntax.h
|
||||
path="amd64"
|
||||
mpi_cpu_arch="x86"
|
||||
;;
|
||||
alpha*-*-*)
|
||||
echo '/* configured for alpha */' >>./mpi/asm-syntax.h
|
||||
path="alpha"
|
||||
mpi_extra_modules="udiv-qrnnd"
|
||||
mpi_cpu_arch="alpha"
|
||||
;;
|
||||
aarch64-*-*)
|
||||
echo '/* configured for aarch64 */' >>./mpi/asm-syntax.h
|
||||
path="aarch64"
|
||||
mpi_cpu_arch="aarch64"
|
||||
;;
|
||||
arm*-*-*)
|
||||
mpi_cpu_arch="arm"
|
||||
if test "$gcry_cv_gcc_arm_platform_as_ok" = "yes" ; then
|
||||
echo '/* configured for arm */' >>./mpi/asm-syntax.h
|
||||
path="arm"
|
||||
else
|
||||
echo '/* No assembler modules configured */' >>./mpi/asm-syntax.h
|
||||
path=""
|
||||
fi
|
||||
;;
|
||||
hppa7000*-*-*)
|
||||
echo '/* configured for HPPA (pa7000) */' >>./mpi/asm-syntax.h
|
||||
path="hppa1.1 hppa"
|
||||
mpi_extra_modules="udiv-qrnnd"
|
||||
mpi_cpu_arch="hppa"
|
||||
;;
|
||||
hppa1.0*-*-*)
|
||||
echo '/* configured for HPPA 1.0 */' >>./mpi/asm-syntax.h
|
||||
path="hppa"
|
||||
mpi_extra_modules="udiv-qrnnd"
|
||||
mpi_cpu_arch="hppa"
|
||||
;;
|
||||
hppa*-*-*) # assume pa7100
|
||||
echo '/* configured for HPPA (pa7100) */' >>./mpi/asm-syntax.h
|
||||
path="pa7100 hppa1.1 hppa"
|
||||
mpi_extra_modules="udiv-qrnnd"
|
||||
mpi_cpu_arch="hppa"
|
||||
;;
|
||||
sparc64-*-linux-gnu)
|
||||
echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
|
||||
path=""
|
||||
mpi_cpu_arch="sparc"
|
||||
;;
|
||||
sparc64-sun-solaris2*)
|
||||
echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
|
||||
path=""
|
||||
mpi_cpu_arch="sparc"
|
||||
;;
|
||||
sparc64-*-netbsd* | sparc64-*-freebsd* | sparc64-*-openbsd*)
|
||||
# There are no sparc64 assembler modules that work on the
|
||||
# *BSDs, so use the generic C functions.
|
||||
echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
|
||||
path=""
|
||||
mpi_cpu_arch="sparc"
|
||||
;;
|
||||
sparc64*-*-*)
|
||||
echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
|
||||
path=""
|
||||
mpi_cpu_arch="sparc"
|
||||
;;
|
||||
sparc9*-*-* | \
|
||||
ultrasparc*-*-* )
|
||||
echo '/* configured for sparc9 or higher */' >>./mpi/asm-syntax.h
|
||||
path="sparc32v8 sparc32"
|
||||
mpi_cpu_arch="sparc"
|
||||
;;
|
||||
sparc8*-*-* | \
|
||||
microsparc*-*-*)
|
||||
echo '/* configured for sparc8 */' >>./mpi/asm-syntax.h
|
||||
path="sparc32v8 sparc32"
|
||||
mpi_cpu_arch="sparc"
|
||||
;;
|
||||
supersparc*-*-*)
|
||||
echo '/* configured for supersparc */' >>./mpi/asm-syntax.h
|
||||
path="supersparc sparc32v8 sparc32"
|
||||
mpi_extra_modules="udiv"
|
||||
mpi_cpu_arch="sparc"
|
||||
;;
|
||||
sparc*-*-*)
|
||||
echo '/* configured for sparc */' >>./mpi/asm-syntax.h
|
||||
path="sparc32"
|
||||
mpi_extra_modules="udiv"
|
||||
mpi_cpu_arch="sparc"
|
||||
;;
|
||||
mips[34]*-*-* | \
|
||||
mips*-*-irix6*)
|
||||
echo '/* configured for MIPS3 */' >>./mpi/asm-syntax.h
|
||||
path="mips3"
|
||||
mpi_cpu_arch="mips"
|
||||
;;
|
||||
mips*-*-*)
|
||||
echo '/* configured for MIPS2 */' >>./mpi/asm-syntax.h
|
||||
path="mips2"
|
||||
mpi_cpu_arch="mips"
|
||||
;;
|
||||
s390x*-*-*)
|
||||
echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
|
||||
path=""
|
||||
mpi_cpu_arch="s390x"
|
||||
;;
|
||||
|
||||
# Motorola 68k configurations. Let m68k mean 68020-68040.
|
||||
@@ -192,58 +225,74 @@ case "${host}" in
|
||||
echo '#define MIT_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
|
||||
path="m68k/mc68020 m68k"
|
||||
mpi_cpu_arch="m68k"
|
||||
;;
|
||||
m68060*-*-linuxaout*)
|
||||
echo '#define MIT_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
|
||||
path="m68k"
|
||||
mpi_cpu_arch="m68k"
|
||||
;;
|
||||
m680[234]0*-*-linux* | \
|
||||
m68k*-*-linux*)
|
||||
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
|
||||
mpi_cpu_arch="m68k"
|
||||
;;
|
||||
m68060*-*-linux*)
|
||||
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
|
||||
path="m68k"
|
||||
mpi_cpu_arch="m68k"
|
||||
;;
|
||||
m68k-atari-mint)
|
||||
echo '#define MIT_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
|
||||
path="m68k/mc68020 m68k"
|
||||
path="m68k"
|
||||
mpi_cpu_arch="m68k"
|
||||
;;
|
||||
m68000*-*-* | \
|
||||
m68060*-*-*)
|
||||
echo '#define MIT_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
|
||||
path="m68k/mc68000"
|
||||
mpi_cpu_arch="m68k"
|
||||
;;
|
||||
m680[234]0*-*-* | \
|
||||
m68k*-*-*)
|
||||
echo '#define MIT_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/m68k/syntax.h >>./mpi/asm-syntax.h
|
||||
path="m68k/mc68020 m68k"
|
||||
mpi_cpu_arch="m68k"
|
||||
;;
|
||||
|
||||
powerpc-apple-darwin*)
|
||||
echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
|
||||
path=""
|
||||
mpi_cpu_arch="ppc"
|
||||
;;
|
||||
|
||||
powerpc*-*-netbsd* | powerpc*-*-openbsd*)
|
||||
echo '/* configured {Open,Net}BSD on powerpc */' >>./mpi/asm-syntax.h
|
||||
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/powerpc32/syntax.h >>./mpi/asm-syntax.h
|
||||
mpi_sflags="-Wa,-mppc"
|
||||
path="powerpc32"
|
||||
mpi_cpu_arch="ppc"
|
||||
;;
|
||||
|
||||
ppc620-*-* | \
|
||||
powerpc64*-*-*)
|
||||
mpi_sflags="-Wa,-mppc"
|
||||
path="powerpc64"
|
||||
mpi_cpu_arch="ppc"
|
||||
;;
|
||||
powerpc*-*-linux*)
|
||||
echo '/* configured for powerpc/ELF */' >>./mpi/asm-syntax.h
|
||||
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
|
||||
cat $srcdir/mpi/powerpc32/syntax.h >>./mpi/asm-syntax.h
|
||||
path="powerpc32"
|
||||
mpi_cpu_arch="ppc"
|
||||
;;
|
||||
|
||||
rs6000-*-aix[456789]* | \
|
||||
@@ -251,6 +300,7 @@ case "${host}" in
|
||||
mpi_sflags="-Wa,-mpwr"
|
||||
path="power"
|
||||
mpi_extra_modules="udiv-w-sdiv"
|
||||
mpi_cpu_arch="ppc"
|
||||
;;
|
||||
rs6000-*-* | \
|
||||
power-*-* | \
|
||||
@@ -258,6 +308,7 @@ case "${host}" in
|
||||
mpi_sflags="-Wa,-mppc"
|
||||
path="power"
|
||||
mpi_extra_modules="udiv-w-sdiv"
|
||||
mpi_cpu_arch="ppc"
|
||||
;;
|
||||
powerpc-ibm-aix4.2.* )
|
||||
# I am not sure about this one but a machine identified by
|
||||
@@ -265,29 +316,54 @@ case "${host}" in
|
||||
mpi_sflags="-Wa,-mpwr"
|
||||
path="power"
|
||||
mpi_extra_modules="udiv-w-sdiv"
|
||||
mpi_cpu_arch="ppc"
|
||||
;;
|
||||
ppc601-*-*)
|
||||
mpi_sflags="-Wa,-mppc"
|
||||
path="power powerpc32"
|
||||
mpi_cpu_arch="ppc"
|
||||
;;
|
||||
ppc60[234]*-*-*)
|
||||
mpi_sflags="-Wa,-mppc"
|
||||
path="powerpc32"
|
||||
mpi_cpu_arch="ppc"
|
||||
;;
|
||||
powerpc*-*-*)
|
||||
mpi_sflags="-Wa,-mppc"
|
||||
path="powerpc32"
|
||||
mpi_cpu_arch="ppc"
|
||||
;;
|
||||
*)
|
||||
echo '/* No assembler modules configured */' >>./mpi/asm-syntax.h
|
||||
echo '/* Platform not known */' >>./mpi/asm-syntax.h
|
||||
path=""
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo '/* Assembler modules disabled on request */' >>./mpi/asm-syntax.h
|
||||
|
||||
# If asm modules are disabled reset the found variables but keep
|
||||
# mpi_cpu_arch.
|
||||
if test "$try_asm_modules" != "yes" ; then
|
||||
echo '/* Assembler modules disabled on request */' >./mpi/asm-syntax.h
|
||||
path=""
|
||||
mpi_sflags=""
|
||||
mpi_extra_modules=""
|
||||
mpi_cpu_arch="disabled"
|
||||
fi
|
||||
|
||||
# Make sure that mpi_cpu_arch is not the empty string.
|
||||
if test x"$mpi_cpu_arch" = x ; then
|
||||
mpi_cpu_arch="unknown"
|
||||
fi
|
||||
|
||||
# Add .note.gnu.property section for Intel CET in assembler sources
|
||||
# when CET is enabled. */
|
||||
if test x"$mpi_cpu_arch" = xx86 ; then
|
||||
cat <<EOF >> ./mpi/asm-syntax.h
|
||||
|
||||
#if defined(__ASSEMBLER__) && defined(__CET__)
|
||||
# include <cet.h>
|
||||
#endif
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Make sysdep.h
|
||||
echo '/* created by config.links - do not edit */' >./mpi/sysdep.h
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/* ec-ed25519.c - Ed25519 optimized elliptic curve functions
|
||||
* Copyright (C) 2013 g10 Code GmbH
|
||||
*
|
||||
* 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>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "mpi-internal.h"
|
||||
#include "longlong.h"
|
||||
#include "g10lib.h"
|
||||
#include "context.h"
|
||||
#include "ec-context.h"
|
||||
#include "ec-internal.h"
|
||||
|
||||
void
|
||||
_gcry_mpi_ec_ed25519_mod (gcry_mpi_t a)
|
||||
{
|
||||
(void)a;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,412 @@
|
||||
/* ec-hw-s390x.c - zSeries ECC acceleration
|
||||
* Copyright (C) 2021 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>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_GCC_INLINE_ASM_S390X
|
||||
|
||||
#include "mpi-internal.h"
|
||||
#include "g10lib.h"
|
||||
#include "context.h"
|
||||
#include "ec-context.h"
|
||||
#include "ec-internal.h"
|
||||
|
||||
#include "../cipher/bufhelp.h"
|
||||
#include "../cipher/asm-inline-s390x.h"
|
||||
|
||||
|
||||
#define S390X_PCC_PARAM_BLOCK_SIZE 4096
|
||||
|
||||
|
||||
extern void reverse_buffer (unsigned char *buffer, unsigned int length);
|
||||
|
||||
static int s390_mul_point_montgomery (mpi_point_t result, gcry_mpi_t scalar,
|
||||
mpi_point_t point, mpi_ec_t ctx,
|
||||
byte *param_block_buf);
|
||||
|
||||
|
||||
static int
|
||||
mpi_copy_to_raw(byte *raw, unsigned int raw_nbytes, gcry_mpi_t a)
|
||||
{
|
||||
unsigned int num_to_zero;
|
||||
unsigned int nbytes;
|
||||
int i, j;
|
||||
|
||||
if (mpi_has_sign (a))
|
||||
return -1;
|
||||
|
||||
if (mpi_get_flag (a, GCRYMPI_FLAG_OPAQUE))
|
||||
{
|
||||
unsigned int nbits;
|
||||
byte *buf;
|
||||
|
||||
buf = mpi_get_opaque (a, &nbits);
|
||||
nbytes = (nbits + 7) / 8;
|
||||
|
||||
if (raw_nbytes < nbytes)
|
||||
return -1;
|
||||
|
||||
num_to_zero = raw_nbytes - nbytes;
|
||||
if (num_to_zero > 0)
|
||||
memset (raw, 0, num_to_zero);
|
||||
if (nbytes > 0)
|
||||
memcpy (raw + num_to_zero, buf, nbytes);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
nbytes = a->nlimbs * BYTES_PER_MPI_LIMB;
|
||||
if (raw_nbytes < nbytes)
|
||||
return -1;
|
||||
|
||||
num_to_zero = raw_nbytes - nbytes;
|
||||
if (num_to_zero > 0)
|
||||
memset (raw, 0, num_to_zero);
|
||||
|
||||
for (j = a->nlimbs - 1, i = 0; i < a->nlimbs; i++, j--)
|
||||
{
|
||||
buf_put_be64(raw + num_to_zero + i * BYTES_PER_MPI_LIMB, a->d[j]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_gcry_s390x_ec_hw_mul_point (mpi_point_t result, gcry_mpi_t scalar,
|
||||
mpi_point_t point, mpi_ec_t ctx)
|
||||
{
|
||||
byte param_block_buf[S390X_PCC_PARAM_BLOCK_SIZE];
|
||||
byte *param_out_x = NULL;
|
||||
byte *param_out_y = NULL;
|
||||
byte *param_in_x = NULL;
|
||||
byte *param_in_y = NULL;
|
||||
byte *param_scalar = NULL;
|
||||
unsigned int field_nbits;
|
||||
unsigned int pcc_func;
|
||||
gcry_mpi_t x, y;
|
||||
gcry_mpi_t d = NULL;
|
||||
int rc = -1;
|
||||
|
||||
if (ctx->name == NULL)
|
||||
return -1;
|
||||
|
||||
if (!(_gcry_get_hw_features () & HWF_S390X_MSA_9))
|
||||
return -1; /* ECC acceleration not supported by HW. */
|
||||
|
||||
if (ctx->model == MPI_EC_MONTGOMERY)
|
||||
return s390_mul_point_montgomery (result, scalar, point, ctx,
|
||||
param_block_buf);
|
||||
|
||||
if (ctx->model == MPI_EC_WEIERSTRASS && ctx->nbits == 256 &&
|
||||
strcmp (ctx->name, "NIST P-256") == 0)
|
||||
{
|
||||
struct pcc_param_block_nistp256_s
|
||||
{
|
||||
byte out_x[256 / 8];
|
||||
byte out_y[256 / 8];
|
||||
byte in_x[256 / 8];
|
||||
byte in_y[256 / 8];
|
||||
byte scalar[256 / 8];
|
||||
byte c_and_ribm[64];
|
||||
} *params = (void *)param_block_buf;
|
||||
|
||||
memset (params->c_and_ribm, 0, sizeof(params->c_and_ribm));
|
||||
|
||||
pcc_func = PCC_FUNCTION_NIST_P256;
|
||||
field_nbits = 256;
|
||||
param_out_x = params->out_x;
|
||||
param_out_y = params->out_y;
|
||||
param_in_x = params->in_x;
|
||||
param_in_y = params->in_y;
|
||||
param_scalar = params->scalar;
|
||||
}
|
||||
else if (ctx->model == MPI_EC_WEIERSTRASS && ctx->nbits == 384 &&
|
||||
strcmp (ctx->name, "NIST P-384") == 0)
|
||||
{
|
||||
struct pcc_param_block_nistp384_s
|
||||
{
|
||||
byte out_x[384 / 8];
|
||||
byte out_y[384 / 8];
|
||||
byte in_x[384 / 8];
|
||||
byte in_y[384 / 8];
|
||||
byte scalar[384 / 8];
|
||||
byte c_and_ribm[64];
|
||||
} *params = (void *)param_block_buf;
|
||||
|
||||
memset (params->c_and_ribm, 0, sizeof(params->c_and_ribm));
|
||||
|
||||
pcc_func = PCC_FUNCTION_NIST_P384;
|
||||
field_nbits = 384;
|
||||
param_out_x = params->out_x;
|
||||
param_out_y = params->out_y;
|
||||
param_in_x = params->in_x;
|
||||
param_in_y = params->in_y;
|
||||
param_scalar = params->scalar;
|
||||
}
|
||||
else if (ctx->model == MPI_EC_WEIERSTRASS && ctx->nbits == 521 &&
|
||||
strcmp (ctx->name, "NIST P-521") == 0)
|
||||
{
|
||||
struct pcc_param_block_nistp521_s
|
||||
{
|
||||
byte out_x[640 / 8]; /* note: first 14 bytes not modified by pcc */
|
||||
byte out_y[640 / 8]; /* note: first 14 bytes not modified by pcc */
|
||||
byte in_x[640 / 8];
|
||||
byte in_y[640 / 8];
|
||||
byte scalar[640 / 8];
|
||||
byte c_and_ribm[64];
|
||||
} *params = (void *)param_block_buf;
|
||||
|
||||
memset (params->out_x, 0, 14);
|
||||
memset (params->out_y, 0, 14);
|
||||
memset (params->c_and_ribm, 0, sizeof(params->c_and_ribm));
|
||||
|
||||
pcc_func = PCC_FUNCTION_NIST_P521;
|
||||
field_nbits = 640;
|
||||
param_out_x = params->out_x;
|
||||
param_out_y = params->out_y;
|
||||
param_in_x = params->in_x;
|
||||
param_in_y = params->in_y;
|
||||
param_scalar = params->scalar;
|
||||
}
|
||||
else if (ctx->model == MPI_EC_EDWARDS && ctx->nbits == 255 &&
|
||||
strcmp (ctx->name, "Ed25519") == 0)
|
||||
{
|
||||
struct pcc_param_block_ed25519_s
|
||||
{
|
||||
byte out_x[256 / 8];
|
||||
byte out_y[256 / 8];
|
||||
byte in_x[256 / 8];
|
||||
byte in_y[256 / 8];
|
||||
byte scalar[256 / 8];
|
||||
byte c_and_ribm[64];
|
||||
} *params = (void *)param_block_buf;
|
||||
|
||||
memset (params->c_and_ribm, 0, sizeof(params->c_and_ribm));
|
||||
|
||||
pcc_func = PCC_FUNCTION_ED25519;
|
||||
field_nbits = 256;
|
||||
param_out_x = params->out_x;
|
||||
param_out_y = params->out_y;
|
||||
param_in_x = params->in_x;
|
||||
param_in_y = params->in_y;
|
||||
param_scalar = params->scalar;
|
||||
}
|
||||
else if (ctx->model == MPI_EC_EDWARDS && ctx->nbits == 448 &&
|
||||
strcmp (ctx->name, "Ed448") == 0)
|
||||
{
|
||||
struct pcc_param_block_ed448_s
|
||||
{
|
||||
byte out_x[512 / 8]; /* note: first 8 bytes not modified by pcc */
|
||||
byte out_y[512 / 8]; /* note: first 8 bytes not modified by pcc */
|
||||
byte in_x[512 / 8];
|
||||
byte in_y[512 / 8];
|
||||
byte scalar[512 / 8];
|
||||
byte c_and_ribm[64];
|
||||
} *params = (void *)param_block_buf;
|
||||
|
||||
memset (params->out_x, 0, 8);
|
||||
memset (params->out_y, 0, 8);
|
||||
memset (params->c_and_ribm, 0, sizeof(params->c_and_ribm));
|
||||
|
||||
pcc_func = PCC_FUNCTION_ED448;
|
||||
field_nbits = 512;
|
||||
param_out_x = params->out_x;
|
||||
param_out_y = params->out_y;
|
||||
param_in_x = params->in_x;
|
||||
param_in_y = params->in_y;
|
||||
param_scalar = params->scalar;
|
||||
}
|
||||
|
||||
if (param_scalar == NULL)
|
||||
return -1; /* No curve match. */
|
||||
|
||||
if (!(pcc_query () & km_function_to_mask (pcc_func)))
|
||||
return -1; /* HW does not support acceleration for this curve. */
|
||||
|
||||
x = mpi_new (0);
|
||||
y = mpi_new (0);
|
||||
|
||||
if (_gcry_mpi_ec_get_affine (x, y, point, ctx) < 0)
|
||||
{
|
||||
/* Point at infinity. */
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (mpi_has_sign (scalar) || mpi_cmp (scalar, ctx->n) >= 0)
|
||||
{
|
||||
d = mpi_is_secure (scalar) ? mpi_snew (ctx->nbits) : mpi_new (ctx->nbits);
|
||||
_gcry_mpi_mod (d, scalar, ctx->n);
|
||||
}
|
||||
else
|
||||
{
|
||||
d = scalar;
|
||||
}
|
||||
|
||||
if (mpi_copy_to_raw (param_in_x, field_nbits / 8, x) < 0)
|
||||
goto out;
|
||||
|
||||
if (mpi_copy_to_raw (param_in_y, field_nbits / 8, y) < 0)
|
||||
goto out;
|
||||
|
||||
if (mpi_copy_to_raw (param_scalar, field_nbits / 8, d) < 0)
|
||||
goto out;
|
||||
|
||||
if (pcc_scalar_multiply (pcc_func, param_block_buf) != 0)
|
||||
goto out;
|
||||
|
||||
_gcry_mpi_set_buffer (result->x, param_out_x, field_nbits / 8, 0);
|
||||
_gcry_mpi_set_buffer (result->y, param_out_y, field_nbits / 8, 0);
|
||||
mpi_set_ui (result->z, 1);
|
||||
mpi_normalize (result->x);
|
||||
mpi_normalize (result->y);
|
||||
if (ctx->model == MPI_EC_EDWARDS)
|
||||
mpi_point_resize (result, ctx);
|
||||
|
||||
rc = 0;
|
||||
|
||||
out:
|
||||
if (d != scalar)
|
||||
mpi_release (d);
|
||||
mpi_release (y);
|
||||
mpi_release (x);
|
||||
wipememory (param_block_buf, S390X_PCC_PARAM_BLOCK_SIZE);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
s390_mul_point_montgomery (mpi_point_t result, gcry_mpi_t scalar,
|
||||
mpi_point_t point, mpi_ec_t ctx,
|
||||
byte *param_block_buf)
|
||||
{
|
||||
byte *param_out_x = NULL;
|
||||
byte *param_in_x = NULL;
|
||||
byte *param_scalar = NULL;
|
||||
unsigned int field_nbits;
|
||||
unsigned int pcc_func;
|
||||
gcry_mpi_t x;
|
||||
gcry_mpi_t d = NULL;
|
||||
int rc = -1;
|
||||
|
||||
if (ctx->nbits == 255 && strcmp (ctx->name, "Curve25519") == 0)
|
||||
{
|
||||
struct pcc_param_block_x25519_s
|
||||
{
|
||||
byte out_x[256 / 8];
|
||||
byte in_x[256 / 8];
|
||||
byte scalar[256 / 8];
|
||||
byte c_and_ribm[64];
|
||||
} *params = (void *)param_block_buf;
|
||||
|
||||
memset (params->c_and_ribm, 0, sizeof(params->c_and_ribm));
|
||||
|
||||
pcc_func = PCC_FUNCTION_X25519;
|
||||
field_nbits = 256;
|
||||
param_out_x = params->out_x;
|
||||
param_in_x = params->in_x;
|
||||
param_scalar = params->scalar;
|
||||
}
|
||||
else if (ctx->nbits == 448 && strcmp (ctx->name, "X448") == 0)
|
||||
{
|
||||
struct pcc_param_block_x448_s
|
||||
{
|
||||
byte out_x[512 / 8]; /* note: first 8 bytes not modified by pcc */
|
||||
byte in_x[512 / 8];
|
||||
byte scalar[512 / 8];
|
||||
byte c_and_ribm[64];
|
||||
} *params = (void *)param_block_buf;
|
||||
|
||||
memset (params->out_x, 0, 8);
|
||||
memset (params->c_and_ribm, 0, sizeof(params->c_and_ribm));
|
||||
|
||||
pcc_func = PCC_FUNCTION_X448;
|
||||
field_nbits = 512;
|
||||
param_out_x = params->out_x;
|
||||
param_in_x = params->in_x;
|
||||
param_scalar = params->scalar;
|
||||
}
|
||||
|
||||
if (param_scalar == NULL)
|
||||
return -1; /* No curve match. */
|
||||
|
||||
if (!(pcc_query () & km_function_to_mask (pcc_func)))
|
||||
return -1; /* HW does not support acceleration for this curve. */
|
||||
|
||||
x = mpi_new (0);
|
||||
|
||||
if (mpi_is_opaque (scalar))
|
||||
{
|
||||
const unsigned int pbits = ctx->nbits;
|
||||
unsigned int n;
|
||||
unsigned char *raw;
|
||||
|
||||
raw = _gcry_mpi_get_opaque_copy (scalar, &n);
|
||||
if ((n + 7) / 8 != (pbits + 7) / 8)
|
||||
log_fatal ("scalar size (%d) != prime size (%d)\n",
|
||||
(n + 7) / 8, (pbits + 7) / 8);
|
||||
|
||||
reverse_buffer (raw, (n + 7 ) / 8);
|
||||
if ((pbits % 8))
|
||||
raw[0] &= (1 << (pbits % 8)) - 1;
|
||||
raw[0] |= (1 << ((pbits + 7) % 8));
|
||||
raw[(pbits + 7) / 8 - 1] &= (256 - ctx->h);
|
||||
d = mpi_is_secure (scalar) ? mpi_snew (pbits) : mpi_new (pbits);
|
||||
_gcry_mpi_set_buffer (d, raw, (n + 7) / 8, 0);
|
||||
xfree (raw);
|
||||
}
|
||||
else
|
||||
{
|
||||
d = scalar;
|
||||
}
|
||||
|
||||
if (_gcry_mpi_ec_get_affine (x, NULL, point, ctx) < 0)
|
||||
{
|
||||
/* Point at infinity. */
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (mpi_copy_to_raw (param_in_x, field_nbits / 8, x) < 0)
|
||||
goto out;
|
||||
|
||||
if (mpi_copy_to_raw (param_scalar, field_nbits / 8, d) < 0)
|
||||
goto out;
|
||||
|
||||
if (pcc_scalar_multiply (pcc_func, param_block_buf) != 0)
|
||||
goto out;
|
||||
|
||||
_gcry_mpi_set_buffer (result->x, param_out_x, field_nbits / 8, 0);
|
||||
mpi_set_ui (result->z, 1);
|
||||
mpi_point_resize (result, ctx);
|
||||
|
||||
rc = 0;
|
||||
|
||||
out:
|
||||
if (d != scalar)
|
||||
mpi_release (d);
|
||||
mpi_release (x);
|
||||
wipememory (param_block_buf, S390X_PCC_PARAM_BLOCK_SIZE);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif /* HAVE_GCC_INLINE_ASM_S390X */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,49 @@
|
||||
/* ec-internal.h - Internal declarations of ec*.c
|
||||
* Copyright (C) 2013 g10 Code GmbH
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef GCRY_EC_INTERNAL_H
|
||||
#define GCRY_EC_INTERNAL_H
|
||||
|
||||
#include <config.h>
|
||||
|
||||
void _gcry_mpi_ec_ed25519_mod (gcry_mpi_t a);
|
||||
|
||||
#ifndef ASM_DISABLED
|
||||
void _gcry_mpi_ec_nist192_mod (gcry_mpi_t w, mpi_ec_t ctx);
|
||||
void _gcry_mpi_ec_nist224_mod (gcry_mpi_t w, mpi_ec_t ctx);
|
||||
void _gcry_mpi_ec_nist256_mod (gcry_mpi_t w, mpi_ec_t ctx);
|
||||
void _gcry_mpi_ec_nist384_mod (gcry_mpi_t w, mpi_ec_t ctx);
|
||||
void _gcry_mpi_ec_nist521_mod (gcry_mpi_t w, mpi_ec_t ctx);
|
||||
#else
|
||||
# define _gcry_mpi_ec_nist192_mod NULL
|
||||
# define _gcry_mpi_ec_nist224_mod NULL
|
||||
# define _gcry_mpi_ec_nist256_mod NULL
|
||||
# define _gcry_mpi_ec_nist384_mod NULL
|
||||
# define _gcry_mpi_ec_nist521_mod NULL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GCC_INLINE_ASM_S390X
|
||||
int _gcry_s390x_ec_hw_mul_point (mpi_point_t result, gcry_mpi_t scalar,
|
||||
mpi_point_t point, mpi_ec_t ctx);
|
||||
# define mpi_ec_hw_mul_point _gcry_s390x_ec_hw_mul_point
|
||||
#else
|
||||
# define mpi_ec_hw_mul_point(r,s,p,c) (-1)
|
||||
#endif
|
||||
|
||||
#endif /*GCRY_EC_INTERNAL_H*/
|
||||
@@ -0,0 +1,826 @@
|
||||
/* ec-nist.c - NIST optimized elliptic curve functions
|
||||
* Copyright (C) 2021 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>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
#ifndef ASM_DISABLED
|
||||
|
||||
|
||||
#include "mpi-internal.h"
|
||||
#include "longlong.h"
|
||||
#include "g10lib.h"
|
||||
#include "context.h"
|
||||
#include "ec-context.h"
|
||||
#include "ec-inline.h"
|
||||
#include "const-time.h"
|
||||
|
||||
|
||||
static inline
|
||||
void prefetch(const void *tab, size_t len)
|
||||
{
|
||||
const volatile byte *vtab = tab;
|
||||
|
||||
if (len > 0 * 64)
|
||||
(void)vtab[0 * 64];
|
||||
if (len > 1 * 64)
|
||||
(void)vtab[1 * 64];
|
||||
if (len > 2 * 64)
|
||||
(void)vtab[2 * 64];
|
||||
if (len > 3 * 64)
|
||||
(void)vtab[3 * 64];
|
||||
if (len > 4 * 64)
|
||||
(void)vtab[4 * 64];
|
||||
if (len > 5 * 64)
|
||||
(void)vtab[5 * 64];
|
||||
if (len > 6 * 64)
|
||||
(void)vtab[6 * 64];
|
||||
if (len > 7 * 64)
|
||||
(void)vtab[7 * 64];
|
||||
if (len > 8 * 64)
|
||||
(void)vtab[8 * 64];
|
||||
if (len > 9 * 64)
|
||||
(void)vtab[9 * 64];
|
||||
if (len > 10 * 64)
|
||||
(void)vtab[10 * 64];
|
||||
(void)vtab[len - 1];
|
||||
}
|
||||
|
||||
|
||||
/* Fast reduction routines for NIST curves. */
|
||||
|
||||
void
|
||||
_gcry_mpi_ec_nist192_mod (gcry_mpi_t w, mpi_ec_t ctx)
|
||||
{
|
||||
static const mpi_limb64_t p_mult[3][4] =
|
||||
{
|
||||
{ /* P * 1 */
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0xffffffffU, 0xfffffffeU),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000000U, 0x00000000U)
|
||||
},
|
||||
{ /* P * 2 */
|
||||
LIMB64_C(0xffffffffU, 0xfffffffeU), LIMB64_C(0xffffffffU, 0xfffffffdU),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000000U, 0x00000001U)
|
||||
},
|
||||
{ /* P * 3 */
|
||||
LIMB64_C(0xffffffffU, 0xfffffffdU), LIMB64_C(0xffffffffU, 0xfffffffcU),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000000U, 0x00000002U)
|
||||
}
|
||||
};
|
||||
const mpi_limb64_t zero = LIMB_TO64(0);
|
||||
mpi_ptr_t wp;
|
||||
mpi_limb64_t s[192 / BITS_PER_MPI_LIMB64 + 1];
|
||||
mpi_limb64_t o[DIM(s)];
|
||||
const mpi_size_t wsize = DIM(s) - 1;
|
||||
mpi_limb_t mask1;
|
||||
mpi_limb_t mask2;
|
||||
mpi_limb_t s_is_negative;
|
||||
int carry;
|
||||
|
||||
MPN_NORMALIZE (w->d, w->nlimbs);
|
||||
if (mpi_nbits_more_than (w, 2 * 192))
|
||||
log_bug ("W must be less than m^2\n");
|
||||
|
||||
RESIZE_AND_CLEAR_IF_NEEDED (w, wsize * 2 * LIMBS_PER_LIMB64);
|
||||
RESIZE_AND_CLEAR_IF_NEEDED (ctx->p, wsize * LIMBS_PER_LIMB64);
|
||||
|
||||
wp = w->d;
|
||||
|
||||
prefetch (p_mult, sizeof(p_mult));
|
||||
|
||||
/* See "FIPS 186-4, D.2.1 Curve P-192". */
|
||||
|
||||
s[0] = LOAD64(wp, 3);
|
||||
ADD3_LIMB64 (s[3], s[2], s[1],
|
||||
zero, zero, LOAD64(wp, 3),
|
||||
zero, LOAD64(wp, 4), LOAD64(wp, 4));
|
||||
|
||||
ADD4_LIMB64 (s[3], s[2], s[1], s[0],
|
||||
s[3], s[2], s[1], s[0],
|
||||
zero, LOAD64(wp, 5), LOAD64(wp, 5), LOAD64(wp, 5));
|
||||
|
||||
ADD4_LIMB64 (s[3], s[2], s[1], s[0],
|
||||
s[3], s[2], s[1], s[0],
|
||||
zero, LOAD64(wp, 2), LOAD64(wp, 1), LOAD64(wp, 0));
|
||||
|
||||
/* mod p:
|
||||
* 's[3]' holds carry value (0..2). Subtract (carry + 1) * p. Result will be
|
||||
* with in range -p...p. Handle result being negative with addition and
|
||||
* conditional store. */
|
||||
|
||||
carry = LO32_LIMB64(s[3]);
|
||||
|
||||
SUB4_LIMB64 (s[3], s[2], s[1], s[0],
|
||||
s[3], s[2], s[1], s[0],
|
||||
p_mult[carry][3], p_mult[carry][2],
|
||||
p_mult[carry][1], p_mult[carry][0]);
|
||||
|
||||
ADD4_LIMB64 (o[3], o[2], o[1], o[0],
|
||||
s[3], s[2], s[1], s[0],
|
||||
zero,
|
||||
p_mult[0][2], p_mult[0][1], p_mult[0][0]);
|
||||
|
||||
s_is_negative = LO32_LIMB64(s[3]) >> 31;
|
||||
|
||||
mask2 = ct_limb_gen_mask(s_is_negative);
|
||||
mask1 = ct_limb_gen_inv_mask(s_is_negative);
|
||||
|
||||
STORE64_COND(wp, 0, mask2, o[0], mask1, s[0]);
|
||||
STORE64_COND(wp, 1, mask2, o[1], mask1, s[1]);
|
||||
STORE64_COND(wp, 2, mask2, o[2], mask1, s[2]);
|
||||
|
||||
w->nlimbs = 192 / BITS_PER_MPI_LIMB;
|
||||
MPN_NORMALIZE (wp, w->nlimbs);
|
||||
}
|
||||
|
||||
void
|
||||
_gcry_mpi_ec_nist224_mod (gcry_mpi_t w, mpi_ec_t ctx)
|
||||
{
|
||||
static const mpi_limb64_t p_mult[5][4] =
|
||||
{
|
||||
{ /* P * -1 */
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000000U, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xffffffffU, 0x00000000U)
|
||||
},
|
||||
{ /* P * 0 */
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U)
|
||||
},
|
||||
{ /* P * 1 */
|
||||
LIMB64_C(0x00000000U, 0x00000001U), LIMB64_C(0xffffffffU, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000000U, 0xffffffffU)
|
||||
},
|
||||
{ /* P * 2 */
|
||||
LIMB64_C(0x00000000U, 0x00000002U), LIMB64_C(0xfffffffeU, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000001U, 0xffffffffU)
|
||||
},
|
||||
{ /* P * 3 */
|
||||
LIMB64_C(0x00000000U, 0x00000003U), LIMB64_C(0xfffffffdU, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000002U, 0xffffffffU)
|
||||
}
|
||||
};
|
||||
const mpi_limb64_t zero = LIMB_TO64(0);
|
||||
mpi_ptr_t wp;
|
||||
mpi_limb64_t s[(224 + BITS_PER_MPI_LIMB64 - 1) / BITS_PER_MPI_LIMB64];
|
||||
mpi_limb64_t d[DIM(s)];
|
||||
const mpi_size_t wsize = DIM(s);
|
||||
mpi_size_t psize = ctx->p->nlimbs;
|
||||
mpi_limb_t mask1;
|
||||
mpi_limb_t mask2;
|
||||
mpi_limb_t s_is_negative;
|
||||
int carry;
|
||||
|
||||
MPN_NORMALIZE (w->d, w->nlimbs);
|
||||
if (mpi_nbits_more_than (w, 2 * 224))
|
||||
log_bug ("W must be less than m^2\n");
|
||||
|
||||
RESIZE_AND_CLEAR_IF_NEEDED (w, wsize * 2 * LIMBS_PER_LIMB64);
|
||||
RESIZE_AND_CLEAR_IF_NEEDED (ctx->p, wsize * LIMBS_PER_LIMB64);
|
||||
ctx->p->nlimbs = psize;
|
||||
|
||||
wp = w->d;
|
||||
|
||||
prefetch (p_mult, sizeof(p_mult));
|
||||
|
||||
/* See "FIPS 186-4, D.2.2 Curve P-224". */
|
||||
|
||||
/* "S1 + S2" with 64-bit limbs:
|
||||
* [0:A10]:[ A9: A8]:[ A7:0]:[0:0]
|
||||
* + [0:0]:[A13:A12]:[A11:0]:[0:0]
|
||||
* => s[3]:s[2]:s[1]:s[0]
|
||||
*/
|
||||
s[0] = zero;
|
||||
ADD3_LIMB64 (s[3], s[2], s[1],
|
||||
LIMB64_HILO(0, LOAD32(wp, 10)),
|
||||
LOAD64(wp, 8 / 2),
|
||||
LIMB64_HILO(LOAD32(wp, 7), 0),
|
||||
zero,
|
||||
LOAD64(wp, 12 / 2),
|
||||
LIMB64_HILO(LOAD32(wp, 11), 0));
|
||||
|
||||
/* "T + S1 + S2" */
|
||||
ADD4_LIMB64 (s[3], s[2], s[1], s[0],
|
||||
s[3], s[2], s[1], s[0],
|
||||
LIMB64_HILO(0, LOAD32(wp, 6)),
|
||||
LOAD64(wp, 4 / 2),
|
||||
LOAD64(wp, 2 / 2),
|
||||
LOAD64(wp, 0 / 2));
|
||||
|
||||
/* "D1 + D2" with 64-bit limbs:
|
||||
* [0:A13]:[A12:A11]:[A10: A9]:[ A8: A7]
|
||||
* + [0:0]:[ 0: 0]:[ 0:A13]:[A12:A11]
|
||||
* => d[3]:d[2]:d[1]:d[0]
|
||||
*/
|
||||
ADD4_LIMB64 (d[3], d[2], d[1], d[0],
|
||||
LIMB64_HILO(0, LOAD32(wp, 13)),
|
||||
LOAD64_UNALIGNED(wp, 11 / 2),
|
||||
LOAD64_UNALIGNED(wp, 9 / 2),
|
||||
LOAD64_UNALIGNED(wp, 7 / 2),
|
||||
zero,
|
||||
zero,
|
||||
LIMB64_HILO(0, LOAD32(wp, 13)),
|
||||
LOAD64_UNALIGNED(wp, 11 / 2));
|
||||
|
||||
/* "T + S1 + S2 - D1 - D2" */
|
||||
SUB4_LIMB64 (s[3], s[2], s[1], s[0],
|
||||
s[3], s[2], s[1], s[0],
|
||||
d[3], d[2], d[1], d[0]);
|
||||
|
||||
/* mod p:
|
||||
* Upper 32-bits of 's[3]' holds carry value (-2..2).
|
||||
* Subtract (carry + 1) * p. Result will be with in range -p...p.
|
||||
* Handle result being negative with addition and conditional store. */
|
||||
|
||||
carry = HI32_LIMB64(s[3]);
|
||||
|
||||
SUB4_LIMB64 (s[3], s[2], s[1], s[0],
|
||||
s[3], s[2], s[1], s[0],
|
||||
p_mult[carry + 2][3], p_mult[carry + 2][2],
|
||||
p_mult[carry + 2][1], p_mult[carry + 2][0]);
|
||||
|
||||
ADD4_LIMB64 (d[3], d[2], d[1], d[0],
|
||||
s[3], s[2], s[1], s[0],
|
||||
p_mult[0 + 2][3], p_mult[0 + 2][2],
|
||||
p_mult[0 + 2][1], p_mult[0 + 2][0]);
|
||||
|
||||
s_is_negative = (HI32_LIMB64(s[3]) >> 31);
|
||||
|
||||
mask2 = ct_limb_gen_mask(s_is_negative);
|
||||
mask1 = ct_limb_gen_inv_mask(s_is_negative);
|
||||
|
||||
STORE64_COND(wp, 0, mask2, d[0], mask1, s[0]);
|
||||
STORE64_COND(wp, 1, mask2, d[1], mask1, s[1]);
|
||||
STORE64_COND(wp, 2, mask2, d[2], mask1, s[2]);
|
||||
STORE64_COND(wp, 3, mask2, d[3], mask1, s[3]);
|
||||
|
||||
w->nlimbs = wsize * LIMBS_PER_LIMB64;
|
||||
MPN_NORMALIZE (wp, w->nlimbs);
|
||||
}
|
||||
|
||||
void
|
||||
_gcry_mpi_ec_nist256_mod (gcry_mpi_t w, mpi_ec_t ctx)
|
||||
{
|
||||
static const mpi_limb64_t p_mult[12][5] =
|
||||
{
|
||||
{ /* P * -3 */
|
||||
LIMB64_C(0x00000000U, 0x00000003U), LIMB64_C(0xfffffffdU, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000002U, 0xfffffffcU),
|
||||
LIMB64_C(0xffffffffU, 0xfffffffdU)
|
||||
},
|
||||
{ /* P * -2 */
|
||||
LIMB64_C(0x00000000U, 0x00000002U), LIMB64_C(0xfffffffeU, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000001U, 0xfffffffdU),
|
||||
LIMB64_C(0xffffffffU, 0xfffffffeU)
|
||||
},
|
||||
{ /* P * -1 */
|
||||
LIMB64_C(0x00000000U, 0x00000001U), LIMB64_C(0xffffffffU, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000000U, 0xfffffffeU),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU)
|
||||
},
|
||||
{ /* P * 0 */
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U),
|
||||
LIMB64_C(0x00000000U, 0x00000000U)
|
||||
},
|
||||
{ /* P * 1 */
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000000U, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xffffffffU, 0x00000001U),
|
||||
LIMB64_C(0x00000000U, 0x00000000U)
|
||||
},
|
||||
{ /* P * 2 */
|
||||
LIMB64_C(0xffffffffU, 0xfffffffeU), LIMB64_C(0x00000001U, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffeU, 0x00000002U),
|
||||
LIMB64_C(0x00000000U, 0x00000001U)
|
||||
},
|
||||
{ /* P * 3 */
|
||||
LIMB64_C(0xffffffffU, 0xfffffffdU), LIMB64_C(0x00000002U, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffdU, 0x00000003U),
|
||||
LIMB64_C(0x00000000U, 0x00000002U)
|
||||
},
|
||||
{ /* P * 4 */
|
||||
LIMB64_C(0xffffffffU, 0xfffffffcU), LIMB64_C(0x00000003U, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffcU, 0x00000004U),
|
||||
LIMB64_C(0x00000000U, 0x00000003U)
|
||||
},
|
||||
{ /* P * 5 */
|
||||
LIMB64_C(0xffffffffU, 0xfffffffbU), LIMB64_C(0x00000004U, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffbU, 0x00000005U),
|
||||
LIMB64_C(0x00000000U, 0x00000004U)
|
||||
},
|
||||
{ /* P * 6 */
|
||||
LIMB64_C(0xffffffffU, 0xfffffffaU), LIMB64_C(0x00000005U, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffaU, 0x00000006U),
|
||||
LIMB64_C(0x00000000U, 0x00000005U)
|
||||
},
|
||||
{ /* P * 7 */
|
||||
LIMB64_C(0xffffffffU, 0xfffffff9U), LIMB64_C(0x00000006U, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffff9U, 0x00000007U),
|
||||
LIMB64_C(0x00000000U, 0x00000006U)
|
||||
}
|
||||
};
|
||||
const mpi_limb64_t zero = LIMB_TO64(0);
|
||||
mpi_ptr_t wp;
|
||||
mpi_limb64_t s[(256 + BITS_PER_MPI_LIMB64 - 1) / BITS_PER_MPI_LIMB64 + 1];
|
||||
mpi_limb64_t t[DIM(s)];
|
||||
mpi_limb64_t d[DIM(s)];
|
||||
mpi_limb64_t e[DIM(s)];
|
||||
const mpi_size_t wsize = DIM(s) - 1;
|
||||
mpi_size_t psize = ctx->p->nlimbs;
|
||||
mpi_limb_t mask1;
|
||||
mpi_limb_t mask2;
|
||||
mpi_limb_t mask3;
|
||||
mpi_limb_t s_is_negative;
|
||||
mpi_limb_t d_is_negative;
|
||||
int carry;
|
||||
|
||||
MPN_NORMALIZE (w->d, w->nlimbs);
|
||||
if (mpi_nbits_more_than (w, 2 * 256))
|
||||
log_bug ("W must be less than m^2\n");
|
||||
|
||||
RESIZE_AND_CLEAR_IF_NEEDED (w, wsize * 2 * LIMBS_PER_LIMB64);
|
||||
RESIZE_AND_CLEAR_IF_NEEDED (ctx->p, wsize * LIMBS_PER_LIMB64);
|
||||
ctx->p->nlimbs = psize;
|
||||
|
||||
wp = w->d;
|
||||
|
||||
prefetch (p_mult, sizeof(p_mult));
|
||||
|
||||
/* See "FIPS 186-4, D.2.3 Curve P-256". */
|
||||
|
||||
/* "S1 + S2" with 64-bit limbs:
|
||||
* [A15:A14]:[A13:A12]:[A11:0]:[0:0]
|
||||
* + [0:A15]:[A14:A13]:[A12:0]:[0:0]
|
||||
* => s[4]:s[3]:s[2]:s[1]:s[0]
|
||||
*/
|
||||
s[0] = zero;
|
||||
ADD4_LIMB64 (s[4], s[3], s[2], s[1],
|
||||
zero,
|
||||
LOAD64(wp, 14 / 2),
|
||||
LOAD64(wp, 12 / 2),
|
||||
LIMB64_HILO(LOAD32(wp, 11), 0),
|
||||
zero,
|
||||
LIMB64_HILO(0, LOAD32(wp, 15)),
|
||||
LOAD64_UNALIGNED(wp, 13 / 2),
|
||||
LIMB64_HILO(LOAD32(wp, 12), 0));
|
||||
|
||||
/* "S3 + S4" with 64-bit limbs:
|
||||
* [A15:A14]:[ 0: 0]:[ 0:A10]:[ A9:A8]
|
||||
* + [A8:A13]:[A15:A14]:[A13:A11]:[A10:A9]
|
||||
* => t[4]:t[3]:t[2]:t[1]:t[0]
|
||||
*/
|
||||
ADD5_LIMB64 (t[4], t[3], t[2], t[1], t[0],
|
||||
zero,
|
||||
LOAD64(wp, 14 / 2),
|
||||
zero,
|
||||
LIMB64_HILO(0, LOAD32(wp, 10)),
|
||||
LOAD64(wp, 8 / 2),
|
||||
zero,
|
||||
LIMB64_HILO(LOAD32(wp, 8), LOAD32(wp, 13)),
|
||||
LOAD64(wp, 14 / 2),
|
||||
LIMB64_HILO(LOAD32(wp, 13), LOAD32(wp, 11)),
|
||||
LOAD64_UNALIGNED(wp, 9 / 2));
|
||||
|
||||
/* "2*S1 + 2*S2" */
|
||||
ADD5_LIMB64 (s[4], s[3], s[2], s[1], s[0],
|
||||
s[4], s[3], s[2], s[1], s[0],
|
||||
s[4], s[3], s[2], s[1], s[0]);
|
||||
|
||||
/* "T + S3 + S4" */
|
||||
ADD5_LIMB64 (t[4], t[3], t[2], t[1], t[0],
|
||||
t[4], t[3], t[2], t[1], t[0],
|
||||
zero,
|
||||
LOAD64(wp, 6 / 2),
|
||||
LOAD64(wp, 4 / 2),
|
||||
LOAD64(wp, 2 / 2),
|
||||
LOAD64(wp, 0 / 2));
|
||||
|
||||
/* "2*S1 + 2*S2 - D3" with 64-bit limbs:
|
||||
* s[4]: s[3]: s[2]: s[1]: s[0]
|
||||
* - [A12:0]:[A10:A9]:[A8:A15]:[A14:A13]
|
||||
* => s[4]:s[3]:s[2]:s[1]:s[0]
|
||||
*/
|
||||
SUB5_LIMB64 (s[4], s[3], s[2], s[1], s[0],
|
||||
s[4], s[3], s[2], s[1], s[0],
|
||||
zero,
|
||||
LIMB64_HILO(LOAD32(wp, 12), 0),
|
||||
LOAD64_UNALIGNED(wp, 9 / 2),
|
||||
LIMB64_HILO(LOAD32(wp, 8), LOAD32(wp, 15)),
|
||||
LOAD64_UNALIGNED(wp, 13 / 2));
|
||||
|
||||
/* "T + 2*S1 + 2*S2 + S3 + S4 - D3" */
|
||||
ADD5_LIMB64 (s[4], s[3], s[2], s[1], s[0],
|
||||
s[4], s[3], s[2], s[1], s[0],
|
||||
t[4], t[3], t[2], t[1], t[0]);
|
||||
|
||||
/* "D1 + D2" with 64-bit limbs:
|
||||
* [0:A13]:[A12:A11] + [A15:A14]:[A13:A12] => d[2]:d[1]:d[0]
|
||||
* [A10:A8] + [A11:A9] => d[4]:d[3]
|
||||
*/
|
||||
ADD3_LIMB64 (d[2], d[1], d[0],
|
||||
zero,
|
||||
LIMB64_HILO(0, LOAD32(wp, 13)),
|
||||
LOAD64_UNALIGNED(wp, 11 / 2),
|
||||
zero,
|
||||
LOAD64(wp, 14 / 2),
|
||||
LOAD64(wp, 12 / 2));
|
||||
ADD2_LIMB64 (d[4], d[3],
|
||||
zero, LIMB64_HILO(LOAD32(wp, 10), LOAD32(wp, 8)),
|
||||
zero, LIMB64_HILO(LOAD32(wp, 11), LOAD32(wp, 9)));
|
||||
|
||||
/* "D1 + D2 + D4" with 64-bit limbs:
|
||||
* d[4]: d[3]: d[2]: d[1]: d[0]
|
||||
* - [A13:0]:[A11:A10]:[A9:0]:[A15:A14]
|
||||
* => d[4]:d[3]:d[2]:d[1]:d[0]
|
||||
*/
|
||||
ADD5_LIMB64 (d[4], d[3], d[2], d[1], d[0],
|
||||
d[4], d[3], d[2], d[1], d[0],
|
||||
zero,
|
||||
LIMB64_HILO(LOAD32(wp, 13), 0),
|
||||
LOAD64(wp, 10 / 2),
|
||||
LIMB64_HILO(LOAD32(wp, 9), 0),
|
||||
LOAD64(wp, 14 / 2));
|
||||
|
||||
/* "T + 2*S1 + 2*S2 + S3 + S4 - D1 - D2 - D3 - D4" */
|
||||
SUB5_LIMB64 (s[4], s[3], s[2], s[1], s[0],
|
||||
s[4], s[3], s[2], s[1], s[0],
|
||||
d[4], d[3], d[2], d[1], d[0]);
|
||||
|
||||
/* mod p:
|
||||
* 's[4]' holds carry value (-4..6). Subtract (carry + 1) * p. Result
|
||||
* will be with in range -2*p...p. Handle result being negative with
|
||||
* addition and conditional store. */
|
||||
|
||||
carry = LO32_LIMB64(s[4]);
|
||||
|
||||
/* Load values to stack to ease register pressure on i386. */
|
||||
e[0] = p_mult[carry + 4][0];
|
||||
e[1] = p_mult[carry + 4][1];
|
||||
e[2] = p_mult[carry + 4][2];
|
||||
e[3] = p_mult[carry + 4][3];
|
||||
e[4] = p_mult[carry + 4][4];
|
||||
SUB5_LIMB64 (s[4], s[3], s[2], s[1], s[0],
|
||||
s[4], s[3], s[2], s[1], s[0],
|
||||
e[4], e[3], e[2], e[1], e[0]);
|
||||
|
||||
/* Add 1*P */
|
||||
ADD5_LIMB64 (d[4], d[3], d[2], d[1], d[0],
|
||||
s[4], s[3], s[2], s[1], s[0],
|
||||
zero,
|
||||
p_mult[0 + 4][3], p_mult[0 + 4][2],
|
||||
p_mult[0 + 4][1], p_mult[0 + 4][0]);
|
||||
|
||||
/* Add 2*P */
|
||||
ADD5_LIMB64 (e[4], e[3], e[2], e[1], e[0],
|
||||
s[4], s[3], s[2], s[1], s[0],
|
||||
zero,
|
||||
p_mult[1 + 4][3], p_mult[1 + 4][2],
|
||||
p_mult[1 + 4][1], p_mult[1 + 4][0]);
|
||||
|
||||
s_is_negative = LO32_LIMB64(s[4]) >> 31;
|
||||
d_is_negative = LO32_LIMB64(d[4]) >> 31;
|
||||
mask3 = ct_limb_gen_mask(d_is_negative);
|
||||
mask2 = ct_limb_gen_mask(s_is_negative) & ~mask3;
|
||||
mask1 = ct_limb_gen_inv_mask(s_is_negative) & ~mask3;
|
||||
|
||||
s[0] = LIMB_OR64(MASK_AND64(mask2, d[0]), MASK_AND64(mask1, s[0]));
|
||||
s[1] = LIMB_OR64(MASK_AND64(mask2, d[1]), MASK_AND64(mask1, s[1]));
|
||||
s[2] = LIMB_OR64(MASK_AND64(mask2, d[2]), MASK_AND64(mask1, s[2]));
|
||||
s[3] = LIMB_OR64(MASK_AND64(mask2, d[3]), MASK_AND64(mask1, s[3]));
|
||||
s[0] = LIMB_OR64(MASK_AND64(mask3, e[0]), s[0]);
|
||||
s[1] = LIMB_OR64(MASK_AND64(mask3, e[1]), s[1]);
|
||||
s[2] = LIMB_OR64(MASK_AND64(mask3, e[2]), s[2]);
|
||||
s[3] = LIMB_OR64(MASK_AND64(mask3, e[3]), s[3]);
|
||||
|
||||
STORE64(wp, 0, s[0]);
|
||||
STORE64(wp, 1, s[1]);
|
||||
STORE64(wp, 2, s[2]);
|
||||
STORE64(wp, 3, s[3]);
|
||||
|
||||
w->nlimbs = wsize * LIMBS_PER_LIMB64;
|
||||
MPN_NORMALIZE (wp, w->nlimbs);
|
||||
}
|
||||
|
||||
void
|
||||
_gcry_mpi_ec_nist384_mod (gcry_mpi_t w, mpi_ec_t ctx)
|
||||
{
|
||||
static const mpi_limb64_t p_mult[11][7] =
|
||||
{
|
||||
{ /* P * -2 */
|
||||
LIMB64_C(0xfffffffeU, 0x00000002U), LIMB64_C(0x00000001U, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000002U), LIMB64_C(0x00000000U, 0x00000000U),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xfffffffeU)
|
||||
},
|
||||
{ /* P * -1 */
|
||||
LIMB64_C(0xffffffffU, 0x00000001U), LIMB64_C(0x00000000U, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000001U), LIMB64_C(0x00000000U, 0x00000000U),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU)
|
||||
},
|
||||
{ /* P * 0 */
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U),
|
||||
LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U),
|
||||
LIMB64_C(0x00000000U, 0x00000000U)
|
||||
},
|
||||
{ /* P * 1 */
|
||||
LIMB64_C(0x00000000U, 0xffffffffU), LIMB64_C(0xffffffffU, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xfffffffeU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000000U)
|
||||
},
|
||||
{ /* P * 2 */
|
||||
LIMB64_C(0x00000001U, 0xfffffffeU), LIMB64_C(0xfffffffeU, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xfffffffdU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000001U)
|
||||
},
|
||||
{ /* P * 3 */
|
||||
LIMB64_C(0x00000002U, 0xfffffffdU), LIMB64_C(0xfffffffdU, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xfffffffcU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000002U)
|
||||
},
|
||||
{ /* P * 4 */
|
||||
LIMB64_C(0x00000003U, 0xfffffffcU), LIMB64_C(0xfffffffcU, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xfffffffbU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000003U)
|
||||
},
|
||||
{ /* P * 5 */
|
||||
LIMB64_C(0x00000004U, 0xfffffffbU), LIMB64_C(0xfffffffbU, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xfffffffaU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000004U)
|
||||
},
|
||||
{ /* P * 6 */
|
||||
LIMB64_C(0x00000005U, 0xfffffffaU), LIMB64_C(0xfffffffaU, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xfffffff9U), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000005U)
|
||||
},
|
||||
{ /* P * 7 */
|
||||
LIMB64_C(0x00000006U, 0xfffffff9U), LIMB64_C(0xfffffff9U, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xfffffff8U), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000006U)
|
||||
},
|
||||
{ /* P * 8 */
|
||||
LIMB64_C(0x00000007U, 0xfffffff8U), LIMB64_C(0xfffffff8U, 0x00000000U),
|
||||
LIMB64_C(0xffffffffU, 0xfffffff7U), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0xffffffffU, 0xffffffffU),
|
||||
LIMB64_C(0x00000000U, 0x00000007U)
|
||||
},
|
||||
};
|
||||
const mpi_limb64_t zero = LIMB_TO64(0);
|
||||
mpi_ptr_t wp;
|
||||
mpi_limb64_t s[(384 + BITS_PER_MPI_LIMB64 - 1) / BITS_PER_MPI_LIMB64 + 1];
|
||||
mpi_limb64_t t[DIM(s)];
|
||||
mpi_limb64_t d[DIM(s)];
|
||||
mpi_limb64_t x[DIM(s)];
|
||||
#if (BITS_PER_MPI_LIMB64 == BITS_PER_MPI_LIMB) && defined(WORDS_BIGENDIAN)
|
||||
mpi_limb_t wp_shr32[(DIM(s) - 1) * LIMBS_PER_LIMB64];
|
||||
#endif
|
||||
const mpi_size_t wsize = DIM(s) - 1;
|
||||
mpi_size_t psize = ctx->p->nlimbs;
|
||||
mpi_limb_t mask1;
|
||||
mpi_limb_t mask2;
|
||||
mpi_limb_t s_is_negative;
|
||||
int carry;
|
||||
|
||||
MPN_NORMALIZE (w->d, w->nlimbs);
|
||||
if (mpi_nbits_more_than (w, 2 * 384))
|
||||
log_bug ("W must be less than m^2\n");
|
||||
|
||||
RESIZE_AND_CLEAR_IF_NEEDED (w, wsize * 2 * LIMBS_PER_LIMB64);
|
||||
RESIZE_AND_CLEAR_IF_NEEDED (ctx->p, wsize * LIMBS_PER_LIMB64);
|
||||
ctx->p->nlimbs = psize;
|
||||
|
||||
wp = w->d;
|
||||
|
||||
prefetch (p_mult, sizeof(p_mult));
|
||||
|
||||
/* See "FIPS 186-4, D.2.4 Curve P-384". */
|
||||
|
||||
#if BITS_PER_MPI_LIMB64 == BITS_PER_MPI_LIMB
|
||||
# ifdef WORDS_BIGENDIAN
|
||||
# define LOAD64_SHR32(idx) LOAD64(wp_shr32, ((idx) / 2 - wsize))
|
||||
_gcry_mpih_rshift (wp_shr32, wp + 384 / BITS_PER_MPI_LIMB,
|
||||
wsize * LIMBS_PER_LIMB64, 32);
|
||||
# else
|
||||
# define LOAD64_SHR32(idx) LOAD64_UNALIGNED(wp, idx / 2)
|
||||
#endif
|
||||
#else
|
||||
# define LOAD64_SHR32(idx) LIMB64_HILO(LOAD32(wp, (idx) + 1), LOAD32(wp, idx))
|
||||
#endif
|
||||
|
||||
/* "S1 + S1" with 64-bit limbs:
|
||||
* [0:A23]:[A22:A21]
|
||||
* + [0:A23]:[A22:A21]
|
||||
* => s[3]:s[2]
|
||||
*/
|
||||
ADD2_LIMB64 (s[3], s[2],
|
||||
LIMB64_HILO(0, LOAD32(wp, 23)),
|
||||
LOAD64_SHR32(21),
|
||||
LIMB64_HILO(0, LOAD32(wp, 23)),
|
||||
LOAD64_SHR32(21));
|
||||
|
||||
/* "S5 + S6" with 64-bit limbs:
|
||||
* [A23:A22]:[A21:A20]:[ 0:0]:[0: 0]
|
||||
* + [ 0: 0]:[A23:A22]:[A21:0]:[0:A20]
|
||||
* => x[4]:x[3]:x[2]:x[1]:x[0]
|
||||
*/
|
||||
x[0] = LIMB64_HILO(0, LOAD32(wp, 20));
|
||||
x[1] = LIMB64_HILO(LOAD32(wp, 21), 0);
|
||||
ADD3_LIMB64 (x[4], x[3], x[2],
|
||||
zero, LOAD64(wp, 22 / 2), LOAD64(wp, 20 / 2),
|
||||
zero, zero, LOAD64(wp, 22 / 2));
|
||||
|
||||
/* "D2 + D3" with 64-bit limbs:
|
||||
* [0:A23]:[A22:A21]:[A20:0]
|
||||
* + [0:A23]:[A23:0]:[0:0]
|
||||
* => d[2]:d[1]:d[0]
|
||||
*/
|
||||
d[0] = LIMB64_HILO(LOAD32(wp, 20), 0);
|
||||
ADD2_LIMB64 (d[2], d[1],
|
||||
LIMB64_HILO(0, LOAD32(wp, 23)),
|
||||
LOAD64_SHR32(21),
|
||||
LIMB64_HILO(0, LOAD32(wp, 23)),
|
||||
LIMB64_HILO(LOAD32(wp, 23), 0));
|
||||
|
||||
/* "2*S1 + S5 + S6" with 64-bit limbs:
|
||||
* s[4]:s[3]:s[2]:s[1]:s[0]
|
||||
* + x[4]:x[3]:x[2]:x[1]:x[0]
|
||||
* => s[4]:s[3]:s[2]:s[1]:s[0]
|
||||
*/
|
||||
s[0] = x[0];
|
||||
s[1] = x[1];
|
||||
ADD3_LIMB64(s[4], s[3], s[2],
|
||||
zero, s[3], s[2],
|
||||
x[4], x[3], x[2]);
|
||||
|
||||
/* "T + S2" with 64-bit limbs:
|
||||
* [A11:A10]:[ A9: A8]:[ A7: A6]:[ A5: A4]:[ A3: A2]:[ A1: A0]
|
||||
* + [A23:A22]:[A21:A20]:[A19:A18]:[A17:A16]:[A15:A14]:[A13:A12]
|
||||
* => t[6]:t[5]:t[4]:t[3]:t[2]:t[1]:t[0]
|
||||
*/
|
||||
ADD7_LIMB64 (t[6], t[5], t[4], t[3], t[2], t[1], t[0],
|
||||
zero,
|
||||
LOAD64(wp, 10 / 2), LOAD64(wp, 8 / 2), LOAD64(wp, 6 / 2),
|
||||
LOAD64(wp, 4 / 2), LOAD64(wp, 2 / 2), LOAD64(wp, 0 / 2),
|
||||
zero,
|
||||
LOAD64(wp, 22 / 2), LOAD64(wp, 20 / 2), LOAD64(wp, 18 / 2),
|
||||
LOAD64(wp, 16 / 2), LOAD64(wp, 14 / 2), LOAD64(wp, 12 / 2));
|
||||
|
||||
/* "2*S1 + S4 + S5 + S6" with 64-bit limbs:
|
||||
* s[6]: s[5]: s[4]: s[3]: s[2]: s[1]: s[0]
|
||||
* + [A19:A18]:[A17:A16]:[A15:A14]:[A13:A12]:[A20:0]:[A23:0]
|
||||
* => s[6]:s[5]:s[4]:s[3]:s[2]:s[1]:s[0]
|
||||
*/
|
||||
ADD7_LIMB64 (s[6], s[5], s[4], s[3], s[2], s[1], s[0],
|
||||
zero, zero, s[4], s[3], s[2], s[1], s[0],
|
||||
zero,
|
||||
LOAD64(wp, 18 / 2), LOAD64(wp, 16 / 2),
|
||||
LOAD64(wp, 14 / 2), LOAD64(wp, 12 / 2),
|
||||
LIMB64_HILO(LOAD32(wp, 20), 0),
|
||||
LIMB64_HILO(LOAD32(wp, 23), 0));
|
||||
|
||||
/* "D1 + D2 + D3" with 64-bit limbs:
|
||||
* d[6]: d[5]: d[4]: d[3]: d[2]: d[1]: d[0]
|
||||
* + [A22:A21]:[A20:A19]:[A18:A17]:[A16:A15]:[A14:A13]:[A12:A23]
|
||||
* => d[6]:d[5]:d[4]:d[3]:d[2]:d[1]:d[0]
|
||||
*/
|
||||
ADD7_LIMB64 (d[6], d[5], d[4], d[3], d[2], d[1], d[0],
|
||||
zero, zero, zero, zero, d[2], d[1], d[0],
|
||||
zero,
|
||||
LOAD64_SHR32(21),
|
||||
LOAD64_SHR32(19),
|
||||
LOAD64_SHR32(17),
|
||||
LOAD64_SHR32(15),
|
||||
LOAD64_SHR32(13),
|
||||
LIMB64_HILO(LOAD32(wp, 12), LOAD32(wp, 23)));
|
||||
|
||||
/* "2*S1 + S3 + S4 + S5 + S6" with 64-bit limbs:
|
||||
* s[6]: s[5]: s[4]: s[3]: s[2]: s[1]: s[0]
|
||||
* + [A20:A19]:[A18:A17]:[A16:A15]:[A14:A13]:[A12:A23]:[A22:A21]
|
||||
* => s[6]:s[5]:s[4]:s[3]:s[2]:s[1]:s[0]
|
||||
*/
|
||||
ADD7_LIMB64 (s[6], s[5], s[4], s[3], s[2], s[1], s[0],
|
||||
s[6], s[5], s[4], s[3], s[2], s[1], s[0],
|
||||
zero,
|
||||
LOAD64_SHR32(19),
|
||||
LOAD64_SHR32(17),
|
||||
LOAD64_SHR32(15),
|
||||
LOAD64_SHR32(13),
|
||||
LIMB64_HILO(LOAD32(wp, 12), LOAD32(wp, 23)),
|
||||
LOAD64_SHR32(21));
|
||||
|
||||
/* "T + 2*S1 + S2 + S3 + S4 + S5 + S6" */
|
||||
ADD7_LIMB64 (s[6], s[5], s[4], s[3], s[2], s[1], s[0],
|
||||
s[6], s[5], s[4], s[3], s[2], s[1], s[0],
|
||||
t[6], t[5], t[4], t[3], t[2], t[1], t[0]);
|
||||
|
||||
/* "T + 2*S1 + S2 + S3 + S4 + S5 + S6 - D1 - D2 - D3" */
|
||||
SUB7_LIMB64 (s[6], s[5], s[4], s[3], s[2], s[1], s[0],
|
||||
s[6], s[5], s[4], s[3], s[2], s[1], s[0],
|
||||
d[6], d[5], d[4], d[3], d[2], d[1], d[0]);
|
||||
|
||||
#undef LOAD64_SHR32
|
||||
|
||||
/* mod p:
|
||||
* 's[6]' holds carry value (-3..7). Subtract (carry + 1) * p. Result
|
||||
* will be with in range -p...p. Handle result being negative with
|
||||
* addition and conditional store. */
|
||||
|
||||
carry = LO32_LIMB64(s[6]);
|
||||
|
||||
/* Load values to stack to ease register pressure on i386. */
|
||||
x[0] = p_mult[carry + 3][0];
|
||||
x[1] = p_mult[carry + 3][1];
|
||||
x[2] = p_mult[carry + 3][2];
|
||||
x[3] = p_mult[carry + 3][3];
|
||||
x[4] = p_mult[carry + 3][4];
|
||||
x[5] = p_mult[carry + 3][5];
|
||||
x[6] = p_mult[carry + 3][6];
|
||||
SUB7_LIMB64 (s[6], s[5], s[4], s[3], s[2], s[1], s[0],
|
||||
s[6], s[5], s[4], s[3], s[2], s[1], s[0],
|
||||
x[6], x[5], x[4], x[3], x[2], x[1], x[0]);
|
||||
|
||||
ADD7_LIMB64 (d[6], d[5], d[4], d[3], d[2], d[1], d[0],
|
||||
s[6], s[5], s[4], s[3], s[2], s[1], s[0],
|
||||
zero,
|
||||
p_mult[0 + 3][5], p_mult[0 + 3][4],
|
||||
p_mult[0 + 3][3], p_mult[0 + 3][2],
|
||||
p_mult[0 + 3][1], p_mult[0 + 3][0]);
|
||||
|
||||
s_is_negative = LO32_LIMB64(s[6]) >> 31;
|
||||
mask2 = ct_limb_gen_mask(s_is_negative);
|
||||
mask1 = ct_limb_gen_inv_mask(s_is_negative);
|
||||
|
||||
STORE64_COND(wp, 0, mask2, d[0], mask1, s[0]);
|
||||
STORE64_COND(wp, 1, mask2, d[1], mask1, s[1]);
|
||||
STORE64_COND(wp, 2, mask2, d[2], mask1, s[2]);
|
||||
STORE64_COND(wp, 3, mask2, d[3], mask1, s[3]);
|
||||
STORE64_COND(wp, 4, mask2, d[4], mask1, s[4]);
|
||||
STORE64_COND(wp, 5, mask2, d[5], mask1, s[5]);
|
||||
|
||||
w->nlimbs = wsize * LIMBS_PER_LIMB64;
|
||||
MPN_NORMALIZE (wp, w->nlimbs);
|
||||
|
||||
#if (BITS_PER_MPI_LIMB64 == BITS_PER_MPI_LIMB) && defined(WORDS_BIGENDIAN)
|
||||
wipememory(wp_shr32, sizeof(wp_shr32));
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_gcry_mpi_ec_nist521_mod (gcry_mpi_t w, mpi_ec_t ctx)
|
||||
{
|
||||
mpi_limb_t s[(521 + BITS_PER_MPI_LIMB - 1) / BITS_PER_MPI_LIMB];
|
||||
const mpi_size_t wsize = DIM(s);
|
||||
mpi_limb_t cy;
|
||||
mpi_ptr_t wp;
|
||||
|
||||
MPN_NORMALIZE (w->d, w->nlimbs);
|
||||
if (mpi_nbits_more_than (w, 2 * 521))
|
||||
log_bug ("W must be less than m^2\n");
|
||||
|
||||
RESIZE_AND_CLEAR_IF_NEEDED (w, wsize * 2);
|
||||
|
||||
wp = w->d;
|
||||
|
||||
/* See "FIPS 186-4, D.2.5 Curve P-521". */
|
||||
|
||||
_gcry_mpih_rshift (s, wp + wsize - 1, wsize, 521 % BITS_PER_MPI_LIMB);
|
||||
s[wsize - 1] &= (1 << (521 % BITS_PER_MPI_LIMB)) - 1;
|
||||
wp[wsize - 1] &= (1 << (521 % BITS_PER_MPI_LIMB)) - 1;
|
||||
_gcry_mpih_add_n (wp, wp, s, wsize);
|
||||
|
||||
/* "mod p" */
|
||||
cy = _gcry_mpih_sub_n (wp, wp, ctx->p->d, wsize);
|
||||
_gcry_mpih_add_n (s, wp, ctx->p->d, wsize);
|
||||
mpih_set_cond (wp, s, wsize, mpih_limb_is_not_zero (cy));
|
||||
|
||||
w->nlimbs = wsize;
|
||||
MPN_NORMALIZE (wp, w->nlimbs);
|
||||
}
|
||||
|
||||
#endif /* !ASM_DISABLED */
|
||||
+1765
-316
File diff suppressed because it is too large.
Load diff
@@ -1,29 +0,0 @@
|
||||
# Manifest - checksums
|
||||
# Copyright 2003 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
mpih-add1.c iQCVAwUAP+Lj2DEAnp832S/7AQKn/AQAwQLWggl6zNQ5EZ+lE+jKV8W3FsogW3/6tp9T5rrSR5JnlWyoHQ9/Pu4knOcLjS6nIfVOiAEifu3nuIysQr9jDSSSJA2LylSUBSXKLKDamPsOCwXOLxiZODslJT3CCGAUtLvXJrWDbTZQrkEuwnLnjQFDzuA7iY9JLrG9kAoXD6Q==WoWm
|
||||
mpih-mul1.c iQCVAwUAP+LkCTEAnp832S/7AQKFVQP+MhBNjcY73JtnsHZfnaVZq3TiKwN151cWV51nDc1RnTaMhSIFeuNlj3vNML2W0Gn8n+GnyiWE2XXdQEaik6BL02eekUn9aq7I/rdpnTHuOjQPK1uwjuNl8RuJ9YrERBAxq4oB71f+iwMab8dsMSUlVC+NdeAocRqLLgnR/efkdLc==2Tkb
|
||||
mpih-mul2.c iQCVAwUAP+LkMjEAnp832S/7AQLPeAQAqmRzxFe/mDqTdZr/pTXT8RVyB1vKB0Ei2THV05BxmI4OPv39uysfFpLMt/INsX7AGqdOlj4jOZ/qNaFXR1ceMrlSXvo8u/epk6rCXFp82kM7Qs983LjoP//PrMCkYkXwblaVrgUGiBUCbuPMliWTK6qKkxxXtEfqZ7nVbEWdBx8==Kwhl
|
||||
mpih-mul3.c iQCVAwUAP+LkVDEAnp832S/7AQL91gP/Qd5iZWxRiN5DdEIVHAedoNvl23NPrT2UUdXvnSK49DpplTxkLiMBj0WqCayG/YIET2NpMRCeLvAZNcSt6lOm0bSZDYo1Hv/N+UoqD3V1McjY16REBv/nnPaMWMZcx7rl5yKTVZiX2PgV6oQOL7Yfrt5ZIOlrHBRs9S2/zcCaVz0==9BQe
|
||||
mpih-lshift.c iQCVAwUAP+LlATEAnp832S/7AQIACAQAhMrpx0SRXE/LN1NkjMO9n74nMrvmzYJyru0gw2O4BYrUPvD/LWGju2FZaggKV0IBjmi0cDoCrNeK9EGjKOO1lfgODbX2IZ1LUhr9jDuMj0QRqj6T9YkAFYTNUk4GfpwIf7T6Ybo7c78Jx93PidCJt7d39eMMEalooC7LZ4IU3NM==nZ4k
|
||||
mpih-rshift.c iQCVAwUAP+LlIjEAnp832S/7AQKiuAP/eYC2ZScd+taBx/kNzRvGjA0eAXvORMkMLV6Ot+OXVzVUi04eoP2yXdxSNFKwUj12p8GWXkdoMG3aOGBKg2a7bY5Q5RUho3hUWb9UsVYVUfXLf7IOTt/3a6MLh2CmV5dFPWJmSlbCyQRcn6n/fLDeJ3A2bWTS/BhqGfpOXUIU1ws==jCf8
|
||||
mpih-sub1.c iQCVAwUAP+LlZzEAnp832S/7AQIEPgP/dLHTDRbPrYJhsLp9SjGstU1M8/IC5XytcDtO3NQeu4mx6vaXjpujtsTvKIbX4QL5IahNntVVKv1xFLEm2yFg7L2ns0uD/mfwGgOhCG1j2o/SaTAWP5KxP7ae5UDcZl2w6NWvEuMj9t32zmziAZjP8W73A37FUspeRDYiL9sQzkI==QQzk
|
||||
udiv-w-sdiv.c iQCVAwUAP+Lk0TEAnp832S/7AQICXAQAsxe1SQD4+xZaZTqBC0V9Cyuo0mrdccnRFzthOtm0ARwKFXU2cuLW/ZBOkmeWOVmOFhBp22/I8dEGYnMA3gcfmOMCpNu9i9zk/XHfptdunA1MnOe3GsoWgfHL0rhpAyPhp/X043ICB41NElnnuxADuQQlD4Z1fca5ygYxMr2crJg==EI/6
|
||||
mpi-asm-defs.h iQCVAwUAP+LkgDEAnp832S/7AQK0FgQAxJZ7xvXhoZa33GWe23LRb3asrno/loZSyAIXrntqtVH8M3pEsCY0OyW4ry4hX2RnxpuhRCM/PdRNLG3xXyMSVIhkHU8WVRLqzF2LLjEkyU3cAmHnnTQ9aO/XpUWtJGTZ8q2bv7ZsAEi4aPl0p6KhPXcPgM9vQ2XcyOPn3Dl0d6Q==xpjI
|
||||
$names$ iQCVAwUAP+LmNDEAnp832S/7AQJa+gP+KQNJpbNOgc+s2UX+Ya2gDaOFcAROImIllhg3ej8EaBF8xxdHmWT1zaKwTwi3moEEleykMR104YAGWyQeMbFYiuPPBW+ohrT6KxRBVJpIA9auOOqqJMyglZyoR3Hv7gduVYUW1h/DebnqiKXKEfzQDFqYuT0ayuteoOR4B5NICbE==nLSh
|
||||
@@ -1,4 +1,3 @@
|
||||
Manifest
|
||||
mpih-add1.c
|
||||
mpih-mul1.c
|
||||
mpih-mul2.c
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
/* This file defines some basic constants for the MPI machinery. We
|
||||
* need to define the types on a per-CPU basis, so it is done with
|
||||
* this file here. */
|
||||
/* This file defines some basic constants for the MPI machinery.
|
||||
* AMD64 compiled for the x32 ABI is special and thus we can't use the
|
||||
* standard values for this ABI. */
|
||||
#if __GNUC__ >= 3 && defined(__x86_64__) && defined(__ILP32__)
|
||||
#define BYTES_PER_MPI_LIMB 8
|
||||
#else
|
||||
#define BYTES_PER_MPI_LIMB (SIZEOF_UNSIGNED_LONG)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/* mpihelp-add_1.c - MPI helper functions
|
||||
* Copyright (C) 1994, 1996, 1997, 1998,
|
||||
* Copyright (C) 1994, 1996, 1997, 1998,
|
||||
* 2000, 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of Libgcrypt.
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -48,7 +48,7 @@ _gcry_mpih_add_n (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
|
||||
res_ptr -= j;
|
||||
|
||||
cy = 0;
|
||||
do
|
||||
do
|
||||
{
|
||||
y = s2_ptr[j];
|
||||
x = s1_ptr[j];
|
||||
@@ -57,7 +57,7 @@ _gcry_mpih_add_n (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
|
||||
y += x; /* add other addend */
|
||||
cy += y < x; /* get out carry from that add, combine */
|
||||
res_ptr[j] = y;
|
||||
}
|
||||
}
|
||||
while ( ++j );
|
||||
|
||||
return cy;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -54,7 +54,7 @@ _gcry_mpih_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
|
||||
low_limb = up[i];
|
||||
retval = low_limb >> sh_2;
|
||||
high_limb = low_limb;
|
||||
while ( --i >= 0 )
|
||||
while ( --i >= 0 )
|
||||
{
|
||||
low_limb = up[i];
|
||||
wp[i] = (high_limb << sh_1) | (low_limb >> sh_2);
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -48,13 +48,13 @@ _gcry_mpih_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
|
||||
res_ptr -= j;
|
||||
|
||||
cy_limb = 0;
|
||||
do
|
||||
do
|
||||
{
|
||||
umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
|
||||
prod_low += cy_limb;
|
||||
cy_limb = (prod_low < cy_limb?1:0) + prod_high;
|
||||
res_ptr[j] = prod_low;
|
||||
}
|
||||
}
|
||||
while( ++j );
|
||||
|
||||
return cy_limb;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -48,7 +48,7 @@ _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
|
||||
s1_ptr -= j;
|
||||
|
||||
cy_limb = 0;
|
||||
do
|
||||
do
|
||||
{
|
||||
umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
|
||||
|
||||
@@ -59,9 +59,9 @@ _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
|
||||
prod_low = x + prod_low;
|
||||
cy_limb += prod_low < x?1:0;
|
||||
res_ptr[j] = prod_low;
|
||||
}
|
||||
}
|
||||
while ( ++j );
|
||||
|
||||
|
||||
return cy_limb;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -48,7 +48,7 @@ _gcry_mpih_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
|
||||
s1_ptr -= j;
|
||||
|
||||
cy_limb = 0;
|
||||
do
|
||||
do
|
||||
{
|
||||
umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb);
|
||||
|
||||
@@ -59,7 +59,7 @@ _gcry_mpih_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
|
||||
prod_low = x - prod_low;
|
||||
cy_limb += prod_low > x?1:0;
|
||||
res_ptr[j] = prod_low;
|
||||
}
|
||||
}
|
||||
while( ++j );
|
||||
|
||||
return cy_limb;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -48,7 +48,7 @@ _gcry_mpih_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
|
||||
res_ptr -= j;
|
||||
|
||||
cy = 0;
|
||||
do
|
||||
do
|
||||
{
|
||||
y = s2_ptr[j];
|
||||
x = s1_ptr[j];
|
||||
@@ -57,7 +57,7 @@ _gcry_mpih_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
|
||||
y = x - y; /* main subtract */
|
||||
cy += y > x; /* get out carry from the subtract, combine */
|
||||
res_ptr[j] = y;
|
||||
}
|
||||
}
|
||||
while( ++j );
|
||||
|
||||
return cy;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
# Manifest - checksums
|
||||
# Copyright 2003 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
mpih-add1.S
|
||||
mpih-mul1.S
|
||||
mpih-mul2.S
|
||||
mpih-mul3.S
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
mpih-sub1.S
|
||||
syntax.h
|
||||
$names$ iQCVAwUAP+LmOTEAnp832S/7AQJZmgQA1+GIl7rXiEY00y5xD2kG5Lm2QD6c9aBME8hTl812OEcj0ul/QSpdv8E2NEKooifr4SiLVhEVfLNaLqAgN3cIsttn3rRX3/pMC5JwSKHDJPsUbpN9tzb5dr2YC9GG9m8xngAQrN11IQPnGfvFLJK+oDnEMIAeHDpOnX9NeQPDAQA==bnOy
|
||||
@@ -1,4 +1,3 @@
|
||||
Manifest
|
||||
mpih-add1.S
|
||||
mpih-mul1.S
|
||||
mpih-mul2.S
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -44,14 +44,22 @@
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_add_n)
|
||||
C_SYMBOL_NAME(_gcry_mpih_add_n:)
|
||||
CFI_STARTPROC()
|
||||
pushl %edi
|
||||
CFI_PUSH(%edi)
|
||||
pushl %esi
|
||||
CFI_PUSH(%esi)
|
||||
|
||||
movl 12(%esp),%edi /* res_ptr */
|
||||
movl 16(%esp),%esi /* s1_ptr */
|
||||
movl 20(%esp),%edx /* s2_ptr */
|
||||
movl 24(%esp),%ecx /* size */
|
||||
|
||||
#if defined __CET__ && (__CET__ & 1) != 0
|
||||
pushl %ebx
|
||||
CFI_PUSH(%ebx)
|
||||
#endif
|
||||
|
||||
movl %ecx,%eax
|
||||
shrl $3,%ecx /* compute count for unrolled loop */
|
||||
negl %eax
|
||||
@@ -63,41 +71,70 @@ C_SYMBOL_NAME(_gcry_mpih_add_n:)
|
||||
subl %eax,%esi /* ... by a constant when we ... */
|
||||
subl %eax,%edx /* ... enter the loop */
|
||||
shrl $2,%eax /* restore previous value */
|
||||
#if defined __CET__ && (__CET__ & 1) != 0
|
||||
leal -4(,%eax,4),%ebx /* Count for 4-byte endbr32 */
|
||||
#endif
|
||||
#ifdef PIC
|
||||
/* Calculate start address in loop for PIC. Due to limitations in some
|
||||
assemblers, Loop-L0-3 cannot be put into the leal */
|
||||
call L0
|
||||
CFI_ADJUST_CFA_OFFSET(4)
|
||||
L0: leal (%eax,%eax,8),%eax
|
||||
addl (%esp),%eax
|
||||
addl $(Loop-L0-3),%eax
|
||||
addl $4,%esp
|
||||
CFI_ADJUST_CFA_OFFSET(-4)
|
||||
#else
|
||||
/* Calculate start address in loop for non-PIC. */
|
||||
leal (Loop - 3)(%eax,%eax,8),%eax
|
||||
#endif
|
||||
#if defined __CET__ && (__CET__ & 1) != 0
|
||||
addl %ebx,%eax /* Adjust for endbr32 */
|
||||
#endif
|
||||
jmp *%eax /* jump into loop */
|
||||
ALIGN (3)
|
||||
Loop: movl (%esi),%eax
|
||||
adcl (%edx),%eax
|
||||
movl %eax,(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 4(%esi),%eax
|
||||
adcl 4(%edx),%eax
|
||||
movl %eax,4(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 8(%esi),%eax
|
||||
adcl 8(%edx),%eax
|
||||
movl %eax,8(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 12(%esi),%eax
|
||||
adcl 12(%edx),%eax
|
||||
movl %eax,12(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 16(%esi),%eax
|
||||
adcl 16(%edx),%eax
|
||||
movl %eax,16(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 20(%esi),%eax
|
||||
adcl 20(%edx),%eax
|
||||
movl %eax,20(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 24(%esi),%eax
|
||||
adcl 24(%edx),%eax
|
||||
movl %eax,24(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 28(%esi),%eax
|
||||
adcl 28(%edx),%eax
|
||||
movl %eax,28(%edi)
|
||||
@@ -110,7 +147,15 @@ Loop: movl (%esi),%eax
|
||||
sbbl %eax,%eax
|
||||
negl %eax
|
||||
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
#if defined __CET__ && (__CET__ & 1) != 0
|
||||
popl %ebx
|
||||
CFI_POP(%ebx)
|
||||
#endif
|
||||
|
||||
popl %esi
|
||||
CFI_POP(%esi)
|
||||
popl %edi
|
||||
CFI_POP(%edi)
|
||||
ret_spec_stop
|
||||
CFI_ENDPROC()
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -42,9 +42,13 @@
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_lshift)
|
||||
C_SYMBOL_NAME(_gcry_mpih_lshift:)
|
||||
CFI_STARTPROC()
|
||||
pushl %edi
|
||||
CFI_PUSH(%edi)
|
||||
pushl %esi
|
||||
CFI_PUSH(%esi)
|
||||
pushl %ebx
|
||||
CFI_PUSH(%ebx)
|
||||
|
||||
movl 16(%esp),%edi /* res_ptr */
|
||||
movl 20(%esp),%esi /* s_ptr */
|
||||
@@ -82,13 +86,17 @@ L1: movl (%esi,%edx,4),%eax
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
ret_spec_stop
|
||||
|
||||
Lend: shll %cl,%ebx /* compute least significant limb */
|
||||
movl %ebx,(%edi) /* store it */
|
||||
|
||||
popl %ebx
|
||||
CFI_POP(%ebx)
|
||||
popl %esi
|
||||
CFI_POP(%esi)
|
||||
popl %edi
|
||||
ret
|
||||
CFI_POP(%edi)
|
||||
ret_spec_stop
|
||||
CFI_ENDPROC()
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -49,10 +49,15 @@
|
||||
GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1)
|
||||
C_SYMBOL_NAME(_gcry_mpih_mul_1:)
|
||||
|
||||
CFI_STARTPROC()
|
||||
INSN1(push,l ,R(edi))
|
||||
CFI_PUSH(%edi)
|
||||
INSN1(push,l ,R(esi))
|
||||
CFI_PUSH(%esi)
|
||||
INSN1(push,l ,R(ebx))
|
||||
CFI_PUSH(%ebx)
|
||||
INSN1(push,l ,R(ebp))
|
||||
CFI_PUSH(%ebp)
|
||||
|
||||
INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
|
||||
INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
|
||||
@@ -77,8 +82,13 @@ Loop:
|
||||
INSN2(mov,l ,R(eax),R(ebx))
|
||||
|
||||
INSN1(pop,l ,R(ebp))
|
||||
CFI_POP(%ebp)
|
||||
INSN1(pop,l ,R(ebx))
|
||||
CFI_POP(%ebx)
|
||||
INSN1(pop,l ,R(esi))
|
||||
CFI_POP(%esi)
|
||||
INSN1(pop,l ,R(edi))
|
||||
ret
|
||||
CFI_POP(%edi)
|
||||
ret_spec_stop
|
||||
CFI_ENDPROC()
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -50,10 +50,15 @@
|
||||
GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1)
|
||||
C_SYMBOL_NAME(_gcry_mpih_addmul_1:)
|
||||
|
||||
CFI_STARTPROC()
|
||||
INSN1(push,l ,R(edi))
|
||||
CFI_PUSH(%edi)
|
||||
INSN1(push,l ,R(esi))
|
||||
CFI_PUSH(%esi)
|
||||
INSN1(push,l ,R(ebx))
|
||||
CFI_PUSH(%ebx)
|
||||
INSN1(push,l ,R(ebp))
|
||||
CFI_PUSH(%ebp)
|
||||
|
||||
INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
|
||||
INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
|
||||
@@ -79,8 +84,13 @@ Loop:
|
||||
INSN2(mov,l ,R(eax),R(ebx))
|
||||
|
||||
INSN1(pop,l ,R(ebp))
|
||||
CFI_POP(%ebp)
|
||||
INSN1(pop,l ,R(ebx))
|
||||
CFI_POP(%ebx)
|
||||
INSN1(pop,l ,R(esi))
|
||||
CFI_POP(%esi)
|
||||
INSN1(pop,l ,R(edi))
|
||||
ret
|
||||
CFI_POP(%edi)
|
||||
ret_spec_stop
|
||||
CFI_ENDPROC()
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -50,10 +50,15 @@
|
||||
GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1)
|
||||
C_SYMBOL_NAME(_gcry_mpih_submul_1:)
|
||||
|
||||
CFI_STARTPROC()
|
||||
INSN1(push,l ,R(edi))
|
||||
CFI_PUSH(%edi)
|
||||
INSN1(push,l ,R(esi))
|
||||
CFI_PUSH(%esi)
|
||||
INSN1(push,l ,R(ebx))
|
||||
CFI_PUSH(%ebx)
|
||||
INSN1(push,l ,R(ebp))
|
||||
CFI_PUSH(%ebp)
|
||||
|
||||
INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
|
||||
INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
|
||||
@@ -79,8 +84,13 @@ Loop:
|
||||
INSN2(mov,l ,R(eax),R(ebx))
|
||||
|
||||
INSN1(pop,l ,R(ebp))
|
||||
CFI_POP(%ebp)
|
||||
INSN1(pop,l ,R(ebx))
|
||||
CFI_POP(%ebx)
|
||||
INSN1(pop,l ,R(esi))
|
||||
CFI_POP(%esi)
|
||||
INSN1(pop,l ,R(edi))
|
||||
ret
|
||||
CFI_POP(%edi)
|
||||
ret_spec_stop
|
||||
CFI_ENDPROC()
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -43,9 +43,13 @@
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_rshift)
|
||||
C_SYMBOL_NAME(_gcry_mpih_rshift:)
|
||||
CFI_STARTPROC()
|
||||
pushl %edi
|
||||
CFI_PUSH(%edi)
|
||||
pushl %esi
|
||||
CFI_PUSH(%esi)
|
||||
pushl %ebx
|
||||
CFI_PUSH(%ebx)
|
||||
|
||||
movl 16(%esp),%edi /* wp */
|
||||
movl 20(%esp),%esi /* up */
|
||||
@@ -67,7 +71,7 @@ C_SYMBOL_NAME(_gcry_mpih_rshift:)
|
||||
movl %ebx,%eax
|
||||
|
||||
ALIGN (3)
|
||||
Loop2: movl (%esi,%edx,4),%ebx /* load next higher limb */
|
||||
Loop2: movl (%esi,%edx,4),%ebx /* load next higher limb */
|
||||
shrdl %cl,%ebx,%eax /* compute result limb */
|
||||
movl %eax,(%edi,%edx,4) /* store it */
|
||||
incl %edx
|
||||
@@ -85,13 +89,17 @@ L2: movl (%esi,%edx,4),%eax
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
ret_spec_stop
|
||||
|
||||
Lend2: shrl %cl,%ebx /* compute most significant limb */
|
||||
movl %ebx,(%edi) /* store it */
|
||||
|
||||
popl %ebx
|
||||
CFI_POP(%ebx)
|
||||
popl %esi
|
||||
CFI_POP(%esi)
|
||||
popl %edi
|
||||
ret
|
||||
CFI_POP(%edi)
|
||||
ret_spec_stop
|
||||
CFI_ENDPROC()
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -45,14 +45,22 @@
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_sub_n)
|
||||
C_SYMBOL_NAME(_gcry_mpih_sub_n:)
|
||||
CFI_STARTPROC()
|
||||
pushl %edi
|
||||
CFI_PUSH(%edi)
|
||||
pushl %esi
|
||||
CFI_PUSH(%esi)
|
||||
|
||||
movl 12(%esp),%edi /* res_ptr */
|
||||
movl 16(%esp),%esi /* s1_ptr */
|
||||
movl 20(%esp),%edx /* s2_ptr */
|
||||
movl 24(%esp),%ecx /* size */
|
||||
|
||||
#if defined __CET__ && (__CET__ & 1) != 0
|
||||
pushl %ebx
|
||||
CFI_PUSH(%ebx)
|
||||
#endif
|
||||
|
||||
movl %ecx,%eax
|
||||
shrl $3,%ecx /* compute count for unrolled loop */
|
||||
negl %eax
|
||||
@@ -64,41 +72,70 @@ C_SYMBOL_NAME(_gcry_mpih_sub_n:)
|
||||
subl %eax,%esi /* ... by a constant when we ... */
|
||||
subl %eax,%edx /* ... enter the loop */
|
||||
shrl $2,%eax /* restore previous value */
|
||||
#if defined __CET__ && (__CET__ & 1) != 0
|
||||
leal -4(,%eax,4),%ebx /* Count for 4-byte endbr32 */
|
||||
#endif
|
||||
#ifdef PIC
|
||||
/* Calculate start address in loop for PIC. Due to limitations in some
|
||||
assemblers, Loop-L0-3 cannot be put into the leal */
|
||||
call L0
|
||||
CFI_ADJUST_CFA_OFFSET(4)
|
||||
L0: leal (%eax,%eax,8),%eax
|
||||
addl (%esp),%eax
|
||||
addl $(Loop-L0-3),%eax
|
||||
addl $4,%esp
|
||||
CFI_ADJUST_CFA_OFFSET(-4)
|
||||
#else
|
||||
/* Calculate start address in loop for non-PIC. */
|
||||
leal (Loop - 3)(%eax,%eax,8),%eax
|
||||
#endif
|
||||
#if defined __CET__ && (__CET__ & 1) != 0
|
||||
addl %ebx,%eax /* Adjust for endbr32 */
|
||||
#endif
|
||||
jmp *%eax /* jump into loop */
|
||||
ALIGN (3)
|
||||
Loop: movl (%esi),%eax
|
||||
sbbl (%edx),%eax
|
||||
movl %eax,(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 4(%esi),%eax
|
||||
sbbl 4(%edx),%eax
|
||||
movl %eax,4(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 8(%esi),%eax
|
||||
sbbl 8(%edx),%eax
|
||||
movl %eax,8(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 12(%esi),%eax
|
||||
sbbl 12(%edx),%eax
|
||||
movl %eax,12(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 16(%esi),%eax
|
||||
sbbl 16(%edx),%eax
|
||||
movl %eax,16(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 20(%esi),%eax
|
||||
sbbl 20(%edx),%eax
|
||||
movl %eax,20(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 24(%esi),%eax
|
||||
sbbl 24(%edx),%eax
|
||||
movl %eax,24(%edi)
|
||||
#ifdef _CET_ENDBR
|
||||
_CET_ENDBR
|
||||
#endif
|
||||
movl 28(%esi),%eax
|
||||
sbbl 28(%edx),%eax
|
||||
movl %eax,28(%edi)
|
||||
@@ -111,7 +148,15 @@ Loop: movl (%esi),%eax
|
||||
sbbl %eax,%eax
|
||||
negl %eax
|
||||
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
#if defined __CET__ && (__CET__ & 1) != 0
|
||||
popl %ebx
|
||||
CFI_POP(%ebx)
|
||||
#endif
|
||||
|
||||
popl %esi
|
||||
CFI_POP(%esi)
|
||||
popl %edi
|
||||
CFI_POP(%edi)
|
||||
ret_spec_stop
|
||||
CFI_ENDPROC()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* syntax.h -- Definitions for x86 syntax variations.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1995, 1998,
|
||||
* Copyright (C) 1992, 1994, 1995, 1998,
|
||||
* 2001, 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of Libgcrypt.
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
@@ -26,6 +26,12 @@
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __i386__
|
||||
#include "asm-common-i386.h"
|
||||
#endif
|
||||
|
||||
#undef ALIGN
|
||||
|
||||
#if defined (BSD_SYNTAX) || defined (ELF_SYNTAX)
|
||||
@@ -66,3 +72,7 @@
|
||||
#undef ALIGN
|
||||
#define ALIGN(log) .align log,0x90
|
||||
#endif
|
||||
|
||||
/* 'ret' instruction replacement for straight-line speculation mitigation */
|
||||
#define ret_spec_stop \
|
||||
ret; int3;
|
||||
@@ -1,27 +0,0 @@
|
||||
# Manifest - checksums
|
||||
# Copyright 2003 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
mpih-add1.S
|
||||
mpih-mul1.S
|
||||
mpih-mul2.S
|
||||
mpih-mul3.S
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
mpih-sub1.S
|
||||
$names$ iQCVAwUAP+LmQDEAnp832S/7AQKCmgQAhG+E7X0KB4qdVf3sMb6Qr+Iv5Jlehzoub/5vxTRgePKzRuOHidCnTzSSoyzA++UcHrOjHQQDMsXnO6PqpS1d/TKkxjnGN7rE8mvMYlFAT8RsawTozSfh14mCzI0HTDbaKL9Z8pcMJtadB3XqAuqWJNO8kyECJFwurt3DRWXSWS8==Rug5
|
||||
@@ -1,26 +0,0 @@
|
||||
This directory contains mpn functions optimized for Intel Pentium
|
||||
processors.
|
||||
|
||||
RELEVANT OPTIMIZATION ISSUES
|
||||
|
||||
1. Pentium doesn't allocate cache lines on writes, unlike most other modern
|
||||
processors. Since the functions in the mpn class do array writes, we have to
|
||||
handle allocating the destination cache lines by reading a word from it in the
|
||||
loops, to achieve the best performance.
|
||||
|
||||
2. Pairing of memory operations requires that the two issued operations refer
|
||||
to different cache banks. The simplest way to insure this is to read/write
|
||||
two words from the same object. If we make operations on different objects,
|
||||
they might or might not be to the same cache bank.
|
||||
|
||||
STATUS
|
||||
|
||||
1. mpn_lshift and mpn_rshift run at about 6 cycles/limb, but the Pentium
|
||||
documentation indicates that they should take only 43/8 = 5.375 cycles/limb,
|
||||
or 5 cycles/limb asymptotically.
|
||||
|
||||
2. mpn_add_n and mpn_sub_n run at asymptotically 2 cycles/limb. Due to loop
|
||||
overhead and other delays (cache refill?), they run at or near 2.5 cycles/limb.
|
||||
|
||||
3. mpn_mul_1, mpn_addmul_1, mpn_submul_1 all run 1 cycle faster than they
|
||||
should...
|
||||
@@ -1,135 +0,0 @@
|
||||
/* i80586 add_n -- Add two limb vectors of the same length > 0 and store
|
||||
* sum in a third limb vector.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1995, 1996, 1998,
|
||||
* 2001, 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_add_n( mpi_ptr_t res_ptr, (sp + 4)
|
||||
* mpi_ptr_t s1_ptr, (sp + 8)
|
||||
* mpi_ptr_t s2_ptr, (sp + 12)
|
||||
* mpi_size_t size) (sp + 16)
|
||||
*/
|
||||
|
||||
.text
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_add_n)
|
||||
C_SYMBOL_NAME(_gcry_mpih_add_n:)
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
pushl %ebp
|
||||
|
||||
movl 20(%esp),%edi /* res_ptr */
|
||||
movl 24(%esp),%esi /* s1_ptr */
|
||||
movl 28(%esp),%ebp /* s2_ptr */
|
||||
movl 32(%esp),%ecx /* size */
|
||||
|
||||
movl (%ebp),%ebx
|
||||
|
||||
decl %ecx
|
||||
movl %ecx,%edx
|
||||
shrl $3,%ecx
|
||||
andl $7,%edx
|
||||
testl %ecx,%ecx /* zero carry flag */
|
||||
jz Lend
|
||||
pushl %edx
|
||||
|
||||
ALIGN (3)
|
||||
Loop: movl 28(%edi),%eax /* fetch destination cache line */
|
||||
leal 32(%edi),%edi
|
||||
|
||||
L1: movl (%esi),%eax
|
||||
movl 4(%esi),%edx
|
||||
adcl %ebx,%eax
|
||||
movl 4(%ebp),%ebx
|
||||
adcl %ebx,%edx
|
||||
movl 8(%ebp),%ebx
|
||||
movl %eax,-32(%edi)
|
||||
movl %edx,-28(%edi)
|
||||
|
||||
L2: movl 8(%esi),%eax
|
||||
movl 12(%esi),%edx
|
||||
adcl %ebx,%eax
|
||||
movl 12(%ebp),%ebx
|
||||
adcl %ebx,%edx
|
||||
movl 16(%ebp),%ebx
|
||||
movl %eax,-24(%edi)
|
||||
movl %edx,-20(%edi)
|
||||
|
||||
L3: movl 16(%esi),%eax
|
||||
movl 20(%esi),%edx
|
||||
adcl %ebx,%eax
|
||||
movl 20(%ebp),%ebx
|
||||
adcl %ebx,%edx
|
||||
movl 24(%ebp),%ebx
|
||||
movl %eax,-16(%edi)
|
||||
movl %edx,-12(%edi)
|
||||
|
||||
L4: movl 24(%esi),%eax
|
||||
movl 28(%esi),%edx
|
||||
adcl %ebx,%eax
|
||||
movl 28(%ebp),%ebx
|
||||
adcl %ebx,%edx
|
||||
movl 32(%ebp),%ebx
|
||||
movl %eax,-8(%edi)
|
||||
movl %edx,-4(%edi)
|
||||
|
||||
leal 32(%esi),%esi
|
||||
leal 32(%ebp),%ebp
|
||||
decl %ecx
|
||||
jnz Loop
|
||||
|
||||
popl %edx
|
||||
Lend:
|
||||
decl %edx /* test %edx w/o clobbering carry */
|
||||
js Lend2
|
||||
incl %edx
|
||||
Loop2:
|
||||
leal 4(%edi),%edi
|
||||
movl (%esi),%eax
|
||||
adcl %ebx,%eax
|
||||
movl 4(%ebp),%ebx
|
||||
movl %eax,-4(%edi)
|
||||
leal 4(%esi),%esi
|
||||
leal 4(%ebp),%ebp
|
||||
decl %edx
|
||||
jnz Loop2
|
||||
Lend2:
|
||||
movl (%esi),%eax
|
||||
adcl %ebx,%eax
|
||||
movl %eax,(%edi)
|
||||
|
||||
sbbl %eax,%eax
|
||||
negl %eax
|
||||
|
||||
popl %ebp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
/* i80586 lshift
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1998,
|
||||
* 2001, 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_lshift( mpi_ptr_t wp, (sp + 4)
|
||||
* mpi_ptr_t up, (sp + 8)
|
||||
* mpi_size_t usize, (sp + 12)
|
||||
* unsigned cnt) (sp + 16)
|
||||
*/
|
||||
|
||||
.text
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_lshift)
|
||||
C_SYMBOL_NAME(_gcry_mpih_lshift:)
|
||||
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
pushl %ebp
|
||||
|
||||
movl 20(%esp),%edi /* res_ptr */
|
||||
movl 24(%esp),%esi /* s_ptr */
|
||||
movl 28(%esp),%ebp /* size */
|
||||
movl 32(%esp),%ecx /* cnt */
|
||||
|
||||
/* We can use faster code for shift-by-1 under certain conditions. */
|
||||
cmp $1,%ecx
|
||||
jne Lnormal
|
||||
leal 4(%esi),%eax
|
||||
cmpl %edi,%eax
|
||||
jnc Lspecial /* jump if s_ptr + 1 >= res_ptr */
|
||||
leal (%esi,%ebp,4),%eax
|
||||
cmpl %eax,%edi
|
||||
jnc Lspecial /* jump if res_ptr >= s_ptr + size */
|
||||
|
||||
Lnormal:
|
||||
leal -4(%edi,%ebp,4),%edi
|
||||
leal -4(%esi,%ebp,4),%esi
|
||||
|
||||
movl (%esi),%edx
|
||||
subl $4,%esi
|
||||
xorl %eax,%eax
|
||||
shldl %cl,%edx,%eax /* compute carry limb */
|
||||
pushl %eax /* push carry limb onto stack */
|
||||
|
||||
decl %ebp
|
||||
pushl %ebp
|
||||
shrl $3,%ebp
|
||||
jz Lend
|
||||
|
||||
movl (%edi),%eax /* fetch destination cache line */
|
||||
|
||||
ALIGN (2)
|
||||
Loop: movl -28(%edi),%eax /* fetch destination cache line */
|
||||
movl %edx,%ebx
|
||||
|
||||
movl (%esi),%eax
|
||||
movl -4(%esi),%edx
|
||||
shldl %cl,%eax,%ebx
|
||||
shldl %cl,%edx,%eax
|
||||
movl %ebx,(%edi)
|
||||
movl %eax,-4(%edi)
|
||||
|
||||
movl -8(%esi),%ebx
|
||||
movl -12(%esi),%eax
|
||||
shldl %cl,%ebx,%edx
|
||||
shldl %cl,%eax,%ebx
|
||||
movl %edx,-8(%edi)
|
||||
movl %ebx,-12(%edi)
|
||||
|
||||
movl -16(%esi),%edx
|
||||
movl -20(%esi),%ebx
|
||||
shldl %cl,%edx,%eax
|
||||
shldl %cl,%ebx,%edx
|
||||
movl %eax,-16(%edi)
|
||||
movl %edx,-20(%edi)
|
||||
|
||||
movl -24(%esi),%eax
|
||||
movl -28(%esi),%edx
|
||||
shldl %cl,%eax,%ebx
|
||||
shldl %cl,%edx,%eax
|
||||
movl %ebx,-24(%edi)
|
||||
movl %eax,-28(%edi)
|
||||
|
||||
subl $32,%esi
|
||||
subl $32,%edi
|
||||
decl %ebp
|
||||
jnz Loop
|
||||
|
||||
Lend: popl %ebp
|
||||
andl $7,%ebp
|
||||
jz Lend2
|
||||
Loop2: movl (%esi),%eax
|
||||
shldl %cl,%eax,%edx
|
||||
movl %edx,(%edi)
|
||||
movl %eax,%edx
|
||||
subl $4,%esi
|
||||
subl $4,%edi
|
||||
decl %ebp
|
||||
jnz Loop2
|
||||
|
||||
Lend2: shll %cl,%edx /* compute least significant limb */
|
||||
movl %edx,(%edi) /* store it */
|
||||
|
||||
popl %eax /* pop carry limb */
|
||||
|
||||
popl %ebp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
/* We loop from least significant end of the arrays, which is only
|
||||
permissable if the source and destination don't overlap, since the
|
||||
function is documented to work for overlapping source and destination.
|
||||
*/
|
||||
|
||||
Lspecial:
|
||||
movl (%esi),%edx
|
||||
addl $4,%esi
|
||||
|
||||
decl %ebp
|
||||
pushl %ebp
|
||||
shrl $3,%ebp
|
||||
|
||||
addl %edx,%edx
|
||||
incl %ebp
|
||||
decl %ebp
|
||||
jz LLend
|
||||
|
||||
movl (%edi),%eax /* fetch destination cache line */
|
||||
|
||||
ALIGN (2)
|
||||
LLoop: movl 28(%edi),%eax /* fetch destination cache line */
|
||||
movl %edx,%ebx
|
||||
|
||||
movl (%esi),%eax
|
||||
movl 4(%esi),%edx
|
||||
adcl %eax,%eax
|
||||
movl %ebx,(%edi)
|
||||
adcl %edx,%edx
|
||||
movl %eax,4(%edi)
|
||||
|
||||
movl 8(%esi),%ebx
|
||||
movl 12(%esi),%eax
|
||||
adcl %ebx,%ebx
|
||||
movl %edx,8(%edi)
|
||||
adcl %eax,%eax
|
||||
movl %ebx,12(%edi)
|
||||
|
||||
movl 16(%esi),%edx
|
||||
movl 20(%esi),%ebx
|
||||
adcl %edx,%edx
|
||||
movl %eax,16(%edi)
|
||||
adcl %ebx,%ebx
|
||||
movl %edx,20(%edi)
|
||||
|
||||
movl 24(%esi),%eax
|
||||
movl 28(%esi),%edx
|
||||
adcl %eax,%eax
|
||||
movl %ebx,24(%edi)
|
||||
adcl %edx,%edx
|
||||
movl %eax,28(%edi)
|
||||
|
||||
leal 32(%esi),%esi /* use leal not to clobber carry */
|
||||
leal 32(%edi),%edi
|
||||
decl %ebp
|
||||
jnz LLoop
|
||||
|
||||
LLend: popl %ebp
|
||||
sbbl %eax,%eax /* save carry in %eax */
|
||||
andl $7,%ebp
|
||||
jz LLend2
|
||||
addl %eax,%eax /* restore carry from eax */
|
||||
LLoop2: movl %edx,%ebx
|
||||
movl (%esi),%edx
|
||||
adcl %edx,%edx
|
||||
movl %ebx,(%edi)
|
||||
|
||||
leal 4(%esi),%esi /* use leal not to clobber carry */
|
||||
leal 4(%edi),%edi
|
||||
decl %ebp
|
||||
jnz LLoop2
|
||||
|
||||
jmp LL1
|
||||
LLend2: addl %eax,%eax /* restore carry from eax */
|
||||
LL1: movl %edx,(%edi) /* store last limb */
|
||||
|
||||
sbbl %eax,%eax
|
||||
negl %eax
|
||||
|
||||
popl %ebp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
/* i80586 mul_1 -- Multiply a limb vector with a limb and store
|
||||
* the result in a second limb vector.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1996, 1998,
|
||||
* 2001, 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (sp + 4)
|
||||
* mpi_ptr_t s1_ptr, (sp + 8)
|
||||
* mpi_size_t s1_size, (sp + 12)
|
||||
* mpi_limb_t s2_limb) (sp + 16)
|
||||
*/
|
||||
|
||||
#define res_ptr edi
|
||||
#define s1_ptr esi
|
||||
#define size ecx
|
||||
#define s2_limb ebp
|
||||
|
||||
TEXT
|
||||
ALIGN (3)
|
||||
GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1)
|
||||
C_SYMBOL_NAME(_gcry_mpih_mul_1:)
|
||||
|
||||
INSN1(push,l ,R(edi))
|
||||
INSN1(push,l ,R(esi))
|
||||
INSN1(push,l ,R(ebx))
|
||||
INSN1(push,l ,R(ebp))
|
||||
|
||||
INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
|
||||
INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
|
||||
INSN2(mov,l ,R(size),MEM_DISP(esp,28))
|
||||
INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
|
||||
|
||||
INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
|
||||
INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
|
||||
INSN1(neg,l ,R(size))
|
||||
INSN2(xor,l ,R(ebx),R(ebx))
|
||||
ALIGN (3)
|
||||
|
||||
Loop: INSN2(adc,l ,R(ebx),$0)
|
||||
INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
|
||||
|
||||
INSN1(mul,l ,R(s2_limb))
|
||||
|
||||
INSN2(add,l ,R(ebx),R(eax))
|
||||
|
||||
INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(ebx))
|
||||
INSN1(inc,l ,R(size))
|
||||
|
||||
INSN2(mov,l ,R(ebx),R(edx))
|
||||
INSN1(jnz, ,Loop)
|
||||
|
||||
INSN2(adc,l ,R(ebx),$0)
|
||||
INSN2(mov,l ,R(eax),R(ebx))
|
||||
INSN1(pop,l ,R(ebp))
|
||||
INSN1(pop,l ,R(ebx))
|
||||
INSN1(pop,l ,R(esi))
|
||||
INSN1(pop,l ,R(edi))
|
||||
ret
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/* i80586 addmul_1 -- Multiply a limb vector with a limb and add
|
||||
* the result to a second limb vector.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1998,
|
||||
* 2001, 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (sp + 4)
|
||||
* mpi_ptr_t s1_ptr, (sp + 8)
|
||||
* mpi_size_t s1_size, (sp + 12)
|
||||
* mpi_limb_t s2_limb) (sp + 16)
|
||||
*/
|
||||
|
||||
#define res_ptr edi
|
||||
#define s1_ptr esi
|
||||
#define size ecx
|
||||
#define s2_limb ebp
|
||||
|
||||
TEXT
|
||||
ALIGN (3)
|
||||
GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1)
|
||||
C_SYMBOL_NAME(_gcry_mpih_addmul_1:)
|
||||
|
||||
INSN1(push,l ,R(edi))
|
||||
INSN1(push,l ,R(esi))
|
||||
INSN1(push,l ,R(ebx))
|
||||
INSN1(push,l ,R(ebp))
|
||||
|
||||
INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
|
||||
INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
|
||||
INSN2(mov,l ,R(size),MEM_DISP(esp,28))
|
||||
INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
|
||||
|
||||
INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
|
||||
INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
|
||||
INSN1(neg,l ,R(size))
|
||||
INSN2(xor,l ,R(ebx),R(ebx))
|
||||
ALIGN (3)
|
||||
|
||||
Loop: INSN2(adc,l ,R(ebx),$0)
|
||||
INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
|
||||
|
||||
INSN1(mul,l ,R(s2_limb))
|
||||
|
||||
INSN2(add,l ,R(eax),R(ebx))
|
||||
INSN2(mov,l ,R(ebx),MEM_INDEX(res_ptr,size,4))
|
||||
|
||||
INSN2(adc,l ,R(edx),$0)
|
||||
INSN2(add,l ,R(ebx),R(eax))
|
||||
|
||||
INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(ebx))
|
||||
INSN1(inc,l ,R(size))
|
||||
|
||||
INSN2(mov,l ,R(ebx),R(edx))
|
||||
INSN1(jnz, ,Loop)
|
||||
|
||||
INSN2(adc,l ,R(ebx),$0)
|
||||
INSN2(mov,l ,R(eax),R(ebx))
|
||||
INSN1(pop,l ,R(ebp))
|
||||
INSN1(pop,l ,R(ebx))
|
||||
INSN1(pop,l ,R(esi))
|
||||
INSN1(pop,l ,R(edi))
|
||||
ret
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/* i80586 submul_1 -- Multiply a limb vector with a limb and add
|
||||
* the result to a second limb vector.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1998,
|
||||
* 2001, 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (sp + 4)
|
||||
* mpi_ptr_t s1_ptr, (sp + 8)
|
||||
* mpi_size_t s1_size, (sp + 12)
|
||||
* mpi_limb_t s2_limb) (sp + 16)
|
||||
*/
|
||||
|
||||
#define res_ptr edi
|
||||
#define s1_ptr esi
|
||||
#define size ecx
|
||||
#define s2_limb ebp
|
||||
|
||||
TEXT
|
||||
ALIGN (3)
|
||||
GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1)
|
||||
C_SYMBOL_NAME(_gcry_mpih_submul_1:)
|
||||
|
||||
INSN1(push,l ,R(edi))
|
||||
INSN1(push,l ,R(esi))
|
||||
INSN1(push,l ,R(ebx))
|
||||
INSN1(push,l ,R(ebp))
|
||||
|
||||
INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
|
||||
INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
|
||||
INSN2(mov,l ,R(size),MEM_DISP(esp,28))
|
||||
INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
|
||||
|
||||
INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
|
||||
INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
|
||||
INSN1(neg,l ,R(size))
|
||||
INSN2(xor,l ,R(ebx),R(ebx))
|
||||
ALIGN (3)
|
||||
|
||||
Loop: INSN2(adc,l ,R(ebx),$0)
|
||||
INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
|
||||
|
||||
INSN1(mul,l ,R(s2_limb))
|
||||
|
||||
INSN2(add,l ,R(eax),R(ebx))
|
||||
INSN2(mov,l ,R(ebx),MEM_INDEX(res_ptr,size,4))
|
||||
|
||||
INSN2(adc,l ,R(edx),$0)
|
||||
INSN2(sub,l ,R(ebx),R(eax))
|
||||
|
||||
INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(ebx))
|
||||
INSN1(inc,l ,R(size))
|
||||
|
||||
INSN2(mov,l ,R(ebx),R(edx))
|
||||
INSN1(jnz, ,Loop)
|
||||
|
||||
INSN2(adc,l ,R(ebx),$0)
|
||||
INSN2(mov,l ,R(eax),R(ebx))
|
||||
INSN1(pop,l ,R(ebp))
|
||||
INSN1(pop,l ,R(ebx))
|
||||
INSN1(pop,l ,R(esi))
|
||||
INSN1(pop,l ,R(edi))
|
||||
ret
|
||||
|
||||
@@ -1,228 +0,0 @@
|
||||
/* i80586 rshift
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1998,
|
||||
* 2001, 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_rshift( mpi_ptr_t wp, (sp + 4)
|
||||
* mpi_ptr_t up, (sp + 8)
|
||||
* mpi_size_t usize, (sp + 12)
|
||||
* unsigned cnt) (sp + 16)
|
||||
*/
|
||||
|
||||
.text
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_rshift)
|
||||
C_SYMBOL_NAME(_gcry_mpih_rshift:)
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
pushl %ebp
|
||||
|
||||
movl 20(%esp),%edi /* res_ptr */
|
||||
movl 24(%esp),%esi /* s_ptr */
|
||||
movl 28(%esp),%ebp /* size */
|
||||
movl 32(%esp),%ecx /* cnt */
|
||||
|
||||
/* We can use faster code for shift-by-1 under certain conditions. */
|
||||
cmp $1,%ecx
|
||||
jne Rnormal
|
||||
leal 4(%edi),%eax
|
||||
cmpl %esi,%eax
|
||||
jnc Rspecial /* jump if res_ptr + 1 >= s_ptr */
|
||||
leal (%edi,%ebp,4),%eax
|
||||
cmpl %eax,%esi
|
||||
jnc Rspecial /* jump if s_ptr >= res_ptr + size */
|
||||
|
||||
Rnormal:
|
||||
movl (%esi),%edx
|
||||
addl $4,%esi
|
||||
xorl %eax,%eax
|
||||
shrdl %cl,%edx,%eax /* compute carry limb */
|
||||
pushl %eax /* push carry limb onto stack */
|
||||
|
||||
decl %ebp
|
||||
pushl %ebp
|
||||
shrl $3,%ebp
|
||||
jz Rend
|
||||
|
||||
movl (%edi),%eax /* fetch destination cache line */
|
||||
|
||||
ALIGN (2)
|
||||
Roop: movl 28(%edi),%eax /* fetch destination cache line */
|
||||
movl %edx,%ebx
|
||||
|
||||
movl (%esi),%eax
|
||||
movl 4(%esi),%edx
|
||||
shrdl %cl,%eax,%ebx
|
||||
shrdl %cl,%edx,%eax
|
||||
movl %ebx,(%edi)
|
||||
movl %eax,4(%edi)
|
||||
|
||||
movl 8(%esi),%ebx
|
||||
movl 12(%esi),%eax
|
||||
shrdl %cl,%ebx,%edx
|
||||
shrdl %cl,%eax,%ebx
|
||||
movl %edx,8(%edi)
|
||||
movl %ebx,12(%edi)
|
||||
|
||||
movl 16(%esi),%edx
|
||||
movl 20(%esi),%ebx
|
||||
shrdl %cl,%edx,%eax
|
||||
shrdl %cl,%ebx,%edx
|
||||
movl %eax,16(%edi)
|
||||
movl %edx,20(%edi)
|
||||
|
||||
movl 24(%esi),%eax
|
||||
movl 28(%esi),%edx
|
||||
shrdl %cl,%eax,%ebx
|
||||
shrdl %cl,%edx,%eax
|
||||
movl %ebx,24(%edi)
|
||||
movl %eax,28(%edi)
|
||||
|
||||
addl $32,%esi
|
||||
addl $32,%edi
|
||||
decl %ebp
|
||||
jnz Roop
|
||||
|
||||
Rend: popl %ebp
|
||||
andl $7,%ebp
|
||||
jz Rend2
|
||||
Roop2: movl (%esi),%eax
|
||||
shrdl %cl,%eax,%edx /* compute result limb */
|
||||
movl %edx,(%edi)
|
||||
movl %eax,%edx
|
||||
addl $4,%esi
|
||||
addl $4,%edi
|
||||
decl %ebp
|
||||
jnz Roop2
|
||||
|
||||
Rend2: shrl %cl,%edx /* compute most significant limb */
|
||||
movl %edx,(%edi) /* store it */
|
||||
|
||||
popl %eax /* pop carry limb */
|
||||
|
||||
popl %ebp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
/* We loop from least significant end of the arrays, which is only
|
||||
permissable if the source and destination don't overlap, since the
|
||||
function is documented to work for overlapping source and destination.
|
||||
*/
|
||||
|
||||
Rspecial:
|
||||
leal -4(%edi,%ebp,4),%edi
|
||||
leal -4(%esi,%ebp,4),%esi
|
||||
|
||||
movl (%esi),%edx
|
||||
subl $4,%esi
|
||||
|
||||
decl %ebp
|
||||
pushl %ebp
|
||||
shrl $3,%ebp
|
||||
|
||||
shrl $1,%edx
|
||||
incl %ebp
|
||||
decl %ebp
|
||||
jz RLend
|
||||
|
||||
movl (%edi),%eax /* fetch destination cache line */
|
||||
|
||||
ALIGN (2)
|
||||
RLoop: movl -28(%edi),%eax /* fetch destination cache line */
|
||||
movl %edx,%ebx
|
||||
|
||||
movl (%esi),%eax
|
||||
movl -4(%esi),%edx
|
||||
rcrl $1,%eax
|
||||
movl %ebx,(%edi)
|
||||
rcrl $1,%edx
|
||||
movl %eax,-4(%edi)
|
||||
|
||||
movl -8(%esi),%ebx
|
||||
movl -12(%esi),%eax
|
||||
rcrl $1,%ebx
|
||||
movl %edx,-8(%edi)
|
||||
rcrl $1,%eax
|
||||
movl %ebx,-12(%edi)
|
||||
|
||||
movl -16(%esi),%edx
|
||||
movl -20(%esi),%ebx
|
||||
rcrl $1,%edx
|
||||
movl %eax,-16(%edi)
|
||||
rcrl $1,%ebx
|
||||
movl %edx,-20(%edi)
|
||||
|
||||
movl -24(%esi),%eax
|
||||
movl -28(%esi),%edx
|
||||
rcrl $1,%eax
|
||||
movl %ebx,-24(%edi)
|
||||
rcrl $1,%edx
|
||||
movl %eax,-28(%edi)
|
||||
|
||||
leal -32(%esi),%esi /* use leal not to clobber carry */
|
||||
leal -32(%edi),%edi
|
||||
decl %ebp
|
||||
jnz RLoop
|
||||
|
||||
RLend: popl %ebp
|
||||
sbbl %eax,%eax /* save carry in %eax */
|
||||
andl $7,%ebp
|
||||
jz RLend2
|
||||
addl %eax,%eax /* restore carry from eax */
|
||||
RLoop2: movl %edx,%ebx
|
||||
movl (%esi),%edx
|
||||
rcrl $1,%edx
|
||||
movl %ebx,(%edi)
|
||||
|
||||
leal -4(%esi),%esi /* use leal not to clobber carry */
|
||||
leal -4(%edi),%edi
|
||||
decl %ebp
|
||||
jnz RLoop2
|
||||
|
||||
jmp RL1
|
||||
RLend2: addl %eax,%eax /* restore carry from eax */
|
||||
RL1: movl %edx,(%edi) /* store last limb */
|
||||
|
||||
movl $0,%eax
|
||||
rcrl $1,%eax
|
||||
|
||||
popl %ebp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
/* i80586 sub_n -- Sub two limb vectors of the same length > 0 and store
|
||||
* sum in a third limb vector.
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1995, 1998,
|
||||
* 2001, 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
*/
|
||||
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "asm-syntax.h"
|
||||
|
||||
|
||||
/*******************
|
||||
* mpi_limb_t
|
||||
* _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (sp + 4)
|
||||
* mpi_ptr_t s1_ptr, (sp + 8)
|
||||
* mpi_ptr_t s2_ptr, (sp + 12)
|
||||
* mpi_size_t size) (sp + 16)
|
||||
*/
|
||||
|
||||
|
||||
.text
|
||||
ALIGN (3)
|
||||
.globl C_SYMBOL_NAME(_gcry_mpih_sub_n)
|
||||
C_SYMBOL_NAME(_gcry_mpih_sub_n:)
|
||||
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
pushl %ebp
|
||||
|
||||
movl 20(%esp),%edi /* res_ptr */
|
||||
movl 24(%esp),%esi /* s1_ptr */
|
||||
movl 28(%esp),%ebp /* s2_ptr */
|
||||
movl 32(%esp),%ecx /* size */
|
||||
|
||||
movl (%ebp),%ebx
|
||||
|
||||
decl %ecx
|
||||
movl %ecx,%edx
|
||||
shrl $3,%ecx
|
||||
andl $7,%edx
|
||||
testl %ecx,%ecx /* zero carry flag */
|
||||
jz Lend
|
||||
pushl %edx
|
||||
|
||||
ALIGN (3)
|
||||
Loop: movl 28(%edi),%eax /* fetch destination cache line */
|
||||
leal 32(%edi),%edi
|
||||
|
||||
L1: movl (%esi),%eax
|
||||
movl 4(%esi),%edx
|
||||
sbbl %ebx,%eax
|
||||
movl 4(%ebp),%ebx
|
||||
sbbl %ebx,%edx
|
||||
movl 8(%ebp),%ebx
|
||||
movl %eax,-32(%edi)
|
||||
movl %edx,-28(%edi)
|
||||
|
||||
L2: movl 8(%esi),%eax
|
||||
movl 12(%esi),%edx
|
||||
sbbl %ebx,%eax
|
||||
movl 12(%ebp),%ebx
|
||||
sbbl %ebx,%edx
|
||||
movl 16(%ebp),%ebx
|
||||
movl %eax,-24(%edi)
|
||||
movl %edx,-20(%edi)
|
||||
|
||||
L3: movl 16(%esi),%eax
|
||||
movl 20(%esi),%edx
|
||||
sbbl %ebx,%eax
|
||||
movl 20(%ebp),%ebx
|
||||
sbbl %ebx,%edx
|
||||
movl 24(%ebp),%ebx
|
||||
movl %eax,-16(%edi)
|
||||
movl %edx,-12(%edi)
|
||||
|
||||
L4: movl 24(%esi),%eax
|
||||
movl 28(%esi),%edx
|
||||
sbbl %ebx,%eax
|
||||
movl 28(%ebp),%ebx
|
||||
sbbl %ebx,%edx
|
||||
movl 32(%ebp),%ebx
|
||||
movl %eax,-8(%edi)
|
||||
movl %edx,-4(%edi)
|
||||
|
||||
leal 32(%esi),%esi
|
||||
leal 32(%ebp),%ebp
|
||||
decl %ecx
|
||||
jnz Loop
|
||||
|
||||
popl %edx
|
||||
Lend:
|
||||
decl %edx /* test %edx w/o clobbering carry */
|
||||
js Lend2
|
||||
incl %edx
|
||||
Loop2:
|
||||
leal 4(%edi),%edi
|
||||
movl (%esi),%eax
|
||||
sbbl %ebx,%eax
|
||||
movl 4(%ebp),%ebx
|
||||
movl %eax,-4(%edi)
|
||||
leal 4(%esi),%esi
|
||||
leal 4(%ebp),%ebp
|
||||
decl %edx
|
||||
jnz Loop2
|
||||
Lend2:
|
||||
movl (%esi),%eax
|
||||
sbbl %ebx,%eax
|
||||
movl %eax,(%edi)
|
||||
|
||||
sbbl %eax,%eax
|
||||
negl %eax
|
||||
|
||||
popl %ebp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,25 +0,0 @@
|
||||
# Manifest - checksums
|
||||
# Copyright 2003 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
syntax.h
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
mpih-add1.S
|
||||
mpih-sub1.S
|
||||
$names$ iQCVAwUAP+LmTDEAnp832S/7AQJHUAP/dxfq2U0pDc5ZLoEizoqgjjcnHIyb9EjMG3YjvgK6jQ62yoAOCuo/jFYlJS+Mdve6bgfdTzYMrnKV7BG2SEcwb263pVnIntS7ZhKQPiMCbFgXWR2VjN3+a1v8yjQDZtgqEgm8OlQ+u7jKBY13Oryiuq5nPNxsXZqJpelG6Zkdg9M==PIee
|
||||
@@ -1,4 +1,3 @@
|
||||
Manifest
|
||||
syntax.h
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
# Manifest - checksums
|
||||
# Copyright 2003 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
mpih-mul1.S
|
||||
mpih-mul2.S
|
||||
mpih-mul3.S
|
||||
$names$ iQCVAwUAP+LmRTEAnp832S/7AQK3rwP/TyGBbii5HCrjDiLCVJHiDNeOdENx6AicRXnu4vuJmMmPZ0y+i7MPusDaeTbIUA0w6RaJx+Ep41nIvthmNDnFePY5Mw0pIUJcpI7AJR4vYqpwNQA6nlEdn/m1jg6sPLKZXUXNUkhroEzcHzoU+12BPS+nvSXlwSksg6rXEGOJ+Ms==XCXP
|
||||
@@ -1,4 +1,3 @@
|
||||
Manifest
|
||||
mpih-mul1.S
|
||||
mpih-mul2.S
|
||||
mpih-mul3.S
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* Copyright (C) 1992, 1994, 1996, 1998,
|
||||
* 2001, 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
*
|
||||
* This file is part of Libgcrypt.
|
||||
*
|
||||
* Libgcrypt is free software; you can redistribute it and/or modify
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
# Manifest - checksums
|
||||
# Copyright 2003 Free Software Foundation, Inc.
|
||||
#
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
mpih-add1.S
|
||||
mpih-sub1.S
|
||||
mpih-mul1.S
|
||||
mpih-mul2.S
|
||||
mpih-mul3.S
|
||||
mpih-lshift.S
|
||||
mpih-rshift.S
|
||||
mpi-asm-defs.h
|
||||
$names$ iQCVAwUAP+LmUTEAnp832S/7AQLm/gP/RHR2aLMwHPxsq0mGO5H0kneVn8a9l9yDNEZBefkYcOJMb7MZGKxbGspyENiU04Mc2TFnA1wS9gjNHlRWtUYxxn/wyuV6BIRgfstXt2nXGgEQrK07GIz8ETFcYqcxu7JKiICIuXZgnIgdwBJswbBV1zaMUDXeg5B8vkkEeRWj8hQ==IQVO
|
||||
@@ -9,7 +9,7 @@ RELEVANT OPTIMIZATION ISSUES
|
||||
|
||||
On the R4600, branches takes a single cycle
|
||||
|
||||
On the R8000, branches often take no noticable cycles, as they are
|
||||
On the R8000, branches often take no noticeable cycles, as they are
|
||||
executed in a separate function unit..
|
||||
|
||||
2. The R4000 and R4400 have a load latency of 4 cycles.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
Manifest
|
||||
README
|
||||
mpih-add1.S
|
||||
mpih-sub1.S
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
/*******************
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
|
||||
|
||||
Loaded 100 of 468 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user