diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-12-07 05:52:49 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2008-01-10 16:16:32 -0500 |
commit | 42c271c6c538857cb13c5ead5184d264d745f675 (patch) | |
tree | 9f6a05c756be3fc3f35ae7fe9b333a33986a2f56 | |
parent | fe70f5dfe1a7b5caab96531089dac3d8728c0ebd (diff) |
[CRYPTO] scatterwalk: Move scatterwalk.h to linux/crypto
The scatterwalk infrastructure is used by algorithms so it needs to
move out of crypto for future users that may live in drivers/crypto
or asm/*/crypto.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | crypto/authenc.c | 3 | ||||
-rw-r--r-- | crypto/blkcipher.c | 2 | ||||
-rw-r--r-- | crypto/digest.c | 3 | ||||
-rw-r--r-- | crypto/gcm.c | 3 | ||||
-rw-r--r-- | crypto/internal.h | 29 | ||||
-rw-r--r-- | crypto/scatterwalk.c | 5 | ||||
-rw-r--r-- | crypto/xcbc.c | 2 | ||||
-rw-r--r-- | include/crypto/scatterwalk.h (renamed from crypto/scatterwalk.h) | 36 |
8 files changed, 42 insertions, 41 deletions
diff --git a/crypto/authenc.c b/crypto/authenc.c index 6c9104ebf2f4..fbbc2b505a21 100644 --- a/crypto/authenc.c +++ b/crypto/authenc.c | |||
@@ -12,6 +12,7 @@ | |||
12 | 12 | ||
13 | #include <crypto/algapi.h> | 13 | #include <crypto/algapi.h> |
14 | #include <crypto/authenc.h> | 14 | #include <crypto/authenc.h> |
15 | #include <crypto/scatterwalk.h> | ||
15 | #include <linux/err.h> | 16 | #include <linux/err.h> |
16 | #include <linux/init.h> | 17 | #include <linux/init.h> |
17 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
@@ -20,8 +21,6 @@ | |||
20 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
21 | #include <linux/spinlock.h> | 22 | #include <linux/spinlock.h> |
22 | 23 | ||
23 | #include "scatterwalk.h" | ||
24 | |||
25 | struct authenc_instance_ctx { | 24 | struct authenc_instance_ctx { |
26 | struct crypto_spawn auth; | 25 | struct crypto_spawn auth; |
27 | struct crypto_spawn enc; | 26 | struct crypto_spawn enc; |
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c index 180d91451476..7939504dfd8b 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c | |||
@@ -14,6 +14,7 @@ | |||
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <crypto/scatterwalk.h> | ||
17 | #include <linux/crypto.h> | 18 | #include <linux/crypto.h> |
18 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
19 | #include <linux/hardirq.h> | 20 | #include <linux/hardirq.h> |
@@ -25,7 +26,6 @@ | |||
25 | #include <linux/string.h> | 26 | #include <linux/string.h> |
26 | 27 | ||
27 | #include "internal.h" | 28 | #include "internal.h" |
28 | #include "scatterwalk.h" | ||
29 | 29 | ||
30 | enum { | 30 | enum { |
31 | BLKCIPHER_WALK_PHYS = 1 << 0, | 31 | BLKCIPHER_WALK_PHYS = 1 << 0, |
diff --git a/crypto/digest.c b/crypto/digest.c index d3e827a141f1..52845f53f8e1 100644 --- a/crypto/digest.c +++ b/crypto/digest.c | |||
@@ -12,6 +12,7 @@ | |||
12 | * | 12 | * |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <crypto/scatterwalk.h> | ||
15 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
16 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
17 | #include <linux/hardirq.h> | 18 | #include <linux/hardirq.h> |
@@ -20,8 +21,6 @@ | |||
20 | #include <linux/module.h> | 21 | #include <linux/module.h> |
21 | #include <linux/scatterlist.h> | 22 | #include <linux/scatterlist.h> |
22 | 23 | ||
23 | #include "internal.h" | ||
24 | |||
25 | static int init(struct hash_desc *desc) | 24 | static int init(struct hash_desc *desc) |
26 | { | 25 | { |
27 | struct crypto_tfm *tfm = crypto_hash_tfm(desc->tfm); | 26 | struct crypto_tfm *tfm = crypto_hash_tfm(desc->tfm); |
diff --git a/crypto/gcm.c b/crypto/gcm.c index d60c340b0b9d..27483f361e80 100644 --- a/crypto/gcm.c +++ b/crypto/gcm.c | |||
@@ -10,13 +10,14 @@ | |||
10 | 10 | ||
11 | #include <crypto/algapi.h> | 11 | #include <crypto/algapi.h> |
12 | #include <crypto/gf128mul.h> | 12 | #include <crypto/gf128mul.h> |
13 | #include <crypto/scatterwalk.h> | ||
13 | #include <linux/err.h> | 14 | #include <linux/err.h> |
14 | #include <linux/init.h> | 15 | #include <linux/init.h> |
15 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
16 | #include <linux/module.h> | 17 | #include <linux/module.h> |
17 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
18 | 19 | ||
19 | #include "scatterwalk.h" | 20 | #include "internal.h" |
20 | 21 | ||
21 | struct gcm_instance_ctx { | 22 | struct gcm_instance_ctx { |
22 | struct crypto_spawn ctr; | 23 | struct crypto_spawn ctr; |
diff --git a/crypto/internal.h b/crypto/internal.h index abb01f71f817..cb13952f82bf 100644 --- a/crypto/internal.h +++ b/crypto/internal.h | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/notifier.h> | 25 | #include <linux/notifier.h> |
26 | #include <linux/rwsem.h> | 26 | #include <linux/rwsem.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <asm/kmap_types.h> | ||
29 | 28 | ||
30 | /* Crypto notification events. */ | 29 | /* Crypto notification events. */ |
31 | enum { | 30 | enum { |
@@ -50,34 +49,6 @@ extern struct list_head crypto_alg_list; | |||
50 | extern struct rw_semaphore crypto_alg_sem; | 49 | extern struct rw_semaphore crypto_alg_sem; |
51 | extern struct blocking_notifier_head crypto_chain; | 50 | extern struct blocking_notifier_head crypto_chain; |
52 | 51 | ||
53 | static inline enum km_type crypto_kmap_type(int out) | ||
54 | { | ||
55 | enum km_type type; | ||
56 | |||
57 | if (in_softirq()) | ||
58 | type = out * (KM_SOFTIRQ1 - KM_SOFTIRQ0) + KM_SOFTIRQ0; | ||
59 | else | ||
60 | type = out * (KM_USER1 - KM_USER0) + KM_USER0; | ||
61 | |||
62 | return type; | ||
63 | } | ||
64 | |||
65 | static inline void *crypto_kmap(struct page *page, int out) | ||
66 | { | ||
67 | return kmap_atomic(page, crypto_kmap_type(out)); | ||
68 | } | ||
69 | |||
70 | static inline void crypto_kunmap(void *vaddr, int out) | ||
71 | { | ||
72 | kunmap_atomic(vaddr, crypto_kmap_type(out)); | ||
73 | } | ||
74 | |||
75 | static inline void crypto_yield(u32 flags) | ||
76 | { | ||
77 | if (flags & CRYPTO_TFM_REQ_MAY_SLEEP) | ||
78 | cond_resched(); | ||
79 | } | ||
80 | |||
81 | #ifdef CONFIG_PROC_FS | 52 | #ifdef CONFIG_PROC_FS |
82 | void __init crypto_init_proc(void); | 53 | void __init crypto_init_proc(void); |
83 | void __exit crypto_exit_proc(void); | 54 | void __exit crypto_exit_proc(void); |
diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c index 206c39a97e57..12d19019e178 100644 --- a/crypto/scatterwalk.c +++ b/crypto/scatterwalk.c | |||
@@ -13,6 +13,8 @@ | |||
13 | * any later version. | 13 | * any later version. |
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | |||
17 | #include <crypto/scatterwalk.h> | ||
16 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
17 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
18 | #include <linux/module.h> | 20 | #include <linux/module.h> |
@@ -20,9 +22,6 @@ | |||
20 | #include <linux/highmem.h> | 22 | #include <linux/highmem.h> |
21 | #include <linux/scatterlist.h> | 23 | #include <linux/scatterlist.h> |
22 | 24 | ||
23 | #include "internal.h" | ||
24 | #include "scatterwalk.h" | ||
25 | |||
26 | static inline void memcpy_dir(void *buf, void *sgdata, size_t nbytes, int out) | 25 | static inline void memcpy_dir(void *buf, void *sgdata, size_t nbytes, int out) |
27 | { | 26 | { |
28 | void *src = out ? buf : sgdata; | 27 | void *src = out ? buf : sgdata; |
diff --git a/crypto/xcbc.c b/crypto/xcbc.c index ac68f3b62fde..789cdeee6b7d 100644 --- a/crypto/xcbc.c +++ b/crypto/xcbc.c | |||
@@ -19,6 +19,7 @@ | |||
19 | * Kazunori Miyazawa <miyazawa@linux-ipv6.org> | 19 | * Kazunori Miyazawa <miyazawa@linux-ipv6.org> |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <crypto/scatterwalk.h> | ||
22 | #include <linux/crypto.h> | 23 | #include <linux/crypto.h> |
23 | #include <linux/err.h> | 24 | #include <linux/err.h> |
24 | #include <linux/hardirq.h> | 25 | #include <linux/hardirq.h> |
@@ -27,7 +28,6 @@ | |||
27 | #include <linux/rtnetlink.h> | 28 | #include <linux/rtnetlink.h> |
28 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
29 | #include <linux/scatterlist.h> | 30 | #include <linux/scatterlist.h> |
30 | #include "internal.h" | ||
31 | 31 | ||
32 | static u_int32_t ks[12] = {0x01010101, 0x01010101, 0x01010101, 0x01010101, | 32 | static u_int32_t ks[12] = {0x01010101, 0x01010101, 0x01010101, 0x01010101, |
33 | 0x02020202, 0x02020202, 0x02020202, 0x02020202, | 33 | 0x02020202, 0x02020202, 0x02020202, 0x02020202, |
diff --git a/crypto/scatterwalk.h b/include/crypto/scatterwalk.h index fd5517d2a7a9..07b6f17122d2 100644 --- a/crypto/scatterwalk.h +++ b/include/crypto/scatterwalk.h | |||
@@ -1,9 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * Cryptographic API. | 2 | * Cryptographic scatter and gather helpers. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> | 4 | * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> |
5 | * Copyright (c) 2002 Adam J. Richter <adam@yggdrasil.com> | 5 | * Copyright (c) 2002 Adam J. Richter <adam@yggdrasil.com> |
6 | * Copyright (c) 2004 Jean-Luc Cooke <jlcooke@certainkey.com> | 6 | * Copyright (c) 2004 Jean-Luc Cooke <jlcooke@certainkey.com> |
7 | * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au> | ||
7 | * | 8 | * |
8 | * This program is free software; you can redistribute it and/or modify it | 9 | * This program is free software; you can redistribute it and/or modify it |
9 | * under the terms of the GNU General Public License as published by the Free | 10 | * under the terms of the GNU General Public License as published by the Free |
@@ -15,10 +16,41 @@ | |||
15 | #ifndef _CRYPTO_SCATTERWALK_H | 16 | #ifndef _CRYPTO_SCATTERWALK_H |
16 | #define _CRYPTO_SCATTERWALK_H | 17 | #define _CRYPTO_SCATTERWALK_H |
17 | 18 | ||
19 | #include <asm/kmap_types.h> | ||
20 | #include <crypto/algapi.h> | ||
21 | #include <linux/hardirq.h> | ||
22 | #include <linux/highmem.h> | ||
23 | #include <linux/kernel.h> | ||
18 | #include <linux/mm.h> | 24 | #include <linux/mm.h> |
19 | #include <linux/scatterlist.h> | 25 | #include <linux/scatterlist.h> |
20 | 26 | ||
21 | #include "internal.h" | 27 | static inline enum km_type crypto_kmap_type(int out) |
28 | { | ||
29 | enum km_type type; | ||
30 | |||
31 | if (in_softirq()) | ||
32 | type = out * (KM_SOFTIRQ1 - KM_SOFTIRQ0) + KM_SOFTIRQ0; | ||
33 | else | ||
34 | type = out * (KM_USER1 - KM_USER0) + KM_USER0; | ||
35 | |||
36 | return type; | ||
37 | } | ||
38 | |||
39 | static inline void *crypto_kmap(struct page *page, int out) | ||
40 | { | ||
41 | return kmap_atomic(page, crypto_kmap_type(out)); | ||
42 | } | ||
43 | |||
44 | static inline void crypto_kunmap(void *vaddr, int out) | ||
45 | { | ||
46 | kunmap_atomic(vaddr, crypto_kmap_type(out)); | ||
47 | } | ||
48 | |||
49 | static inline void crypto_yield(u32 flags) | ||
50 | { | ||
51 | if (flags & CRYPTO_TFM_REQ_MAY_SLEEP) | ||
52 | cond_resched(); | ||
53 | } | ||
22 | 54 | ||
23 | static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in, | 55 | static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in, |
24 | struct scatter_walk *walk_out) | 56 | struct scatter_walk *walk_out) |