From f64510b563c8c3d72360bde9720e22060d5db5c8 Mon Sep 17 00:00:00 2001 From: Yashpal Dutta Date: Thu, 6 Mar 2014 06:38:20 +0545 Subject: Added support for PKC keygen As a part of PKC support, RSA, DSA DH, ECDH, ECDSA requires key generation. The patch adds support for key generation support for DSA, ECDSA, DH, ECDH. Signed-off-by: Yashpal Dutta Change-Id: Ifc90734302e0b581db1b3c30f9e62266bb4674e7 Reviewed-on: http://git.am.freescale.net:8181/9545 Tested-by: Review Code-CDREVIEW Reviewed-by: Ruchika Gupta Reviewed-by: Jose Rivera diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 69e9b5c..038b556 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -39,6 +39,7 @@ #define CRYPTO_ALG_TYPE_HASH 0x00000008 #define CRYPTO_ALG_TYPE_SHASH 0x00000009 #define CRYPTO_ALG_TYPE_AHASH 0x0000000a +#define CRYPTO_ALG_TYPE_PKC_DH 0x0000000b #define CRYPTO_ALG_TYPE_RNG 0x0000000c #define CRYPTO_ALG_TYPE_PKC_DSA 0x0000000d #define CRYPTO_ALG_TYPE_PKC_RSA 0x0000000e @@ -186,6 +187,10 @@ enum pkc_req_type { DSA_VERIFY, ECDSA_SIGN, ECDSA_VERIFY, + DH_COMPUTE_KEY, + ECDH_COMPUTE_KEY, + DLC_KEYGEN, + ECC_KEYGEN, MAX_TYPES }; @@ -265,6 +270,85 @@ struct rsa_priv_frm3_req_s { uint32_t c_len; }; +/* DLC and ECC Keygen request + @len_L - size of the field + @len_N - size of the group + @q -Prime number or irreducible polynomial that creates the field,length L + @r - Order of the field of private keys, length N + @g -Generator or generator point (ECC),length L or 2*L(ECC) + @ab -ECC curve parameters(for ECC only). length 2*L + */ +struct keygen_req_s { + uint8_t *q; + uint8_t *r; + uint8_t *g; + uint8_t *priv_key; + uint8_t *pub_key; + uint8_t *ab; + uint32_t q_len; + uint32_t r_len; + uint32_t g_len; + uint32_t priv_key_len; + uint32_t pub_key_len; + uint32_t ab_len; +}; + +/* + * Temporary Changes to make cryptodev work with OC release + * To be simply removed after OC final release + */ +#define ECDSA_KEYGEN ECC_KEYGEN +#define ECDH_KEYGEN ECC_KEYGEN +#define DSA_KEYGEN DLC_KEYGEN +#define DH_KEYGEN DLC_KEYGEN + +/* + @len_L - size of the field + @len_N - size of the group + @q -Prime number or irreducible polynomial that creates the field,length L + @r - Order of the field of private keys, length N + @g -Generator or generator point (ECC),length L or 2*L(ECC) + @ab -ECC curve parameters(for ECC only). length 2*L + */ +struct dsa_keygen_req_s { + uint8_t *q; + uint8_t *r; + uint8_t *g; + uint8_t *prvkey; + uint8_t *pubkey; + uint8_t *ab; + uint32_t q_len; + uint32_t r_len; + uint32_t g_len; + uint32_t prvkey_len; + uint32_t pubkey_len; + uint32_t ab_len; +}; + + +/* + @len_L - size of the field + @len_N - size of the group + @q -Prime number or irreducible polynomial that creates the field,length L + @r - Order of the field of private keys, length N + @g -Generator or generator point (ECC),length L or 2*L(ECC) + @ab -ECC curve parameters(for ECC only). length 2*L + */ +struct dh_keygen_req_s { + uint8_t *q; + uint8_t *r; + uint8_t *g; + uint8_t *prvkey; + uint8_t *pubkey; + uint8_t *ab; + uint32_t q_len; + uint32_t r_len; + uint32_t g_len; + uint32_t prvkey_len; + uint32_t pubkey_len; + uint32_t ab_len; +}; + /* DSA Sign request @len_L - size of the field @len_N - size of the group @@ -329,6 +413,33 @@ struct dsa_verify_req_s { uint32_t ab_len; }; +/* DH Compute_Key request + @q -Prime number or irreducible polynomial that creates the field,length L + @a,b -ECC curve parameters, Length 2L + @pub_key - Public key of other party, length L or 2L + @s - Own private Key + @z - Shared secret output of Length L + */ +struct dh_key_req_s { + uint8_t *q; + uint8_t *ab; + uint8_t *pub_key; /* Other party;s public key */ + uint8_t *s; + uint8_t *z; + uint32_t q_len; + uint32_t ab_len; + uint32_t pub_key_len; + uint32_t s_len; + uint32_t z_len; +}; + +enum curve_t { + DISCRETE_LOG, + ECC_PRIME, + ECC_BINARY, + MAX_ECC_TYPE +}; + /* * PKC request structure to be provided by cryptoAPI to driver hook functions. * The request may be generated by application via crytodev interface or within @@ -338,6 +449,7 @@ struct pkc_request { struct crypto_async_request base; enum pkc_req_type type; + enum curve_t curve_type; union { struct rsa_pub_req_s rsa_pub_req; struct rsa_priv_frm1_req_s rsa_priv_f1; @@ -345,6 +457,10 @@ struct pkc_request { struct rsa_priv_frm3_req_s rsa_priv_f3; struct dsa_sign_req_s dsa_sign; struct dsa_verify_req_s dsa_verify; + struct keygen_req_s keygen; + struct dh_key_req_s dh_req; + struct dsa_keygen_req_s dsa_keygen; + struct dh_keygen_req_s dh_keygenreq; } req_u; }; -- cgit v0.10.2