[PATCH 04/16] PGP: Add definitions (RFC 4880) and packet parser [ver #2]

2011-11-29 Thread David Howells
Add some useful PGP definitions from RFC 4880.  These describe details of
public key crypto as used by crypto keys for things like signature
verification.

Also add a simple parser that extracts the packets from a PGP blob and passes
the desirous ones to the given processor function:

struct pgp_parse_context {
u64 types_of_interest;
int (*process_packet)(struct pgp_parse_context *context,
  enum pgp_packet_tag type,
  u8 headerlen,
  const u8 *data,
  size_t datalen);
};

int pgp_parse_packets(const u8 *data, size_t datalen,
  struct pgp_parse_context *ctx);

Signed-off-by: David Howells 
---

 include/linux/pgp.h   |  230 +
 security/keys/pgp_parse.c |  254 +
 2 files changed, 484 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/pgp.h
 create mode 100644 security/keys/pgp_parse.c


diff --git a/include/linux/pgp.h b/include/linux/pgp.h
new file mode 100644
index 000..7e86a06
--- /dev/null
+++ b/include/linux/pgp.h
@@ -0,0 +1,230 @@
+/* PGP definitions (RFC 4880)
+ *
+ * Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#ifndef _LINUX_PGP_H
+#define _LINUX_PGP_H
+
+#include 
+
+struct pgp_key_ID {
+   u8 id[8];
+};
+
+struct pgp_time {
+   u8 time[4];
+};
+
+/*
+ * PGP public-key algorithm identifiers [RFC4880: 9.1]
+ */
+enum pgp_pubkey_algo {
+   PGP_PUBKEY_RSA_ENC_OR_SIG   = 1,
+   PGP_PUBKEY_RSA_ENC_ONLY = 2,
+   PGP_PUBKEY_RSA_SIG_ONLY = 3,
+   PGP_PUBKEY_ELGAMAL  = 16,
+   PGP_PUBKEY_DSA  = 17,
+};
+
+/*
+ * PGP symmetric-key algorithm identifiers [RFC4880: 9.2]
+ */
+enum pgp_symkey_algo {
+   PGP_SYMKEY_PLAINTEXT= 0,
+   PGP_SYMKEY_IDEA = 1,
+   PGP_SYMKEY_3DES = 2,
+   PGP_SYMKEY_CAST5= 3,
+   PGP_SYMKEY_BLOWFISH = 4,
+   PGP_SYMKEY_AES_128KEY   = 7,
+   PGP_SYMKEY_AES_192KEY   = 8,
+   PGP_SYMKEY_AES_256KEY   = 9,
+   PGP_SYMKEY_TWOFISH_256KEY   = 10,
+};
+
+/*
+ * PGP compression algorithm identifiers [RFC4880: 9.3]
+ */
+enum pgp_compr_algo {
+   PGP_COMPR_UNCOMPRESSED  = 0,
+   PGP_COMPR_ZIP   = 1,
+   PGP_COMPR_ZLIB  = 2,
+   PGP_COMPR_BZIP2 = 3,
+};
+
+/*
+ * PGP hash algorithm identifiers [RFC4880: 9.4]
+ */
+enum pgp_hash_algo {
+   PGP_HASH_MD5= 1,
+   PGP_HASH_SHA1   = 2,
+   PGP_HASH_RIPE_MD_160= 3,
+   PGP_HASH_SHA256 = 8,
+   PGP_HASH_SHA384 = 9,
+   PGP_HASH_SHA512 = 10,
+   PGP_HASH_SHA224 = 11,
+   PGP_HASH__LAST
+};
+
+extern const char *const pgp_hash_algorithms[PGP_HASH__LAST];
+
+/*
+ * PGP packet type tags [RFC4880: 4.3].
+ */
+enum pgp_packet_tag {
+   PGP_PKT_RESERVED= 0,
+   PGP_PKT_PUBKEY_ENC_SESSION_KEY  = 1,
+   PGP_PKT_SIGNATURE   = 2,
+   PGP_PKT_SYMKEY_ENC_SESSION_KEY  = 3,
+   PGP_PKT_ONEPASS_SIGNATURE   = 4,
+   PGP_PKT_SECRET_KEY  = 5,
+   PGP_PKT_PUBLIC_KEY  = 6,
+   PGP_PKT_SECRET_SUBKEY   = 7,
+   PGP_PKT_COMPRESSED_DATA = 8,
+   PGP_PKT_SYM_ENC_DATA= 9,
+   PGP_PKT_MARKER  = 10,
+   PGP_PKT_LITERAL_DATA= 11,
+   PGP_PKT_TRUST   = 12,
+   PGP_PKT_USER_ID = 13,
+   PGP_PKT_PUBLIC_SUBKEY   = 14,
+   PGP_PKT_USER_ATTRIBUTE  = 17,
+   PGP_PKT_SYM_ENC_AND_INTEG_DATA  = 18,
+   PGP_PKT_MODIFY_DETECT_CODE  = 19,
+   PGP_PKT_PRIVATE_0   = 60,
+   PGP_PKT_PRIVATE_3   = 63,
+   PGP_PKT__HIGHEST= 63
+};
+
+/*
+ * Signature (tag 2) packet [RFC4880: 5.2].
+ */
+enum pgp_signature_version {
+   PGP_SIG_VERSION_3   = 3,
+   PGP_SIG_VERSION_4   = 4,
+};
+
+enum pgp_signature_type {
+   PGP_SIG_BINARY_DOCUMENT_SIG = 0x00,
+   PGP_SIG_CANONICAL_TEXT_DOCUMENT_SIG = 0x01,
+   PGP_SIG_STANDALONE_SIG  = 0x02,
+   PGP_SIG_GENERAL_CERT_OF_UID_PUBKEY  = 0x10,
+   PGP_SIG_PERSONAL_CERT_OF_UID_PUBKEY = 0x11,
+   PGP_SIG_CASUAL_CER

[PATCH 15/16] MODSIGN: Module ELF verifier [ver #2]

2011-11-29 Thread David Howells
Do preliminary verification of the ELF structure of a module.  This is used to
make sure that the ELF structure can then be used to check the module signature
and access the module data without breaking the module loader.

If the module's ELF metadata is determined to be bad, then ELIBBAD will be
returned and a message will be logged to the kernel log.

Signed-Off-By: David Howells 
---

 init/Kconfig   |   11 +
 kernel/Makefile|2 
 kernel/module-verify-elf.c |  344 
 kernel/module-verify.c |   41 +
 kernel/module-verify.h |   53 +++
 kernel/module.c|6 +
 6 files changed, 457 insertions(+), 0 deletions(-)
 create mode 100644 kernel/module-verify-elf.c
 create mode 100644 kernel/module-verify.c
 create mode 100644 kernel/module-verify.h


diff --git a/init/Kconfig b/init/Kconfig
index 43298f9..42e685d 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1383,6 +1383,17 @@ config MODULE_SRCVERSION_ALL
  the version).  With this option, such a "srcversion" field
  will be created for all modules.  If unsure, say N.
 
+config MODULE_VERIFY_ELF
+   bool "Module ELF structure verification"
+   depends on MODULES
+   help
+ Check ELF structure of modules upon load
+
+config MODULE_VERIFY
+   bool
+   depends on MODULES
+   default y if MODULE_VERIFY_ELF
+
 endif # MODULES
 
 config INIT_ALL_POSSIBLE
diff --git a/kernel/Makefile b/kernel/Makefile
index e898c5b..3c34fab 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -51,6 +51,8 @@ obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
 obj-$(CONFIG_PROVE_LOCKING) += spinlock.o
 obj-$(CONFIG_UID16) += uid16.o
 obj-$(CONFIG_MODULES) += module.o
+obj-$(CONFIG_MODULE_VERIFY) += module-verify.o
+obj-$(CONFIG_MODULE_VERIFY_ELF) += module-verify-elf.o
 obj-$(CONFIG_KALLSYMS) += kallsyms.o
 obj-$(CONFIG_PM) += power/
 obj-$(CONFIG_FREEZER) += power/
diff --git a/kernel/module-verify-elf.c b/kernel/module-verify-elf.c
new file mode 100644
index 000..4dea8d0
--- /dev/null
+++ b/kernel/module-verify-elf.c
@@ -0,0 +1,344 @@
+/* module-verify-elf.c: module ELF verifier
+ *
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "module-verify.h"
+
+#if 0
+#define _debug(FMT, ...) printk(FMT, ##__VA_ARGS__)
+#else
+#define _debug(FMT, ...) do {} while (0)
+#endif
+
+/*
+ * verify the ELF structure of a module
+ */
+int module_verify_elf(struct module_verify_data *mvdata)
+{
+   const struct elf_note *note;
+   const Elf_Ehdr *hdr = mvdata->hdr;
+   const Elf_Shdr *section, *section2, *secstop;
+   const Elf_Rela *relas, *rela, *relastop;
+   const Elf_Rel *rels, *rel, *relstop;
+   const Elf_Sym *symbol, *symstop;
+   const void *start, *p, *stop;
+   const char *q, *qs;
+   size_t size, sssize, *secsize, tmp, tmp2;
+   long last;
+   int line;
+
+   size = mvdata->size;
+   mvdata->nsects = hdr->e_shnum;
+
+#define elfcheck(X)\
+do { if (unlikely(!(X))) { line = __LINE__; goto elfcheck_error; } } while(0)
+
+#define seccheck(X)\
+do { if (unlikely(!(X))) { line = __LINE__; goto seccheck_error; } } while(0)
+
+#define symcheck(X)\
+do { if (unlikely(!(X))) { line = __LINE__; goto symcheck_error; } } while(0)
+
+#define relcheck(X)\
+do { if (unlikely(!(X))) { line = __LINE__; goto relcheck_error; } } while(0)
+
+#define relacheck(X)   \
+do { if (unlikely(!(X))) { line = __LINE__; goto relacheck_error; } } while(0)
+
+#define notecheck(X)   \
+do { if (unlikely(!(X))) { line = __LINE__; goto notecheck_error; } } while(0)
+
+   /* validate the ELF header */
+   elfcheck(hdr->e_ehsize < size);
+   /*elfcheck(hdr->e_entry == 0);*/
+   elfcheck(hdr->e_phoff == 0);
+   elfcheck(hdr->e_phnum == 0);
+
+   elfcheck(hdr->e_shnum < SHN_LORESERVE);
+   elfcheck(hdr->e_shoff < size);
+   elfcheck(hdr->e_shoff >= hdr->e_ehsize);
+   elfcheck((hdr->e_shoff & (sizeof(long) - 1)) == 0);
+   elfcheck(hdr->e_shstrndx > 0);
+   elfcheck(hdr->e_shstrndx < hdr->e_shnum);
+   elfcheck(hdr->e_shentsize == sizeof(Elf_Shdr));
+
+   tmp = (size_t) hdr->e_shentsize * (size_t) hdr->e_shnum;
+   elfcheck(tmp <= size - hdr->e_shoff);
+
+   /* allocate a table to hold in-file section sizes */
+   mvdata->secsizes = kcalloc(hdr->e_sh

[PATCH 06/16] KEYS: Add a DSA crypto key subtype [ver #2]

2011-11-29 Thread David Howells
Add a key subtype for handling DSA crypto keys.  For the moment it only
provides a signature verification facility.

Signed-off-by: David Howells 
---

 security/Kconfig   |   10 +
 security/keys/Makefile |2 
 security/keys/crypto_dsa.h |   36 
 security/keys/crypto_dsa_subtype.c |  338 
 4 files changed, 386 insertions(+), 0 deletions(-)
 create mode 100644 security/keys/crypto_dsa.h
 create mode 100644 security/keys/crypto_dsa_subtype.c


diff --git a/security/Kconfig b/security/Kconfig
index ef39878..48926af 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -62,6 +62,16 @@ config CRYPTO_KEY_TYPE
  required for cryptographic operations such as encryption, decryption,
  signature generation and signature verification.
 
+config CRYPTO_KEY_DSA
+   tristate "DSA key type"
+   depends on CRYPTO_KEY_TYPE
+   select CRYPTO
+   select MPILIB
+   select MPILIB_EXTRA
+   help
+ This option makes DSA cryptographic keys available.  They can be used
+ for signature verification.
+
 config KEYS_DEBUG_PROC_KEYS
bool "Enable the /proc/keys file by which keys may be viewed"
depends on KEYS
diff --git a/security/keys/Makefile b/security/keys/Makefile
index ca85b01..8c499b1 100644
--- a/security/keys/Makefile
+++ b/security/keys/Makefile
@@ -16,8 +16,10 @@ obj-y := \
 obj-$(CONFIG_TRUSTED_KEYS) += trusted.o
 obj-$(CONFIG_ENCRYPTED_KEYS) += encrypted-keys/
 obj-$(CONFIG_CRYPTO_KEY_TYPE) += crypto_keys.o
+obj-$(CONFIG_CRYPTO_KEY_DSA) += crypto_dsa.o
 obj-$(CONFIG_KEYS_COMPAT) += compat.o
 obj-$(CONFIG_PROC_FS) += proc.o
 obj-$(CONFIG_SYSCTL) += sysctl.o
 
 crypto_keys-y  := crypto_type.o pgp_parse.o
+crypto_dsa-y   := crypto_dsa_subtype.o
diff --git a/security/keys/crypto_dsa.h b/security/keys/crypto_dsa.h
new file mode 100644
index 000..0455634
--- /dev/null
+++ b/security/keys/crypto_dsa.h
@@ -0,0 +1,36 @@
+/* DSA internal definitions
+ *
+ * Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#define DSA_NPKEY  4   /* number of MPI's in DSA public key */
+
+extern struct crypto_key_subtype DSA_crypto_key_subtype;
+
+/*
+ * public key record
+ */
+struct DSA_public_key {
+   struct pgp_parse_pubkey pgp;
+   union {
+   MPI pkey[DSA_NPKEY];
+   struct {
+   MPI p;  /* DSA prime */
+   MPI q;  /* DSA group order */
+   MPI g;  /* DSA group generator */
+   MPI y;  /* DSA public-key value = g^x mod p */
+   };
+   };
+};
+
+struct DSA_payload {
+   u8  key_id[8];  /* ID of this key pair */
+   u8  key_id_size;/* Number of bytes in key_id */
+   struct DSA_public_key   *public_key;
+};
diff --git a/security/keys/crypto_dsa_subtype.c 
b/security/keys/crypto_dsa_subtype.c
new file mode 100644
index 000..ae6133b
--- /dev/null
+++ b/security/keys/crypto_dsa_subtype.c
@@ -0,0 +1,338 @@
+/* DSA crypto key subtype
+ *
+ * Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This file is derived from GnuPG.
+ * Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ *
+ * 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
+ */
+
+#define DEBUG
+#define pr_fmt(fmt) "DSA: "fmt
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#define __KDEBUG
+#include "internal.h"
+#include "crypto_dsa.h"
+
+MODULE_LICENSE("GPL");
+
+static inline void digest_putc(struct shash_desc *digest, uint8_t ch)
+{
+   crypto_shash_update(digest, &ch, 1);
+}
+
+/*
+ * Destroy the contents of a DSA payload
+ */
+static void DSA_destroy_payload(struct DSA_payload *dsa)
+{
+   int i;
+
+   if (dsa->public_key) {
+   for (i = 0; i < DSA_NPKEY; i++)
+   mpi_free(dsa->public_key->pkey

[PATCH 02/16] MPILIB: Add a missing ENOMEM check [ver #2]

2011-11-29 Thread David Howells
Add a missing ENOMEM check.

Signed-off-by: David Howells 
---

 lib/mpi/mpicoder.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)


diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
index fe84bb9..6e225a8 100644
--- a/lib/mpi/mpicoder.c
+++ b/lib/mpi/mpicoder.c
@@ -255,6 +255,8 @@ void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign)
if (!n)
n++;/* avoid zero length allocation */
p = buffer = kmalloc(n, GFP_KERNEL);
+   if (p < 0)
+   return NULL;
 
for (i = a->nlimbs - 1; i >= 0; i--) {
alimb = a->d[i];

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/16] KEYS: Create a key type that can be used for general cryptographic operations [ver #2]

2011-11-29 Thread David Howells
Create a key type that can be used for general cryptographic operations, such
as encryption, decryption, signature generation and signature verification.

The key type is "crypto" and can provide access to a variety of cryptographic
algorithms.

Signed-off-by: David Howells 
---

 Documentation/security/keys-crypto.txt |  170 +
 include/keys/crypto-subtype.h  |   46 +
 include/keys/crypto-type.h |   25 +++
 security/Kconfig   |8 +
 security/keys/Makefile |3 
 security/keys/crypto_keys.h|   21 ++
 security/keys/crypto_type.c|  315 
 7 files changed, 588 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/security/keys-crypto.txt
 create mode 100644 include/keys/crypto-subtype.h
 create mode 100644 include/keys/crypto-type.h
 create mode 100644 security/keys/crypto_keys.h
 create mode 100644 security/keys/crypto_type.c


diff --git a/Documentation/security/keys-crypto.txt 
b/Documentation/security/keys-crypto.txt
new file mode 100644
index 000..44c936a
--- /dev/null
+++ b/Documentation/security/keys-crypto.txt
@@ -0,0 +1,170 @@
+   ==
+   CRYPTOGRAPHIC KEY TYPE
+   ==
+
+Contents:
+
+  - Overview.
+  - Key identification.
+  - Crypto subtypes.
+  - Accessing crypto keys.
+  - Implementing crypto subtypes.
+
+
+
+OVERVIEW
+
+
+The "crypto" key type is designed to be a container for cryptographic keys,
+without imposing any particular restrictions on the form of the cryptography or
+the key.
+
+The crypto key is given a subtype that defines what sort of data is associated
+with the key and what operations might be performed with it.  However, no
+requirement is made that the key data actually be loaded into the key or that
+the operations are done by the kernel.
+
+For instance, cryptographic hardware (such as a TPM) might be used to both
+retain the relevant key and provide operations using that key.  In such a case,
+the crypto key would then merely be an interface to the TPM driver.
+
+
+==
+KEY IDENTIFICATION
+==
+
+Because the identity of a key is not necessarily known or is not easily
+calculated when a crypto key is allocated, it may not be a simple matter to set
+a key description to something that's useful for determining whether this is
+the key you're looking for.  Furthermore, it may be necessary to perform a
+partial match upon the key identity.
+
+To help with this, when a key is loaded, the key subtype's instantiation
+routine calculates the key fingerprint and stores a copy in the key struct.
+
+The crypto key type's key matching function then performs more checks than just
+the straightforward comparison of the description with the criterion string:
+
+ (1) If the criterion string is of the form "id:" then the match
+ function will examine a key's fingerprint to see if the hex digits given
+ after the "id:" match the tail.  For instance:
+
+   keyctl search @s crypto id:5acc2142
+
+ will match a key with fingerprint:
+
+   1A00 2040 7601 7889 DE11  882C 3823 04AD 5ACC 2142
+
+ (2) If the criterion string is of the form ":" then the
+ match will match the ID as in (1), but with the added restriction that
+ only keys of the specified subtype (e.g. dsa or rsa) will be matched.  For
+ instance:
+
+   keyctl search @s crypto dsa:5acc2142
+
+Looking in /proc/keys, the last 8 hex digits of the key fingerprint are
+displayed, along with the subtype:
+
+   1a39e171 I- 1 perm 3f01 0 0 cryptomodsign.0: 
dsa 5acc2142 []
+
+
+===
+CRYPTO SUBTYPES
+===
+
+The crypto key is just a simple container.  It contains no data of its own and
+does very little except provide a place to hang a function pointer table.  The
+key subtype does the actual work.
+
+When a crypto key is instantiated, it looks through its list of registered
+subtypes to try and find one that can handle the data blob it is given.  If the
+data blob begins with a byte with the top bit set, it is assumed to be a PGP
+packet format blob [RFC 4880] and is treated so.  The blob is parsed to find a
+PGP key, and then a subtype is looked for that says it can handle the
+appropriate algorithm type.
+
+
+=
+ACCESSING CRYPTO KEYS
+=
+
+To access crypto keys from within the kernel, the following inclusion is
+required:
+
+   #include 
+
+This gives access to the key type:
+
+   struct key_type key_type_crypto;
+
+
+
+IMPLEMENTING CRYPTO SUBTYPES
+
+
+If a suitable subtype is found, then key->type_data.p[0] is set to point to the
+subtype definition and the module usage count is incremented.
+
+The subtype definition structure looks like the following:
+
+ 

[PATCH 07/16] KEYS: Add a RSA crypto key subtype [ver #2]

2011-11-29 Thread David Howells
Add a key subtype for handling RSA crypto keys.  For the moment it only
provides a signature verification facility.

Signed-off-by: David Howells 
---

 security/Kconfig   |9 +
 security/keys/Makefile |2 
 security/keys/crypto_rsa.h |   36 +++
 security/keys/crypto_rsa_subtype.c |  371 
 4 files changed, 418 insertions(+), 0 deletions(-)
 create mode 100644 security/keys/crypto_rsa.h
 create mode 100644 security/keys/crypto_rsa_subtype.c


diff --git a/security/Kconfig b/security/Kconfig
index 48926af..4167b4f 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -72,6 +72,15 @@ config CRYPTO_KEY_DSA
  This option makes DSA cryptographic keys available.  They can be used
  for signature verification.
 
+config CRYPTO_KEY_RSA
+   tristate "RSA key type"
+   depends on CRYPTO_KEY_TYPE
+   select CRYPTO
+   select MPILIB
+   help
+ This option makes RSA cryptographic keys available.  They can be used
+ for signature verification.
+
 config KEYS_DEBUG_PROC_KEYS
bool "Enable the /proc/keys file by which keys may be viewed"
depends on KEYS
diff --git a/security/keys/Makefile b/security/keys/Makefile
index 8c499b1..0cb7d08 100644
--- a/security/keys/Makefile
+++ b/security/keys/Makefile
@@ -17,9 +17,11 @@ obj-$(CONFIG_TRUSTED_KEYS) += trusted.o
 obj-$(CONFIG_ENCRYPTED_KEYS) += encrypted-keys/
 obj-$(CONFIG_CRYPTO_KEY_TYPE) += crypto_keys.o
 obj-$(CONFIG_CRYPTO_KEY_DSA) += crypto_dsa.o
+obj-$(CONFIG_CRYPTO_KEY_RSA) += crypto_rsa.o
 obj-$(CONFIG_KEYS_COMPAT) += compat.o
 obj-$(CONFIG_PROC_FS) += proc.o
 obj-$(CONFIG_SYSCTL) += sysctl.o
 
 crypto_keys-y  := crypto_type.o pgp_parse.o
 crypto_dsa-y   := crypto_dsa_subtype.o
+crypto_rsa-y   := crypto_rsa_subtype.o
diff --git a/security/keys/crypto_rsa.h b/security/keys/crypto_rsa.h
new file mode 100644
index 000..2ec8edc
--- /dev/null
+++ b/security/keys/crypto_rsa.h
@@ -0,0 +1,36 @@
+/* RSA internal definitions
+ *
+ * Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#define RSA_NPKEY  2   /* number of MPI's in an RSA public key */
+
+extern struct crypto_key_subtype RSA_crypto_key_subtype;
+extern struct crypto_key_subtype RSA_crypto_key_subtype_2;
+extern struct crypto_key_subtype RSA_crypto_key_subtype_3;
+
+/*
+ * public key record
+ */
+struct RSA_public_key {
+   struct pgp_parse_pubkey pgp;
+   union {
+   MPI pkey[RSA_NPKEY];
+   struct {
+   MPI n;  /* RSA public modulus */
+   MPI e;  /* RSA public encryption exponent */
+   };
+   };
+};
+
+struct RSA_payload {
+   u8  key_id[8];  /* ID of this key pair */
+   u8  key_id_size;/* Number of bytes in key_id */
+   struct RSA_public_key   *public_key;
+};
diff --git a/security/keys/crypto_rsa_subtype.c 
b/security/keys/crypto_rsa_subtype.c
new file mode 100644
index 000..da0d4cf
--- /dev/null
+++ b/security/keys/crypto_rsa_subtype.c
@@ -0,0 +1,371 @@
+/* RSA crypto key subtype
+ *
+ * Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This file is derived from GnuPG.
+ * Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ *
+ * 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
+ */
+
+#define DEBUG
+#define pr_fmt(fmt) "RSA: "fmt
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "crypto_rsa.h"
+#define __KDEBUG
+#include "internal.h"
+
+MODULE_LICENSE("GPL");
+
+static inline void digest_putc(struct shash_desc *digest, uint8_t ch)
+{
+   crypto_shash_update(digest, &ch, 1);
+}
+
+/*
+ * Destroy the contents of a RSA payload
+ */
+static void RSA_destroy_payload(struct RSA_payload *rsa)
+{
+   int i;
+
+   if (rsa->public_key) {
+   for (i = 0; i < RSA_NPKEY; i++)
+   mpi_f

[PATCH 14/16] MODSIGN: Add indications of module ELF types [ver #2]

2011-11-29 Thread David Howells
Add per-arch indications of module ELF types and relocation table entry types.

Signed-Off-By: David Howells 
---

 arch/alpha/include/asm/module.h   |3 +++
 arch/arm/include/asm/module.h |5 +
 arch/cris/include/asm/module.h|5 +
 arch/h8300/include/asm/module.h   |5 +
 arch/ia64/include/asm/module.h|5 +
 arch/m32r/include/asm/module.h|5 +
 arch/m68k/include/asm/module.h|5 +
 arch/mips/include/asm/module.h|   12 ++--
 arch/parisc/include/asm/module.h  |8 
 arch/powerpc/include/asm/module.h |   10 ++
 arch/s390/include/asm/module.h|3 +++
 include/asm-generic/module.h  |   10 ++
 12 files changed, 74 insertions(+), 2 deletions(-)


diff --git a/arch/alpha/include/asm/module.h b/arch/alpha/include/asm/module.h
index 7b63743..3d5a3ea 100644
--- a/arch/alpha/include/asm/module.h
+++ b/arch/alpha/include/asm/module.h
@@ -6,6 +6,7 @@ struct mod_arch_specific
unsigned int gotsecindex;
 };
 
+#define MODULES_ARE_ELF64
 #define Elf_Sym Elf64_Sym
 #define Elf_Shdr Elf64_Shdr
 #define Elf_Ehdr Elf64_Ehdr
@@ -13,6 +14,8 @@ struct mod_arch_specific
 #define Elf_Dyn Elf64_Dyn
 #define Elf_Rel Elf64_Rel
 #define Elf_Rela Elf64_Rela
+#define ELF_R_TYPE(X)  ELF64_R_TYPE(X)
+#define ELF_R_SYM(X)   ELF64_R_SYM(X)
 
 #define ARCH_SHF_SMALL SHF_ALPHA_GPREL
 
diff --git a/arch/arm/include/asm/module.h b/arch/arm/include/asm/module.h
index 6c6809f..f47d9cd 100644
--- a/arch/arm/include/asm/module.h
+++ b/arch/arm/include/asm/module.h
@@ -1,9 +1,14 @@
 #ifndef _ASM_ARM_MODULE_H
 #define _ASM_ARM_MODULE_H
 
+#define MODULES_ARE_ELF32
 #define Elf_Shdr   Elf32_Shdr
 #define Elf_SymElf32_Sym
 #define Elf_Ehdr   Elf32_Ehdr
+#define Elf_RelElf32_Rel
+#define Elf_Rela   Elf32_Rela
+#define ELF_R_TYPE(X)  ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)   ELF32_R_SYM(X)
 
 struct unwind_table;
 
diff --git a/arch/cris/include/asm/module.h b/arch/cris/include/asm/module.h
index 7ee7231..03f7b2e 100644
--- a/arch/cris/include/asm/module.h
+++ b/arch/cris/include/asm/module.h
@@ -3,7 +3,12 @@
 /* cris is simple */
 struct mod_arch_specific { };
 
+#define MODULES_ARE_ELF32
 #define Elf_Shdr Elf32_Shdr
 #define Elf_Sym Elf32_Sym
 #define Elf_Ehdr Elf32_Ehdr
+#define Elf_Rel Elf32_Rel
+#define Elf_Rela Elf32_Rela
+#define ELF_R_TYPE(X)  ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)   ELF32_R_SYM(X)
 #endif /* _ASM_CRIS_MODULE_H */
diff --git a/arch/h8300/include/asm/module.h b/arch/h8300/include/asm/module.h
index 8e46724..5140128 100644
--- a/arch/h8300/include/asm/module.h
+++ b/arch/h8300/include/asm/module.h
@@ -4,8 +4,13 @@
  * This file contains the H8/300 architecture specific module code.
  */
 struct mod_arch_specific { };
+#define MODULES_ARE_ELF32
 #define Elf_Shdr Elf32_Shdr
 #define Elf_Sym Elf32_Sym
 #define Elf_Ehdr Elf32_Ehdr
+#define Elf_Rel Elf32_Rel
+#define Elf_Rela Elf32_Rela
+#define ELF_R_TYPE(X)  ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)   ELF32_R_SYM(X)
 
 #endif /* _ASM_H8/300_MODULE_H */
diff --git a/arch/ia64/include/asm/module.h b/arch/ia64/include/asm/module.h
index 908eaef..3c4cd94 100644
--- a/arch/ia64/include/asm/module.h
+++ b/arch/ia64/include/asm/module.h
@@ -29,9 +29,14 @@ struct mod_arch_specific {
unsigned int next_got_entry;/* index of next available got entry */
 };
 
+#define MODULES_ARE_ELF64
 #define Elf_Shdr   Elf64_Shdr
 #define Elf_SymElf64_Sym
 #define Elf_Ehdr   Elf64_Ehdr
+#define Elf_RelElf64_Rel
+#define Elf_Rela   Elf64_Rela
+#define ELF_R_TYPE(X)  ELF64_R_TYPE(X)
+#define ELF_R_SYM(X)   ELF64_R_SYM(X)
 
 #define MODULE_PROC_FAMILY "ia64"
 #define MODULE_ARCH_VERMAGIC   MODULE_PROC_FAMILY \
diff --git a/arch/m32r/include/asm/module.h b/arch/m32r/include/asm/module.h
index eb73ee0..7146455 100644
--- a/arch/m32r/include/asm/module.h
+++ b/arch/m32r/include/asm/module.h
@@ -3,8 +3,13 @@
 
 struct mod_arch_specific { };
 
+#define MODULES_ARE_ELF32
 #define Elf_Shdr   Elf32_Shdr
 #define Elf_SymElf32_Sym
 #define Elf_Ehdr   Elf32_Ehdr
+#define Elf_RelElf32_Rel
+#define Elf_Rela   Elf32_Rela
+#define ELF_R_TYPE(X)  ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)   ELF32_R_SYM(X)
 
 #endif /* _ASM_M32R_MODULE_H */
diff --git a/arch/m68k/include/asm/module.h b/arch/m68k/include/asm/module.h
index edffe66..9e2cd74 100644
--- a/arch/m68k/include/asm/module.h
+++ b/arch/m68k/include/asm/module.h
@@ -36,8 +36,13 @@ struct module;
 extern void module_fixup(struct module *mod, struct m68k_fixup_info *start,
 struct m68k_fixup_info *end);
 
+#define MODULES_ARE_ELF32
 #define Elf_Shdr Elf32_Shdr
 #define Elf_Sym Elf32_Sym
 #define Elf_Ehdr Elf32_Ehdr
+#define Elf_RelElf32_Rel
+#define Elf_Rela   Elf32_Rela
+#define ELF_R_TYPE(X)  ELF32_R_TYPE(X)
+#define ELF_R_SYM(X)   ELF32_R_SYM(X)
 
 #endif /* _ASM_M68K_MODULE_H */

[PATCH 08/16] PGP: Add signature parser [ver #2]

2011-11-29 Thread David Howells
Add some PGP signature parsing helpers:

 (1) A function to parse V4 signature subpackets and pass the desired ones to
 a processor function:

int pgp_parse_sig_subpkts(const u8 *data, size_t datalen,
  struct pgp_parse_sig_context *ctx);

 (2) A function to parse out basic signature parameters from any PGP signature
 such that the algorithms and public key can be selected:

int pgp_parse_sig_params(const u8 **_data, size_t *_datalen,
 struct pgp_sig_parameters *p);

Signed-off-by: David Howells 
---

 include/linux/pgp.h   |   24 
 security/keys/pgp_parse.c |  274 +
 2 files changed, 298 insertions(+), 0 deletions(-)


diff --git a/include/linux/pgp.h b/include/linux/pgp.h
index 7e86a06..29b9758 100644
--- a/include/linux/pgp.h
+++ b/include/linux/pgp.h
@@ -227,4 +227,28 @@ struct pgp_parse_pubkey {
 extern int pgp_parse_public_key(const u8 **_data, size_t *_datalen,
struct pgp_parse_pubkey *pk);
 
+struct pgp_parse_sig_context {
+   unsigned long types_of_interest[128 / BITS_PER_LONG];
+   int (*process_packet)(struct pgp_parse_sig_context *context,
+ enum pgp_sig_subpkt_type type,
+ const u8 *data,
+ size_t datalen);
+};
+
+extern int pgp_parse_sig_packets(const u8 *data, size_t datalen,
+struct pgp_parse_sig_context *ctx);
+
+struct pgp_sig_parameters {
+   enum pgp_signature_type signature_type : 8;
+   union {
+   struct pgp_key_ID issuer;
+   __be32 issuer32[2];
+   };
+   enum pgp_pubkey_algo pubkey_algo : 8;
+   enum pgp_hash_algo hash_algo : 8;
+};
+
+extern int pgp_parse_sig_params(const u8 **_data, size_t *_datalen,
+   struct pgp_sig_parameters *p);
+
 #endif /* _LINUX_PGP_H */
diff --git a/security/keys/pgp_parse.c b/security/keys/pgp_parse.c
index fb8d64a..b7bfeb1 100644
--- a/security/keys/pgp_parse.c
+++ b/security/keys/pgp_parse.c
@@ -252,3 +252,277 @@ int pgp_parse_public_key(const u8 **_data, size_t 
*_datalen,
return 0;
 }
 EXPORT_SYMBOL_GPL(pgp_parse_public_key);
+
+/**
+ * pgp_parse_sig_subpkt_header - Parse a PGP V4 signature subpacket header
+ * @_data: Start of the subpacket (updated to subpacket data)
+ * @_datalen: Amount of data remaining in buffer (decreased)
+ * @_type: Where the subpacket type will be returned
+ *
+ * Parse a PGP V4 signature subpacket header [RFC 4880: 5.2.3.1].
+ *
+ * Returns packet data size on success; non-zero on error.  If successful,
+ * *_data and *_datalen will have been updated and *_headerlen will be set to
+ * hold the length of the packet header.
+ */
+ssize_t pgp_parse_sig_subpkt_header(const u8 **_data, size_t *_datalen,
+   enum pgp_sig_subpkt_type *_type)
+{
+   enum pgp_sig_subpkt_type type;
+   const u8 *data = *_data;
+   size_t size, datalen = *_datalen;
+
+   pr_devel("-->pgp_parse_sig_subpkt_header(,%zu,,)", datalen);
+
+   if (datalen < 2)
+   goto short_subpacket;
+
+   pr_devel("subpkt hdr %02x, %02x\n", data[0], data[1]);
+
+   switch (data[0]) {
+   case 0x00 ... 0xbf:
+   /* One-byte length */
+   size = data[0];
+   data++;
+   datalen--;
+   break;
+   case 0xc0 ... 0xfe:
+   /* Two-byte length */
+   if (datalen < 3)
+   goto short_subpacket;
+   size = (data[0] - 192) * 256;
+   size += data[1] + 192;
+   data += 2;
+   datalen -= 2;
+   break;
+   case 0xff:
+   if (datalen < 6)
+   goto short_subpacket;
+   size  = data[1] << 24;
+   size |= data[2] << 16;
+   size |= data[3] << 8;
+   size |= data[4];
+   data += 5;
+   datalen -= 5;
+   break;
+   }
+
+   /* The type octet is included in the size */
+   if (size == 0) {
+   pr_warning("Signature subpacket size can't be zero\n");
+   return -EBADMSG;
+   }
+
+   type = *data++ & ~PGP_SIG_SUBPKT_TYPE_CRITICAL_MASK;
+   datalen--;
+   size--;
+
+   pr_devel("datalen=%zu size=%zu", datalen, size);
+   if (datalen < size)
+   goto short_subpacket;
+
+   *_data = data;
+   *_datalen = datalen;
+   *_type = type;
+   pr_devel("Found subpkt type=%u size=%zd\n", type, size);
+   return size;
+
+short_subpacket:
+   pr_warning("Attempt to parse short signature subpacket\n");
+   return -EBADMSG;
+}
+
+/**
+ * pgp_parse_sig_subpkts - Parse a set of PGP V4 signatute subpackets
+ * @_data: Data to be parsed (updated)
+ * @_datalen: Amount of data (updated)
+ *

[PATCH 10/16] KEYS: DSA key signature verification [ver #2]

2011-11-29 Thread David Howells
Signature verification routines for DSA crypto key subtype.

Signed-off-by: David Howells 
---

 security/keys/Makefile|2 
 security/keys/crypto_dsa.h|   11 +
 security/keys/crypto_dsa_verify.c |  384 +
 3 files changed, 396 insertions(+), 1 deletions(-)
 create mode 100644 security/keys/crypto_dsa_verify.c


diff --git a/security/keys/Makefile b/security/keys/Makefile
index 8f48527..bde336e 100644
--- a/security/keys/Makefile
+++ b/security/keys/Makefile
@@ -23,5 +23,5 @@ obj-$(CONFIG_PROC_FS) += proc.o
 obj-$(CONFIG_SYSCTL) += sysctl.o
 
 crypto_keys-y  := crypto_type.o pgp_parse.o crypto_verify.o
-crypto_dsa-y   := crypto_dsa_subtype.o
+crypto_dsa-y   := crypto_dsa_subtype.o crypto_dsa_verify.o
 crypto_rsa-y   := crypto_rsa_subtype.o
diff --git a/security/keys/crypto_dsa.h b/security/keys/crypto_dsa.h
index 0455634..8c7c6e9 100644
--- a/security/keys/crypto_dsa.h
+++ b/security/keys/crypto_dsa.h
@@ -34,3 +34,14 @@ struct DSA_payload {
u8  key_id_size;/* Number of bytes in key_id */
struct DSA_public_key   *public_key;
 };
+
+/*
+ * crypto_dsa_verify.c
+ */
+extern struct crypto_key_verify_context *DSA_verify_sig_begin(
+   struct key *key, const u8 *sig, size_t siglen);
+extern int DSA_verify_sig_add_data(struct crypto_key_verify_context *ctx,
+  const void *data, size_t datalen);
+extern int DSA_verify_sig_end(struct crypto_key_verify_context *ctx,
+ const u8 *sig, size_t siglen);
+extern void DSA_verify_sig_cancel(struct crypto_key_verify_context *ctx);
diff --git a/security/keys/crypto_dsa_verify.c 
b/security/keys/crypto_dsa_verify.c
new file mode 100644
index 000..c9dc180
--- /dev/null
+++ b/security/keys/crypto_dsa_verify.c
@@ -0,0 +1,384 @@
+/* DSA signature verification algorithm
+ *
+ * Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#define DEBUG
+#define pr_fmt(fmt) "DSA: "fmt
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "internal.h"
+#include "crypto_dsa.h"
+
+#define DSA_NSIG   2   /* number of MPI's in DSA signature */
+
+struct DSA_signature {
+   struct crypto_key_verify_context base;
+   enum pgp_hash_algo hash_algo : 8;
+   u8 signed_hash_msw[2];
+   union {
+   MPI mpi[2];
+   struct {
+   MPI r;
+   MPI s;
+   };
+   };
+   struct shash_desc hash; /* This must go last! */
+};
+
+struct DSA_sig_parse_context {
+   struct pgp_parse_context pgp;
+   struct pgp_sig_parameters params;
+};
+
+static int DSA_parse_signature(struct pgp_parse_context *context,
+  enum pgp_packet_tag type,
+  u8 headerlen,
+  const u8 *data,
+  size_t datalen)
+{
+   struct DSA_sig_parse_context *ctx =
+   container_of(context, struct DSA_sig_parse_context, pgp);
+
+   return pgp_parse_sig_params(&data, &datalen, &ctx->params);
+}
+
+/*
+ * Begin the process of verifying a DSA signature.
+ *
+ * This involves allocating the hash into which first the data and then the
+ * metadata will be put, and parsing the signature to check that it matches the
+ * key.
+ */
+struct crypto_key_verify_context *DSA_verify_sig_begin(
+   struct key *key, const u8 *sigdata, size_t siglen)
+{
+   struct DSA_sig_parse_context p;
+   struct DSA_signature *sig;
+   struct crypto_shash *tfm;
+   struct DSA_payload *dsa = key->payload.data;
+   int ret;
+
+   kenter("{%d},,%zu", key_serial(key), siglen);
+
+   if (!dsa->public_key) {
+   kleave(" = -ENOKEY [no public key]");
+   return ERR_PTR(-ENOKEY);
+   }
+
+   p.pgp.types_of_interest = (1 << PGP_PKT_SIGNATURE);
+   p.pgp.process_packet = DSA_parse_signature;
+   ret = pgp_parse_packets(sigdata, siglen, &p.pgp);
+   if (ret < 0)
+   return ERR_PTR(ret);
+
+   if (p.params.pubkey_algo != PGP_PUBKEY_DSA) {
+   kleave(" = -ENOKEY [wrong pk algo]");
+   return ERR_PTR(-ENOKEY);
+   }
+
+   if (p.params.hash_algo >= PGP_HASH__LAST ||
+   !pgp_hash_algorithms[p.params.hash_algo]) {
+   kleave(" = -ENOPKG [hash]");
+   return ERR_PTR(-ENOPKG);
+   }
+
+   pr_notice("Signature generated with %s hash\n",
+ pgp_hash_algorithms[p.params.hash_algo]);
+
+   if (memcmp(&p.params.issuer, dsa->key_id, 8) != 0) {
+   kleave(" = -

[PATCH 12/16] KEYS: Add a crypto key request function [ver #2]

2011-11-29 Thread David Howells
Add a function by which crypto keys can be requested.  A keyring is supplied
for the function to search (which can be, say, a system keyring containing keys
for kernel module signature checking).  The function also provides a point at
which hardware key caches, such as a TPM, can be consulted.

Signed-off-by: David Howells 
---

 Documentation/security/keys-crypto.txt |   12 
 include/keys/crypto-type.h |3 +
 security/keys/Makefile |2 -
 security/keys/crypto_request.c |   87 
 4 files changed, 103 insertions(+), 1 deletions(-)
 create mode 100644 security/keys/crypto_request.c


diff --git a/Documentation/security/keys-crypto.txt 
b/Documentation/security/keys-crypto.txt
index 236d750..e1c19ea 100644
--- a/Documentation/security/keys-crypto.txt
+++ b/Documentation/security/keys-crypto.txt
@@ -158,6 +158,18 @@ using a key to provide the public key:
  not necessary if verify_sig_end() was called.
 
 
+To find a key to use for signature verification, the following function may be
+called:
+
+   struct key *request_crypto_key_for_PGP_sig(struct key *keyring,
+ const u8 *sig, size_t siglen);
+
+This parses the specified signature blob to find the signing key identity and
+then searches the given keyring for a matching key.  It may also examine a
+hardware keystore (such as a TPM) for a usable signature matching service and
+generate a key to provide an access method to that service.
+
+
 
 IMPLEMENTING CRYPTO SUBTYPES
 
diff --git a/include/keys/crypto-type.h b/include/keys/crypto-type.h
index 6b93366..142611b 100644
--- a/include/keys/crypto-type.h
+++ b/include/keys/crypto-type.h
@@ -31,4 +31,7 @@ extern void verify_sig_cancel(struct 
crypto_key_verify_context *ctx);
  * The payload is at the discretion of the subtype.
  */
 
+extern struct key *request_crypto_key_for_PGP_sig(struct key *keyring,
+ const u8 *sig, size_t siglen);
+
 #endif /* _KEYS_CRYPTO_TYPE_H */
diff --git a/security/keys/Makefile b/security/keys/Makefile
index 78a3aa6..722be34 100644
--- a/security/keys/Makefile
+++ b/security/keys/Makefile
@@ -22,6 +22,6 @@ obj-$(CONFIG_KEYS_COMPAT) += compat.o
 obj-$(CONFIG_PROC_FS) += proc.o
 obj-$(CONFIG_SYSCTL) += sysctl.o
 
-crypto_keys-y  := crypto_type.o pgp_parse.o crypto_verify.o
+crypto_keys-y  := crypto_type.o pgp_parse.o crypto_verify.o crypto_request.o
 crypto_dsa-y   := crypto_dsa_subtype.o crypto_dsa_verify.o
 crypto_rsa-y   := crypto_rsa_subtype.o crypto_rsa_verify.o
diff --git a/security/keys/crypto_request.c b/security/keys/crypto_request.c
new file mode 100644
index 000..0a1819a3
--- /dev/null
+++ b/security/keys/crypto_request.c
@@ -0,0 +1,87 @@
+/* Cryptographic key request handling
+ *
+ * Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ *
+ * See Documentation/security/keys-crypto.txt
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "crypto_keys.h"
+
+struct PGP_sig_parse_context {
+   struct pgp_parse_context pgp;
+   struct pgp_sig_parameters params;
+   bool found_sig;
+};
+
+/*
+ * Look inside signature sections for a key ID
+ */
+static int PGP_sig_parse_signature(struct pgp_parse_context *context,
+  enum pgp_packet_tag type,
+  u8 headerlen,
+  const u8 *data,
+  size_t datalen)
+{
+   struct PGP_sig_parse_context *ctx =
+   container_of(context, struct PGP_sig_parse_context, pgp);
+
+   ctx->found_sig = true;
+   return pgp_parse_sig_params(&data, &datalen, &ctx->params);
+}
+
+/**
+ * request_crypto_key_for_PGP_sig - Request a key matching a PGP signature
+ * @keyring: The keyring that might contain the key.
+ * @sig: The PGP signature blob.
+ * @siglen: The size of the PGP signature blob.
+ *
+ * Attempt to find a key to use for PGP signature verification, starting off by
+ * looking in the supplied keyring.  The function may also look for other key
+ * sources such as a TPM.  If an alternative key is found it will be added to
+ * the keyring for future reference.
+ */
+struct key *request_crypto_key_for_PGP_sig(struct key *keyring,
+  const u8 *sig, size_t siglen)
+{
+   struct PGP_sig_parse_context p;
+   key_ref_t key;
+   char criterion[3 + 8 * 2 + 1];
+   int ret;
+
+   if (!keyring)
+   return ERR_PTR(-ENOKEY);
+
+   /* Need to find the key ID */
+   p.p

[PATCH 11/16] KEYS: RSA key signature verification [ver #2]

2011-11-29 Thread David Howells
Signature verification routines for RSA crypto key subtype.

Signed-off-by: David Howells 
---

 security/keys/Makefile |2 
 security/keys/crypto_rsa.h |   11 +
 security/keys/crypto_rsa_subtype.c |   15 +
 security/keys/crypto_rsa_verify.c  |  519 
 4 files changed, 546 insertions(+), 1 deletions(-)
 create mode 100644 security/keys/crypto_rsa_verify.c


diff --git a/security/keys/Makefile b/security/keys/Makefile
index bde336e..78a3aa6 100644
--- a/security/keys/Makefile
+++ b/security/keys/Makefile
@@ -24,4 +24,4 @@ obj-$(CONFIG_SYSCTL) += sysctl.o
 
 crypto_keys-y  := crypto_type.o pgp_parse.o crypto_verify.o
 crypto_dsa-y   := crypto_dsa_subtype.o crypto_dsa_verify.o
-crypto_rsa-y   := crypto_rsa_subtype.o
+crypto_rsa-y   := crypto_rsa_subtype.o crypto_rsa_verify.o
diff --git a/security/keys/crypto_rsa.h b/security/keys/crypto_rsa.h
index 2ec8edc..6670458 100644
--- a/security/keys/crypto_rsa.h
+++ b/security/keys/crypto_rsa.h
@@ -34,3 +34,14 @@ struct RSA_payload {
u8  key_id_size;/* Number of bytes in key_id */
struct RSA_public_key   *public_key;
 };
+
+/*
+ * crypto_rsa_verify.c
+ */
+extern struct crypto_key_verify_context *RSA_verify_sig_begin(
+   struct key *key, const u8 *sig, size_t siglen);
+extern int RSA_verify_sig_add_data(struct crypto_key_verify_context *ctx,
+  const void *data, size_t datalen);
+extern int RSA_verify_sig_end(struct crypto_key_verify_context *ctx,
+ const u8 *sig, size_t siglen);
+extern void RSA_verify_sig_cancel(struct crypto_key_verify_context *ctx);
diff --git a/security/keys/crypto_rsa_subtype.c 
b/security/keys/crypto_rsa_subtype.c
index da0d4cf..1eb5839 100644
--- a/security/keys/crypto_rsa_subtype.c
+++ b/security/keys/crypto_rsa_subtype.c
@@ -313,6 +313,11 @@ struct crypto_key_subtype RSA_crypto_key_subtype = {
.info   = CRYPTO_KEY_IS_PUBKEY_ALGO,
.instantiate= RSA_instantiate,
.destroy= RSA_destroy,
+
+   .verify_sig_begin   = RSA_verify_sig_begin,
+   .verify_sig_add_data= RSA_verify_sig_add_data,
+   .verify_sig_end = RSA_verify_sig_end,
+   .verify_sig_cancel  = RSA_verify_sig_cancel,
 };
 
 struct crypto_key_subtype RSA_crypto_key_subtype_2 = {
@@ -322,6 +327,11 @@ struct crypto_key_subtype RSA_crypto_key_subtype_2 = {
.info   = CRYPTO_KEY_IS_PUBKEY_ALGO,
.instantiate= RSA_instantiate,
.destroy= RSA_destroy,
+
+   .verify_sig_begin   = RSA_verify_sig_begin,
+   .verify_sig_add_data= RSA_verify_sig_add_data,
+   .verify_sig_end = RSA_verify_sig_end,
+   .verify_sig_cancel  = RSA_verify_sig_cancel,
 };
 
 struct crypto_key_subtype RSA_crypto_key_subtype_3 = {
@@ -331,6 +341,11 @@ struct crypto_key_subtype RSA_crypto_key_subtype_3 = {
.info   = CRYPTO_KEY_IS_PUBKEY_ALGO,
.instantiate= RSA_instantiate,
.destroy= RSA_destroy,
+
+   .verify_sig_begin   = RSA_verify_sig_begin,
+   .verify_sig_add_data= RSA_verify_sig_add_data,
+   .verify_sig_end = RSA_verify_sig_end,
+   .verify_sig_cancel  = RSA_verify_sig_cancel,
 };
 
 /*
diff --git a/security/keys/crypto_rsa_verify.c 
b/security/keys/crypto_rsa_verify.c
new file mode 100644
index 000..736e2f9
--- /dev/null
+++ b/security/keys/crypto_rsa_verify.c
@@ -0,0 +1,519 @@
+/* RSA signature verification algorithm [RFC3447]
+ *
+ * Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowe...@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#define DEBUG
+#define pr_fmt(fmt) "RSA: "fmt
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "crypto_rsa.h"
+#include "internal.h"
+
+struct RSA_signature {
+   struct crypto_key_verify_context base;
+   enum pgp_hash_algo hash_algo : 8;
+   u8 signed_hash_msw[2];
+   union {
+   MPI mpi[1];
+   struct {
+   MPI s;  /* m^d mod n */
+   };
+   };
+   struct shash_desc hash; /* This must go last! */
+};
+
+/*
+ * Hash algorithm OIDs plus ASN.1 DER wrappings [RFC4880 sec 5.2.2].
+ */
+static const u8 RSA_digest_info_MD5[] = {
+   0x30, 0x20, 0x30, 0x0C, 0x06, 0x08,
+   0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, /* OID */
+   0x05, 0x00, 0x04, 0x10
+};
+
+static const u8 RSA_digest_info_SHA1[] = {
+   0x30, 0x21, 0x30, 0x09, 0x06, 0x05,
+   0x2b, 0x0E, 0x03, 0x02, 0x1A,
+   0x05, 0x00, 0x04, 0x14
+};
+
+static const u8 RSA_digest_info_RIPE_MD_160[] = {
+

[PATCH 01/16] MPILIB: Export some more symbols [ver #2]

2011-11-29 Thread David Howells
Export some more symbols for use by the DSA key subtype.

Signed-off-by: David Howells 
---

 lib/mpi/mpi-cmp.c  |2 ++
 lib/mpi/mpi-div.c  |1 +
 lib/mpi/mpi-inv.c  |1 +
 lib/mpi/mpi-mpow.c |1 +
 lib/mpi/mpi-mul.c  |1 +
 5 files changed, 6 insertions(+), 0 deletions(-)


diff --git a/lib/mpi/mpi-cmp.c b/lib/mpi/mpi-cmp.c
index 914bc42..1871e7b 100644
--- a/lib/mpi/mpi-cmp.c
+++ b/lib/mpi/mpi-cmp.c
@@ -39,6 +39,7 @@ int mpi_cmp_ui(MPI u, unsigned long v)
else
return -1;
 }
+EXPORT_SYMBOL_GPL(mpi_cmp_ui);
 
 int mpi_cmp(MPI u, MPI v)
 {
@@ -66,3 +67,4 @@ int mpi_cmp(MPI u, MPI v)
return 1;
return -1;
 }
+EXPORT_SYMBOL_GPL(mpi_cmp);
diff --git a/lib/mpi/mpi-div.c b/lib/mpi/mpi-div.c
index c3087d1..3da9402 100644
--- a/lib/mpi/mpi-div.c
+++ b/lib/mpi/mpi-div.c
@@ -59,6 +59,7 @@ nomem:
mpi_free(temp_divisor);
return rc;
 }
+EXPORT_SYMBOL_GPL(mpi_fdiv_r);
 
 /
  * Division rounding the quotient towards -infinity.
diff --git a/lib/mpi/mpi-inv.c b/lib/mpi/mpi-inv.c
index 0951f98..bfc5ca1 100644
--- a/lib/mpi/mpi-inv.c
+++ b/lib/mpi/mpi-inv.c
@@ -185,3 +185,4 @@ cleanup:
mpi_free(v);
return rc;
 }
+EXPORT_SYMBOL_GPL(mpi_invm);
diff --git a/lib/mpi/mpi-mpow.c b/lib/mpi/mpi-mpow.c
index 4cc7593..5752194 100644
--- a/lib/mpi/mpi-mpow.c
+++ b/lib/mpi/mpi-mpow.c
@@ -131,3 +131,4 @@ nomem:
kfree(G);
return rc;
 }
+EXPORT_SYMBOL_GPL(mpi_mulpowm);
diff --git a/lib/mpi/mpi-mul.c b/lib/mpi/mpi-mul.c
index 1f3219e..3d514b9 100644
--- a/lib/mpi/mpi-mul.c
+++ b/lib/mpi/mpi-mul.c
@@ -192,3 +192,4 @@ int mpi_mulm(MPI w, MPI u, MPI v, MPI m)
return -ENOMEM;
return mpi_fdiv_r(w, w, m);
 }
+EXPORT_SYMBOL_GPL(mpi_mulm);

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/16] KEYS: Add signature verification facility [ver #2]

2011-11-29 Thread David Howells
Add a facility whereby a key subtype may be asked to verify a signature against
the data it is purported to have signed.

Signed-off-by: David Howells 
---

 Documentation/security/keys-crypto.txt |  106 +++-
 include/keys/crypto-subtype.h  |   15 +
 include/keys/crypto-type.h |9 +++
 security/keys/Makefile |2 -
 security/keys/crypto_verify.c  |   87 ++
 5 files changed, 214 insertions(+), 5 deletions(-)
 create mode 100644 security/keys/crypto_verify.c


diff --git a/Documentation/security/keys-crypto.txt 
b/Documentation/security/keys-crypto.txt
index 44c936a..236d750 100644
--- a/Documentation/security/keys-crypto.txt
+++ b/Documentation/security/keys-crypto.txt
@@ -8,7 +8,9 @@ Contents:
   - Key identification.
   - Crypto subtypes.
   - Accessing crypto keys.
+- Signature verification.
   - Implementing crypto subtypes.
+- Registration.
 
 
 
@@ -98,14 +100,69 @@ This gives access to the key type:
struct key_type key_type_crypto;
 
 
+SIGNATURE VERIFICATION
+--
+
+The four operations that can perform cryptographic signature verification,
+using a key to provide the public key:
+
+ (1) Begin verification procedure.
+
+   struct crypto_key_verify_context *
+   verify_sig_begin(struct key *key, const void *sig, size_t siglen);
+
+ This function sets up a verification context from the specified key and
+ the signature blob.  The signature blob must be presented again at the end
+ of the procedure.  The key is checked against parameters in the signature,
+ and if it's not the right key then an error will be given.
+
+ If such a thing applies, the hashing algorithm, will be extracted from the
+ signature and the appropriate crypto module will be used.  -ENOPKG will be
+ returned if the hash algorithm is unavailable.
+
+ The return value is an opaque pointer to be passed to the other functions,
+ or a negative error code.
+
+ (2) Indicate data to be verified.
+
+   int verify_sig_add_data(struct crypto_key_verify_context *ctx,
+   const void *data, size_t datalen);
+
+ This function is used to shovel data to the verification procedure so that
+ it can load it into the hash, pass it to hardware or whatever is
+ appropriate for the algorithm being employed.
+
+ The data is not canonicalised for the document type specified in the
+ signature.  The caller must do that.
+
+ It will return 0 if successful and a negative error code if not.
+
+ (3) Complete the verification process.
+
+   int verify_sig_end(struct crypto_key_verify_context *ctx,
+  const void *sig, size_t siglen);
+
+ This function performs the actual signature verification step and cleans
+ up the resources allocated at the beginning.  The signature must be
+ presented again as some of the data therein may need to be added to the
+ internal hash.
+
+ It will return -EKEYREJECTED if the signature didn't match, 0 if
+ successful and may return other errors as appropriate.
+
+ (4) Cancel the verification process.
+
+   void verify_sig_cancel(struct crypto_key_verify_context *ctx);
+
+ This function cleans up the resources allocated at the beginning.  This is
+ not necessary if verify_sig_end() was called.
+
+
 
 IMPLEMENTING CRYPTO SUBTYPES
 
 
-If a suitable subtype is found, then key->type_data.p[0] is set to point to the
-subtype definition and the module usage count is incremented.
-
-The subtype definition structure looks like the following:
+Each subtype is specified through a definition structure:
 
struct crypto_key_subtype {
struct module   *owner;
@@ -118,6 +175,14 @@ The subtype definition structure looks like the following:
 
void (*revoke)(struct key *key);
void (*destroy)(struct key *key);
+
+   struct crypto_key_verify_context *(*verify_sig_begin)(
+   struct key *key, const u8 *sig, size_t siglen);
+   int (*verify_sig_add_data)(struct crypto_key_verify_context 
*ctx,
+  const void *data, size_t datalen);
+   int (*verify_sig_end)(struct crypto_key_verify_context *ctx,
+ const u8 *sig, size_t siglen);
+   void (*verify_sig_cancel)(struct crypto_key_verify_context 
*ctx);
};
 
 The owner and name fields should be set to the owning module and the name of
@@ -160,6 +225,39 @@ management of the key itself:
  must free whatever key->payload refers to.
 
 
+There are then sets of method pointers to actually use the key for things:
+
+ (*) Signature verification
+
+ Then there are functions to verify a signature using the public key 
stored in
+ this key

[PATCH 13/16] KEYS: Provide a function to load keys from a PGP keyring blob [ver #2]

2011-11-29 Thread David Howells
Provide a function to load keys from a PGP keyring blob for use in initialising
the module signing key keyring:

int load_PGP_keys(const u8 *pgpdata, size_t pgpdatalen,
  struct key *keyring, const char *descprefix);

The keys are labelled with descprefix plus a number to uniquify them.  The keys
will actually be identified by the ID calculated from the PGP data rather than
by the description, so this shouldn't be a problem.

The keys are attached to the keyring supplied.

Looking as root in /proc/keys after the module signing keyring has been loaded:

24460d1c I- 1 perm 3f01 0 0 cryptomodsign.0: dsa 
5acc2142 []
3ca85723 I- 1 perm 1f01 0 0 keyring   .module_sign: 1/4

Signed-off-by: David Howells 
---

 Documentation/security/keys-crypto.txt |   19 +
 include/keys/crypto-type.h |3 +
 security/keys/crypto_request.c |   66 
 3 files changed, 88 insertions(+), 0 deletions(-)


diff --git a/Documentation/security/keys-crypto.txt 
b/Documentation/security/keys-crypto.txt
index e1c19ea..35e61b1 100644
--- a/Documentation/security/keys-crypto.txt
+++ b/Documentation/security/keys-crypto.txt
@@ -9,6 +9,7 @@ Contents:
   - Crypto subtypes.
   - Accessing crypto keys.
 - Signature verification.
+- Initial pgp key loading.
   - Implementing crypto subtypes.
 - Registration.
 
@@ -170,6 +171,24 @@ hardware keystore (such as a TPM) for a usable signature 
matching service and
 generate a key to provide an access method to that service.
 
 
+INITIAL PGP KEY LOADING
+---
+
+A function is provided to perform an initial load of a set of public keys bound
+into a PGP keyring blob:
+
+   int load_PGP_keys(const u8 *pgpdata, size_t pgpdatalen,
+ struct key *keyring, const char *descprefix);
+
+This takes the blob of data defined by pgpdata and pgpdatalen, extracts keys
+from them and adds them to the specified keyring.  The keys are labelled with
+descprefix plus a simple uniquifier - it is not expected that the description
+will be used to identify the key.  The description is required to prevent all
+but the last key being discarded when the keys are linked into the keyring.
+
+This function is only available during initial kernel set up.
+
+
 
 IMPLEMENTING CRYPTO SUBTYPES
 
diff --git a/include/keys/crypto-type.h b/include/keys/crypto-type.h
index 142611b..ef961d9 100644
--- a/include/keys/crypto-type.h
+++ b/include/keys/crypto-type.h
@@ -34,4 +34,7 @@ extern void verify_sig_cancel(struct 
crypto_key_verify_context *ctx);
 extern struct key *request_crypto_key_for_PGP_sig(struct key *keyring,
  const u8 *sig, size_t siglen);
 
+extern __init int load_PGP_keys(const u8 *pgpdata, size_t pgpdatalen,
+   struct key *keyring, const char *descprefix);
+
 #endif /* _KEYS_CRYPTO_TYPE_H */
diff --git a/security/keys/crypto_request.c b/security/keys/crypto_request.c
index 0a1819a3..416c69f 100644
--- a/security/keys/crypto_request.c
+++ b/security/keys/crypto_request.c
@@ -85,3 +85,69 @@ struct key *request_crypto_key_for_PGP_sig(struct key 
*keyring,
return ERR_CAST(key);
return key_ref_to_ptr(key);
 }
+
+struct load_PGP_keys_context {
+   struct pgp_parse_context pgp;
+   key_ref_t keyring;
+   char descbuf[20];
+   u8 key_n;
+   u8 dsize;
+};
+
+/*
+ * Extract a public key or subkey from the PGP stream.
+ */
+static int found_PGP_key(struct pgp_parse_context *context,
+enum pgp_packet_tag type, u8 headerlen,
+const u8 *data, size_t datalen)
+{
+   struct load_PGP_keys_context *ctx =
+   container_of(context, struct load_PGP_keys_context, pgp);
+   key_ref_t key;
+
+   sprintf(ctx->descbuf + ctx->dsize, "%d", ctx->key_n++);
+
+   key = key_create_or_update(ctx->keyring, "crypto", ctx->descbuf,
+  data - headerlen, datalen + headerlen,
+  KEY_POS_ALL | KEY_USR_VIEW,
+  KEY_ALLOC_NOT_IN_QUOTA);
+
+   if (IS_ERR(key))
+   return PTR_ERR(key);
+   key_ref_put(key);
+   return 0;
+}
+
+/**
+ * load_PGP_keys - Load keys from a PGP keyring blob
+ * @pgpdata: The PGP keyring blob containing the keys.
+ * @pgpdatalen: The size of the @pgpdata blob.
+ * @keyring: The keyring to add the new keys to.
+ * @descprefix: The key description prefix.
+ *
+ * Load a pack of keys from a PGP keyring blob.
+ *
+ * The keys are given description of @descprefix + the number of the key in the
+ * list.  Since keys can be matched on their key IDs independently of the key
+ * description, the description is mostly irrelevant apart from the fact that
+ * keys of the same description displace on

[PATCH 03/16] KEYS: Permit key_serial() to be called with a const key pointer [ver #2]

2011-11-29 Thread David Howells
Permit key_serial() to be called with a const key pointer.

Signed-off-by: David Howells 
---

 include/linux/key.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/include/linux/key.h b/include/linux/key.h
index 183a6af..f87b51b 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -271,7 +271,7 @@ extern int keyring_add_key(struct key *keyring,
 
 extern struct key *key_lookup(key_serial_t id);
 
-static inline key_serial_t key_serial(struct key *key)
+static inline key_serial_t key_serial(const struct key *key)
 {
return key ? key->serial : 0;
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 00/16] Crypto keys and module signing [ver #2]

2011-11-29 Thread David Howells

Here are a set of patches that create a framework for using cryptographic keys
within the kernel.  The patches can also be found at:


http://git.kernel.org/?p=linux/kernel/git/dhowells/linux-modsign.git;a=shortlog;h=refs/heads/devel

The basic crypto key has no requirements as to how the key is implemented; it's
basically a jump table for the operations and an anchor for any relevant data.

I have provided a couple of subtypes: DSA and RSA.  Both types have signature
verification facilities available within the kernel, and both can be used for
module signature verification with any encryption algorithm known by the PGP
parser, provided the appropriate algorithm is compiled directly into the
kernel.

These two subtypes store their public key data attached to the key and
implement the algorithms within the kernel.  However, it would be possible to
merely refer to keys held in a hardware keystore (such as a TPM) and have the
accessor methods offload the actual work to that keystore to be done in
hardware.

With kernel module signing enabled, and a pair of keys (one RSA, one DSA)
compiled into the kernel, root can see these keys and the keyring that holds
them in /proc/keys:

195fa736 I- 1 perm 3f01 0 0 cryptomodsign.1: dsa 
5acc2142 []
335ab517 I- 1 perm 1f03 0 0 keyring   .module_sign: 2/4
38d7d169 I- 1 perm 3f01 0 0 cryptomodsign.0: rsa 
57532ca5 []

Module signing combinations that have been tested: DSA with SHA1 and RSA with
all the SHA algorithms.

The patches break down into a number of areas:

 (0) Dmitry Kasatkin's MPI library patches - which I have not included in this
 posting, but can be obtained from the GIT tree.

 (1) Utility: MPI function exports and make key_serial() handle a const
 pointer.  Also fix a bug in the MPI library.

 (2) PGP defs and PGP packet parser; basic crypto key infrastructure.

 (3) DSA key and RSA key basic implementations.

 (4) PGP signature parser; signature verification operations.

 (5) DSA and RSA verification algorithms.

 (6) Module ELF verification and module signature verification.

The complete crypto type documentation can be found within the GIT tree here:


http://git.kernel.org/?p=linux/kernel/git/dhowells/linux-modsign.git;a=blob;f=Documentation/security/keys-crypto.txt;h=35e61b1bc636543bc77c0c2a33c3ef323b9f96b5;hb=6eea6dc28e465163611d26112f0ea68ec0e0a0d2

and the module signature verification documentation can be found here:


http://git.kernel.org/?p=linux/kernel/git/dhowells/linux-modsign.git;a=blob;f=Documentation/module-signing.txt;h=300b91a701818409f37f6065d5f14c5c73ce1b44;hb=20258f1df3a9580a26c5fc5028086bf02d28974d

---
Changes made 29/11/2011:

 (*) Added RSA signature verification.

 (*) Stopped signature verification crashing on unsupported hash algorithm.

 (*) Fixed ENOMEM handling bug in MPI.

 (*) Worked around ccache problems with compilation of PGP public keyring into
 kernel (ccache hashes the preprocessor output, but the assembler includes
 the binary data, so ccache doesn't see that it changed).

 (*) Added a choice in kernel config for hash algorithm to use; forced the
 appropriate crypto module to be built directly into the kernel.

 (*) Cleaned out some debugging code.

 (*) Updated documentation.

David
---
David Howells (16):
  MODSIGN: Apply signature checking to modules on module load
  MODSIGN: Module ELF verifier
  MODSIGN: Add indications of module ELF types
  KEYS: Provide a function to load keys from a PGP keyring blob
  KEYS: Add a crypto key request function
  KEYS: RSA key signature verification
  KEYS: DSA key signature verification
  KEYS: Add signature verification facility
  PGP: Add signature parser
  KEYS: Add a RSA crypto key subtype
  KEYS: Add a DSA crypto key subtype
  KEYS: Create a key type that can be used for general cryptographic 
operations
  PGP: Add definitions (RFC 4880) and packet parser
  KEYS: Permit key_serial() to be called with a const key pointer
  MPILIB: Add a missing ENOMEM check
  MPILIB: Export some more symbols


 .gitignore |   15 +
 Documentation/module-signing.txt   |  186 +++
 Documentation/security/keys-crypto.txt |  299 ++
 Makefile   |1 
 arch/alpha/include/asm/module.h|3 
 arch/arm/include/asm/module.h  |5 
 arch/cris/include/asm/module.h |5 
 arch/h8300/include/asm/module.h|5 
 arch/ia64/include/asm/module.h |5 
 arch/m32r/include/asm/module.h |5 
 arch/m68k/include/asm/module.h |5 
 arch/mips/include/asm/module.h |   12 
 arch/parisc/include/asm/module.h   |8 
 arch/powerpc/include/asm/module.h  |   10 
 arch/s390/include/asm/module.h |3 
 include/asm-generic/module.h   |   10 
 include/keys/crypto-subtype.h

Announce loop-AES-v3.6e file/swap crypto package

2011-11-29 Thread Jari Ruusu
loop-AES changes since previous release:
- Worked around block layer interface breakage on 3.2-rc kernels.

bzip2 compressed tarball is here:

http://loop-aes.sourceforge.net/loop-AES/loop-AES-v3.6e.tar.bz2
md5sum b8bf83f3d21a6ad1ea49ac30f9ec130d

http://loop-aes.sourceforge.net/loop-AES/loop-AES-v3.6e.tar.bz2.sign

-- 
Jari Ruusu  1024R/3A220F51 5B 4B F9 BB D3 3F 52 E9  DB 1D EB E3 24 0E A9 DD
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html