aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-11 00:51:23 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-11 00:51:23 -0500
commite7691a1ce341c80ed9504244a36b31c025217391 (patch)
treee9941bb350f64a726130e299c411821da6f41a53 /include
parent5cd9599bba428762025db6027764f1c59d0b1e1b (diff)
parent8fcc99549522fc7a0bbaeb5755855ab0d9a59ce8 (diff)
Merge branch 'for-linus' of git://selinuxproject.org/~jmorris/linux-security
* 'for-linus' of git://selinuxproject.org/~jmorris/linux-security: (32 commits) ima: fix invalid memory reference ima: free duplicate measurement memory security: update security_file_mmap() docs selinux: Casting (void *) value returned by kmalloc is useless apparmor: fix module parameter handling Security: tomoyo: add .gitignore file tomoyo: add missing rcu_dereference() apparmor: add missing rcu_dereference() evm: prevent racing during tfm allocation evm: key must be set once during initialization mpi/mpi-mpow: NULL dereference on allocation failure digsig: build dependency fix KEYS: Give key types their own lockdep class for key->sem TPM: fix transmit_cmd error logic TPM: NSC and TIS drivers X86 dependency fix TPM: Export wait_for_stat for other vendor specific drivers TPM: Use vendor specific function for status probe tpm_tis: add delay after aborting command tpm_tis: Check return code from getting timeouts/durations tpm: Introduce function to poll for result of self test ... Fix up trivial conflict in lib/Makefile due to addition of CONFIG_MPI and SIGSIG next to CONFIG_DQL addition.
Diffstat (limited to 'include')
-rw-r--r--include/linux/digsig.h64
-rw-r--r--include/linux/key-type.h1
-rw-r--r--include/linux/mpi.h146
-rw-r--r--include/linux/security.h4
4 files changed, 214 insertions, 1 deletions
diff --git a/include/linux/digsig.h b/include/linux/digsig.h
new file mode 100644
index 000000000000..efae755017d7
--- /dev/null
+++ b/include/linux/digsig.h
@@ -0,0 +1,64 @@
1/*
2 * Copyright (C) 2011 Nokia Corporation
3 * Copyright (C) 2011 Intel Corporation
4 *
5 * Author:
6 * Dmitry Kasatkin <dmitry.kasatkin@nokia.com>
7 * <dmitry.kasatkin@intel.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, version 2 of the License.
12 *
13 */
14
15#ifndef _DIGSIG_H
16#define _DIGSIG_H
17
18#include <linux/key.h>
19
20enum pubkey_algo {
21 PUBKEY_ALGO_RSA,
22 PUBKEY_ALGO_MAX,
23};
24
25enum digest_algo {
26 DIGEST_ALGO_SHA1,
27 DIGEST_ALGO_SHA256,
28 DIGEST_ALGO_MAX
29};
30
31struct pubkey_hdr {
32 uint8_t version; /* key format version */
33 time_t timestamp; /* key made, always 0 for now */
34 uint8_t algo;
35 uint8_t nmpi;
36 char mpi[0];
37} __packed;
38
39struct signature_hdr {
40 uint8_t version; /* signature format version */
41 time_t timestamp; /* signature made */
42 uint8_t algo;
43 uint8_t hash;
44 uint8_t keyid[8];
45 uint8_t nmpi;
46 char mpi[0];
47} __packed;
48
49#if defined(CONFIG_DIGSIG) || defined(CONFIG_DIGSIG_MODULE)
50
51int digsig_verify(struct key *keyring, const char *sig, int siglen,
52 const char *digest, int digestlen);
53
54#else
55
56static inline int digsig_verify(struct key *keyring, const char *sig,
57 int siglen, const char *digest, int digestlen)
58{
59 return -EOPNOTSUPP;
60}
61
62#endif /* CONFIG_DIGSIG */
63
64#endif /* _DIGSIG_H */
diff --git a/include/linux/key-type.h b/include/linux/key-type.h
index 9efd081bb31e..39e3c082c49d 100644
--- a/include/linux/key-type.h
+++ b/include/linux/key-type.h
@@ -92,6 +92,7 @@ struct key_type {
92 92
93 /* internal fields */ 93 /* internal fields */
94 struct list_head link; /* link in types list */ 94 struct list_head link; /* link in types list */
95 struct lock_class_key lock_class; /* key->sem lock class */
95}; 96};
96 97
97extern struct key_type key_type_keyring; 98extern struct key_type key_type_keyring;
diff --git a/include/linux/mpi.h b/include/linux/mpi.h
new file mode 100644
index 000000000000..06f88994ccaa
--- /dev/null
+++ b/include/linux/mpi.h
@@ -0,0 +1,146 @@
1/* mpi.h - Multi Precision Integers
2 * Copyright (C) 1994, 1996, 1998, 1999,
3 * 2000, 2001 Free Software Foundation, Inc.
4 *
5 * This file is part of GNUPG.
6 *
7 * GNUPG is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * GNUPG is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 *
21 * Note: This code is heavily based on the GNU MP Library.
22 * Actually it's the same code with only minor changes in the
23 * way the data is stored; this is to support the abstraction
24 * of an optional secure memory allocation which may be used
25 * to avoid revealing of sensitive data due to paging etc.
26 * The GNU MP Library itself is published under the LGPL;
27 * however I decided to publish this code under the plain GPL.
28 */
29
30#ifndef G10_MPI_H
31#define G10_MPI_H
32
33#include <linux/types.h>
34
35/* DSI defines */
36
37#define SHA1_DIGEST_LENGTH 20
38
39/*end of DSI defines */
40
41#define BYTES_PER_MPI_LIMB (BITS_PER_LONG / 8)
42#define BITS_PER_MPI_LIMB BITS_PER_LONG
43
44typedef unsigned long int mpi_limb_t;
45typedef signed long int mpi_limb_signed_t;
46
47struct gcry_mpi {
48 int alloced; /* array size (# of allocated limbs) */
49 int nlimbs; /* number of valid limbs */
50 int nbits; /* the real number of valid bits (info only) */
51 int sign; /* indicates a negative number */
52 unsigned flags; /* bit 0: array must be allocated in secure memory space */
53 /* bit 1: not used */
54 /* bit 2: the limb is a pointer to some m_alloced data */
55 mpi_limb_t *d; /* array with the limbs */
56};
57
58typedef struct gcry_mpi *MPI;
59
60#define MPI_NULL NULL
61
62#define mpi_get_nlimbs(a) ((a)->nlimbs)
63#define mpi_is_neg(a) ((a)->sign)
64
65/*-- mpiutil.c --*/
66MPI mpi_alloc(unsigned nlimbs);
67MPI mpi_alloc_secure(unsigned nlimbs);
68MPI mpi_alloc_like(MPI a);
69void mpi_free(MPI a);
70int mpi_resize(MPI a, unsigned nlimbs);
71int mpi_copy(MPI *copy, const MPI a);
72void mpi_clear(MPI a);
73int mpi_set(MPI w, MPI u);
74int mpi_set_ui(MPI w, ulong u);
75MPI mpi_alloc_set_ui(unsigned long u);
76void mpi_m_check(MPI a);
77void mpi_swap(MPI a, MPI b);
78
79/*-- mpicoder.c --*/
80MPI do_encode_md(const void *sha_buffer, unsigned nbits);
81MPI mpi_read_from_buffer(const void *buffer, unsigned *ret_nread);
82int mpi_fromstr(MPI val, const char *str);
83u32 mpi_get_keyid(MPI a, u32 *keyid);
84void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign);
85void *mpi_get_secure_buffer(MPI a, unsigned *nbytes, int *sign);
86int mpi_set_buffer(MPI a, const void *buffer, unsigned nbytes, int sign);
87
88#define log_mpidump g10_log_mpidump
89
90/*-- mpi-add.c --*/
91int mpi_add_ui(MPI w, MPI u, ulong v);
92int mpi_add(MPI w, MPI u, MPI v);
93int mpi_addm(MPI w, MPI u, MPI v, MPI m);
94int mpi_sub_ui(MPI w, MPI u, ulong v);
95int mpi_sub(MPI w, MPI u, MPI v);
96int mpi_subm(MPI w, MPI u, MPI v, MPI m);
97
98/*-- mpi-mul.c --*/
99int mpi_mul_ui(MPI w, MPI u, ulong v);
100int mpi_mul_2exp(MPI w, MPI u, ulong cnt);
101int mpi_mul(MPI w, MPI u, MPI v);
102int mpi_mulm(MPI w, MPI u, MPI v, MPI m);
103
104/*-- mpi-div.c --*/
105ulong mpi_fdiv_r_ui(MPI rem, MPI dividend, ulong divisor);
106int mpi_fdiv_r(MPI rem, MPI dividend, MPI divisor);
107int mpi_fdiv_q(MPI quot, MPI dividend, MPI divisor);
108int mpi_fdiv_qr(MPI quot, MPI rem, MPI dividend, MPI divisor);
109int mpi_tdiv_r(MPI rem, MPI num, MPI den);
110int mpi_tdiv_qr(MPI quot, MPI rem, MPI num, MPI den);
111int mpi_tdiv_q_2exp(MPI w, MPI u, unsigned count);
112int mpi_divisible_ui(const MPI dividend, ulong divisor);
113
114/*-- mpi-gcd.c --*/
115int mpi_gcd(MPI g, const MPI a, const MPI b);
116
117/*-- mpi-pow.c --*/
118int mpi_pow(MPI w, MPI u, MPI v);
119int mpi_powm(MPI res, MPI base, MPI exp, MPI mod);
120
121/*-- mpi-mpow.c --*/
122int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI mod);
123
124/*-- mpi-cmp.c --*/
125int mpi_cmp_ui(MPI u, ulong v);
126int mpi_cmp(MPI u, MPI v);
127
128/*-- mpi-scan.c --*/
129int mpi_getbyte(MPI a, unsigned idx);
130void mpi_putbyte(MPI a, unsigned idx, int value);
131unsigned mpi_trailing_zeros(MPI a);
132
133/*-- mpi-bit.c --*/
134void mpi_normalize(MPI a);
135unsigned mpi_get_nbits(MPI a);
136int mpi_test_bit(MPI a, unsigned n);
137int mpi_set_bit(MPI a, unsigned n);
138int mpi_set_highbit(MPI a, unsigned n);
139void mpi_clear_highbit(MPI a, unsigned n);
140void mpi_clear_bit(MPI a, unsigned n);
141int mpi_rshift(MPI x, MPI a, unsigned n);
142
143/*-- mpi-inv.c --*/
144int mpi_invm(MPI x, MPI u, MPI v);
145
146#endif /*G10_MPI_H */
diff --git a/include/linux/security.h b/include/linux/security.h
index 98112cf93884..0ccceb9b1046 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -590,6 +590,8 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
590 * @reqprot contains the protection requested by the application. 590 * @reqprot contains the protection requested by the application.
591 * @prot contains the protection that will be applied by the kernel. 591 * @prot contains the protection that will be applied by the kernel.
592 * @flags contains the operational flags. 592 * @flags contains the operational flags.
593 * @addr contains virtual address that will be used for the operation.
594 * @addr_only contains a boolean: 0 if file-backed VMA, otherwise 1.
593 * Return 0 if permission is granted. 595 * Return 0 if permission is granted.
594 * @file_mprotect: 596 * @file_mprotect:
595 * Check permissions before changing memory access permissions. 597 * Check permissions before changing memory access permissions.
@@ -2043,7 +2045,7 @@ static inline void security_inode_free(struct inode *inode)
2043static inline int security_inode_init_security(struct inode *inode, 2045static inline int security_inode_init_security(struct inode *inode,
2044 struct inode *dir, 2046 struct inode *dir,
2045 const struct qstr *qstr, 2047 const struct qstr *qstr,
2046 initxattrs initxattrs, 2048 const initxattrs initxattrs,
2047 void *fs_data) 2049 void *fs_data)
2048{ 2050{
2049 return 0; 2051 return 0;