iPXE
elliptic.h
Go to the documentation of this file.
1#ifndef _IPXE_ELLIPTIC_H
2#define _IPXE_ELLIPTIC_H
3
4/** @file
5 *
6 * Elliptic curves
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <ipxe/crypto.h>
15
16/** An uncompressed elliptic curve point */
17#define elliptic_uncompressed_t( len ) \
18 struct { \
19 uint8_t format; \
20 union { \
21 struct { \
22 uint8_t x[ (len) ]; \
23 uint8_t y[ (len) ]; \
24 } __attribute__ (( packed )); \
25 uint8_t xy[ (len) * 2 ]; \
26 }; \
27 } __attribute__ (( packed ))
28
29/** Format byte for uncompressed curve point representation */
30#define ELLIPTIC_FORMAT_UNCOMPRESSED 0x04
31
32extern int elliptic_share ( struct exchange_algorithm *exchange,
33 const void *private, void *public );
34extern int elliptic_agree ( struct exchange_algorithm *exchange,
35 const void *private, const void *partner,
36 void *shared );
37
38/** Define an uncompressed elliptic curve point key exchange algorithm */
39#define ELLIPTIC_EXCHANGE( _name, _exchange, _len, _curve ) \
40 struct exchange_algorithm _exchange = { \
41 .name = #_name, \
42 .privsize = (_len), \
43 .pubsize = sizeof ( elliptic_uncompressed_t (_len) ), \
44 .sharedsize = (_len), \
45 .share = elliptic_share, \
46 .agree = elliptic_agree, \
47 .priv = _curve, \
48 }
49
50#endif /* _IPXE_ELLIPTIC_H */
int elliptic_agree(struct exchange_algorithm *exchange, const void *private, const void *partner, void *shared)
Agree shared secret.
Definition elliptic.c:80
int elliptic_share(struct exchange_algorithm *exchange, const void *private, void *public)
Share public key.
Definition elliptic.c:47
struct eth_slow_lacp_entity_tlv partner
Partner information.
Definition eth_slow.h:5
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951
Cryptographic API.
A key exchange algorithm.
Definition crypto.h:210