libcdoc 0.1.8
libcdoc::NetworkBackend Struct Reference

#include <NetworkBackend.h>

Classes

struct  CapsuleInfo
 Share information returned by server. More...
 
struct  ProxyCredentials
 Proxy credentials used for network access. More...
 
struct  ShareInfo
 Share information returned by server. More...
 

Public Member Functions

 NetworkBackend ()=default
 
virtual ~NetworkBackend () noexcept=default
 
 NetworkBackend (const NetworkBackend &)=delete
 
NetworkBackendoperator= (const NetworkBackend &)=delete
 
 CDOC_DISABLE_MOVE (NetworkBackend)
 
virtual std::string getLastErrorStr (result_t code) const
 Get the textual description of the last error.
 
virtual result_t sendKey (CapsuleInfo &dst, const std::string &url, const std::vector< uint8_t > &rcpt_key, const std::vector< uint8_t > &key_material, const std::string &type)
 send key material to keyserver
 
virtual result_t sendShare (std::vector< uint8_t > &dst, const std::string &url, const std::string &recipient, const std::vector< uint8_t > &share)
 send key share to server
 
virtual result_t fetchKey (std::vector< uint8_t > &dst, const std::string &url, const std::string &transaction_id)
 fetch key material from keyserver
 
virtual result_t fetchNonce (std::vector< uint8_t > &dst, const std::string &url, const std::string &share_id)
 fetch authentication nonce from share server
 
virtual result_t fetchShare (ShareInfo &share, const std::string &url, const std::string &share_id, const std::string &ticket, const std::vector< uint8_t > &cert)
 fetch key share from share server
 
virtual result_t getClientTLSCertificate (std::vector< uint8_t > &dst)
 get client TLS certificate in der format
 
virtual result_t getPeerTLSCertificates (std::vector< std::vector< uint8_t > > &dst)
 get a list of peer TLS certificates in der format
 
virtual result_t getPeerTLSCertificates (std::vector< std::vector< uint8_t > > &dst, const std::string &url)
 get a list of peer TLS certificates in der format
 
virtual result_t getProxyCredentials (ProxyCredentials &credentials) const
 Get proxy configuration currently set.
 
virtual result_t signTLS (std::vector< uint8_t > &dst, CryptoBackend::HashAlgorithm algorithm, const std::vector< uint8_t > &digest)
 sign TLS digest with client's private key
 
virtual result_t showVerificationCode (unsigned int code)
 show MID/SID verification code
 
result_t signSID (std::vector< uint8_t > &dst, std::vector< uint8_t > &cert, const std::string &url, const std::string &rp_uuid, const std::string &rp_name, const std::string &rcpt_id, const std::vector< uint8_t > &digest, CryptoBackend::HashAlgorithm algo)
 Sign digest with SmartID authentication key.
 
result_t signMID (std::vector< uint8_t > &dst, std::vector< uint8_t > &cert, const std::string &url, const std::string &rp_uuid, const std::string &rp_name, const std::string &phone, const std::string &rcpt_id, const std::vector< uint8_t > &digest, CryptoBackend::HashAlgorithm algo)
 Sign digest with Mobile ID authentication key.
 

Static Public Attributes

static constexpr int NETWORK_ERROR = -300
 Generic network error.
 
static constexpr int MIDSID_USER_REFUSED = -350
 
static constexpr int MIDSID_TIMEOUT = -351
 
static constexpr int MIDSID_DOCUMENT_UNUSABLE = -352
 
static constexpr int MIDSID_WRONG_VC = -353
 
static constexpr int MIDSID_REQUIRED_INTERACTION_NOT_SUPPORTED_BY_APP = -354
 
static constexpr int MIDSID_USER_REFUSED_CERT_CHOICE = -355
 
static constexpr int MIDSID_USER_REFUSED_DISPLAYTEXTANDPIN = -356
 
static constexpr int MIDSID_USER_REFUSED_VC_CHOICE = -357
 
static constexpr int MIDSID_USER_REFUSED_CONFIRMATIONMESSAGE = -358
 
static constexpr int MIDSID_USER_REFUSED_CONFIRMATIONMESSAGE_WITH_VC_CHOICE = -359
 
static constexpr int MIDSID_NOT_MID_CLIENT = -360
 
static constexpr int MIDSID_USER_CANCELLED = -361
 
static constexpr int MIDSID_SIGNATURE_HASH_MISMATCH = -362
 
static constexpr int MIDSID_PHONE_ABSENT = -363
 
static constexpr int MIDSID_DELIVERY_ERROR = -364
 
static constexpr int MIDSID_SIM_ERROR = -365
 

Constructor & Destructor Documentation

◆ NetworkBackend() [1/2]

libcdoc::NetworkBackend::NetworkBackend ( )
default

◆ ~NetworkBackend()

virtual libcdoc::NetworkBackend::~NetworkBackend ( )
virtualdefaultnoexcept

◆ NetworkBackend() [2/2]

libcdoc::NetworkBackend::NetworkBackend ( const NetworkBackend )
delete

Member Function Documentation

