iPXE
crypto.h
Go to the documentation of this file.
1#ifndef _IPXE_CRYPTO_H
2#define _IPXE_CRYPTO_H
3
4/** @file
5 *
6 * Cryptographic API
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <stddef.h>
15#include <assert.h>
16#include <ipxe/asn1.h>
17
18/** A message digest algorithm */
20 /** Algorithm name */
21 const char *name;
22 /** Context size */
23 size_t ctxsize;
24 /** Block size */
25 size_t blocksize;
26 /** Digest size */
27 size_t digestsize;
28 /** Initialise digest
29 *
30 * @v digest Digest algorithm
31 * @v ctx Context
32 */
33 void ( * init ) ( struct digest_algorithm *digest, void *ctx );
34 /** Update digest with new data
35 *
36 * @v digest Digest algorithm
37 * @v ctx Context
38 * @v src Data to digest
39 * @v len Length of data
40 *
41 * @v len is not necessarily a multiple of @c blocksize.
42 */
43 void ( * update ) ( struct digest_algorithm *digest, void *ctx,
44 const void *src, size_t len );
45 /** Finalise digest
46 *
47 * @v digest Digest algorithm
48 * @v ctx Context
49 * @v out Buffer for digest output
50 */
51 void ( * final ) ( struct digest_algorithm *digest, void *ctx,
52 void *out );
53 /** Algorithm private data */
54 void *priv;
55};
56
57/** A cipher algorithm */
59 /** Algorithm name */
60 const char *name;
61 /** Context size */
62 size_t ctxsize;
63 /** Block size
64 *
65 * Every call to encrypt() or decrypt() must be for a multiple
66 * of this size.
67 */
68 size_t blocksize;
69 /** Alignment size
70 *
71 * Every call to encrypt() or decrypt() must begin at a
72 * multiple of this offset from the start of the stream.
73 * (Equivalently: all but the last call to encrypt() or
74 * decrypt() must be for a multiple of this size.)
75 *
76 * For ciphers supporting additional data, the main data
77 * stream and additional data stream are both considered to
78 * begin at offset zero.
79 */
80 size_t alignsize;
81 /** Authentication tag size */
82 size_t authsize;
83 /** Cipher is capable of providing confidentiality */
85 /** Set key
86 *
87 * @v cipher Cipher algorithm
88 * @v ctx Context
89 * @v key Key
90 * @v keylen Key length
91 * @ret rc Return status code
92 */
93 int ( * setkey ) ( struct cipher_algorithm *cipher, void *ctx,
94 const void *key, size_t keylen );
95 /** Set initialisation vector
96 *
97 * @v cipher Cipher algorithm
98 * @v ctx Context
99 * @v iv Initialisation vector
100 * @v ivlen Initialisation vector length
101 * @ret rc Return status code
102 */
103 int ( * setiv ) ( struct cipher_algorithm *cipher, void *ctx,
104 const void *iv, size_t ivlen );
105 /** Encrypt data
106 *
107 * @v cipher Cipher algorithm
108 * @v ctx Context
109 * @v src Data to encrypt
110 * @v dst Buffer for encrypted data, or NULL for additional data
111 * @v len Length of data
112 *
113 * @v len is guaranteed to be a multiple of @c blocksize.
114 */
115 void ( * encrypt ) ( struct cipher_algorithm *cipher, void *ctx,
116 const void *src, void *dst, size_t len );
117 /** Decrypt data
118 *
119 * @v cipher Cipher algorithm
120 * @v ctx Context
121 * @v src Data to decrypt
122 * @v dst Buffer for decrypted data, or NULL for additional data
123 * @v len Length of data
124 *
125 * @v len is guaranteed to be a multiple of @c blocksize.
126 */
127 void ( * decrypt ) ( struct cipher_algorithm *cipher, void *ctx,
128 const void *src, void *dst, size_t len );
129 /** Generate authentication tag
130 *
131 * @v cipher Cipher algorithm
132 * @v ctx Context
133 * @v auth Authentication tag
134 */
135 void ( * auth ) ( struct cipher_algorithm *cipher, void *ctx,
136 void *auth );
137 /** Algorithm private data */
138 void *priv;
139};
140
141/** A public key algorithm */
143 /** Algorithm name */
144 const char *name;
145 /** Encrypt
146 *
147 * @v pubkey Public key algorithm
148 * @v key Key
149 * @v plaintext Plaintext
150 * @v ciphertext Ciphertext
151 * @ret rc Return status code
152 */
153 int ( * encrypt ) ( struct pubkey_algorithm *pubkey,
154 const struct asn1_cursor *key,
155 const struct asn1_cursor *plaintext,
156 struct asn1_builder *ciphertext );
157 /** Decrypt
158 *
159 * @v pubkey Public key algorithm
160 * @v key Key
161 * @v ciphertext Ciphertext
162 * @v plaintext Plaintext
163 * @ret rc Return status code
164 */
165 int ( * decrypt ) ( struct pubkey_algorithm *pubkey,
166 const struct asn1_cursor *key,
167 const struct asn1_cursor *ciphertext,
168 struct asn1_builder *plaintext );
169 /** Sign digest value
170 *
171 * @v pubkey Public key algorithm
172 * @v key Key
173 * @v digest Digest algorithm
174 * @v value Digest value
175 * @v signature Signature
176 * @ret rc Return status code
177 */
178 int ( * sign ) ( struct pubkey_algorithm *pubkey,
179 const struct asn1_cursor *key,
180 struct digest_algorithm *digest, const void *value,
181 struct asn1_builder *builder );
182 /** Verify signed digest value
183 *
184 * @v pubkey Public key algorithm
185 * @v key Key
186 * @v digest Digest algorithm
187 * @v value Digest value
188 * @v signature Signature
189 * @ret rc Return status code
190 */
191 int ( * verify ) ( struct pubkey_algorithm *pubkey,
192 const struct asn1_cursor *key,
193 struct digest_algorithm *digest, const void *value,
194 const struct asn1_cursor *signature );
195 /** Check that public key matches private key
196 *
197 * @v pubkey Public key algorithm
198 * @v private_key Private key
199 * @v public_key Public key
200 * @ret rc Return status code
201 */
202 int ( * match ) ( struct pubkey_algorithm *pubkey,
203 const struct asn1_cursor *private_key,
204 const struct asn1_cursor *public_key );
205 /** Algorithm private data */
206 void *priv;
207};
208
209/** A key exchange algorithm */
211 /** Algorithm name */
212 const char *name;
213 /** Private key size */
214 size_t privsize;
215 /** Public key size */
216 size_t pubsize;
217 /** Shared secret size */
219 /**
220 * Share public key
221 *
222 * @v exchange Key exchange algorithm
223 * @v private Private key
224 * @v public Public key to fill in
225 * @ret rc Return status code
226 */
227 int ( * share ) ( struct exchange_algorithm *exchange,
228 const void *private, void *public );
229 /**
230 * Agree shared secret
231 *
232 * @v exchange Key exchange algorithm
233 * @v private Private key
234 * @v partner Partner public key
235 * @v shared Shared secret to fill in
236 * @ret rc Return status code
237 */
238 int ( * agree ) ( struct exchange_algorithm *exchange,
239 const void *private, const void *partner,
240 void *shared );
241 /** Algorithm private data */
242 void *priv;
243};
244
245/** An elliptic curve */
247 /** Curve name */
248 const char *name;
249 /** Point (and public key) size */
250 size_t pointsize;
251 /** Scalar (and private key) size */
252 size_t keysize;
253 /** Generator base point */
254 const void *base;
255 /** Order of the generator (if prime) */
256 const void *order;
257 /** Check if this is the point at infinity
258 *
259 * @v curve Elliptic curve
260 * @v point Curve point
261 * @ret is_infinity This is the point at infinity
262 *
263 * The point at infinity cannot be represented in affine
264 * coordinates. Each curve must choose a representation of
265 * the point at infinity (e.g. all zeroes).
266 */
267 int ( * is_infinity ) ( struct elliptic_curve *curve,
268 const void *point );
269 /** Multiply scalar by curve point
270 *
271 * @v curve Elliptic curve
272 * @v base Base point
273 * @v scalar Scalar multiple
274 * @v result Result point to fill in
275 * @ret rc Return status code
276 */
277 int ( * multiply ) ( struct elliptic_curve *curve, const void *base,
278 const void *scalar, void *result );
279 /** Add curve points (as a one-off operation)
280 *
281 * @v curve Elliptic curve
282 * @v addend Curve point to add
283 * @v augend Curve point to add
284 * @v result Curve point to hold result
285 * @ret rc Return status code
286 */
287 int ( * add ) ( struct elliptic_curve *curve, const void *addend,
288 const void *augend, void *result );
289 /** Algorithm private data */
290 void *priv;
291};
292
293static inline __attribute__ (( always_inline )) void
294digest_init ( struct digest_algorithm *digest, void *ctx ) {
295 digest->init ( digest, ctx );
296}
297
298static inline __attribute__ (( always_inline )) void
299digest_update ( struct digest_algorithm *digest, void *ctx,
300 const void *data, size_t len ) {
301 digest->update ( digest, ctx, data, len );
302}
303
304static inline __attribute__ (( always_inline )) void
305digest_final ( struct digest_algorithm *digest, void *ctx, void *out ) {
306 digest->final ( digest, ctx, out );
307}
308
309static inline __attribute__ (( always_inline )) int
310cipher_setkey ( struct cipher_algorithm *cipher, void *ctx,
311 const void *key, size_t keylen ) {
312 return cipher->setkey ( cipher, ctx, key, keylen );
313}
314
315static inline __attribute__ (( always_inline )) int
316cipher_setiv ( struct cipher_algorithm *cipher, void *ctx,
317 const void *iv, size_t ivlen ) {
318 return cipher->setiv ( cipher, ctx, iv, ivlen );
319}
320
321static inline __attribute__ (( always_inline )) void
322cipher_encrypt ( struct cipher_algorithm *cipher, void *ctx,
323 const void *src, void *dst, size_t len ) {
324 cipher->encrypt ( cipher, ctx, src, dst, len );
325}
326#define cipher_encrypt( cipher, ctx, src, dst, len ) do { \
327 assert ( ( (len) & ( (cipher)->blocksize - 1 ) ) == 0 ); \
328 cipher_encrypt ( (cipher), (ctx), (src), (dst), (len) ); \
329 } while ( 0 )
330
331static inline __attribute__ (( always_inline )) void
332cipher_decrypt ( struct cipher_algorithm *cipher, void *ctx,
333 const void *src, void *dst, size_t len ) {
334 cipher->decrypt ( cipher, ctx, src, dst, len );
335}
336#define cipher_decrypt( cipher, ctx, src, dst, len ) do { \
337 assert ( ( (len) & ( (cipher)->blocksize - 1 ) ) == 0 ); \
338 cipher_decrypt ( (cipher), (ctx), (src), (dst), (len) ); \
339 } while ( 0 )
340
341static inline __attribute__ (( always_inline )) void
342cipher_auth ( struct cipher_algorithm *cipher, void *ctx, void *auth ) {
343 cipher->auth ( cipher, ctx, auth );
344}
345
346static inline __attribute__ (( always_inline )) int
348 return ( cipher->blocksize == 1 );
349}
350
351static inline __attribute__ (( always_inline )) int
353 return ( cipher->blocksize > 1 );
354}
355
356static inline __attribute__ (( always_inline )) int
358 return cipher->authsize;
359}
360
361static inline __attribute__ (( always_inline )) int
362pubkey_encrypt ( struct pubkey_algorithm *pubkey, const struct asn1_cursor *key,
363 const struct asn1_cursor *plaintext,
364 struct asn1_builder *ciphertext ) {
365 return pubkey->encrypt ( pubkey, key, plaintext, ciphertext );
366}
367
368static inline __attribute__ (( always_inline )) int
369pubkey_decrypt ( struct pubkey_algorithm *pubkey, const struct asn1_cursor *key,
370 const struct asn1_cursor *ciphertext,
371 struct asn1_builder *plaintext ) {
372 return pubkey->decrypt ( pubkey, key, ciphertext, plaintext );
373}
374
375static inline __attribute__ (( always_inline )) int
376pubkey_sign ( struct pubkey_algorithm *pubkey, const struct asn1_cursor *key,
377 struct digest_algorithm *digest, const void *value,
378 struct asn1_builder *signature ) {
379 return pubkey->sign ( pubkey, key, digest, value, signature );
380}
381
382static inline __attribute__ (( always_inline )) int
383pubkey_verify ( struct pubkey_algorithm *pubkey, const struct asn1_cursor *key,
384 struct digest_algorithm *digest, const void *value,
385 const struct asn1_cursor *signature ) {
386 return pubkey->verify ( pubkey, key, digest, value, signature );
387}
388
389static inline __attribute__ (( always_inline )) int
391 const struct asn1_cursor *private_key,
392 const struct asn1_cursor *public_key ) {
393 return pubkey->match ( pubkey, private_key, public_key );
394}
395
396static inline __attribute__ (( always_inline )) int
397exchange_share ( struct exchange_algorithm *exchange, const void *private,
398 void *public ) {
399 return exchange->share ( exchange, private, public );
400}
401
402static inline __attribute__ (( always_inline )) int
403exchange_agree ( struct exchange_algorithm *exchange, const void *private,
404 const void *partner, void *shared ) {
405 return exchange->agree ( exchange, private, partner, shared );
406}
407
408static inline __attribute__ (( always_inline )) int
409elliptic_is_infinity ( struct elliptic_curve *curve, const void *point ) {
410 return curve->is_infinity ( curve, point );
411}
412
413static inline __attribute__ (( always_inline )) int
415 const void *base, const void *scalar, void *result ) {
416 return curve->multiply ( curve, base, scalar, result );
417}
418
419static inline __attribute__ (( always_inline )) int
420elliptic_add ( struct elliptic_curve *curve, const void *addend,
421 const void *augend, void *result ) {
422 return curve->add ( curve, addend, augend, result );
423}
424
425extern void digest_null_init ( struct digest_algorithm *digest, void *ctx );
426extern void digest_null_update ( struct digest_algorithm *digest, void *ctx,
427 const void *src, size_t len );
428extern void digest_null_final ( struct digest_algorithm *digest, void *ctx,
429 void *out );
430
431extern int cipher_null_setkey ( struct cipher_algorithm *cipher, void *ctx,
432 const void *key, size_t keylen );
433extern int cipher_null_setiv ( struct cipher_algorithm *cipehr, void *ctx,
434 const void *iv, size_t ivlen );
435extern void cipher_null_encrypt ( struct cipher_algorithm *cipher, void *ctx,
436 const void *src, void *dst, size_t len );
437extern void cipher_null_decrypt ( struct cipher_algorithm *cipher, void *ctx,
438 const void *src, void *dst, size_t len );
439extern void cipher_null_auth ( struct cipher_algorithm *cipher, void *ctx,
440 void *auth );
441
442extern int pubkey_null_encrypt ( struct pubkey_algorithm *pubkey,
443 const struct asn1_cursor *key,
444 const struct asn1_cursor *plaintext,
445 struct asn1_builder *ciphertext );
446extern int pubkey_null_decrypt ( struct pubkey_algorithm *pubkey,
447 const struct asn1_cursor *key,
448 const struct asn1_cursor *ciphertext,
449 struct asn1_builder *plaintext );
450extern int pubkey_null_sign ( struct pubkey_algorithm *pubkey,
451 const struct asn1_cursor *key,
452 struct digest_algorithm *digest,
453 const void *value,
454 struct asn1_builder *signature );
455extern int pubkey_null_verify ( struct pubkey_algorithm *pubkey,
456 const struct asn1_cursor *key,
457 struct digest_algorithm *digest,
458 const void *value,
459 const struct asn1_cursor *signature );
460extern int pubkey_null_match ( struct pubkey_algorithm *pubkey,
461 const struct asn1_cursor *private_key,
462 const struct asn1_cursor *public_key );
463
464extern struct digest_algorithm digest_null;
465extern struct cipher_algorithm cipher_null;
466extern struct pubkey_algorithm pubkey_null;
467
468#endif /* _IPXE_CRYPTO_H */
struct golan_eq_context ctx
Definition CIB_PRM.h:0
__be32 out[4]
Definition CIB_PRM.h:8
u8 signature
CPU signature.
Definition CIB_PRM.h:7
union @162305117151260234136356364136041353210355154177 key
pseudo_bit_t value[0x00020]
Definition arbel.h:2
uint16_t result
Definition hyperv.h:33
static const void * src
Definition string.h:48
ASN.1 encoding.
Assertions.
struct cipher_algorithm cipher_null
Definition crypto_null.c:94
struct pubkey_algorithm pubkey_null
struct digest_algorithm digest_null
Definition crypto_null.c:53
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11
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
#define __attribute__(x)
Definition compiler.h:10
static int is_block_cipher(struct cipher_algorithm *cipher)
Definition crypto.h:352
int pubkey_null_match(struct pubkey_algorithm *pubkey, const struct asn1_cursor *private_key, const struct asn1_cursor *public_key)
static int pubkey_match(struct pubkey_algorithm *pubkey, const struct asn1_cursor *private_key, const struct asn1_cursor *public_key)
Definition crypto.h:390
static void digest_init(struct digest_algorithm *digest, void *ctx)
Definition crypto.h:294
static int elliptic_multiply(struct elliptic_curve *curve, const void *base, const void *scalar, void *result)
Definition crypto.h:414
void cipher_null_auth(struct cipher_algorithm *cipher, void *ctx, void *auth)
void cipher_null_decrypt(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
int pubkey_null_encrypt(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, const struct asn1_cursor *plaintext, struct asn1_builder *ciphertext)
static int cipher_setkey(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
Definition crypto.h:310
void digest_null_update(struct digest_algorithm *digest, void *ctx, const void *src, size_t len)
int pubkey_null_verify(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, const struct asn1_cursor *signature)
static void digest_final(struct digest_algorithm *digest, void *ctx, void *out)
Definition crypto.h:305
static int elliptic_is_infinity(struct elliptic_curve *curve, const void *point)
Definition crypto.h:409
int cipher_null_setkey(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
static int is_stream_cipher(struct cipher_algorithm *cipher)
Definition crypto.h:347
static int pubkey_encrypt(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, const struct asn1_cursor *plaintext, struct asn1_builder *ciphertext)
Definition crypto.h:362
void cipher_null_encrypt(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
static int exchange_share(struct exchange_algorithm *exchange, const void *private, void *public)
Definition crypto.h:397
static int pubkey_verify(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, const struct asn1_cursor *signature)
Definition crypto.h:383
static int exchange_agree(struct exchange_algorithm *exchange, const void *private, const void *partner, void *shared)
Definition crypto.h:403
static int cipher_setiv(struct cipher_algorithm *cipher, void *ctx, const void *iv, size_t ivlen)
Definition crypto.h:316
static int elliptic_add(struct elliptic_curve *curve, const void *addend, const void *augend, void *result)
Definition crypto.h:420
static void digest_update(struct digest_algorithm *digest, void *ctx, const void *data, size_t len)
Definition crypto.h:299
#define cipher_decrypt(cipher, ctx, src, dst, len)
Definition crypto.h:336
void digest_null_final(struct digest_algorithm *digest, void *ctx, void *out)
void digest_null_init(struct digest_algorithm *digest, void *ctx)
int cipher_null_setiv(struct cipher_algorithm *cipehr, void *ctx, const void *iv, size_t ivlen)
static int pubkey_decrypt(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, const struct asn1_cursor *ciphertext, struct asn1_builder *plaintext)
Definition crypto.h:369
int pubkey_null_sign(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, struct asn1_builder *signature)
static int is_auth_cipher(struct cipher_algorithm *cipher)
Definition crypto.h:357
static int pubkey_sign(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, struct asn1_builder *signature)
Definition crypto.h:376
#define cipher_encrypt(cipher, ctx, src, dst, len)
Definition crypto.h:326
int pubkey_null_decrypt(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, const struct asn1_cursor *ciphertext, struct asn1_builder *plaintext)
static void cipher_auth(struct cipher_algorithm *cipher, void *ctx, void *auth)
Definition crypto.h:342
uint32_t base
Base.
Definition librm.h:3
An ASN.1 object builder.
Definition asn1.h:29
An ASN.1 object cursor.
Definition asn1.h:21
A cipher algorithm.
Definition crypto.h:58
void(* decrypt)(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
Decrypt data.
Definition crypto.h:127
int(* setiv)(struct cipher_algorithm *cipher, void *ctx, const void *iv, size_t ivlen)
Set initialisation vector.
Definition crypto.h:103
void(* encrypt)(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
Encrypt data.
Definition crypto.h:115
void * priv
Algorithm private data.
Definition crypto.h:138
const char * name
Algorithm name.
Definition crypto.h:60
size_t blocksize
Block size.
Definition crypto.h:68
int confidential
Cipher is capable of providing confidentiality.
Definition crypto.h:84
size_t ctxsize
Context size.
Definition crypto.h:62
size_t authsize
Authentication tag size.
Definition crypto.h:82
void(* auth)(struct cipher_algorithm *cipher, void *ctx, void *auth)
Generate authentication tag.
Definition crypto.h:135
int(* setkey)(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
Set key.
Definition crypto.h:93
size_t alignsize
Alignment size.
Definition crypto.h:80
A message digest algorithm.
Definition crypto.h:19
size_t digestsize
Digest size.
Definition crypto.h:27
size_t blocksize
Block size.
Definition crypto.h:25
void * priv
Algorithm private data.
Definition crypto.h:54
void(* update)(struct digest_algorithm *digest, void *ctx, const void *src, size_t len)
Update digest with new data.
Definition crypto.h:43
void(* final)(struct digest_algorithm *digest, void *ctx, void *out)
Finalise digest.
Definition crypto.h:51
size_t ctxsize
Context size.
Definition crypto.h:23
const char * name
Algorithm name.
Definition crypto.h:21
void(* init)(struct digest_algorithm *digest, void *ctx)
Initialise digest.
Definition crypto.h:33
An elliptic curve.
Definition crypto.h:246
const void * order
Order of the generator (if prime).
Definition crypto.h:256
const char * name
Curve name.
Definition crypto.h:248
size_t keysize
Scalar (and private key) size.
Definition crypto.h:252
size_t pointsize
Point (and public key) size.
Definition crypto.h:250
int(* is_infinity)(struct elliptic_curve *curve, const void *point)
Check if this is the point at infinity.
Definition crypto.h:267
void * priv
Algorithm private data.
Definition crypto.h:290
const void * base
Generator base point.
Definition crypto.h:254
int(* multiply)(struct elliptic_curve *curve, const void *base, const void *scalar, void *result)
Multiply scalar by curve point.
Definition crypto.h:277
int(* add)(struct elliptic_curve *curve, const void *addend, const void *augend, void *result)
Add curve points (as a one-off operation).
Definition crypto.h:287
A key exchange algorithm.
Definition crypto.h:210
int(* agree)(struct exchange_algorithm *exchange, const void *private, const void *partner, void *shared)
Agree shared secret.
Definition crypto.h:238
size_t sharedsize
Shared secret size.
Definition crypto.h:218
size_t privsize
Private key size.
Definition crypto.h:214
size_t pubsize
Public key size.
Definition crypto.h:216
void * priv
Algorithm private data.
Definition crypto.h:242
int(* share)(struct exchange_algorithm *exchange, const void *private, void *public)
Share public key.
Definition crypto.h:227
const char * name
Algorithm name.
Definition crypto.h:212
A private key.
Definition privkey.h:17
A public key algorithm.
Definition crypto.h:142
int(* sign)(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, struct asn1_builder *builder)
Sign digest value.
Definition crypto.h:178
int(* decrypt)(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, const struct asn1_cursor *ciphertext, struct asn1_builder *plaintext)
Decrypt.
Definition crypto.h:165
int(* verify)(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, const struct asn1_cursor *signature)
Verify signed digest value.
Definition crypto.h:191
void * priv
Algorithm private data.
Definition crypto.h:206
int(* match)(struct pubkey_algorithm *pubkey, const struct asn1_cursor *private_key, const struct asn1_cursor *public_key)
Check that public key matches private key.
Definition crypto.h:202
const char * name
Algorithm name.
Definition crypto.h:144
int(* encrypt)(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, const struct asn1_cursor *plaintext, struct asn1_builder *ciphertext)
Encrypt.
Definition crypto.h:153
u8 iv[16]
Initialization vector.
Definition wpa.h:33