libcdoc 0.1.8
|
A descriptor of encryption method and key to be used in container. More...
#include <Recipient.h>
Public Types | |
enum | Type : unsigned char { NONE , SYMMETRIC_KEY , PUBLIC_KEY , CERTIFICATE , SERVER , KEYSHARE } |
The recipient type. More... | |
enum | PKType : unsigned char { ECC , RSA } |
The public key type. More... | |
enum | EIDType { Unknown , IDCard , DigiID , DigiID_EResident } |
The EID type. More... | |
Public Member Functions | |
Recipient ()=default | |
bool | isEmpty () const |
test whether the Recipient structure is initialized | |
bool | isSymmetric () const |
check whether Recipient is based on symmetric key | |
bool | isPKI () const |
check whether Recipient is based on public key | |
bool | isCertificate () const |
check whether Recipient is based on certificate | |
bool | isKeyServer () const |
check whether Recipient is keyserver | |
bool | isKeyShare () const |
check whether Recipient is keyshare | |
void | clear () |
Clear all values and set type to NONE. | |
bool | isTheSameRecipient (const Recipient &other) const |
A convenience method to check whether two recipients are both public key based and have the same keys. | |
bool | isTheSameRecipient (const std::vector< uint8_t > &public_key) const |
A convenience method to check whether a recipient is public key based and has the given keys. | |
bool | operator== (const Recipient &other) const =default |
Static Public Member Functions | |
static Recipient | makeSymmetric (const std::string &label, int32_t kdf_iter) |
Create a new symmetric key based Recipient. | |
static Recipient | makePublicKey (const std::string &label, const std::vector< uint8_t > &public_key, PKType pk_type) |
Create a new public key based Recipient. | |
static Recipient | makeCertificate (std::string label, std::vector< uint8_t > cert) |
Create a new certificate based Recipient. | |
static Recipient | makeEID (std::vector< uint8_t > cert) |
Create a new certificate based Recipient filling label from certificate. | |
static Recipient | makeServer (std::string label, std::vector< uint8_t > public_key, PKType pk_type, std::string server_id) |
Create new server based Recipient. | |
static Recipient | makeEIDServer (std::vector< uint8_t > cert, std::string server_id) |
Create new server based Recipient filling label from certificate. | |
static Recipient | makeShare (const std::string &label, const std::string &server_id, const std::string &recipient_id) |
Create new keyshare recipient. | |
static std::string | buildLabel (std::vector< std::pair< std::string_view, std::string_view > > components) |
build machine-readable CDoc2 label | |
static std::string | BuildLabelEID (int version, EIDType type, std::string_view cn, std::string_view serial_number, std::string_view last_name, std::string_view first_name) |
build machine-readable CDoc2 label for EID recipient | |
static std::string | BuildLabelEID (const std::vector< uint8_t > &cert) |
build machine-readable CDoc2 label for EID recipient filling info from certificate | |
static std::string | BuildLabelCertificate (int version, std::string_view file, std::string_view cn, const std::vector< uint8_t > &cert_sha1) |
build machine-readable CDoc2 label for certificate-based recipient | |
static std::string | BuildLabelCertificate (std::string_view file, const std::vector< uint8_t > &cert) |
build machine-readable CDoc2 label for certificate-based recipient filling info from certificate | |
static std::string | BuildLabelPublicKey (int version, const std::string file) |
build machine-readable CDoc2 label for public key based recipient | |
static std::string | BuildLabelSymmetricKey (int version, const std::string &label, const std::string file) |
build machine-readable CDoc2 label for symmetric key based recipient | |
static std::string | BuildLabelPassword (int version, const std::string &label) |
build machine-readable CDoc2 label for password key based recipient | |
static EIDType | getEIDType (const std::vector< std::string > &policies) |
get EID type from policies list | |
static std::map< std::string, std::string > | parseLabel (const std::string &label) |
parse machine-readable CDoc2 label | |
Public Attributes | |
Type | type = Type::NONE |
The recipient type. | |
PKType | pk_type = PKType::ECC |
The public key type. | |
int32_t | kdf_iter = 0 |
The number of iterations for PBKDF. Value 0 means directly provided symmetric key. | |
std::string | label |
The recipient's label. | |
std::vector< uint8_t > | rcpt_key |
Recipient's public key (for all PKI types) | |
std::vector< uint8_t > | cert |
The recipient's certificate (if present) | |
std::string | id |
The recipient id for share server (PNOEE-XXXXXXXXXXX) | |
std::string | server_id |
The keyserver or share server list id (if present) | |
Protected Member Functions | |
Recipient (Type _type) | |
A descriptor of encryption method and key to be used in container.
Recipient determines all the relevant properties to encrypt the FMK for a certain target.
enum libcdoc::Recipient::PKType : unsigned char |
enum libcdoc::Recipient::Type : unsigned char |
|
default |
|
inlineprotected |
|
static |
build machine-readable CDoc2 label
components | a list of string pairs |
|
static |
build machine-readable CDoc2 label for certificate-based recipient
version | the label version |
file | the name of certificate file |
cn | the common name |
cert_sha1 | the certificate SHA1 hash |
|
static |
build machine-readable CDoc2 label for certificate-based recipient filling info from certificate
file | the name of certificate file |
cert | the certificate value (der-encoded) |
|
static |
build machine-readable CDoc2 label for EID recipient filling info from certificate
cert | the certificate value (der-encoded) |
|
static |
build machine-readable CDoc2 label for EID recipient
version | the label version |
type | EID type |
cn | the common name |
serial_number | the serial number |
last_name | the last name |
first_name | the first name |
|
static |
build machine-readable CDoc2 label for password key based recipient
version | the label version |
label | the password label |
|
static |
build machine-readable CDoc2 label for public key based recipient
version | the label version |
file | the name of public key file |
|
static |
build machine-readable CDoc2 label for symmetric key based recipient
version | the label version |
label | the key label |
file | the name of key file |
|
inline |
Clear all values and set type to NONE.
|
static |
get EID type from policies list
policies | the list of policies |
|
inline |
check whether Recipient is based on certificate
|
inline |
test whether the Recipient structure is initialized
|
inline |
check whether Recipient is keyserver
|
inline |
check whether Recipient is keyshare
|
inline |
check whether Recipient is based on public key
|
inline |
check whether Recipient is based on symmetric key
bool libcdoc::Recipient::isTheSameRecipient | ( | const Recipient & | other | ) | const |
A convenience method to check whether two recipients are both public key based and have the same keys.
other | another Recipient |
bool libcdoc::Recipient::isTheSameRecipient | ( | const std::vector< uint8_t > & | public_key | ) | const |
A convenience method to check whether a recipient is public key based and has the given keys.
public_key | a public key to test |
|
static |
|
static |
Create a new certificate based Recipient filling label from certificate.
cert | the certificate value (der-encoded) |
|
static |
Create new server based Recipient filling label from certificate.
cert | the certificate value (der-encoded) |
server_id | the keyserver id |
|
static |
|
static |
|
default |
|
static |
parse machine-readable CDoc2 label
label | the label |
std::vector<uint8_t> libcdoc::Recipient::cert |
The recipient's certificate (if present)
std::string libcdoc::Recipient::id |
The recipient id for share server (PNOEE-XXXXXXXXXXX)
int32_t libcdoc::Recipient::kdf_iter = 0 |
The number of iterations for PBKDF. Value 0 means directly provided symmetric key.
std::string libcdoc::Recipient::label |
The recipient's label.
PKType libcdoc::Recipient::pk_type = PKType::ECC |
The public key type.
std::vector<uint8_t> libcdoc::Recipient::rcpt_key |
Recipient's public key (for all PKI types)
std::string libcdoc::Recipient::server_id |
The keyserver or share server list id (if present)
Type libcdoc::Recipient::type = Type::NONE |
The recipient type.