mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6 into next
Pull crypto updates from Herbert Xu: "Here is the crypto update for 3.16: - Added test vectors for SHA/AES-CCM/DES-CBC/3DES-CBC. - Fixed a number of error-path memory leaks in tcrypt. - Fixed error-path memory leak in caam. - Removed unnecessary global mutex from mxs-dcp. - Added ahash walk interface that can actually be asynchronous. - Cleaned up caam error reporting. - Allow crypto_user get operation to be used by non-root users. - Add support for SSS module on Exynos. - Misc fixes" * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6: (60 commits) crypto: testmgr - add aead cbc des, des3_ede tests crypto: testmgr - Fix DMA-API warning crypto: cesa - tfm->__crt_alg->cra_type directly crypto: sahara - tfm->__crt_alg->cra_name directly crypto: padlock - tfm->__crt_alg->cra_name directly crypto: n2 - tfm->__crt_alg->cra_name directly crypto: dcp - tfm->__crt_alg->cra_name directly crypto: cesa - tfm->__crt_alg->cra_name directly crypto: ccp - tfm->__crt_alg->cra_name directly crypto: geode - Don't use tfm->__crt_alg->cra_name directly crypto: geode - Weed out printk() from probe() crypto: geode - Consistently use AES_KEYSIZE_128 crypto: geode - Kill AES_IV_LENGTH crypto: geode - Kill AES_MIN_BLOCK_SIZE crypto: mxs-dcp - Remove global mutex crypto: hash - Add real ahash walk interface hwrng: n2-drv - Introduce the use of the managed version of kzalloc crypto: caam - reinitialize keys_fit_inline for decrypt and givencrypt crypto: s5p-sss - fix multiplatform build hwrng: timeriomem - remove unnecessary OOM messages ...
This commit is contained in:
commit
639b4ac691
37 changed files with 2369 additions and 746 deletions
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <crypto/internal/hash.h>
|
||||
#include <crypto/scatterwalk.h>
|
||||
#include <linux/bug.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
|
@ -46,7 +47,10 @@ static int hash_walk_next(struct crypto_hash_walk *walk)
|
|||
unsigned int nbytes = min(walk->entrylen,
|
||||
((unsigned int)(PAGE_SIZE)) - offset);
|
||||
|
||||
walk->data = kmap_atomic(walk->pg);
|
||||
if (walk->flags & CRYPTO_ALG_ASYNC)
|
||||
walk->data = kmap(walk->pg);
|
||||
else
|
||||
walk->data = kmap_atomic(walk->pg);
|
||||
walk->data += offset;
|
||||
|
||||
if (offset & alignmask) {
|
||||
|
|
@ -93,8 +97,16 @@ int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err)
|
|||
return nbytes;
|
||||
}
|
||||
|
||||
kunmap_atomic(walk->data);
|
||||
crypto_yield(walk->flags);
|
||||
if (walk->flags & CRYPTO_ALG_ASYNC)
|
||||
kunmap(walk->pg);
|
||||
else {
|
||||
kunmap_atomic(walk->data);
|
||||
/*
|
||||
* The may sleep test only makes sense for sync users.
|
||||
* Async users don't need to sleep here anyway.
|
||||
*/
|
||||
crypto_yield(walk->flags);
|
||||
}
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
|
@ -124,12 +136,31 @@ int crypto_hash_walk_first(struct ahash_request *req,
|
|||
|
||||
walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
|
||||
walk->sg = req->src;
|
||||
walk->flags = req->base.flags;
|
||||
walk->flags = req->base.flags & CRYPTO_TFM_REQ_MASK;
|
||||
|
||||
return hash_walk_new_entry(walk);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_hash_walk_first);
|
||||
|
||||
int crypto_ahash_walk_first(struct ahash_request *req,
|
||||
struct crypto_hash_walk *walk)
|
||||
{
|
||||
walk->total = req->nbytes;
|
||||
|
||||
if (!walk->total)
|
||||
return 0;
|
||||
|
||||
walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
|
||||
walk->sg = req->src;
|
||||
walk->flags = req->base.flags & CRYPTO_TFM_REQ_MASK;
|
||||
walk->flags |= CRYPTO_ALG_ASYNC;
|
||||
|
||||
BUILD_BUG_ON(CRYPTO_TFM_REQ_MASK & CRYPTO_ALG_ASYNC);
|
||||
|
||||
return hash_walk_new_entry(walk);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_ahash_walk_first);
|
||||
|
||||
int crypto_hash_walk_first_compat(struct hash_desc *hdesc,
|
||||
struct crypto_hash_walk *walk,
|
||||
struct scatterlist *sg, unsigned int len)
|
||||
|
|
@ -141,7 +172,7 @@ int crypto_hash_walk_first_compat(struct hash_desc *hdesc,
|
|||
|
||||
walk->alignmask = crypto_hash_alignmask(hdesc->tfm);
|
||||
walk->sg = sg;
|
||||
walk->flags = hdesc->flags;
|
||||
walk->flags = hdesc->flags & CRYPTO_TFM_REQ_MASK;
|
||||
|
||||
return hash_walk_new_entry(walk);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||
struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
|
||||
LIST_HEAD(list);
|
||||
|
||||
if (!netlink_capable(skb, CAP_NET_ADMIN))
|
||||
return -EPERM;
|
||||
|
||||
if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
|
||||
return -EINVAL;
|
||||
|
||||
|
|
@ -295,6 +298,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||
struct crypto_alg *alg;
|
||||
struct crypto_user_alg *p = nlmsg_data(nlh);
|
||||
|
||||
if (!netlink_capable(skb, CAP_NET_ADMIN))
|
||||
return -EPERM;
|
||||
|
||||
if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
|
||||
return -EINVAL;
|
||||
|
||||
|
|
@ -379,6 +385,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||
struct crypto_user_alg *p = nlmsg_data(nlh);
|
||||
struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
|
||||
|
||||
if (!netlink_capable(skb, CAP_NET_ADMIN))
|
||||
return -EPERM;
|
||||
|
||||
if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
|
||||
return -EINVAL;
|
||||
|
||||
|
|
@ -466,9 +475,6 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
|
|||
type -= CRYPTO_MSG_BASE;
|
||||
link = &crypto_dispatch[type];
|
||||
|
||||
if (!netlink_capable(skb, CAP_NET_ADMIN))
|
||||
return -EPERM;
|
||||
|
||||
if ((type == (CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE) &&
|
||||
(nlh->nlmsg_flags & NLM_F_DUMP))) {
|
||||
struct crypto_alg *alg;
|
||||
|
|
|
|||
|
|
@ -282,6 +282,11 @@ static void test_aead_speed(const char *algo, int enc, unsigned int sec,
|
|||
unsigned int *b_size;
|
||||
unsigned int iv_len;
|
||||
|
||||
if (aad_size >= PAGE_SIZE) {
|
||||
pr_err("associate data length (%u) too big\n", aad_size);
|
||||
return;
|
||||
}
|
||||
|
||||
if (enc == ENCRYPT)
|
||||
e = "encryption";
|
||||
else
|
||||
|
|
@ -308,14 +313,14 @@ static void test_aead_speed(const char *algo, int enc, unsigned int sec,
|
|||
if (IS_ERR(tfm)) {
|
||||
pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo,
|
||||
PTR_ERR(tfm));
|
||||
return;
|
||||
goto out_notfm;
|
||||
}
|
||||
|
||||
req = aead_request_alloc(tfm, GFP_KERNEL);
|
||||
if (!req) {
|
||||
pr_err("alg: aead: Failed to allocate request for %s\n",
|
||||
algo);
|
||||
goto out;
|
||||
goto out_noreq;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
|
@ -323,14 +328,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int sec,
|
|||
b_size = aead_sizes;
|
||||
do {
|
||||
assoc = axbuf[0];
|
||||
|
||||
if (aad_size < PAGE_SIZE)
|
||||
memset(assoc, 0xff, aad_size);
|
||||
else {
|
||||
pr_err("associate data length (%u) too big\n",
|
||||
aad_size);
|
||||
goto out_nosg;
|
||||
}
|
||||
memset(assoc, 0xff, aad_size);
|
||||
sg_init_one(&asg[0], assoc, aad_size);
|
||||
|
||||
if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
|
||||
|
|
@ -392,7 +390,10 @@ static void test_aead_speed(const char *algo, int enc, unsigned int sec,
|
|||
} while (*keysize);
|
||||
|
||||
out:
|
||||
aead_request_free(req);
|
||||
out_noreq:
|
||||
crypto_free_aead(tfm);
|
||||
out_notfm:
|
||||
kfree(sg);
|
||||
out_nosg:
|
||||
testmgr_free_buf(xoutbuf);
|
||||
|
|
@ -1518,7 +1519,36 @@ static int do_test(int m)
|
|||
case 157:
|
||||
ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))");
|
||||
break;
|
||||
|
||||
case 181:
|
||||
ret += tcrypt_test("authenc(hmac(sha1),cbc(des))");
|
||||
break;
|
||||
case 182:
|
||||
ret += tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))");
|
||||
break;
|
||||
case 183:
|
||||
ret += tcrypt_test("authenc(hmac(sha224),cbc(des))");
|
||||
break;
|
||||
case 184:
|
||||
ret += tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))");
|
||||
break;
|
||||
case 185:
|
||||
ret += tcrypt_test("authenc(hmac(sha256),cbc(des))");
|
||||
break;
|
||||
case 186:
|
||||
ret += tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))");
|
||||
break;
|
||||
case 187:
|
||||
ret += tcrypt_test("authenc(hmac(sha384),cbc(des))");
|
||||
break;
|
||||
case 188:
|
||||
ret += tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))");
|
||||
break;
|
||||
case 189:
|
||||
ret += tcrypt_test("authenc(hmac(sha512),cbc(des))");
|
||||
break;
|
||||
case 190:
|
||||
ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))");
|
||||
break;
|
||||
case 200:
|
||||
test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_16_24_32);
|
||||
|
|
|
|||
181
crypto/testmgr.c
181
crypto/testmgr.c
|
|
@ -414,16 +414,18 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
|
|||
void *input;
|
||||
void *output;
|
||||
void *assoc;
|
||||
char iv[MAX_IVLEN];
|
||||
char *iv;
|
||||
char *xbuf[XBUFSIZE];
|
||||
char *xoutbuf[XBUFSIZE];
|
||||
char *axbuf[XBUFSIZE];
|
||||
|
||||
iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
|
||||
if (!iv)
|
||||
return ret;
|
||||
if (testmgr_alloc_buf(xbuf))
|
||||
goto out_noxbuf;
|
||||
if (testmgr_alloc_buf(axbuf))
|
||||
goto out_noaxbuf;
|
||||
|
||||
if (diff_dst && testmgr_alloc_buf(xoutbuf))
|
||||
goto out_nooutbuf;
|
||||
|
||||
|
|
@ -767,6 +769,7 @@ out_nooutbuf:
|
|||
out_noaxbuf:
|
||||
testmgr_free_buf(xbuf);
|
||||
out_noxbuf:
|
||||
kfree(iv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1831,8 +1834,38 @@ static const struct alg_test_desc alg_test_descs[] = {
|
|||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs = hmac_sha1_aes_cbc_enc_tv_template,
|
||||
.count = HMAC_SHA1_AES_CBC_ENC_TEST_VECTORS
|
||||
.vecs =
|
||||
hmac_sha1_aes_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA1_AES_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "authenc(hmac(sha1),cbc(des))",
|
||||
.test = alg_test_aead,
|
||||
.fips_allowed = 1,
|
||||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs =
|
||||
hmac_sha1_des_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA1_DES_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "authenc(hmac(sha1),cbc(des3_ede))",
|
||||
.test = alg_test_aead,
|
||||
.fips_allowed = 1,
|
||||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs =
|
||||
hmac_sha1_des3_ede_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA1_DES3_EDE_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1843,12 +1876,44 @@ static const struct alg_test_desc alg_test_descs[] = {
|
|||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs = hmac_sha1_ecb_cipher_null_enc_tv_template,
|
||||
.count = HMAC_SHA1_ECB_CIPHER_NULL_ENC_TEST_VECTORS
|
||||
.vecs =
|
||||
hmac_sha1_ecb_cipher_null_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA1_ECB_CIPHER_NULL_ENC_TEST_VEC
|
||||
},
|
||||
.dec = {
|
||||
.vecs = hmac_sha1_ecb_cipher_null_dec_tv_template,
|
||||
.count = HMAC_SHA1_ECB_CIPHER_NULL_DEC_TEST_VECTORS
|
||||
.vecs =
|
||||
hmac_sha1_ecb_cipher_null_dec_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA1_ECB_CIPHER_NULL_DEC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "authenc(hmac(sha224),cbc(des))",
|
||||
.test = alg_test_aead,
|
||||
.fips_allowed = 1,
|
||||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs =
|
||||
hmac_sha224_des_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA224_DES_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "authenc(hmac(sha224),cbc(des3_ede))",
|
||||
.test = alg_test_aead,
|
||||
.fips_allowed = 1,
|
||||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs =
|
||||
hmac_sha224_des3_ede_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA224_DES3_EDE_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1859,8 +1924,66 @@ static const struct alg_test_desc alg_test_descs[] = {
|
|||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs = hmac_sha256_aes_cbc_enc_tv_template,
|
||||
.count = HMAC_SHA256_AES_CBC_ENC_TEST_VECTORS
|
||||
.vecs =
|
||||
hmac_sha256_aes_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA256_AES_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "authenc(hmac(sha256),cbc(des))",
|
||||
.test = alg_test_aead,
|
||||
.fips_allowed = 1,
|
||||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs =
|
||||
hmac_sha256_des_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA256_DES_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "authenc(hmac(sha256),cbc(des3_ede))",
|
||||
.test = alg_test_aead,
|
||||
.fips_allowed = 1,
|
||||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs =
|
||||
hmac_sha256_des3_ede_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA256_DES3_EDE_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "authenc(hmac(sha384),cbc(des))",
|
||||
.test = alg_test_aead,
|
||||
.fips_allowed = 1,
|
||||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs =
|
||||
hmac_sha384_des_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA384_DES_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "authenc(hmac(sha384),cbc(des3_ede))",
|
||||
.test = alg_test_aead,
|
||||
.fips_allowed = 1,
|
||||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs =
|
||||
hmac_sha384_des3_ede_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA384_DES3_EDE_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1871,8 +1994,38 @@ static const struct alg_test_desc alg_test_descs[] = {
|
|||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs = hmac_sha512_aes_cbc_enc_tv_template,
|
||||
.count = HMAC_SHA512_AES_CBC_ENC_TEST_VECTORS
|
||||
.vecs =
|
||||
hmac_sha512_aes_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA512_AES_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "authenc(hmac(sha512),cbc(des))",
|
||||
.test = alg_test_aead,
|
||||
.fips_allowed = 1,
|
||||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs =
|
||||
hmac_sha512_des_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA512_DES_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "authenc(hmac(sha512),cbc(des3_ede))",
|
||||
.test = alg_test_aead,
|
||||
.fips_allowed = 1,
|
||||
.suite = {
|
||||
.aead = {
|
||||
.enc = {
|
||||
.vecs =
|
||||
hmac_sha512_des3_ede_cbc_enc_tv_temp,
|
||||
.count =
|
||||
HMAC_SHA512_DES3_EDE_CBC_ENC_TEST_VEC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3273,8 +3426,8 @@ test_done:
|
|||
panic("%s: %s alg self test failed in fips mode!\n", driver, alg);
|
||||
|
||||
if (fips_enabled && !rc)
|
||||
printk(KERN_INFO "alg: self-tests for %s (%s) passed\n",
|
||||
driver, alg);
|
||||
pr_info(KERN_INFO "alg: self-tests for %s (%s) passed\n",
|
||||
driver, alg);
|
||||
|
||||
return rc;
|
||||
|
||||
|
|
|
|||
1441
crypto/testmgr.h
1441
crypto/testmgr.h
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue