iPXE
ecdhe.c File Reference

Elliptic Curve Ephemeral Diffie-Hellman (ECDHE) key exchange. More...

#include <string.h>
#include <errno.h>
#include <ipxe/ecdhe.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
int ecdhe_key (struct elliptic_curve *curve, const void *partner, const void *private, void *public, void *shared)
 Calculate ECDHE key.

Detailed Description

Elliptic Curve Ephemeral Diffie-Hellman (ECDHE) key exchange.

Definition in file ecdhe.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ ecdhe_key()

int ecdhe_key ( struct elliptic_curve * curve,
const void * partner,
const void * private,
void * public,
void * shared )

Calculate ECDHE key.

Parameters
curveElliptic curve
partnerPartner public curve point
privatePrivate key
publicPublic curve point to fill in (may overlap partner key)
sharedShared secret curve point to fill in
Return values
rcReturn status code

Definition at line 47 of file ecdhe.c.

48 {
49 int rc;
50
51 /* Construct shared key */
52 if ( ( rc = elliptic_multiply ( curve, partner, private,
53 shared ) ) != 0 ) {
54 DBGC ( curve, "CURVE %s could not generate shared key: %s\n",
55 curve->name, strerror ( rc ) );
56 return rc;
57 }
58
59 /* Construct public key */
60 if ( ( rc = elliptic_multiply ( curve, curve->base, private,
61 public ) ) != 0 ) {
62 DBGC ( curve, "CURVE %s could not generate public key: %s\n",
63 curve->name, strerror ( rc ) );
64 return rc;
65 }
66
67 /* Check that partner and shared keys are not the point at infinity */
68 if ( elliptic_is_infinity ( curve, shared ) ) {
69 DBGC ( curve, "CURVE %s constructed point at infinity\n",
70 curve->name );
71 return -EPERM;
72 }
73
74 return 0;
75}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
struct eth_slow_lacp_entity_tlv partner
Partner information.
Definition eth_slow.h:5
#define DBGC(...)
Definition compiler.h:505
#define EPERM
Operation not permitted.
Definition errno.h:615
static int elliptic_multiply(struct elliptic_curve *curve, const void *base, const void *scalar, void *result)
Definition crypto.h:327
static int elliptic_is_infinity(struct elliptic_curve *curve, const void *point)
Definition crypto.h:322
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
const char * name
Curve name.
Definition crypto.h:180
const void * base
Generator base point.
Definition crypto.h:186

References elliptic_curve::base, DBGC, elliptic_is_infinity(), elliptic_multiply(), EPERM, elliptic_curve::name, partner, rc, and strerror().

Referenced by tls_send_client_key_exchange_ecdhe().