| 1 | #cxx . . $ `<file>/mlspp/src/credential.cpp`/include <hpke/certificate.h>cxx . . $ `<file>/mlspp/lib/hpke/include/hpke/certificate.h`/ |
| 2 | #include <hpke/userinfo_vc.h>cxx . . $ `<file>/mlspp/lib/hpke/include/hpke/userinfo_vc.h`/ |
| 3 | #include <mls/credential.h>cxx . . $ `<file>/mlspp/include/mls/credential.h`/ |
| 4 | #include <tls/tls_syntax.h>cxx . . $ `<file>/mlspp/lib/bytes/include/tls/tls_syntax.h`/ |
| 5 | |
| 6 | namespace mlsppcxx . . $ mlspp/ { |
| 7 | |
| 8 | /// |
| 9 | /// X509Credential |
| 10 | /// |
| 11 | |
| 12 | using mlsppcxx . . $ mlspp/::hpkecxx . . $ mlspp/hpke/::Certificatecxx . . $ mlspp/Certificate#; // NOLINT(misc-unused-using-decls) |
| 13 | using mlsppcxx . . $ mlspp/::hpkecxx . . $ mlspp/hpke/::Signaturecxx . . $ mlspp/Signature#; // NOLINT(misc-unused-using-decls) |
| 14 | using mlsppcxx . . $ mlspp/::hpkecxx . . $ mlspp/hpke/::UserInfoVCcxx . . $ mlspp/UserInfoVC#; // NOLINT(misc-unused-using-decls) |
| 15 | |
| 16 | static const Signaturecxx . . $ mlspp/Signature#& |
| 17 | find_signaturecxx . . $ mlspp/find_signature(d50defb9af3e200b).(Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID# id) |
| 18 | { |
| 19 | switch (id) { |
| 20 | case Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::P256_SHA256cxx . . $ mlspp/hpke/Signature#ID#P256_SHA256.: |
| 21 | return Signaturecxx . . $ mlspp/hpke/Signature#::getcxx . . $ mlspp/hpke/Signature#get(9e8bfd5ad9358347).<Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::P256_SHA256cxx . . $ mlspp/hpke/Signature#ID#P256_SHA256.>(); |
| 22 | case Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::P384_SHA384cxx . . $ mlspp/hpke/Signature#ID#P384_SHA384.: |
| 23 | return Signaturecxx . . $ mlspp/hpke/Signature#::getcxx . . $ mlspp/hpke/Signature#get(9e8bfd5ad9358347).<Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::P384_SHA384cxx . . $ mlspp/hpke/Signature#ID#P384_SHA384.>(); |
| 24 | case Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::P521_SHA512cxx . . $ mlspp/hpke/Signature#ID#P521_SHA512.: |
| 25 | return Signaturecxx . . $ mlspp/hpke/Signature#::getcxx . . $ mlspp/hpke/Signature#get(9e8bfd5ad9358347).<Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::P521_SHA512cxx . . $ mlspp/hpke/Signature#ID#P521_SHA512.>(); |
| 26 | case Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::Ed25519cxx . . $ mlspp/hpke/Signature#ID#Ed25519.: |
| 27 | return Signaturecxx . . $ mlspp/hpke/Signature#::getcxx . . $ mlspp/hpke/Signature#get(9e8bfd5ad9358347).<Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::Ed25519cxx . . $ mlspp/hpke/Signature#ID#Ed25519.>(); |
| 28 | #if !defined(WITH_BORINGSSL) |
| 29 | case Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::Ed448cxx . . $ mlspp/hpke/Signature#ID#Ed448.: |
| 30 | return Signaturecxx . . $ mlspp/hpke/Signature#::getcxx . . $ mlspp/hpke/Signature#get(9e8bfd5ad9358347).<Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::Ed448cxx . . $ mlspp/hpke/Signature#ID#Ed448.>(); |
| 31 | #endif |
| 32 | case Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::RSA_SHA256cxx . . $ mlspp/hpke/Signature#ID#RSA_SHA256.: |
| 33 | return Signaturecxx . . $ mlspp/hpke/Signature#::getcxx . . $ mlspp/hpke/Signature#get(9e8bfd5ad9358347).<Signaturecxx . . $ mlspp/hpke/Signature#::IDcxx . . $ mlspp/hpke/Signature#ID#::RSA_SHA256cxx . . $ mlspp/hpke/Signature#ID#RSA_SHA256.>(); |
| 34 | default: |
| 35 | throw InvalidParameterErrorcxx . . $ mlspp/InvalidParameterError#("Unsupported algorithm"); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | static stdcxx . . $ std/::vectorcxx . . $ std/vector#<X509Credentialcxx . . $ mlspp/X509Credential#::CertDatacxx . . $ mlspp/X509Credential#CertData#> |
| 40 | bytes_to_x509_credential_datacxx . . $ mlspp/bytes_to_x509_credential_data(a34e0adcf7f36f2c).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<bytescxx . . $ mlspp/bytes_ns/bytes#>& data_in) |
| 41 | { |
| 42 | return stdxcxx . . $ mlspp/stdx/::transformcxx . . $ mlspp/stdx/transform(895a059819fd6266).<X509Credentialcxx . . $ mlspp/X509Credential#::CertDatacxx . . $ mlspp/X509Credential#CertData#>( |
| 43 | data_in, [](const bytescxx . . $ mlspp/bytes_ns/bytes#& der) { return X509Credentialcxx . . $ mlspp/X509Credential#::CertDatacxx . . $ mlspp/X509Credential#CertData#{ der }; }); |
| 44 | } |
| 45 | |
| 46 | X509Credentialcxx . . $ mlspp/X509Credential#::X509Credentialcxx . . $ mlspp/X509Credential#X509Credential(89eaccbce9cd186b).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<bytescxx . . $ mlspp/bytes_ns/bytes#>& der_chain_in) |
| 47 | : der_chaincxx . . $ mlspp/X509Credential#der_chain.(bytes_to_x509_credential_datacxx . . $ mlspp/bytes_to_x509_credential_data(a34e0adcf7f36f2c).(der_chain_in)) |
| 48 | { |
| 49 | if (der_chaincxx . . $ mlspp/X509Credential#der_chain..emptycxx . . $ std/vector#empty(3482b152b9333168).()) { |
| 50 | throw stdcxx . . $ std/::invalid_argumentcxx . . $ std/invalid_argument#("empty certificate chain"); |
| 51 | } |
| 52 | |
| 53 | // Parse the chain |
| 54 | auto parsed = stdcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).::vectorcxx . . $ std/vector#<Certificatecxx . . $ mlspp/Certificate#>(); |
| 55 | for (const auto& cert : der_chaincxx . . $ mlspp/X509Credential#der_chain.) { |
| 56 | parsed.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(cert.datacxx . . $ mlspp/X509Credential#CertData#data.); |
| 57 | } |
| 58 | |
| 59 | // first element represents leaf cert |
| 60 | const auto& sig = find_signaturecxx . . $ mlspp/find_signature(d50defb9af3e200b).(parsed[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].public_key_algorithmcxx . . $ mlspp/hpke/Certificate#public_key_algorithm(b408284008ef55c).()); |
| 61 | const auto pub_data = sig.serializecxx . . $ mlspp/hpke/Signature#serialize(85b79100656811f8).(*cxx . . $ std/unique_ptr#`operator*`(26c95836c1e8ca05).parsed[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].public_keycxx . . $ mlspp/hpke/Certificate#public_key.); |
| 62 | _signature_schemecxx . . $ mlspp/X509Credential#_signature_scheme. = tls_signature_schemecxx . . $ mlspp/tls_signature_scheme(902aafe9a6722bee).(parsed[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).0].public_key_algorithmcxx . . $ mlspp/hpke/Certificate#public_key_algorithm(b408284008ef55c).()); |
| 63 | _public_keycxx . . $ mlspp/X509Credential#_public_key. =cxx . . $ mlspp/SignaturePublicKey#`operator=`(d72040f9c8f023cb). SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey#{ pub_data }; |
| 64 | |
| 65 | // verify chain for valid signatures |
| 66 | for (size_t i = 0; i < der_chaincxx . . $ mlspp/X509Credential#der_chain..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() - 1; i++) { |
| 67 | if (!parsed[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i].valid_fromcxx . . $ mlspp/hpke/Certificate#valid_from(f27b537b6bc2a77e).(parsed[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i + 1])) { |
| 68 | throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#("Certificate Chain validation failure"); |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | SignatureSchemecxx . . $ mlspp/SignatureScheme# |
| 74 | X509Credentialcxx . . $ mlspp/X509Credential#::signature_schemecxx . . $ mlspp/X509Credential#signature_scheme(25c8e3499195dd1).() const |
| 75 | { |
| 76 | return _signature_schemecxx . . $ mlspp/X509Credential#_signature_scheme.; |
| 77 | } |
| 78 | |
| 79 | SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey# |
| 80 | X509Credentialcxx . . $ mlspp/X509Credential#::public_keycxx . . $ mlspp/X509Credential#public_key(12d241d5a3fd9b02).() const |
| 81 | { |
| 82 | return _public_keycxx . . $ mlspp/X509Credential#_public_key.; |
| 83 | } |
| 84 | |
| 85 | bool |
| 86 | X509Credentialcxx . . $ mlspp/X509Credential#::valid_forcxx . . $ mlspp/X509Credential#valid_for(9a76ab9c2cdc40ef).(const SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey#& pub) const |
| 87 | { |
| 88 | return pub ==cxx . . $ mlspp/`operator==`(5401d31d8ac0aee4). public_keycxx . . $ mlspp/X509Credential#public_key(12d241d5a3fd9b02).(); |
| 89 | } |
| 90 | |
| 91 | tlscxx . . $ mlspp/tls/::ostreamcxx . . $ mlspp/tls/ostream#& |
| 92 | operatorcxx . . $ mlspp/`operator<<`(29b09f31e48c5f2c).<<(tlscxx . . $ mlspp/tls/::ostreamcxx . . $ mlspp/tls/ostream#& str, const X509Credentialcxx . . $ mlspp/X509Credential#& obj) |
| 93 | { |
| 94 | return str <<cxx . . $ mlspp/tls/`operator<<`(60620eb73935a469). obj.der_chaincxx . . $ mlspp/X509Credential#der_chain.; |
| 95 | } |
| 96 | |
| 97 | tlscxx . . $ mlspp/tls/::istreamcxx . . $ mlspp/tls/istream#& |
| 98 | operatorcxx . . $ mlspp/`operator>>`(53950f4f66bc7667).>>(tlscxx . . $ mlspp/tls/::istreamcxx . . $ mlspp/tls/istream#& str, X509Credentialcxx . . $ mlspp/X509Credential#& obj) |
| 99 | { |
| 100 | auto der_chain = stdcxx . . $ std/vector#vector(49f6e7a06ebc5aa8).::vectorcxx . . $ std/vector#<X509Credentialcxx . . $ mlspp/X509Credential#::CertDatacxx . . $ mlspp/X509Credential#CertData#>{}; |
| 101 | str >>cxx . . $ mlspp/tls/`operator>>`(7ff05afe8fa0e542). der_chain; |
| 102 | |
| 103 | auto der_in = stdxcxx . . $ mlspp/stdx/::transformcxx . . $ mlspp/stdx/transform(895a059819fd6266).<bytescxx . . $ mlspp/bytes_ns/bytes#>( |
| 104 | der_chain, [](const auto& cert_data) { return cert_data.data; }); |
| 105 | obj =cxx . . $ mlspp/X509Credential#`operator=`(c25c44bc979a6315). X509Credentialcxx . . $ mlspp/X509Credential#(der_in); |
| 106 | |
| 107 | return str; |
| 108 | } |
| 109 | |
| 110 | bool |
| 111 | operatorcxx . . $ mlspp/`operator==`(be1fd05050b0c885).==(const X509Credentialcxx . . $ mlspp/X509Credential#& lhs, const X509Credentialcxx . . $ mlspp/X509Credential#& rhs) |
| 112 | { |
| 113 | return lhs.der_chaincxx . . $ mlspp/X509Credential#der_chain. ==cxx . . $ std/`operator==`(a0a51a13f7e42509). rhs.der_chaincxx . . $ mlspp/X509Credential#der_chain.; |
| 114 | } |
| 115 | |
| 116 | /// |
| 117 | /// UserInfoVCCredential |
| 118 | /// |
| 119 | UserInfoVCCredentialcxx . . $ mlspp/UserInfoVCCredential#::UserInfoVCCredentialcxx . . $ mlspp/UserInfoVCCredential#UserInfoVCCredential(8d4ab0a187bf9331).(stdcxx . . $ std/::stringcxx . . $ std/string# userinfo_vc_jwt_in) |
| 120 | : userinfo_vc_jwtcxx . . $ mlspp/UserInfoVCCredential#userinfo_vc_jwt.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(userinfo_vc_jwt_in)) |
| 121 | , _vccxx . . $ mlspp/UserInfoVCCredential#_vc.(stdcxx . . $ std/::make_sharedcxx . . $ std/make_shared(ffca0f3977536948).<hpkecxx . . $ mlspp/hpke/::UserInfoVCcxx . . $ mlspp/hpke/UserInfoVC#>(userinfo_vc_jwtcxx . . $ mlspp/UserInfoVCCredential#userinfo_vc_jwt.)) |
| 122 | { |
| 123 | } |
| 124 | |
| 125 | bool |
| 126 | // NOLINTNEXTLINE(readability-convert-member-functions-to-static) |
| 127 | UserInfoVCCredentialcxx . . $ mlspp/UserInfoVCCredential#::valid_forcxx . . $ mlspp/UserInfoVCCredential#valid_for(9a76ab9c2cdc40ef).(const SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey#& pub) const |
| 128 | { |
| 129 | const auto& vc_pub = _vccxx . . $ mlspp/UserInfoVCCredential#_vc.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).public_keycxx . . $ mlspp/hpke/UserInfoVC#public_key(49df469d8c60bc98).(); |
| 130 | return pub.datacxx . . $ mlspp/SignaturePublicKey#data. ==cxx . . $ mlspp/bytes_ns/bytes#`operator==`(efd4f3c976ab92ce). vc_pub.sigcxx . . $ mlspp/hpke/Signature#PublicJWK#sig..serializecxx . . $ mlspp/hpke/Signature#serialize(85b79100656811f8).(*cxx . . $ std/unique_ptr#`operator*`(26c95836c1e8ca05).vc_pub.keycxx . . $ mlspp/hpke/Signature#PublicJWK#key.); |
| 131 | } |
| 132 | |
| 133 | bool |
| 134 | UserInfoVCCredentialcxx . . $ mlspp/UserInfoVCCredential#::valid_fromcxx . . $ mlspp/UserInfoVCCredential#valid_from(37c0a6423f04786b).(const PublicJWKcxx . . $ mlspp/PublicJWK#& pub) const |
| 135 | { |
| 136 | const auto& sig = _vccxx . . $ mlspp/UserInfoVCCredential#_vc.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).signature_algorithmcxx . . $ mlspp/hpke/UserInfoVC#signature_algorithm(aab2196748eae221).(); |
| 137 | if (pub.signature_schemecxx . . $ mlspp/PublicJWK#signature_scheme. != tls_signature_schemecxx . . $ mlspp/tls_signature_scheme(902aafe9a6722bee).(sig.idcxx . . $ mlspp/hpke/Signature#id.)) { |
| 138 | return false; |
| 139 | } |
| 140 | |
| 141 | const auto sig_pub = sig.deserializecxx . . $ mlspp/hpke/Signature#deserialize(321ec828a61140d).(pub.public_keycxx . . $ mlspp/PublicJWK#public_key..datacxx . . $ mlspp/SignaturePublicKey#data.); |
| 142 | return _vccxx . . $ mlspp/UserInfoVCCredential#_vc.->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).valid_fromcxx . . $ mlspp/hpke/UserInfoVC#valid_from(f3d66fc16086329f).(*cxx . . $ std/unique_ptr#`operator*`(26c95836c1e8ca05).sig_pub); |
| 143 | } |
| 144 | |
| 145 | tlscxx . . $ mlspp/tls/::ostreamcxx . . $ mlspp/tls/ostream# |
| 146 | operatorcxx . . $ mlspp/`operator<<`(3d592eb4e02d4d67).<<(tlscxx . . $ mlspp/tls/::ostreamcxx . . $ mlspp/tls/ostream#& str, const UserInfoVCCredentialcxx . . $ mlspp/UserInfoVCCredential#& obj) |
| 147 | { |
| 148 | return str <<cxx . . $ mlspp/tls/`operator<<`(412b32e9a88efffb). from_asciicxx . . $ mlspp/bytes_ns/from_ascii(fc01d114001b7256).(obj.userinfo_vc_jwtcxx . . $ mlspp/UserInfoVCCredential#userinfo_vc_jwt.); |
| 149 | } |
| 150 | |
| 151 | tlscxx . . $ mlspp/tls/::istreamcxx . . $ mlspp/tls/istream# |
| 152 | operatorcxx . . $ mlspp/`operator>>`(fc9244adb8e2d223).>>(tlscxx . . $ mlspp/tls/::istreamcxx . . $ mlspp/tls/istream#& str, UserInfoVCCredentialcxx . . $ mlspp/UserInfoVCCredential#& obj) |
| 153 | { |
| 154 | auto jwt = bytescxx . . $ mlspp/bytes_ns/bytes#bytes(ced63f7c635d850d).{}; |
| 155 | str >>cxx . . $ mlspp/tls/`operator>>`(b2c72a419bbd3d19). jwt; |
| 156 | obj =cxx . . $ mlspp/UserInfoVCCredential#`operator=`(6a5a62f3596d0d57). UserInfoVCCredentialcxx . . $ mlspp/UserInfoVCCredential#(to_asciicxx . . $ mlspp/bytes_ns/to_ascii(b0627b6bf491e6e2).(jwt)); |
| 157 | return str; |
| 158 | } |
| 159 | |
| 160 | bool |
| 161 | operatorcxx . . $ mlspp/`operator==`(20dac2ddef4f4d38).==(const UserInfoVCCredentialcxx . . $ mlspp/UserInfoVCCredential#& lhs, const UserInfoVCCredentialcxx . . $ mlspp/UserInfoVCCredential#& rhs) |
| 162 | { |
| 163 | return lhs.userinfo_vc_jwtcxx . . $ mlspp/UserInfoVCCredential#userinfo_vc_jwt. ==cxx . . $ std/`operator==`(5ea818b58063a774). rhs.userinfo_vc_jwtcxx . . $ mlspp/UserInfoVCCredential#userinfo_vc_jwt.; |
| 164 | } |
| 165 | |
| 166 | bool |
| 167 | operatorcxx . . $ mlspp/`operator!=`(20dac2ddef4f4d38).!=(const UserInfoVCCredentialcxx . . $ mlspp/UserInfoVCCredential#& lhs, const UserInfoVCCredentialcxx . . $ mlspp/UserInfoVCCredential#& rhs) |
| 168 | { |
| 169 | return !(lhs ==cxx . . $ mlspp/`operator==`(20dac2ddef4f4d38). rhs); |
| 170 | } |
| 171 | |
| 172 | /// |
| 173 | /// CredentialBinding and MultiCredential |
| 174 | /// |
| 175 | |
| 176 | struct CredentialBindingTBScxx . . $ mlspp/CredentialBindingTBS# |
| 177 | { |
| 178 | const CipherSuitecxx . . $ mlspp/CipherSuite#& cipher_suitecxx . . $ mlspp/CredentialBindingTBS#cipher_suite.; |
| 179 | const Credentialcxx . . $ mlspp/Credential#& credentialcxx . . $ mlspp/CredentialBindingTBS#credential.; |
| 180 | const SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey#& credential_keycxx . . $ mlspp/CredentialBindingTBS#credential_key.; |
| 181 | const SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey#& signature_keycxx . . $ mlspp/CredentialBindingTBS#signature_key.; |
| 182 | |
| 183 | TLS_SERIALIZABLEcxx . . $ `mlspp/lib/bytes/include/tls/tls_syntax.h:333:9`!(cipher_suite, credential, credential_key, signature_key) |
| 184 | }; |
| 185 | |
| 186 | CredentialBindingcxx . . $ mlspp/CredentialBinding#::CredentialBindingcxx . . $ mlspp/CredentialBinding#CredentialBinding(3fd21b6206897d2).(CipherSuitecxx . . $ mlspp/CipherSuite# cipher_suite_in, |
| 187 | Credentialcxx . . $ mlspp/Credential# credential_in, |
| 188 | const SignaturePrivateKeycxx . . $ mlspp/SignaturePrivateKey#& credential_priv, |
| 189 | const SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey#& signature_key) |
| 190 | : cipher_suitecxx . . $ mlspp/CredentialBinding#cipher_suite.(cipher_suite_in) |
| 191 | , credentialcxx . . $ mlspp/CredentialBinding#credential.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(credential_in)) |
| 192 | , credential_keycxx . . $ mlspp/CredentialBinding#credential_key.(credential_priv.public_keycxx . . $ mlspp/SignaturePrivateKey#public_key.) |
| 193 | { |
| 194 | if (credentialcxx . . $ mlspp/CredentialBinding#credential..typecxx . . $ mlspp/Credential#type(4ec975920d5c26ae).() == CredentialTypecxx . . $ mlspp/CredentialType#::multi_draft_00cxx . . $ mlspp/CredentialType#multi_draft_00.) { |
| 195 | throw InvalidParameterErrorcxx . . $ mlspp/InvalidParameterError#("Multi-credentials cannot be nested"); |
| 196 | } |
| 197 | |
| 198 | if (!credentialcxx . . $ mlspp/CredentialBinding#credential..valid_forcxx . . $ mlspp/Credential#valid_for(9a76ab9c2cdc40ef).(credential_keycxx . . $ mlspp/CredentialBinding#credential_key.)) { |
| 199 | throw InvalidParameterErrorcxx . . $ mlspp/InvalidParameterError#("Credential key does not match credential"); |
| 200 | } |
| 201 | |
| 202 | signaturecxx . . $ mlspp/CredentialBinding#signature. =cxx . . $ mlspp/bytes_ns/bytes#`operator=`(463b53a2545785ed). credential_priv.signcxx . . $ mlspp/SignaturePrivateKey#sign(9a20592b3b42a8ed).( |
| 203 | cipher_suitecxx . . $ mlspp/CredentialBinding#cipher_suite., sign_labelcxx . . $ mlspp/sign_label/::multi_credentialcxx . . $ mlspp/sign_label/multi_credential., to_be_signedcxx . . $ mlspp/CredentialBinding#to_be_signed(2aa6f66295221c4d).(signature_key)); |
| 204 | } |
| 205 | |
| 206 | bytescxx . . $ mlspp/bytes_ns/bytes# |
| 207 | CredentialBindingcxx . . $ mlspp/CredentialBinding#::to_be_signedcxx . . $ mlspp/CredentialBinding#to_be_signed(2aa6f66295221c4d).(const SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey#& signature_key) const |
| 208 | { |
| 209 | return tlscxx . . $ mlspp/bytes_ns/bytes#bytes(dd8c33c7e39dbe02).::marshalcxx . . $ mlspp/tls/marshal(7df0b13a9cabe487).(CredentialBindingTBScxx . . $ mlspp/CredentialBindingTBS#{ |
| 210 | cipher_suitecxx . . $ mlspp/CredentialBinding#cipher_suite., credentialcxx . . $ mlspp/CredentialBinding#credential., credential_keycxx . . $ mlspp/CredentialBinding#credential_key., signature_key }); |
| 211 | } |
| 212 | |
| 213 | bool |
| 214 | CredentialBindingcxx . . $ mlspp/CredentialBinding#::valid_forcxx . . $ mlspp/CredentialBinding#valid_for(9a76ab9c2cdc40ef).(const SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey#& signature_key) const |
| 215 | { |
| 216 | auto valid_self = credentialcxx . . $ mlspp/CredentialBinding#credential..valid_forcxx . . $ mlspp/Credential#valid_for(9a76ab9c2cdc40ef).(credential_keycxx . . $ mlspp/CredentialBinding#credential_key.); |
| 217 | auto valid_other = credential_keycxx . . $ mlspp/CredentialBinding#credential_key..verifycxx . . $ mlspp/SignaturePublicKey#verify(e28f084f4f4fb6fe).(cipher_suitecxx . . $ mlspp/CredentialBinding#cipher_suite., |
| 218 | sign_labelcxx . . $ mlspp/sign_label/::multi_credentialcxx . . $ mlspp/sign_label/multi_credential., |
| 219 | to_be_signedcxx . . $ mlspp/CredentialBinding#to_be_signed(2aa6f66295221c4d).(signature_key), |
| 220 | signaturecxx . . $ mlspp/CredentialBinding#signature.); |
| 221 | |
| 222 | return valid_self && valid_other; |
| 223 | } |
| 224 | |
| 225 | MultiCredentialcxx . . $ mlspp/MultiCredential#::MultiCredentialcxx . . $ mlspp/MultiCredential#MultiCredential(1a27324a5f510bbe).( |
| 226 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<CredentialBindingInputcxx . . $ mlspp/CredentialBindingInput#>& binding_inputs, |
| 227 | const SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey#& signature_key) |
| 228 | { |
| 229 | bindingscxx . . $ mlspp/MultiCredential#bindings. =cxx . . $ std/vector#`operator=`(1104576815caab1a). |
| 230 | stdxcxx . . $ mlspp/stdx/::transformcxx . . $ mlspp/stdx/transform(895a059819fd6266).<CredentialBindingcxx . . $ mlspp/CredentialBinding#>(binding_inputs, [&](auto&& input) { |
| 231 | return CredentialBindingcxx . . $ mlspp/CredentialBinding#(input.cipher_suite, |
| 232 | input.credential, |
| 233 | input.credential_priv, |
| 234 | signature_key); |
| 235 | }); |
| 236 | } |
| 237 | |
| 238 | bool |
| 239 | MultiCredentialcxx . . $ mlspp/MultiCredential#::valid_forcxx . . $ mlspp/MultiCredential#valid_for(9a76ab9c2cdc40ef).(const SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey#& pub) const |
| 240 | { |
| 241 | return stdxcxx . . $ mlspp/stdx/::all_ofcxx . . $ mlspp/stdx/all_of(acb94948942028a1).( |
| 242 | bindingscxx . . $ mlspp/MultiCredential#bindings., [&](const auto& binding) { return binding.valid_for(pub); }); |
| 243 | } |
| 244 | |
| 245 | /// |
| 246 | /// Credential |
| 247 | /// |
| 248 | |
| 249 | CredentialTypecxx . . $ mlspp/CredentialType# |
| 250 | Credentialcxx . . $ mlspp/Credential#::typecxx . . $ mlspp/Credential#type(4ec975920d5c26ae).() const |
| 251 | { |
| 252 | return tlscxx . . $ mlspp/tls/::variantcxx . . $ mlspp/tls/variant#<CredentialType>::typecxx . . $ mlspp/tls/variant#type(8316fbe92d80cb85).(_credcxx . . $ mlspp/Credential#_cred.); |
| 253 | } |
| 254 | |
| 255 | Credentialcxx . . $ mlspp/Credential# |
| 256 | Credentialcxx . . $ mlspp/Credential#::basiccxx . . $ mlspp/Credential#basic(2a432aa7c0aa22fc).(const bytescxx . . $ mlspp/bytes_ns/bytes#& identity) |
| 257 | { |
| 258 | return {cxx . . $ mlspp/Credential#Credential(c0b2462d20828d3c). BasicCredentialcxx . . $ std/variant#variant(5ba8255a4607184).{ identitycxx . . $ mlspp/bytes_ns/bytes#bytes(68ca607eebb5be3e). } }; |
| 259 | } |
| 260 | |
| 261 | Credentialcxx . . $ mlspp/Credential# |
| 262 | Credentialcxx . . $ mlspp/Credential#::x509cxx . . $ mlspp/Credential#x509(3dd90220e7cf33f5).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<bytescxx . . $ mlspp/bytes_ns/bytes#>& der_chain) |
| 263 | { |
| 264 | return {cxx . . $ mlspp/Credential#Credential(c0b2462d20828d3c). X509Credentialcxx . . $ std/variant#variant(5ba8255a4607184).{ der_chain } }; |
| 265 | } |
| 266 | |
| 267 | Credentialcxx . . $ mlspp/Credential# |
| 268 | Credentialcxx . . $ mlspp/Credential#::multicxx . . $ mlspp/Credential#multi(2baa8a922395a7e9).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<CredentialBindingInputcxx . . $ mlspp/CredentialBindingInput#>& binding_inputs, |
| 269 | const SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey#& signature_key) |
| 270 | { |
| 271 | return {cxx . . $ mlspp/Credential#Credential(c0b2462d20828d3c). MultiCredentialcxx . . $ std/variant#variant(5ba8255a4607184).{ binding_inputs, signature_key } }; |
| 272 | } |
| 273 | |
| 274 | Credentialcxx . . $ mlspp/Credential# |
| 275 | Credentialcxx . . $ mlspp/Credential#::userinfo_vccxx . . $ mlspp/Credential#userinfo_vc(608e56844219f95b).(const stdcxx . . $ std/::stringcxx . . $ std/string#& userinfo_vc_jwt) |
| 276 | { |
| 277 | return {cxx . . $ mlspp/Credential#Credential(c0b2462d20828d3c). UserInfoVCCredentialcxx . . $ std/variant#variant(5ba8255a4607184).{ userinfo_vc_jwtcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5). } }; |
| 278 | } |
| 279 | |
| 280 | bool |
| 281 | Credentialcxx . . $ mlspp/Credential#::valid_forcxx . . $ mlspp/Credential#valid_for(9a76ab9c2cdc40ef).(const SignaturePublicKeycxx . . $ mlspp/SignaturePublicKey#& pub) const |
| 282 | { |
| 283 | const auto pub_key_match = overloaded{ |
| 284 | [&](const X509Credentialcxx . . $ mlspp/X509Credential#& x509) { return x509.valid_forcxx . . $ mlspp/X509Credential#valid_for(9a76ab9c2cdc40ef).(pub); }, |
| 285 | [](const BasicCredentialcxx . . $ mlspp/BasicCredential#& /* basic */) { return true; }, |
| 286 | [&](const UserInfoVCCredentialcxx . . $ mlspp/UserInfoVCCredential#& vc) { return vc.valid_forcxx . . $ mlspp/UserInfoVCCredential#valid_for(9a76ab9c2cdc40ef).(pub); }, |
| 287 | [&](const MultiCredentialcxx . . $ mlspp/MultiCredential#& multi) { return multi.valid_forcxx . . $ mlspp/MultiCredential#valid_for(9a76ab9c2cdc40ef).(pub); }, |
| 288 | }; |
| 289 | |
| 290 | return var::visitcxx . . $ std/visit(9828ab07ec69b3d0).(pub_key_match, _credcxx . . $ mlspp/Credential#_cred.); |
| 291 | } |
| 292 | |
| 293 | Credentialcxx . . $ mlspp/Credential#::Credentialcxx . . $ mlspp/Credential#Credential(c0b2462d20828d3c).(SpecificCredentialcxx . . $ mlspp/Credential#SpecificCredential# specific) |
| 294 | : _credcxx . . $ mlspp/Credential#_cred.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(specific)) |
| 295 | { |
| 296 | } |
| 297 | |
| 298 | } // namespace mlspp |