◆ CDOC_DISABLE_MOVE()

libcdoc::NetworkBackend::CDOC_DISABLE_MOVE ( NetworkBackend  )

◆ fetchKey()

virtual result_t libcdoc::NetworkBackend::fetchKey ( std::vector< uint8_t > &  dst,
const std::string &  url,
const std::string &  transaction_id 
)
virtual

fetch key material from keyserver

The default implementation uses internal http client, peer TLS list and client TLS certificate

Parameters
dsta destination container for key material
urlserver url
transaction_idtransaction id of capsule
Returns
error code or OK

◆ fetchNonce()

virtual result_t libcdoc::NetworkBackend::fetchNonce ( std::vector< uint8_t > &  dst,
const std::string &  url,
const std::string &  share_id 
)
virtual

fetch authentication nonce from share server

Parameters
dsta destination container for nonce
urlserver url
share_idshare id (transaction id)
Returns
error code or OK

◆ fetchShare()

virtual result_t libcdoc::NetworkBackend::fetchShare ( ShareInfo share,
const std::string &  url,
const std::string &  share_id,
const std::string &  ticket,
const std::vector< uint8_t > &  cert 
)
virtual

fetch key share from share server

Parameters
sharea container for result
urlserver url
share_idshare id (transaction id)
ticketsigned ticket with disclosed url
certa certificate of signing key (PEM without newlines)
Returns
error code or OK

◆ getClientTLSCertificate()

virtual result_t libcdoc::NetworkBackend::getClientTLSCertificate ( std::vector< uint8_t > &  dst)
inlinevirtual

get client TLS certificate in der format

Parameters
dsta destination container for certificate
Returns
error code or OK

References libcdoc::NOT_IMPLEMENTED.

◆ getLastErrorStr()

virtual std::string libcdoc::NetworkBackend::getLastErrorStr ( result_t  code) const
virtual

Get the textual description of the last error.

The result is undefined if the error code does not match the most recent error

Parameters
codeThe error code
Returns
std::string error description

◆ getPeerTLSCertificates() [1/2]

virtual result_t libcdoc::NetworkBackend::getPeerTLSCertificates ( std::vector< std::vector< uint8_t > > &  dst)
inlinevirtual

get a list of peer TLS certificates in der format

Parameters
dsta destination container for certificate
Returns
error code or OK

References libcdoc::NOT_IMPLEMENTED.

◆ getPeerTLSCertificates() [2/2]

virtual result_t libcdoc::NetworkBackend::getPeerTLSCertificates ( std::vector< std::vector< uint8_t > > &  dst,
const std::string &  url 
)
inlinevirtual

get a list of peer TLS certificates in der format

Parameters
dsta destination container for certificate
urlthe base url ("https://servername:port/")
Returns
error code or OK

◆ getProxyCredentials()

virtual result_t libcdoc::NetworkBackend::getProxyCredentials ( ProxyCredentials credentials) const
inlinevirtual

Get proxy configuration currently set.

Parameters
credentialsoutput for proxy credentials

References libcdoc::NOT_IMPLEMENTED.

◆ operator=()

NetworkBackend & libcdoc::NetworkBackend::operator= ( const NetworkBackend )
delete

◆ sendKey()

virtual result_t libcdoc::NetworkBackend::sendKey ( CapsuleInfo dst,
const std::string &  url,
const std::vector< uint8_t > &  rcpt_key,
const std::vector< uint8_t > &  key_material,
const std::string &  type 
)
virtual

send key material to keyserver

The default implementation uses internal http client and peer TLS certificate list.

Parameters
dstthe transaction id and expiry date of the capsule on server
urlserver url
rcpt_keyrecipient's public key
key_materialencrypted KEK or ECDH public Key used to derive shared secret
typealgorithm type, currently either "rsa" or "ecc_secp384r1"
Returns
error code or OK

◆ sendShare()

virtual result_t libcdoc::NetworkBackend::sendShare ( std::vector< uint8_t > &  dst,
const std::string &  url,
const std::string &  recipient,
const std::vector< uint8_t > &  share 
)
virtual

send key share to server

The recipient has to be in form "etsi/PNOEE-XXXXXXXXXXXX" and must match certificate subject serial number field (without "etsi/" prefix).

Parameters
dsta container for share id
urlserver url
recipientthe recipient id (ETSI319412-1)
sharebase64 encoded Key Share
Returns
error code or OK

◆ showVerificationCode()

virtual result_t libcdoc::NetworkBackend::showVerificationCode ( unsigned int  code)
virtual

show MID/SID verification code

Show SID/MID verification code. The default implementation logs it with level INFO.

Parameters
codeverification code
Returns
error code or OK

◆ signMID()

result_t libcdoc::NetworkBackend::signMID ( std::vector< uint8_t > &  dst,
std::vector< uint8_t > &  cert,
const std::string &  url,
const std::string &  rp_uuid,
const std::string &  rp_name,
const std::string &  phone,
const std::string &  rcpt_id,
const std::vector< uint8_t > &  digest,
CryptoBackend::HashAlgorithm  algo 
)

