iPXE
|
X25519 key exchange. More...
Go to the source code of this file.
Data Structures | |
union | x25519_oct258 |
An X25519 unsigned 258-bit integer. More... | |
union | x25519_quad257 |
An X25519 unsigned 257-bit integer. More... | |
struct | x25519_value |
An X25519 32-byte value. More... | |
Macros | |
#define | X25519_SIZE bigint_required_size ( ( 267 /* bits */ + 7 ) / 8 ) |
X25519 unsigned big integer size. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
typedef | bigint_t (X25519_SIZE) x25519_t |
An X25519 unsigned big integer used in internal calculations. More... | |
void | x25519_multiply (const union x25519_oct258 *multiplicand, const union x25519_oct258 *multiplier, union x25519_quad257 *result) |
Multiply big integers modulo field prime. More... | |
void | x25519_invert (const union x25519_oct258 *invertend, union x25519_quad257 *result) |
Compute multiplicative inverse. More... | |
void | x25519_reduce (union x25519_quad257 *value) |
Reduce big integer to canonical range. More... | |
int | x25519_key (const struct x25519_value *base, const struct x25519_value *scalar, struct x25519_value *result) |
Calculate X25519 key. More... | |
Variables | |
struct elliptic_curve | x25519_curve |
X25519 elliptic curve. More... | |
X25519 key exchange.
Definition in file x25519.h.
#define X25519_SIZE bigint_required_size ( ( 267 /* bits */ + 7 ) / 8 ) |
X25519 unsigned big integer size.
X25519 uses the finite field of integers modulo the prime p=2^255-19. The canonical representations of integers in this field therefore require only 255 bits.
For internal calculations we use big integers containing up to 267 bits, since this ends up allowing us to avoid some unnecessary (and expensive) intermediate reductions modulo p.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
typedef bigint_t | ( | X25519_SIZE | ) |
An X25519 unsigned big integer used in internal calculations.
Referenced by bigint_add_sample(), bigint_bit_is_set_sample(), bigint_copy_sample(), bigint_done_sample(), bigint_grow_sample(), bigint_init_sample(), bigint_is_geq_sample(), bigint_is_zero_sample(), bigint_max_set_bit_sample(), bigint_mod_exp_raw(), bigint_mod_exp_sample(), bigint_mod_multiply_raw(), bigint_mod_multiply_sample(), bigint_multiply_raw(), bigint_multiply_sample(), bigint_rol_sample(), bigint_ror_sample(), bigint_shrink_sample(), bigint_subtract_sample(), bigint_swap_sample(), dhe_key(), rsa_alloc(), rsa_cipher(), and rsa_init().
void x25519_multiply | ( | const union x25519_oct258 * | multiplicand, |
const union x25519_oct258 * | multiplier, | ||
union x25519_quad257 * | result | ||
) |
Multiply big integers modulo field prime.
multiplicand | Big integer to be multiplied |
multiplier | Big integer to be multiplied |
result | Big integer to hold result (may overlap either input) |
Definition at line 425 of file x25519.c.
References bigint_add, bigint_grow, bigint_multiply, memset(), multiplier, x25519_multiply_step1::parts, x25519_multiply_step2::parts, result, static_assert, tmp, and x25519_oct258::value.
Referenced by x25519_invert(), x25519_invert_okx(), x25519_ladder(), x25519_multiply_okx(), and x25519_step().
void x25519_invert | ( | const union x25519_oct258 * | invertend, |
union x25519_quad257 * | result | ||
) |
Compute multiplicative inverse.
invertend | Big integer to be inverted |
result | Big integer to hold result (may not overlap input) |
Definition at line 527 of file x25519.c.
References assert(), bigint_copy, result, x25519_oct258::value, and x25519_multiply().
Referenced by x25519_invert_okx(), and x25519_ladder().
void x25519_reduce | ( | union x25519_quad257 * | value | ) |
Reduce big integer to canonical range.
value | Big integer to be reduced |
Definition at line 584 of file x25519.c.
References value, x25519_2p, x25519_p, and x25519_reduce_by().
Referenced by x25519_invert_okx(), x25519_ladder(), and x25519_multiply_okx().
int x25519_key | ( | const struct x25519_value * | base, |
const struct x25519_value * | scalar, | ||
struct x25519_value * | result | ||
) |
Calculate X25519 key.
base | Base point |
scalar | Scalar multiple |
result | Point to hold result (may overlap base point) |
rc | Return status code |
Definition at line 793 of file x25519.c.
References base, bigint_done, bigint_init, bigint_is_zero, EPERM, memcpy(), result, tmp, x25519_quad257::value, x25519_ladder(), and x25519_reverse().
Referenced by x25519_curve_multiply(), and x25519_key_okx().
struct elliptic_curve x25519_curve |