diff options
author | Michael Brown <mcb30@ipxe.org> | 2020-12-15 16:11:34 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2020-12-15 16:54:06 +0000 |
commit | f43a8f8b9f808fb0a8347663abf6efe6908821ed (patch) | |
tree | 012d6ffcb49d4c4744e12b8a8cbc207f13d3bf65 /src/include/ipxe/privkey.h | |
parent | 6a8664d9ec8010a717855ca92173c63c3c166c4e (diff) | |
download | ipxe-f43a8f8b9f808fb0a8347663abf6efe6908821ed.tar.gz |
[crypto] Allow private key to be specified as a TLS connection parameter
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/privkey.h')
-rw-r--r-- | src/include/ipxe/privkey.h | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/include/ipxe/privkey.h b/src/include/ipxe/privkey.h index 81108b6bf..a65cf6106 100644 --- a/src/include/ipxe/privkey.h +++ b/src/include/ipxe/privkey.h @@ -10,7 +10,60 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include <ipxe/asn1.h> +#include <ipxe/refcnt.h> -extern struct asn1_cursor private_key; +/** A private key */ +struct private_key { + /** Reference counter */ + struct refcnt refcnt; + /** ASN.1 object builder */ + struct asn1_builder builder; +}; + +/** + * Get reference to private key + * + * @v key Private key + * @ret key Private key + */ +static inline __attribute__ (( always_inline )) struct private_key * +privkey_get ( struct private_key *key ) { + ref_get ( &key->refcnt ); + return key; +} + +/** + * Drop reference to private key + * + * @v key Private key + */ +static inline __attribute__ (( always_inline )) void +privkey_put ( struct private_key *key ) { + ref_put ( &key->refcnt ); +} + +/** + * Get private key ASN.1 cursor + * + * @v key Private key + * @ret cursor ASN.1 cursor + */ +static inline __attribute__ (( always_inline )) struct asn1_cursor * +privkey_cursor ( struct private_key *key ) { + return asn1_built ( &key->builder ); +} + +extern void privkey_free ( struct refcnt *refcnt ); + +/** + * Initialise empty private key + * + */ +static inline __attribute__ (( always_inline )) void +privkey_init ( struct private_key *key ) { + ref_init ( &key->refcnt, privkey_free ); +} + +extern struct private_key private_key; #endif /* _IPXE_PRIVKEY_H */ |