Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Barnes committed Sep 11, 2023
1 parent be8c34c commit 8e84d21
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
11 changes: 7 additions & 4 deletions include/mls/credential.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace MLS_NAMESPACE {

namespace hpke {
struct UserInfoVC;
struct UserInfoVC;
}

// struct {
Expand Down Expand Up @@ -68,10 +68,13 @@ struct UserInfoVCCredential
bool valid_for(const SignaturePublicKey& pub) const;
bool valid_from(const PublicJWK& pub) const;

friend tls::ostream operator<<(tls::ostream& str, const UserInfoVCCredential& obj);
friend tls::ostream operator<<(tls::ostream& str,
const UserInfoVCCredential& obj);
friend tls::istream operator>>(tls::istream& str, UserInfoVCCredential& obj);
friend bool operator==(const UserInfoVCCredential& lhs, const UserInfoVCCredential& rhs);
friend bool operator!=(const UserInfoVCCredential& lhs, const UserInfoVCCredential& rhs);
friend bool operator==(const UserInfoVCCredential& lhs,
const UserInfoVCCredential& rhs);
friend bool operator!=(const UserInfoVCCredential& lhs,
const UserInfoVCCredential& rhs);

private:
std::shared_ptr<hpke::UserInfoVC> _vc;
Expand Down
3 changes: 2 additions & 1 deletion include/mls/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ struct SignaturePublicKey
TLS_SERIALIZABLE(data)
};

struct PublicJWK {
struct PublicJWK
{
SignatureScheme signature_scheme;
std::optional<std::string> key_id;
SignaturePublicKey public_key;
Expand Down
22 changes: 14 additions & 8 deletions src/credential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ operator==(const X509Credential& lhs, const X509Credential& rhs)
UserInfoVCCredential::UserInfoVCCredential(std::string userinfo_vc_jwt_in)
: userinfo_vc_jwt(std::move(userinfo_vc_jwt_in))
, _vc(std::make_shared<hpke::UserInfoVC>(userinfo_vc_jwt))
{}
{
}

bool
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
Expand All @@ -140,28 +141,33 @@ UserInfoVCCredential::valid_from(const PublicJWK& pub) const
return _vc->valid_from(*sig_pub);
}

tls::ostream operator<<(tls::ostream& str, const UserInfoVCCredential& obj) {
tls::ostream
operator<<(tls::ostream& str, const UserInfoVCCredential& obj)
{
return str << from_ascii(obj.userinfo_vc_jwt);
}

tls::istream operator>>(tls::istream& str, UserInfoVCCredential& obj) {
tls::istream
operator>>(tls::istream& str, UserInfoVCCredential& obj)
{
auto jwt = bytes{};
str >> jwt;
obj = UserInfoVCCredential(to_ascii(jwt));
return str;
}

bool operator==(const UserInfoVCCredential& lhs, const UserInfoVCCredential& rhs) {
bool
operator==(const UserInfoVCCredential& lhs, const UserInfoVCCredential& rhs)
{
return lhs.userinfo_vc_jwt == rhs.userinfo_vc_jwt;
}

bool operator!=(const UserInfoVCCredential& lhs, const UserInfoVCCredential& rhs) {
bool
operator!=(const UserInfoVCCredential& lhs, const UserInfoVCCredential& rhs)
{
return !(lhs == rhs);
}




///
/// CredentialBinding and MultiCredential
///
Expand Down
3 changes: 2 additions & 1 deletion test/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ TEST_CASE("Signature Key JWK Import/Export")

const auto known_scheme = SignatureScheme::ed25519;
const auto known_key_id = std::string("059fc2ee-5ef6-456a-91d8-49c422c772b2");
const auto knwon_pub_data = from_hex("9a2963aa2940655db2164a88061af186fb76c0832f3ed90d105ceece21063ad2");
const auto knwon_pub_data = from_hex(
"9a2963aa2940655db2164a88061af186fb76c0832f3ed90d105ceece21063ad2");

const auto jwk = PublicJWK::parse(full_jwk);
REQUIRE(jwk.signature_scheme == known_scheme);
Expand Down

0 comments on commit 8e84d21

Please sign in to comment.