fix: Properly check error conditions for int-returning functions.
OpenSSL functions returning an int like `EVP_PKEY_derive_init` return non-positive (0 or negative) integers on an error condition, so we need to check for both. See e.g. https://www.openssl.org/docs/man1.1.1/man3/EVP_PKEY_derive.html
This commit is contained in:
parent
b82dab50c9
commit
a02f3d9f82
1 changed files with 9 additions and 1 deletions
|
@ -34,13 +34,21 @@ static const std::size_t SHA256_BLOCK_LENGTH = 64;
|
||||||
static const std::uint8_t HKDF_DEFAULT_SALT[32] = {};
|
static const std::uint8_t HKDF_DEFAULT_SALT[32] = {};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static T checked(T val) {
|
inline T checked(T val) {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline int checked(int val) {
|
||||||
|
if (val <= 0) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void _olm_crypto_curve25519_generate_key(
|
void _olm_crypto_curve25519_generate_key(
|
||||||
|
|
Loading…
Reference in a new issue