iPXE
Functions
elliptic_test.c File Reference

Elliptic curve self-tests. More...

#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <ipxe/crypto.h>
#include <ipxe/test.h>
#include "elliptic_test.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void elliptic_okx (struct elliptic_test *test, const char *file, unsigned int line)
 Report elliptic curve point multiplication test result. More...
 

Detailed Description

Elliptic curve self-tests.

Definition in file elliptic_test.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ elliptic_okx()

void elliptic_okx ( struct elliptic_test test,
const char *  file,
unsigned int  line 
)

Report elliptic curve point multiplication test result.

Parameters
testElliptic curve point multiplication test
fileTest code file
lineTest code line

Definition at line 49 of file elliptic_test.c.

50  {
51  struct elliptic_curve *curve = test->curve;
52  size_t pointsize = curve->pointsize;
53  size_t keysize = curve->keysize;
54  uint8_t actual[pointsize];
55  int rc;
56 
57  /* Sanity checks */
58  okx ( ( test->base_len == pointsize ) || ( ! test->base_len ),
59  file, line );
60  okx ( test->scalar_len == keysize, file, line );
61  okx ( ( test->expected_len == pointsize ) || ( ! test->expected_len ),
62  file, line );
63 
64  /* Perform point multiplication */
65  rc = elliptic_multiply ( curve, ( test->base_len ? test->base : NULL ),
66  test->scalar, actual );
67  if ( test->expected_len ) {
68  okx ( rc == 0, file, line );
69  } else {
70  okx ( rc != 0, file, line );
71  }
72 
73  /* Check expected result */
74  okx ( memcmp ( actual, test->expected, test->expected_len ) == 0,
75  file, line );
76 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int elliptic_multiply(struct elliptic_curve *curve, const void *base, const void *scalar, void *result)
Definition: crypto.h:310
#define okx(success, file, line)
Report test result.
Definition: test.h:44
size_t keysize
Scalar (and private key) size.
Definition: crypto.h:190
unsigned char uint8_t
Definition: stdint.h:10
u16 keysize
Length of encryption key to be used, network byte order.
Definition: wpa.h:37
An elliptic curve.
Definition: crypto.h:184
size_t pointsize
Point (and public key) size.
Definition: crypto.h:188
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static int test
Definition: epic100.c:73

References elliptic_multiply(), keysize, elliptic_curve::keysize, memcmp(), NULL, okx, elliptic_curve::pointsize, rc, and test.