diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-10-25 05:43:47 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-10-25 05:43:47 -0400 |
commit | 6913a9dbf18f08e3577695032da15812bda92b66 (patch) | |
tree | 05ca8620b11f2898022a7fd8a00f1f8566161428 /security/apparmor/crypto.c | |
parent | 7342017f4a0f129d277f78b8761f2732661ba30a (diff) | |
parent | 9645083ca5ef365b7b750cf219bb20b61bb925f8 (diff) |
Merge tag 'asoc-v3.13' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
ASoC: Updates for v3.13
- Further work on the dmaengine helpers, including support for
configuring the parameters for DMA by reading the capabilities of the
DMA controller which removes some guesswork and magic numbers fromm
drivers.
- A refresh of the documentation.
- Conversions of many drivers to direct regmap API usage in order to
allow the ASoC level register I/O code to be removed, this will
hopefully be completed by v3.14.
- Support for using async register I/O in DAPM, reducing the time taken
to implement power transitions on systems that support it.
Diffstat (limited to 'security/apparmor/crypto.c')
-rw-r--r-- | security/apparmor/crypto.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/security/apparmor/crypto.c b/security/apparmor/crypto.c index d6222ba4e919..532471d0b3a0 100644 --- a/security/apparmor/crypto.c +++ b/security/apparmor/crypto.c | |||
@@ -15,14 +15,14 @@ | |||
15 | * it should be. | 15 | * it should be. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/crypto.h> | 18 | #include <crypto/hash.h> |
19 | 19 | ||
20 | #include "include/apparmor.h" | 20 | #include "include/apparmor.h" |
21 | #include "include/crypto.h" | 21 | #include "include/crypto.h" |
22 | 22 | ||
23 | static unsigned int apparmor_hash_size; | 23 | static unsigned int apparmor_hash_size; |
24 | 24 | ||
25 | static struct crypto_hash *apparmor_tfm; | 25 | static struct crypto_shash *apparmor_tfm; |
26 | 26 | ||
27 | unsigned int aa_hash_size(void) | 27 | unsigned int aa_hash_size(void) |
28 | { | 28 | { |
@@ -32,35 +32,33 @@ unsigned int aa_hash_size(void) | |||
32 | int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start, | 32 | int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start, |
33 | size_t len) | 33 | size_t len) |
34 | { | 34 | { |
35 | struct scatterlist sg[2]; | 35 | struct { |
36 | struct hash_desc desc = { | 36 | struct shash_desc shash; |
37 | .tfm = apparmor_tfm, | 37 | char ctx[crypto_shash_descsize(apparmor_tfm)]; |
38 | .flags = 0 | 38 | } desc; |
39 | }; | ||
40 | int error = -ENOMEM; | 39 | int error = -ENOMEM; |
41 | u32 le32_version = cpu_to_le32(version); | 40 | u32 le32_version = cpu_to_le32(version); |
42 | 41 | ||
43 | if (!apparmor_tfm) | 42 | if (!apparmor_tfm) |
44 | return 0; | 43 | return 0; |
45 | 44 | ||
46 | sg_init_table(sg, 2); | ||
47 | sg_set_buf(&sg[0], &le32_version, 4); | ||
48 | sg_set_buf(&sg[1], (u8 *) start, len); | ||
49 | |||
50 | profile->hash = kzalloc(apparmor_hash_size, GFP_KERNEL); | 45 | profile->hash = kzalloc(apparmor_hash_size, GFP_KERNEL); |
51 | if (!profile->hash) | 46 | if (!profile->hash) |
52 | goto fail; | 47 | goto fail; |
53 | 48 | ||
54 | error = crypto_hash_init(&desc); | 49 | desc.shash.tfm = apparmor_tfm; |
50 | desc.shash.flags = 0; | ||
51 | |||
52 | error = crypto_shash_init(&desc.shash); | ||
55 | if (error) | 53 | if (error) |
56 | goto fail; | 54 | goto fail; |
57 | error = crypto_hash_update(&desc, &sg[0], 4); | 55 | error = crypto_shash_update(&desc.shash, (u8 *) &le32_version, 4); |
58 | if (error) | 56 | if (error) |
59 | goto fail; | 57 | goto fail; |
60 | error = crypto_hash_update(&desc, &sg[1], len); | 58 | error = crypto_shash_update(&desc.shash, (u8 *) start, len); |
61 | if (error) | 59 | if (error) |
62 | goto fail; | 60 | goto fail; |
63 | error = crypto_hash_final(&desc, profile->hash); | 61 | error = crypto_shash_final(&desc.shash, profile->hash); |
64 | if (error) | 62 | if (error) |
65 | goto fail; | 63 | goto fail; |
66 | 64 | ||
@@ -75,19 +73,19 @@ fail: | |||
75 | 73 | ||
76 | static int __init init_profile_hash(void) | 74 | static int __init init_profile_hash(void) |
77 | { | 75 | { |
78 | struct crypto_hash *tfm; | 76 | struct crypto_shash *tfm; |
79 | 77 | ||
80 | if (!apparmor_initialized) | 78 | if (!apparmor_initialized) |
81 | return 0; | 79 | return 0; |
82 | 80 | ||
83 | tfm = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC); | 81 | tfm = crypto_alloc_shash("sha1", 0, CRYPTO_ALG_ASYNC); |
84 | if (IS_ERR(tfm)) { | 82 | if (IS_ERR(tfm)) { |
85 | int error = PTR_ERR(tfm); | 83 | int error = PTR_ERR(tfm); |
86 | AA_ERROR("failed to setup profile sha1 hashing: %d\n", error); | 84 | AA_ERROR("failed to setup profile sha1 hashing: %d\n", error); |
87 | return error; | 85 | return error; |
88 | } | 86 | } |
89 | apparmor_tfm = tfm; | 87 | apparmor_tfm = tfm; |
90 | apparmor_hash_size = crypto_hash_digestsize(apparmor_tfm); | 88 | apparmor_hash_size = crypto_shash_digestsize(apparmor_tfm); |
91 | 89 | ||
92 | aa_info_message("AppArmor sha1 policy hashing enabled"); | 90 | aa_info_message("AppArmor sha1 policy hashing enabled"); |
93 | 91 | ||