libcdoc 0.1.8
|
A descriptor of decryption scheme in container. More...
#include <Lock.h>
Public Types | |
enum | Type : unsigned char { INVALID , SYMMETRIC_KEY , PASSWORD , PUBLIC_KEY , CDOC1 , SERVER , SHARE_SERVER } |
The lock type. More... | |
enum | PKType : unsigned char { ECC , RSA } |
The public key type. More... | |
enum | Params : unsigned int { SALT , PW_SALT , KDF_ITER , RCPT_KEY , CERT , KEY_MATERIAL , KEYSERVER_ID , TRANSACTION_ID , RECIPIENT_ID , SHARE_URLS , CONCAT_DIGEST , METHOD , ALGORITHM_ID , PARTY_UINFO , PARTY_VINFO } |
Extra parameters depending on key type. More... | |
Public Member Functions | |
const std::vector< uint8_t > & | getBytes (Params param) const |
get lock parameter value | |
std::string | getString (Params key) const |
get lock parameter as string | |
int32_t | getInt (Params key) const |
get lock parameter as integer | |
bool | isValid () const noexcept |
check whether lock is valid | |
constexpr bool | isSymmetric () const noexcept |
check whether lock is based on symmetric key | |
constexpr bool | isPKI () const noexcept |
check whether lock is based on public key | |
constexpr bool | isCertificate () const noexcept |
check whether lock is based on certificate | |
constexpr bool | isCDoc1 () const noexcept |
check whether lock is CDoc1 version | |
constexpr bool | isRSA () const noexcept |
check whether public key lock uses RSA algorithm | |
bool | hasTheSameKey (const Lock &other) const |
check whether two locks have the same public key | |
bool | hasTheSameKey (const std::vector< uint8_t > &public_key) const |
check whether lock has the given public key | |
Lock () noexcept=default | |
Lock (Type _type) noexcept | |
void | setBytes (Params param, const std::vector< uint8_t > &val) |
Set lock parameter value. | |
void | setString (Params param, const std::string &val) |
Set lock parameter value from string. | |
void | setInt (Params param, int32_t val) |
Set lock parameter value from integer. | |
void | setCertificate (const std::vector< uint8_t > &cert) |
A convenience method to initialize CERTIFICATE, RCPT_KEY and PK_TYPE values from given certificate. | |
bool | operator== (const Lock &other) const =default |
Public Attributes | |
Type | type = Type::INVALID |
The lock type. | |
PKType | pk_type = PKType::ECC |
algorithm type for public key based locks | |
std::string | label |
the lock label | |
std::vector< uint8_t > | encrypted_fmk |
encrypted FMK (File Master Key) | |
A descriptor of decryption scheme in container.
A Lock represents an encryption scheme with certain key and mechanism in encrypted container. A single container may contain many locks (for example one lock for one intended recipient).
To decrypt the container, the FMK (File Master Key) has to be obtained from a lock. Lock type determines, which exact procedures and cryptographic keys are needed for that.
enum libcdoc::Lock::Params : unsigned int |
Extra parameters depending on key type.
Enumerator | |
---|---|
SALT | HKDF salt (SYMMETRIC_KEY, PASSWORD and SHARE_SERVER) |
PW_SALT | PBKDF salt (PASSWORD) |
KDF_ITER | PBKDF iteration count (PASSWORD) |
RCPT_KEY | Recipient's public key (PUBLIC_KEY, CDOC1, SERVER) |
CERT | Recipient's certificate (CDOC1) |
KEY_MATERIAL | ECC ephemereal key or RSA encrypted KEK. |
KEYSERVER_ID | Keyserver Id. |
TRANSACTION_ID | Keyserver transaction Id. |
RECIPIENT_ID | Keyshare recipient ID. |
SHARE_URLS | Keyshare server urls (separated by ';') |
CONCAT_DIGEST | CDoc1 specific. |
METHOD | CDoc1 specific. |
ALGORITHM_ID | CDoc1 specific. |
PARTY_UINFO | CDoc1 specific. |
PARTY_VINFO | CDoc1 specific. |
enum libcdoc::Lock::PKType : unsigned char |
enum libcdoc::Lock::Type : unsigned char |
|
defaultnoexcept |
|
inlinenoexcept |
|
inline |
get lock parameter value
param | a parameter type |
int32_t libcdoc::Lock::getInt | ( | Params | key | ) | const |
get lock parameter as integer
key | a parameter type |
std::string libcdoc::Lock::getString | ( | Params | key | ) | const |
get lock parameter as string
key | a parameter type |
bool libcdoc::Lock::hasTheSameKey | ( | const Lock & | other | ) | const |
check whether two locks have the same public key
This convenience method checks whether both locks are public key based, and if they are, whether the RCPT_KEY parameters are identical (i.e. both can be decrypted by the same private key)
other | the other lock |
bool libcdoc::Lock::hasTheSameKey | ( | const std::vector< uint8_t > & | public_key | ) | const |
check whether lock has the given public key
This convenience method checks whether lock is public key based, and if it is, whether the RCPT_KEY parameters is identical to ptovided key(i.e. it can be decrypted by the corresponding private key)
public_key | the public key (short format) |
|
inlineconstexprnoexcept |
check whether lock is CDoc1 version
|
inlineconstexprnoexcept |
check whether lock is based on certificate
|
inlineconstexprnoexcept |
check whether lock is based on public key
|
inlineconstexprnoexcept |
check whether public key lock uses RSA algorithm
|
inlineconstexprnoexcept |
check whether lock is based on symmetric key
|
inlinenoexcept |
check whether lock is valid
|
default |
|
inline |
Set lock parameter value.
param | a parameter type |
val | the value |
void libcdoc::Lock::setCertificate | ( | const std::vector< uint8_t > & | cert | ) |
A convenience method to initialize CERTIFICATE, RCPT_KEY and PK_TYPE values from given certificate.
cert | the certificate (der-encoded) |
void libcdoc::Lock::setInt | ( | Params | param, |
int32_t | val | ||
) |
Set lock parameter value from integer.
param | a parameter type |
val | the value |
|
inline |
Set lock parameter value from string.
param | a parameter type |
val | the value |
std::vector<uint8_t> libcdoc::Lock::encrypted_fmk |
encrypted FMK (File Master Key)
std::string libcdoc::Lock::label |
the lock label
PKType libcdoc::Lock::pk_type = PKType::ECC |
algorithm type for public key based locks
Type libcdoc::Lock::type = Type::INVALID |
The lock type.