From 6755fd269d5c100b0eca420db501ae58435efd6e Mon Sep 17 00:00:00 2001 From: Tudor-Dan Ambarus Date: Tue, 30 May 2017 17:52:48 +0300 Subject: crypto: ecdh - add privkey generation support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for generating ecc private keys. Generation of ecc private keys is helpful in a user-space to kernel ecdh offload because the keys are not revealed to user-space. Private key generation is also helpful to implement forward secrecy. If the user provides a NULL ecc private key, the kernel will generate it and further use it for ecdh. Move ecdh's object files below drbg's. drbg must be present in the kernel at the time of calling. Signed-off-by: Tudor Ambarus Reviewed-by: Stephan Müller Signed-off-by: Herbert Xu --- crypto/ecc.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'crypto/ecc.h') diff --git a/crypto/ecc.h b/crypto/ecc.h index e13fe8800ee8..e4fd4492c765 100644 --- a/crypto/ecc.h +++ b/crypto/ecc.h @@ -43,6 +43,20 @@ int ecc_is_key_valid(unsigned int curve_id, unsigned int ndigits, const u64 *private_key, unsigned int private_key_len); +/** + * ecc_gen_privkey() - Generates an ECC private key. + * The private key is a random integer in the range 0 < random < n, where n is a + * prime that is the order of the cyclic subgroup generated by the distinguished + * point G. + * @curve_id: id representing the curve to use + * @ndigits: curve number of digits + * @private_key: buffer for storing the generated private key + * + * Returns 0 if the private key was generated successfully, a negative value + * if an error occurred. + */ +int ecc_gen_privkey(unsigned int curve_id, unsigned int ndigits, u64 *privkey); + /** * ecc_make_pub_key() - Compute an ECC public key * -- cgit v1.2.3