Adds the multi-precision-integer maths library which was originally taken
from GnuPG and ported to the kernel by (among others) David Howells.
This version is taken from Fedora kernel 2.6.32-71.14.1.el6.
The difference is that checkpatch reported errors and warnings have been fixed.
This library is used to implemenet RSA digital signature verification
used in IMA/EVM integrity protection subsystem.
Due to patch size limitation, the patch is divided into 4 parts.
This code is unnecessary for RSA digital signature verification,
but for completeness it is included here and can be compiled,
if CONFIG_MPILIB_EXTRA is enabled.
Signed-off-by: Dmitry Kasatkin dmitry.kasat...@intel.com
---
lib/Kconfig| 10 ++
lib/mpi/Makefile | 12 ++
lib/mpi/generic_mpi-asm-defs.h |4 +
lib/mpi/generic_udiv-w-sdiv.c | 106 +
lib/mpi/mpi-add.c | 234
lib/mpi/mpi-cmp.c | 68
lib/mpi/mpi-div.c | 333
lib/mpi/mpi-gcd.c | 59 +++
lib/mpi/mpi-inline.c | 31
lib/mpi/mpi-inv.c | 187 ++
lib/mpi/mpi-mpow.c | 133
lib/mpi/mpi-mul.c | 194 +++
lib/mpi/mpi-scan.c | 136
13 files changed, 1507 insertions(+), 0 deletions(-)
create mode 100644 lib/mpi/generic_mpi-asm-defs.h
create mode 100644 lib/mpi/generic_udiv-w-sdiv.c
create mode 100644 lib/mpi/mpi-add.c
create mode 100644 lib/mpi/mpi-cmp.c
create mode 100644 lib/mpi/mpi-div.c
create mode 100644 lib/mpi/mpi-gcd.c
create mode 100644 lib/mpi/mpi-inline.c
create mode 100644 lib/mpi/mpi-inv.c
create mode 100644 lib/mpi/mpi-mpow.c
create mode 100644 lib/mpi/mpi-mul.c
create mode 100644 lib/mpi/mpi-scan.c
diff --git a/lib/Kconfig b/lib/Kconfig
index f69ce08..b5dd7ef 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -286,4 +286,14 @@ config MPILIB
It is used to implement RSA digital signature verification,
which is used by IMA/EVM digital signature extension.
+config MPILIB_EXTRA
+ bool Multiprecision maths library - additional sources
+ depends on MPILIB
+ help
+ Multiprecision maths library from GnuPG.
+ It is used to implement RSA digital signature verification,
+ which is used by IMA/EVM digital signature extension.
+ This code in unnecessary for RSA digital signature verification,
+ and can be compiled if needed.
+
endmenu
diff --git a/lib/mpi/Makefile b/lib/mpi/Makefile
index 0c1c6c3..6ce238b 100644
--- a/lib/mpi/Makefile
+++ b/lib/mpi/Makefile
@@ -20,3 +20,15 @@ mpi-y = \
mpi-pow.o \
mpiutil.o
+mpi-$(CONFIG_MPILIB_EXTRA) += \
+ generic_udiv-w-sdiv.o \
+ mpi-add.o \
+ mpi-div.o \
+ mpi-cmp.o \
+ mpi-gcd.o \
+ mpi-inline.o\
+ mpi-inv.o \
+ mpi-mpow.o \
+ mpi-mul.o \
+ mpi-scan.o \
+
diff --git a/lib/mpi/generic_mpi-asm-defs.h b/lib/mpi/generic_mpi-asm-defs.h
new file mode 100644
index 000..047d1f5
--- /dev/null
+++ b/lib/mpi/generic_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)
diff --git a/lib/mpi/generic_udiv-w-sdiv.c b/lib/mpi/generic_udiv-w-sdiv.c
new file mode 100644
index 000..cb8f5f0
--- /dev/null
+++ b/lib/mpi/generic_udiv-w-sdiv.c
@@ -0,0 +1,106 @@
+/* mpihelp_udiv_w_sdiv -- implement udiv_qrnnd on machines with only signed
+ * division.
+ * Copyright (C) 1992, 1994, 1996, 1998 Free Software Foundation, Inc.
+ * Contributed by Peter L. Montgomery.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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 mpi-internal.h
+#include longlong.h
+
+#if 0 /* not yet ported to MPI */
+
+mpi_limb_t