Sign digest with Mobile ID authentication key.

Parameters
dsta container for signature
certa container for certificate
urlMobile ID gateway base URL
rp_uuidrelying party UUID
rp_namerelying party name
phonerecipient's phone number
rcpt_idrecipient id (etsi/PNOEE-XYZXYZXYZXY)
digestdigest to sign
algoalgorithm type (SHA256, SHA385, SHA512)
Returns
error code or OK

◆ signSID()

result_t libcdoc::NetworkBackend::signSID ( std::vector< uint8_t > &  dst,
std::vector< uint8_t > &  cert,
const std::string &  url,
const std::string &  rp_uuid,
const std::string &  rp_name,
const std::string &  rcpt_id,
const std::vector< uint8_t > &  digest,
CryptoBackend::HashAlgorithm  algo 
)

Sign digest with SmartID authentication key.

Parameters
dsta container for signature
certa container for certificate
urlSmartID gateway base URL
rp_uuidrelying party UUID
rp_namerelying party name
rcpt_idrecipient id (etsi/PNOEE-XYZXYZXYZXY)
digestdigest to sign
algoalgorithm type (SHA256, SHA385, SHA512)
Returns
error code or OK

◆ signTLS()

virtual result_t libcdoc::NetworkBackend::signTLS ( std::vector< uint8_t > &  dst,
CryptoBackend::HashAlgorithm  algorithm,
const std::vector< uint8_t > &  digest 
)
inlinevirtual

sign TLS digest with client's private key

Parameters
dsta destination container for signature
algorithmsigning algorithm
digestdata to be signed
Returns
error code or OK

References libcdoc::NOT_IMPLEMENTED.

Member Data Documentation

◆ MIDSID_DELIVERY_ERROR

constexpr int libcdoc::NetworkBackend::MIDSID_DELIVERY_ERROR = -364
staticconstexpr

◆ MIDSID_DOCUMENT_UNUSABLE

constexpr int libcdoc::NetworkBackend::MIDSID_DOCUMENT_UNUSABLE = -352
staticconstexpr

◆ MIDSID_NOT_MID_CLIENT

constexpr int libcdoc::NetworkBackend::MIDSID_NOT_MID_CLIENT = -360
staticconstexpr

◆ MIDSID_PHONE_ABSENT

constexpr int libcdoc::NetworkBackend::MIDSID_PHONE_ABSENT = -363
staticconstexpr

◆ MIDSID_REQUIRED_INTERACTION_NOT_SUPPORTED_BY_APP

constexpr int libcdoc::NetworkBackend::MIDSID_REQUIRED_INTERACTION_NOT_SUPPORTED_BY_APP = -354
staticconstexpr

◆ MIDSID_SIGNATURE_HASH_MISMATCH

constexpr int libcdoc::NetworkBackend::MIDSID_SIGNATURE_HASH_MISMATCH = -362
staticconstexpr

◆ MIDSID_SIM_ERROR

constexpr int libcdoc::NetworkBackend::MIDSID_SIM_ERROR = -365
staticconstexpr

◆ MIDSID_TIMEOUT

constexpr int libcdoc::NetworkBackend::MIDSID_TIMEOUT = -351
staticconstexpr

◆ MIDSID_USER_CANCELLED

constexpr int libcdoc::NetworkBackend::MIDSID_USER_CANCELLED = -361
staticconstexpr

◆ MIDSID_USER_REFUSED

constexpr int libcdoc::NetworkBackend::MIDSID_USER_REFUSED = -350
staticconstexpr

◆ MIDSID_USER_REFUSED_CERT_CHOICE

constexpr int libcdoc::NetworkBackend::MIDSID_USER_REFUSED_CERT_CHOICE = -355
staticconstexpr

◆ MIDSID_USER_REFUSED_CONFIRMATIONMESSAGE

constexpr int libcdoc::NetworkBackend::MIDSID_USER_REFUSED_CONFIRMATIONMESSAGE = -358
staticconstexpr

◆ MIDSID_USER_REFUSED_CONFIRMATIONMESSAGE_WITH_VC_CHOICE

constexpr int libcdoc::NetworkBackend::MIDSID_USER_REFUSED_CONFIRMATIONMESSAGE_WITH_VC_CHOICE = -359
staticconstexpr

◆ MIDSID_USER_REFUSED_DISPLAYTEXTANDPIN

constexpr int libcdoc::NetworkBackend::MIDSID_USER_REFUSED_DISPLAYTEXTANDPIN = -356
staticconstexpr

◆ MIDSID_USER_REFUSED_VC_CHOICE

constexpr int libcdoc::NetworkBackend::MIDSID_USER_REFUSED_VC_CHOICE = -357
staticconstexpr

◆ MIDSID_WRONG_VC

constexpr int libcdoc::NetworkBackend::MIDSID_WRONG_VC = -353
staticconstexpr

◆ NETWORK_ERROR

constexpr int libcdoc::NetworkBackend::NETWORK_ERROR = -300
staticconstexpr

Generic network error.


The documentation for this struct was generated from the following file: