Skip to content
Merged
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: 4 additions & 0 deletions src/core/crypto/crypto_hkdf_apple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ auto to_selector(const sourcemeta::core::KDFHash hash) noexcept -> int {
return 2;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto octets(const std::string_view value) noexcept -> const unsigned char * {
Expand Down
4 changes: 4 additions & 0 deletions src/core/crypto/crypto_hkdf_openssl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ auto digest_name(const sourcemeta::core::KDFHash hash) noexcept -> const
return "SHA512";
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

// An empty view may carry a null pointer, which the parameter interface would
Expand Down
8 changes: 8 additions & 0 deletions src/core/crypto/crypto_hkdf_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ auto hash_name(const sourcemeta::core::KDFHash hash) noexcept -> LPCWSTR {
return BCRYPT_SHA512_ALGORITHM;
}

// Clang settles that no other value arrives, so only GCC and MSVC

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Both comments are over-indented for the configured LLVM style, so clang_format_test fails. Indent each comment by two spaces.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/core/crypto/crypto_hkdf_windows.cc, line 29:

<comment>Both comments are over-indented for the configured LLVM style, so `clang_format_test` fails. Indent each comment by two spaces.</comment>

<file context>
@@ -26,7 +26,11 @@ auto hash_name(const sourcemeta::core::KDFHash hash) noexcept -> LPCWSTR {
       return BCRYPT_SHA512_ALGORITHM;
   }
 
+    // Clang settles that no other value arrives, so only GCC and MSVC
+    // need to be told that the end of this function is never reached
+#if !defined(__clang__)
</file context>

// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto hash_name_bytes(const sourcemeta::core::KDFHash hash) noexcept -> ULONG {
Expand All @@ -39,7 +43,11 @@ auto hash_name_bytes(const sourcemeta::core::KDFHash hash) noexcept -> ULONG {
return sizeof(BCRYPT_SHA512_ALGORITHM);
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto as_native(const std::string_view value) noexcept -> PUCHAR {
Expand Down
4 changes: 4 additions & 0 deletions src/core/crypto/crypto_rsa_oaep_apple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ auto to_oaep_algorithm(const RSAOAEPHash hash) -> SecKeyAlgorithm {
return kSecKeyAlgorithmRSAEncryptionOAEPSHA256;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}
} // namespace

Expand Down
4 changes: 4 additions & 0 deletions src/core/crypto/crypto_rsa_oaep_openssl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ auto to_message_digest(const RSAOAEPHash hash) -> const EVP_MD * {
return EVP_sha256();
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto configure(EVP_PKEY_CTX *context, const RSAOAEPHash hash) -> bool {
Expand Down
4 changes: 4 additions & 0 deletions src/core/crypto/crypto_rsa_oaep_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ auto to_cng_algorithm(const RSAOAEPHash hash) -> LPCWSTR {
return BCRYPT_SHA256_ALGORITHM;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto as_buffer(const std::string_view value) -> PUCHAR {
Expand Down
24 changes: 24 additions & 0 deletions src/core/crypto/crypto_sign_apple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ auto to_sec_key_pkcs1_v15_algorithm(
return kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA512;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

// These algorithm variants fix the salt length to the hash function output,
Expand All @@ -51,7 +55,11 @@ auto to_sec_key_pss_algorithm(
return kSecKeyAlgorithmRSASignatureMessagePSSSHA512;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto to_sec_key_ecdsa_algorithm(
Expand All @@ -66,7 +74,11 @@ auto to_sec_key_ecdsa_algorithm(
return kSecKeyAlgorithmECDSASignatureMessageX962SHA512;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto make_data(const std::string_view value) -> CFDataRef {
Expand Down Expand Up @@ -332,7 +344,11 @@ auto make_private_key(const std::string_view pem) -> std::optional<PrivateKey> {
}
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto make_ec_private_key(const EllipticCurve curve,
Expand Down Expand Up @@ -482,7 +498,11 @@ auto eddsa_sign(const PrivateKey &key, const std::string_view message)
return edwards448_sign(internal->edwards_seed, message);
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto derive_public_key(const PrivateKey &key) -> std::optional<PublicKey> {
Expand Down Expand Up @@ -542,7 +562,11 @@ auto derive_public_key(const PrivateKey &key) -> std::optional<PublicKey> {
}
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

} // namespace sourcemeta::core
16 changes: 16 additions & 0 deletions src/core/crypto/crypto_sign_openssl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ auto to_message_digest(
return EVP_sha512();
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

// Refuse encrypted documents by offering no password, rather than letting the
Expand All @@ -53,7 +57,11 @@ auto to_group_name(const sourcemeta::core::EllipticCurve curve) noexcept
return "P-521";
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto to_pkey_id(const sourcemeta::core::EdwardsCurve curve) noexcept -> int {
Expand All @@ -64,7 +72,11 @@ auto to_pkey_id(const sourcemeta::core::EdwardsCurve curve) noexcept -> int {
return EVP_PKEY_ED448;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

// The signing functions only cover the three NIST prime curves, so a parsed key
Expand Down Expand Up @@ -511,7 +523,11 @@ auto derive_public_key(const PrivateKey &key) -> std::optional<PublicKey> {
}
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

} // namespace sourcemeta::core
24 changes: 24 additions & 0 deletions src/core/crypto/crypto_sign_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ auto to_cng_algorithm(
return BCRYPT_SHA512_ALGORITHM;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto to_ecdsa_algorithm(const sourcemeta::core::EllipticCurve curve) noexcept
Expand All @@ -54,7 +58,11 @@ auto to_ecdsa_algorithm(const sourcemeta::core::EllipticCurve curve) noexcept
return BCRYPT_ECDSA_P521_ALGORITHM;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto to_ecc_private_magic(const sourcemeta::core::EllipticCurve curve) noexcept
Expand All @@ -68,7 +76,11 @@ auto to_ecc_private_magic(const sourcemeta::core::EllipticCurve curve) noexcept
return BCRYPT_ECDSA_PRIVATE_P521_MAGIC;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

struct KeyPair {
Expand Down Expand Up @@ -414,7 +426,11 @@ auto make_private_key(const std::string_view pem) -> std::optional<PrivateKey> {
}
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto make_ec_private_key(const EllipticCurve curve,
Expand Down Expand Up @@ -548,7 +564,11 @@ auto eddsa_sign(const PrivateKey &key, const std::string_view message)
return edwards448_sign(internal->edwards_seed, message);
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto derive_public_key(const PrivateKey &key) -> std::optional<PublicKey> {
Expand Down Expand Up @@ -607,7 +627,11 @@ auto derive_public_key(const PrivateKey &key) -> std::optional<PublicKey> {
}
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

} // namespace sourcemeta::core
16 changes: 16 additions & 0 deletions src/core/crypto/crypto_verify_apple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ auto to_sec_key_pkcs1_v15_algorithm(
return kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA512;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

// These algorithm variants fix the salt length to the hash function output,
Expand All @@ -50,7 +54,11 @@ auto to_sec_key_pss_algorithm(
return kSecKeyAlgorithmRSASignatureMessagePSSSHA512;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto to_sec_key_ecdsa_algorithm(
Expand All @@ -65,7 +73,11 @@ auto to_sec_key_ecdsa_algorithm(
return kSecKeyAlgorithmECDSASignatureMessageX962SHA512;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto make_data(const std::string_view value) -> CFDataRef {
Expand Down Expand Up @@ -355,7 +367,11 @@ auto eddsa_verify(const PublicKey &key, const std::string_view message,
return edwards448_verify(internal->edwards_point, message, signature);
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto rsa_public_components(const PublicKey &key)
Expand Down
12 changes: 12 additions & 0 deletions src/core/crypto/crypto_verify_openssl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ auto to_message_digest(
return EVP_sha512();
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto to_group_name(const sourcemeta::core::EllipticCurve curve) noexcept
Expand All @@ -47,7 +51,11 @@ auto to_group_name(const sourcemeta::core::EllipticCurve curve) noexcept
return "P-521";
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto to_pkey_id(const sourcemeta::core::EdwardsCurve curve) noexcept -> int {
Expand All @@ -58,7 +66,11 @@ auto to_pkey_id(const sourcemeta::core::EdwardsCurve curve) noexcept -> int {
return EVP_PKEY_ED448;
}

// Clang settles that no other value arrives, so only GCC and MSVC
// need to be told that the end of this function is never reached
#if !defined(__clang__)
std::unreachable();
#endif
}

auto native_rsa_key(const std::string_view modulus,
Expand Down
Loading
Loading