Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/electronic-id/electronic-id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ class ElectronicID
* By default, this function does nothing. It serves as an extension point for
* Pkcs11ElectronicID which needs to release the PKCS#11 module before the application exits to
* prevent potential crashes. */
virtual void release() const {}
virtual void release() const { }

virtual std::string name() const = 0;
virtual Type type() const = 0;

virtual pcsc_cpp::SmartCard const& smartcard() const { return card; }

protected:
ElectronicID(pcsc_cpp::SmartCard&& _card) noexcept : card(std::move(_card)) {}
ElectronicID(pcsc_cpp::SmartCard&& _card) noexcept : card(std::move(_card)) { }

pcsc_cpp::SmartCard card;
};
Expand Down
21 changes: 9 additions & 12 deletions include/electronic-id/enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <string>
#include <string_view>
#include <utility>

namespace electronic_id
{
Expand All @@ -36,7 +37,7 @@ class CertificateType
enum CertificateTypeEnum : int8_t { AUTHENTICATION, SIGNING, NONE = -1 };

constexpr CertificateType() noexcept = default;
constexpr CertificateType(const CertificateTypeEnum _value) noexcept : value(_value) {}
constexpr CertificateType(const CertificateTypeEnum _value) noexcept : value(_value) { }

constexpr bool isAuthentication() const noexcept { return value == AUTHENTICATION; }
constexpr bool isSigning() const noexcept { return value == SIGNING; }
Expand Down Expand Up @@ -64,12 +65,10 @@ class HashAlgorithm
SHA3_256 = 256 * 10,
SHA3_384 = 384 * 10,
SHA3_512 = 512 * 10,

NONE = -1
};

constexpr HashAlgorithm() = default;
constexpr HashAlgorithm(const HashAlgorithmEnum _value) noexcept : value(_value) {}
constexpr HashAlgorithm(const HashAlgorithmEnum _value) noexcept : value(_value) { }
// String conversion constructor.
explicit HashAlgorithm(const std::string&);

Expand Down Expand Up @@ -97,7 +96,7 @@ class HashAlgorithm
static pcsc_cpp::byte_vector rsaOID(const HashAlgorithmEnum hash);

private:
HashAlgorithmEnum value = NONE;
HashAlgorithmEnum value;
};

/** Signature algorithms */
Expand Down Expand Up @@ -135,10 +134,10 @@ class SignatureAlgorithm
RS3_256 = RS | int16_t(HashAlgorithm::SHA3_256),
RS3_384 = RS | int16_t(HashAlgorithm::SHA3_384),
RS3_512 = RS | int16_t(HashAlgorithm::SHA3_512),
NONE = -1
NONE = -1,
};

constexpr SignatureAlgorithm(const SignatureAlgorithmEnum _value) noexcept : value(_value) {}
constexpr SignatureAlgorithm(const SignatureAlgorithmEnum _value) noexcept : value(_value) { }
constexpr SignatureAlgorithm(const SignatureAlgorithmEnum key,
const HashAlgorithm hash) noexcept :
value(SignatureAlgorithmEnum(key | int16_t(hash)))
Expand Down Expand Up @@ -187,7 +186,7 @@ class JsonWebSignatureAlgorithm

operator std::string_view() const noexcept;

constexpr HashAlgorithm hashAlgorithm() const
constexpr HashAlgorithm hashAlgorithm() const noexcept
{
switch (value) {
case ES256:
Expand All @@ -202,18 +201,16 @@ class JsonWebSignatureAlgorithm
case PS512:
case RS512:
return HashAlgorithm::SHA512;
default:
throw std::logic_error("JsonWebSignatureAlgorithm::hashAlgorithm(): Invalid value "
+ std::to_string(value));
}
std::unreachable();
}

constexpr bool isRSAWithPKCS1Padding() const noexcept
{
return value == RS256 || value == RS384 || value == RS512;
}

constexpr size_t hashByteLength() const { return hashAlgorithm().hashByteLength(); }
constexpr size_t hashByteLength() const noexcept { return hashAlgorithm().hashByteLength(); }

private:
static constexpr JsonWebSignatureAlgorithmEnum validate(JsonWebSignatureAlgorithmEnum v)
Expand Down
2 changes: 1 addition & 1 deletion lib/libpcsc-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ target_include_directories(${PROJECT_NAME}

target_compile_features(${PROJECT_NAME}
PUBLIC
cxx_std_20
cxx_std_23
)

target_compile_options(${PROJECT_NAME} PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion src/electronic-id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct MaskedATREntry
{
}

bool operator==(const byte_vector& atr) const
PCSC_CPP_CONSTEXPR_VECTOR bool operator==(const byte_vector& atr) const
{
return std::equal(atr.cbegin(), atr.cend(), pattern.cbegin(), pattern.cend(),
[mask_ptr = mask.data()](byte_type a, byte_type p) mutable {
Expand Down
Loading