MCPcopy Create free account
hub / github.com/brainboxdotcc/DPP / X509Credential

Method X509Credential

mlspp/src/credential.cpp:46–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46X509Credential::X509Credential(const std::vector<bytes>& der_chain_in)
47 : der_chain(bytes_to_x509_credential_data(der_chain_in))
48{
49 if (der_chain.empty()) {
50 throw std::invalid_argument("empty certificate chain");
51 }
52
53 // Parse the chain
54 auto parsed = std::vector<Certificate>();
55 for (const auto& cert : der_chain) {
56 parsed.emplace_back(cert.data);
57 }
58
59 // first element represents leaf cert
60 const auto& sig = find_signature(parsed[0].public_key_algorithm());
61 const auto pub_data = sig.serialize(*parsed[0].public_key);
62 _signature_scheme = tls_signature_scheme(parsed[0].public_key_algorithm());
63 _public_key = SignaturePublicKey{ pub_data };
64
65 // verify chain for valid signatures
66 for (size_t i = 0; i < der_chain.size() - 1; i++) {
67 if (!parsed[i].valid_from(parsed[i + 1])) {
68 throw std::runtime_error("Certificate Chain validation failure");
69 }
70 }
71}
72
73SignatureScheme
74X509Credential::signature_scheme() const

Callers

nothing calls this directly

Calls 7

tls_signature_schemeFunction · 0.85
emptyMethod · 0.45
public_key_algorithmMethod · 0.45
serializeMethod · 0.45
sizeMethod · 0.45
valid_fromMethod · 0.45

Tested by

no test coverage detected