iPXE
privkey.h
Go to the documentation of this file.
1 #ifndef _IPXE_PRIVKEY_H
2 #define _IPXE_PRIVKEY_H
3 
4 /** @file
5  *
6  * Private key
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <ipxe/asn1.h>
13 #include <ipxe/refcnt.h>
14 
15 /** A private key */
16 struct private_key {
17  /** Reference counter */
18  struct refcnt refcnt;
19  /** ASN.1 object builder */
21 };
22 
23 /**
24  * Get reference to private key
25  *
26  * @v key Private key
27  * @ret key Private key
28  */
29 static inline __attribute__ (( always_inline )) struct private_key *
31  ref_get ( &key->refcnt );
32  return key;
33 }
34 
35 /**
36  * Drop reference to private key
37  *
38  * @v key Private key
39  */
40 static inline __attribute__ (( always_inline )) void
42  ref_put ( &key->refcnt );
43 }
44 
45 /**
46  * Get private key ASN.1 cursor
47  *
48  * @v key Private key
49  * @ret cursor ASN.1 cursor
50  */
51 static inline __attribute__ (( always_inline )) struct asn1_cursor *
53  return asn1_built ( &key->builder );
54 }
55 
56 extern void privkey_free ( struct refcnt *refcnt );
57 
58 /**
59  * Initialise empty private key
60  *
61  */
62 static inline __attribute__ (( always_inline )) void
64  ref_init ( &key->refcnt, privkey_free );
65 }
66 
67 extern struct private_key private_key;
68 
69 #endif /* _IPXE_PRIVKEY_H */
#define __attribute__(x)
Definition: compiler.h:10
static void privkey_put(struct private_key *key)
Drop reference to private key.
Definition: privkey.h:41
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
static struct private_key * privkey_get(struct private_key *key)
Get reference to private key.
Definition: privkey.h:30
A reference counter.
Definition: refcnt.h:26
static struct asn1_cursor * privkey_cursor(struct private_key *key)
Get private key ASN.1 cursor.
Definition: privkey.h:52
struct asn1_builder builder
ASN.1 object builder.
Definition: privkey.h:20
ASN.1 encoding.
void privkey_free(struct refcnt *refcnt)
Free private key.
Definition: privkey.c:94
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
An ASN.1 object builder.
Definition: asn1.h:28
Reference counting.
A private key.
Definition: privkey.h:16
static struct asn1_cursor * asn1_built(struct asn1_builder *builder)
Get cursor for built object.
Definition: asn1.h:393
static void privkey_init(struct private_key *key)
Initialise empty private key.
Definition: privkey.h:63
An ASN.1 object cursor.
Definition: asn1.h:20
union @382 key
Sense key.
Definition: crypto.h:284
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106