mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
crypto: ecdsa - Register NIST P384 and extend test suite
Register NIST P384 as an akcipher and extend the testmgr with NIST P384-specific test vectors. Summary of changes: * crypto/ecdsa.c - add ecdsa_nist_p384_init_tfm - register and unregister P384 tfm * crypto/testmgr.c - add test vector for P384 on vector of tests * crypto/testmgr.h - add test vector params for P384(sha1, sha224, sha256, sha384 and sha512) Signed-off-by: Saulo Alessandre <saulo.alessandre@tse.jus.br> Tested-by: Stefan Berger <stefanb@linux.ibm.com> Acked-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
committed by
Herbert Xu
parent
149ca1611d
commit
c12d448ba9
@@ -122,7 +122,7 @@ static int _ecdsa_verify(struct ecc_ctx *ctx, const u64 *hash, const u64 *r, con
|
||||
|
||||
/* res.x = res.x mod n (if res.x > order) */
|
||||
if (unlikely(vli_cmp(res.x, curve->n, ndigits) == 1))
|
||||
/* faster alternative for NIST p256 & p192 */
|
||||
/* faster alternative for NIST p384, p256 & p192 */
|
||||
vli_sub(res.x, res.x, curve->n, ndigits);
|
||||
|
||||
if (!vli_cmp(res.x, r, ndigits))
|
||||
@@ -265,6 +265,28 @@ static unsigned int ecdsa_max_size(struct crypto_akcipher *tfm)
|
||||
return ctx->pub_key.ndigits << ECC_DIGITS_TO_BYTES_SHIFT;
|
||||
}
|
||||
|
||||
static int ecdsa_nist_p384_init_tfm(struct crypto_akcipher *tfm)
|
||||
{
|
||||
struct ecc_ctx *ctx = akcipher_tfm_ctx(tfm);
|
||||
|
||||
return ecdsa_ecc_ctx_init(ctx, ECC_CURVE_NIST_P384);
|
||||
}
|
||||
|
||||
static struct akcipher_alg ecdsa_nist_p384 = {
|
||||
.verify = ecdsa_verify,
|
||||
.set_pub_key = ecdsa_set_pub_key,
|
||||
.max_size = ecdsa_max_size,
|
||||
.init = ecdsa_nist_p384_init_tfm,
|
||||
.exit = ecdsa_exit_tfm,
|
||||
.base = {
|
||||
.cra_name = "ecdsa-nist-p384",
|
||||
.cra_driver_name = "ecdsa-nist-p384-generic",
|
||||
.cra_priority = 100,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_ctxsize = sizeof(struct ecc_ctx),
|
||||
},
|
||||
};
|
||||
|
||||
static int ecdsa_nist_p256_init_tfm(struct crypto_akcipher *tfm)
|
||||
{
|
||||
struct ecc_ctx *ctx = akcipher_tfm_ctx(tfm);
|
||||
@@ -321,8 +343,16 @@ static int ecdsa_init(void)
|
||||
ret = crypto_register_akcipher(&ecdsa_nist_p256);
|
||||
if (ret)
|
||||
goto nist_p256_error;
|
||||
|
||||
ret = crypto_register_akcipher(&ecdsa_nist_p384);
|
||||
if (ret)
|
||||
goto nist_p384_error;
|
||||
|
||||
return 0;
|
||||
|
||||
nist_p384_error:
|
||||
crypto_unregister_akcipher(&ecdsa_nist_p256);
|
||||
|
||||
nist_p256_error:
|
||||
if (ecdsa_nist_p192_registered)
|
||||
crypto_unregister_akcipher(&ecdsa_nist_p192);
|
||||
@@ -334,6 +364,7 @@ static void ecdsa_exit(void)
|
||||
if (ecdsa_nist_p192_registered)
|
||||
crypto_unregister_akcipher(&ecdsa_nist_p192);
|
||||
crypto_unregister_akcipher(&ecdsa_nist_p256);
|
||||
crypto_unregister_akcipher(&ecdsa_nist_p384);
|
||||
}
|
||||
|
||||
subsys_initcall(ecdsa_init);
|
||||
|
Reference in New Issue
Block a user