aboutsummaryrefslogtreecommitdiffstats
path: root/include/crypto
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/crypto
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'include/crypto')
-rw-r--r--include/crypto/algapi.h3
-rw-r--r--include/crypto/blowfish.h23
-rw-r--r--include/crypto/cast5.h23
-rw-r--r--include/crypto/cast6.h24
-rw-r--r--include/crypto/cast_common.h9
-rw-r--r--include/crypto/internal/aead.h2
-rw-r--r--include/crypto/internal/hash.h2
-rw-r--r--include/crypto/internal/skcipher.h2
-rw-r--r--include/crypto/lrw.h43
-rw-r--r--include/crypto/public_key.h108
-rw-r--r--include/crypto/scatterwalk.h28
-rw-r--r--include/crypto/serpent.h27
-rw-r--r--include/crypto/sha.h5
-rw-r--r--include/crypto/twofish.h2
-rw-r--r--include/crypto/vmac.h2
-rw-r--r--include/crypto/xts.h27
16 files changed, 25 insertions, 305 deletions
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index 418d270e180..59c3e5bd2c0 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -15,7 +15,6 @@
15#include <linux/crypto.h> 15#include <linux/crypto.h>
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/skbuff.h>
19 18
20struct module; 19struct module;
21struct rtattr; 20struct rtattr;
@@ -27,7 +26,6 @@ struct crypto_type {
27 int (*init)(struct crypto_tfm *tfm, u32 type, u32 mask); 26 int (*init)(struct crypto_tfm *tfm, u32 type, u32 mask);
28 int (*init_tfm)(struct crypto_tfm *tfm); 27 int (*init_tfm)(struct crypto_tfm *tfm);
29 void (*show)(struct seq_file *m, struct crypto_alg *alg); 28 void (*show)(struct seq_file *m, struct crypto_alg *alg);
30 int (*report)(struct sk_buff *skb, struct crypto_alg *alg);
31 struct crypto_alg *(*lookup)(const char *name, u32 type, u32 mask); 29 struct crypto_alg *(*lookup)(const char *name, u32 type, u32 mask);
32 30
33 unsigned int type; 31 unsigned int type;
@@ -134,7 +132,6 @@ struct crypto_template *crypto_lookup_template(const char *name);
134 132
135int crypto_register_instance(struct crypto_template *tmpl, 133int crypto_register_instance(struct crypto_template *tmpl,
136 struct crypto_instance *inst); 134 struct crypto_instance *inst);
137int crypto_unregister_instance(struct crypto_alg *alg);
138 135
139int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg, 136int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
140 struct crypto_instance *inst, u32 mask); 137 struct crypto_instance *inst, u32 mask);
diff --git a/include/crypto/blowfish.h b/include/crypto/blowfish.h
deleted file mode 100644
index 1450d4a2798..00000000000
--- a/include/crypto/blowfish.h
+++ /dev/null
@@ -1,23 +0,0 @@
1/*
2 * Common values for blowfish algorithms
3 */
4
5#ifndef _CRYPTO_BLOWFISH_H
6#define _CRYPTO_BLOWFISH_H
7
8#include <linux/types.h>
9#include <linux/crypto.h>
10
11#define BF_BLOCK_SIZE 8
12#define BF_MIN_KEY_SIZE 4
13#define BF_MAX_KEY_SIZE 56
14
15struct bf_ctx {
16 u32 p[18];
17 u32 s[1024];
18};
19
20int blowfish_setkey(struct crypto_tfm *tfm, const u8 *key,
21 unsigned int key_len);
22
23#endif
diff --git a/include/crypto/cast5.h b/include/crypto/cast5.h
deleted file mode 100644
index 14fbf39d638..00000000000
--- a/include/crypto/cast5.h
+++ /dev/null
@@ -1,23 +0,0 @@
1#ifndef _CRYPTO_CAST5_H
2#define _CRYPTO_CAST5_H
3
4#include <linux/types.h>
5#include <linux/crypto.h>
6#include <crypto/cast_common.h>
7
8#define CAST5_BLOCK_SIZE 8
9#define CAST5_MIN_KEY_SIZE 5
10#define CAST5_MAX_KEY_SIZE 16
11
12struct cast5_ctx {
13 u32 Km[16];
14 u8 Kr[16];
15 int rr; /* rr ? rounds = 12 : rounds = 16; (rfc 2144) */
16};
17
18int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
19
20void __cast5_encrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src);
21void __cast5_decrypt(struct cast5_ctx *ctx, u8 *dst, const u8 *src);
22
23#endif
diff --git a/include/crypto/cast6.h b/include/crypto/cast6.h
deleted file mode 100644
index 32b60eb8bd2..00000000000
--- a/include/crypto/cast6.h
+++ /dev/null
@@ -1,24 +0,0 @@
1#ifndef _CRYPTO_CAST6_H
2#define _CRYPTO_CAST6_H
3
4#include <linux/types.h>
5#include <linux/crypto.h>
6#include <crypto/cast_common.h>
7
8#define CAST6_BLOCK_SIZE 16
9#define CAST6_MIN_KEY_SIZE 16
10#define CAST6_MAX_KEY_SIZE 32
11
12struct cast6_ctx {
13 u32 Km[12][4];
14 u8 Kr[12][4];
15};
16
17int __cast6_setkey(struct cast6_ctx *ctx, const u8 *key,
18 unsigned int keylen, u32 *flags);
19int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
20
21void __cast6_encrypt(struct cast6_ctx *ctx, u8 *dst, const u8 *src);
22void __cast6_decrypt(struct cast6_ctx *ctx, u8 *dst, const u8 *src);
23
24#endif
diff --git a/include/crypto/cast_common.h b/include/crypto/cast_common.h
deleted file mode 100644
index b7df35cd9f0..00000000000
--- a/include/crypto/cast_common.h
+++ /dev/null
@@ -1,9 +0,0 @@
1#ifndef _CRYPTO_CAST_COMMON_H
2#define _CRYPTO_CAST_COMMON_H
3
4extern const u32 cast_s1[256];
5extern const u32 cast_s2[256];
6extern const u32 cast_s3[256];
7extern const u32 cast_s4[256];
8
9#endif
diff --git a/include/crypto/internal/aead.h b/include/crypto/internal/aead.h
index 2eba340230a..d838c945575 100644
--- a/include/crypto/internal/aead.h
+++ b/include/crypto/internal/aead.h
@@ -31,8 +31,6 @@ static inline void crypto_set_aead_spawn(
31 crypto_set_spawn(&spawn->base, inst); 31 crypto_set_spawn(&spawn->base, inst);
32} 32}
33 33
34struct crypto_alg *crypto_lookup_aead(const char *name, u32 type, u32 mask);
35
36int crypto_grab_aead(struct crypto_aead_spawn *spawn, const char *name, 34int crypto_grab_aead(struct crypto_aead_spawn *spawn, const char *name,
37 u32 type, u32 mask); 35 u32 type, u32 mask);
38 36
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h
index 821eae8cbd8..5bfad8c8059 100644
--- a/include/crypto/internal/hash.h
+++ b/include/crypto/internal/hash.h
@@ -83,8 +83,6 @@ struct hash_alg_common *ahash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
83 83
84int crypto_register_shash(struct shash_alg *alg); 84int crypto_register_shash(struct shash_alg *alg);
85int crypto_unregister_shash(struct shash_alg *alg); 85int crypto_unregister_shash(struct shash_alg *alg);
86int crypto_register_shashes(struct shash_alg *algs, int count);
87int crypto_unregister_shashes(struct shash_alg *algs, int count);
88int shash_register_instance(struct crypto_template *tmpl, 86int shash_register_instance(struct crypto_template *tmpl,
89 struct shash_instance *inst); 87 struct shash_instance *inst);
90void shash_free_instance(struct crypto_instance *inst); 88void shash_free_instance(struct crypto_instance *inst);
diff --git a/include/crypto/internal/skcipher.h b/include/crypto/internal/skcipher.h
index 06e8b32d541..3a748a6bf77 100644
--- a/include/crypto/internal/skcipher.h
+++ b/include/crypto/internal/skcipher.h
@@ -34,8 +34,6 @@ static inline void crypto_set_skcipher_spawn(
34int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, 34int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name,
35 u32 type, u32 mask); 35 u32 type, u32 mask);
36 36
37struct crypto_alg *crypto_lookup_skcipher(const char *name, u32 type, u32 mask);
38
39static inline void crypto_drop_skcipher(struct crypto_skcipher_spawn *spawn) 37static inline void crypto_drop_skcipher(struct crypto_skcipher_spawn *spawn)
40{ 38{
41 crypto_drop_spawn(&spawn->base); 39 crypto_drop_spawn(&spawn->base);
diff --git a/include/crypto/lrw.h b/include/crypto/lrw.h
deleted file mode 100644
index 25a2c871637..00000000000
--- a/include/crypto/lrw.h
+++ /dev/null
@@ -1,43 +0,0 @@
1#ifndef _CRYPTO_LRW_H
2#define _CRYPTO_LRW_H
3
4#include <crypto/b128ops.h>
5
6struct scatterlist;
7struct gf128mul_64k;
8struct blkcipher_desc;
9
10#define LRW_BLOCK_SIZE 16
11
12struct lrw_table_ctx {
13 /* optimizes multiplying a random (non incrementing, as at the
14 * start of a new sector) value with key2, we could also have
15 * used 4k optimization tables or no optimization at all. In the
16 * latter case we would have to store key2 here */
17 struct gf128mul_64k *table;
18 /* stores:
19 * key2*{ 0,0,...0,0,0,0,1 }, key2*{ 0,0,...0,0,0,1,1 },
20 * key2*{ 0,0,...0,0,1,1,1 }, key2*{ 0,0,...0,1,1,1,1 }
21 * key2*{ 0,0,...1,1,1,1,1 }, etc
22 * needed for optimized multiplication of incrementing values
23 * with key2 */
24 be128 mulinc[128];
25};
26
27int lrw_init_table(struct lrw_table_ctx *ctx, const u8 *tweak);
28void lrw_free_table(struct lrw_table_ctx *ctx);
29
30struct lrw_crypt_req {
31 be128 *tbuf;
32 unsigned int tbuflen;
33
34 struct lrw_table_ctx *table_ctx;
35 void *crypt_ctx;
36 void (*crypt_fn)(void *ctx, u8 *blks, unsigned int nbytes);
37};
38
39int lrw_crypt(struct blkcipher_desc *desc, struct scatterlist *dst,
40 struct scatterlist *src, unsigned int nbytes,
41 struct lrw_crypt_req *req);
42
43#endif /* _CRYPTO_LRW_H */
diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
deleted file mode 100644
index f5b0224c996..00000000000
--- a/include/crypto/public_key.h
+++ /dev/null
@@ -1,108 +0,0 @@
1/* Asymmetric public-key algorithm definitions
2 *
3 * See Documentation/crypto/asymmetric-keys.txt
4 *
5 * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
6 * Written by David Howells (dhowells@redhat.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public Licence
10 * as published by the Free Software Foundation; either version
11 * 2 of the Licence, or (at your option) any later version.
12 */
13
14#ifndef _LINUX_PUBLIC_KEY_H
15#define _LINUX_PUBLIC_KEY_H
16
17#include <linux/mpi.h>
18
19enum pkey_algo {
20 PKEY_ALGO_DSA,
21 PKEY_ALGO_RSA,
22 PKEY_ALGO__LAST
23};
24
25extern const char *const pkey_algo[PKEY_ALGO__LAST];
26
27enum pkey_hash_algo {
28 PKEY_HASH_MD4,
29 PKEY_HASH_MD5,
30 PKEY_HASH_SHA1,
31 PKEY_HASH_RIPE_MD_160,
32 PKEY_HASH_SHA256,
33 PKEY_HASH_SHA384,
34 PKEY_HASH_SHA512,
35 PKEY_HASH_SHA224,
36 PKEY_HASH__LAST
37};
38
39extern const char *const pkey_hash_algo[PKEY_HASH__LAST];
40
41enum pkey_id_type {
42 PKEY_ID_PGP, /* OpenPGP generated key ID */
43 PKEY_ID_X509, /* X.509 arbitrary subjectKeyIdentifier */
44 PKEY_ID_TYPE__LAST
45};
46
47extern const char *const pkey_id_type[PKEY_ID_TYPE__LAST];
48
49/*
50 * Cryptographic data for the public-key subtype of the asymmetric key type.
51 *
52 * Note that this may include private part of the key as well as the public
53 * part.
54 */
55struct public_key {
56 const struct public_key_algorithm *algo;
57 u8 capabilities;
58#define PKEY_CAN_ENCRYPT 0x01
59#define PKEY_CAN_DECRYPT 0x02
60#define PKEY_CAN_SIGN 0x04
61#define PKEY_CAN_VERIFY 0x08
62 enum pkey_id_type id_type : 8;
63 union {
64 MPI mpi[5];
65 struct {
66 MPI p; /* DSA prime */
67 MPI q; /* DSA group order */
68 MPI g; /* DSA group generator */
69 MPI y; /* DSA public-key value = g^x mod p */
70 MPI x; /* DSA secret exponent (if present) */
71 } dsa;
72 struct {
73 MPI n; /* RSA public modulus */
74 MPI e; /* RSA public encryption exponent */
75 MPI d; /* RSA secret encryption exponent (if present) */
76 MPI p; /* RSA secret prime (if present) */
77 MPI q; /* RSA secret prime (if present) */
78 } rsa;
79 };
80};
81
82extern void public_key_destroy(void *payload);
83
84/*
85 * Public key cryptography signature data
86 */
87struct public_key_signature {
88 u8 *digest;
89 u8 digest_size; /* Number of bytes in digest */
90 u8 nr_mpi; /* Occupancy of mpi[] */
91 enum pkey_hash_algo pkey_hash_algo : 8;
92 union {
93 MPI mpi[2];
94 struct {
95 MPI s; /* m^d mod n */
96 } rsa;
97 struct {
98 MPI r;
99 MPI s;
100 } dsa;
101 };
102};
103
104struct key;
105extern int verify_signature(const struct key *key,
106 const struct public_key_signature *sig);
107
108#endif /* _LINUX_PUBLIC_KEY_H */
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
index 3744d2a642d..4fd95a323be 100644
--- a/include/crypto/scatterwalk.h
+++ b/include/crypto/scatterwalk.h
@@ -25,6 +25,28 @@
25#include <linux/scatterlist.h> 25#include <linux/scatterlist.h>
26#include <linux/sched.h> 26#include <linux/sched.h>
27 27
28static inline enum km_type crypto_kmap_type(int out)
29{
30 enum km_type type;
31
32 if (in_softirq())
33 type = out * (KM_SOFTIRQ1 - KM_SOFTIRQ0) + KM_SOFTIRQ0;
34 else
35 type = out * (KM_USER1 - KM_USER0) + KM_USER0;
36
37 return type;
38}
39
40static inline void *crypto_kmap(struct page *page, int out)
41{
42 return kmap_atomic(page, crypto_kmap_type(out));
43}
44
45static inline void crypto_kunmap(void *vaddr, int out)
46{
47 kunmap_atomic(vaddr, crypto_kmap_type(out));
48}
49
28static inline void crypto_yield(u32 flags) 50static inline void crypto_yield(u32 flags)
29{ 51{
30 if (flags & CRYPTO_TFM_REQ_MAY_SLEEP) 52 if (flags & CRYPTO_TFM_REQ_MAY_SLEEP)
@@ -99,15 +121,15 @@ static inline struct page *scatterwalk_page(struct scatter_walk *walk)
99 return sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT); 121 return sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT);
100} 122}
101 123
102static inline void scatterwalk_unmap(void *vaddr) 124static inline void scatterwalk_unmap(void *vaddr, int out)
103{ 125{
104 kunmap_atomic(vaddr); 126 crypto_kunmap(vaddr, out);
105} 127}
106 128
107void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg); 129void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg);
108void scatterwalk_copychunks(void *buf, struct scatter_walk *walk, 130void scatterwalk_copychunks(void *buf, struct scatter_walk *walk,
109 size_t nbytes, int out); 131 size_t nbytes, int out);
110void *scatterwalk_map(struct scatter_walk *walk); 132void *scatterwalk_map(struct scatter_walk *walk, int out);
111void scatterwalk_done(struct scatter_walk *walk, int out, int more); 133void scatterwalk_done(struct scatter_walk *walk, int out, int more);
112 134
113void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg, 135void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
diff --git a/include/crypto/serpent.h b/include/crypto/serpent.h
deleted file mode 100644
index b7e0941eb6f..00000000000
--- a/include/crypto/serpent.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * Common values for serpent algorithms
3 */
4
5#ifndef _CRYPTO_SERPENT_H
6#define _CRYPTO_SERPENT_H
7
8#include <linux/types.h>
9#include <linux/crypto.h>
10
11#define SERPENT_MIN_KEY_SIZE 0
12#define SERPENT_MAX_KEY_SIZE 32
13#define SERPENT_EXPKEY_WORDS 132
14#define SERPENT_BLOCK_SIZE 16
15
16struct serpent_ctx {
17 u32 expkey[SERPENT_EXPKEY_WORDS];
18};
19
20int __serpent_setkey(struct serpent_ctx *ctx, const u8 *key,
21 unsigned int keylen);
22int serpent_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
23
24void __serpent_encrypt(struct serpent_ctx *ctx, u8 *dst, const u8 *src);
25void __serpent_decrypt(struct serpent_ctx *ctx, u8 *dst, const u8 *src);
26
27#endif
diff --git a/include/crypto/sha.h b/include/crypto/sha.h
index c6c9c1fe460..069e85ba97e 100644
--- a/include/crypto/sha.h
+++ b/include/crypto/sha.h
@@ -82,9 +82,4 @@ struct sha512_state {
82 u8 buf[SHA512_BLOCK_SIZE]; 82 u8 buf[SHA512_BLOCK_SIZE];
83}; 83};
84 84
85struct shash_desc;
86
87extern int crypto_sha1_update(struct shash_desc *desc, const u8 *data,
88 unsigned int len);
89
90#endif 85#endif
diff --git a/include/crypto/twofish.h b/include/crypto/twofish.h
index 095c901a8af..c408522595c 100644
--- a/include/crypto/twofish.h
+++ b/include/crypto/twofish.h
@@ -17,8 +17,6 @@ struct twofish_ctx {
17 u32 s[4][256], w[8], k[32]; 17 u32 s[4][256], w[8], k[32];
18}; 18};
19 19
20int __twofish_setkey(struct twofish_ctx *ctx, const u8 *key,
21 unsigned int key_len, u32 *flags);
22int twofish_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len); 20int twofish_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len);
23 21
24#endif 22#endif
diff --git a/include/crypto/vmac.h b/include/crypto/vmac.h
index 6b700c7b2fe..c4467c55df1 100644
--- a/include/crypto/vmac.h
+++ b/include/crypto/vmac.h
@@ -56,8 +56,6 @@ typedef u64 vmac_t;
56struct vmac_ctx_t { 56struct vmac_ctx_t {
57 struct crypto_cipher *child; 57 struct crypto_cipher *child;
58 struct vmac_ctx __vmac_ctx; 58 struct vmac_ctx __vmac_ctx;
59 u8 partial[VMAC_NHBYTES]; /* partial block */
60 int partial_size; /* size of the partial block */
61}; 59};
62 60
63#endif /* __CRYPTO_VMAC_H */ 61#endif /* __CRYPTO_VMAC_H */
diff --git a/include/crypto/xts.h b/include/crypto/xts.h
deleted file mode 100644
index 72c09eb5643..00000000000
--- a/include/crypto/xts.h
+++ /dev/null
@@ -1,27 +0,0 @@
1#ifndef _CRYPTO_XTS_H
2#define _CRYPTO_XTS_H
3
4#include <crypto/b128ops.h>
5
6struct scatterlist;
7struct blkcipher_desc;
8
9#define XTS_BLOCK_SIZE 16
10
11struct xts_crypt_req {
12 be128 *tbuf;
13 unsigned int tbuflen;
14
15 void *tweak_ctx;
16 void (*tweak_fn)(void *ctx, u8* dst, const u8* src);
17 void *crypt_ctx;
18 void (*crypt_fn)(void *ctx, u8 *blks, unsigned int nbytes);
19};
20
21#define XTS_TWEAK_CAST(x) ((void (*)(void *, u8*, const u8*))(x))
22
23int xts_crypt(struct blkcipher_desc *desc, struct scatterlist *dst,
24 struct scatterlist *src, unsigned int nbytes,
25 struct xts_crypt_req *req);
26
27#endif /* _CRYPTO_XTS_H */