Skip to content

Commit

Permalink
crypto: ecc - add curve25519 params and expose them
Browse files Browse the repository at this point in the history
1. Add curve 25519 parameters in 'crypto/ecc_curve_defs.h';
2. Add curve25519 interface 'ecc_get_curve25519_param' in
   'include/crypto/ecc_curve.h', to make its parameters be
   exposed to everyone in kernel tree.

Signed-off-by: Meng Yu <[email protected]>
Reviewed-by: Zaibo Xu <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
yumeng0117 authored and herbertx committed Mar 12, 2021
1 parent 05e7b90 commit 8fb9340
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crypto/ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ typedef struct {
u64 m_high;
} uint128_t;

/* Returns curv25519 curve param */
const struct ecc_curve *ecc_get_curve25519(void)
{
return &ecc_25519;
}
EXPORT_SYMBOL(ecc_get_curve25519);

const struct ecc_curve *ecc_get_curve(unsigned int curve_id)
{
Expand Down
17 changes: 17 additions & 0 deletions crypto/ecc_curve_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,21 @@ static struct ecc_curve nist_p256 = {
.b = nist_p256_b
};

/* curve25519 */
static u64 curve25519_g_x[] = { 0x0000000000000009, 0x0000000000000000,
0x0000000000000000, 0x0000000000000000 };
static u64 curve25519_p[] = { 0xffffffffffffffed, 0xffffffffffffffff,
0xffffffffffffffff, 0x7fffffffffffffff };
static u64 curve25519_a[] = { 0x000000000001DB41, 0x0000000000000000,
0x0000000000000000, 0x0000000000000000 };
static const struct ecc_curve ecc_25519 = {
.name = "curve25519",
.g = {
.x = curve25519_g_x,
.ndigits = 4,
},
.p = curve25519_p,
.a = curve25519_a,
};

#endif
7 changes: 7 additions & 0 deletions include/crypto/ecc_curve.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,11 @@ struct ecc_curve {
*/
const struct ecc_curve *ecc_get_curve(unsigned int curve_id);

/**
* ecc_get_curve25519() - get curve25519 curve;
*
* Returns curve25519
*/
const struct ecc_curve *ecc_get_curve25519(void);

#endif

0 comments on commit 8fb9340

Please sign in to comment.