Key exchange self-tests.
More...
#include <stdlib.h>
#include <string.h>
#include <ipxe/crypto.h>
#include "exchange_test.h"
Go to the source code of this file.
Key exchange self-tests.
Definition in file exchange_test.c.
◆ FILE_LICENCE()
| FILE_LICENCE |
( |
GPL2_OR_LATER_OR_UBDL | | ) |
|
◆ exchange_okx()
| void exchange_okx |
( |
struct exchange_test * | test, |
|
|
const char * | file, |
|
|
unsigned int | line ) |
Report a key exchange test result.
- Parameters
-
| test | Key exchange test |
| file | Test code file |
| line | Test code line |
Definition at line 47 of file exchange_test.c.
48 {
50 struct {
53 } *actual;
55
56
60 okx ( ( (
test->shared_len == 0 ) ||
62
63
64 actual =
malloc (
sizeof ( *actual ) );
65 okx ( actual !=
NULL, file, line );
66
67
71 file, line );
75 file, line );
76
77
81 actual->shared );
82 if (
test->shared_len ) {
83
84 okx (
rc == 0, file, line );
85 DBGC (
test,
"KEX %s shared secret:\n", exchange->
name );
89 } else {
90
91 okx (
rc != 0, file, line );
92 }
93
94
96}
#define NULL
NULL pointer (VOID *).
struct arbelprm_rc_send_wqe rc
static int exchange_share(struct exchange_algorithm *exchange, const void *private, void *public)
static int exchange_agree(struct exchange_algorithm *exchange, const void *private, const void *partner, void *shared)
void * malloc(size_t size)
Allocate memory.
static void(* free)(struct refcnt *refcnt))
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
A key exchange algorithm.
size_t sharedsize
Shared secret size.
size_t privsize
Private key size.
size_t pubsize
Public key size.
const char * name
Algorithm name.
#define okx(success, file, line)
Report test result.
References DBGC, DBGC_HDA, exchange_agree(), exchange_share(), free, malloc(), memcmp(), exchange_algorithm::name, NULL, okx, exchange_algorithm::privsize, exchange_algorithm::pubsize, rc, exchange_algorithm::sharedsize, and test.