ECKey ECKey::Create(Curve curve)
{
EVP_PKEY *pkeyTmp = nullptr;
- std::unique_ptr<EVP_PKEY_CTX, decltype(&EVP_PKEY_CTX_free)> ctx(
+ const std::unique_ptr<EVP_PKEY_CTX, decltype(&EVP_PKEY_CTX_free)> ctx(
EVP_PKEY_CTX_new_id(EVP_PKEY_EC, nullptr), EVP_PKEY_CTX_free);
if (!ctx)
THROW_OPENSSL("EVP_PKEY_CTX_new_id() error");
if (!ec)
THROW_OPENSSL("EC_KEY_new() error");
- std::unique_ptr<EC_GROUP, decltype(&EC_GROUP_clear_free)> group(
+ const std::unique_ptr<EC_GROUP, decltype(&EC_GROUP_clear_free)> group(
EC_GROUP_new_by_curve_name(Curve2NID(curve)), EC_GROUP_clear_free);
if (!group)
THROW_OPENSSL("EC_GROUP_new_by_curve_name() error");
if (EC_KEY_oct2priv(ec.get(), input.data(), input.size()) != 1)
THROW_OPENSSL("EC_KEY_oct2priv() error");
- std::unique_ptr<EC_POINT, decltype(&EC_POINT_clear_free)> point(EC_POINT_new(group.get()),
- EC_POINT_clear_free);
+ const std::unique_ptr<EC_POINT, decltype(&EC_POINT_clear_free)> point(EC_POINT_new(group.get()),
+ EC_POINT_clear_free);
if (!point)
THROW_OPENSSL("EC_POINT_new() error");
if (EVP_PKEY_assign_EC_KEY(pkey.get(), ec.get()) != 1)
THROW_OPENSSL("EVP_PKEY_assign_EC_KEY() error");
-
- ec.release();
+ (void)ec.release();
return ECKey{pkey.release()};
}
if (!ec)
THROW_OPENSSL("EC_KEY_new() error");
- std::unique_ptr<EC_GROUP, decltype(&EC_GROUP_clear_free)> group(
+ const std::unique_ptr<EC_GROUP, decltype(&EC_GROUP_clear_free)> group(
EC_GROUP_new_by_curve_name(Curve2NID(curve)), EC_GROUP_clear_free);
if (!group)
THROW_OPENSSL("EC_GROUP_new_by_curve_name() error");
if (EVP_PKEY_assign_EC_KEY(pkey.get(), ec.get()) != 1)
THROW_OPENSSL("EVP_PKEY_assign_EC_KEY() error");
-
- ec.release();
+ (void)ec.release();
return ECKey{pkey.release()};
}
ECKey ECKey::ImportPublicKey(Curve curve, const CryptoBuffer &x, const CryptoBuffer &y)
{
- std::unique_ptr<BIGNUM, decltype(&BN_free)> bx(BN_new(), BN_free);
+ const std::unique_ptr<BIGNUM, decltype(&BN_free)> bx(BN_new(), BN_free);
if (!bx)
THROW_OPENSSL("BN_new() error");
- std::unique_ptr<BIGNUM, decltype(&BN_free)> by(BN_new(), BN_free);
+ const std::unique_ptr<BIGNUM, decltype(&BN_free)> by(BN_new(), BN_free);
if (!by)
THROW_OPENSSL("BN_new() error");
if (EVP_PKEY_assign_EC_KEY(evpKey.get(), ecKey.get()) != 1)
THROW_OPENSSL("EVP_PKEY_assign_EC_KEY() failed");
-
- ecKey.release();
+ (void)ecKey.release();
return ECKey{evpKey.release()};
}
TEST(Messages, MakeCredentialResponse_Negative)
{
MakeCredentialResponse msg;
- auto cborUnexpectedType = BUFFER_VIEW("\x11");
- auto errorProcessing = BUFFER_VIEW("\x21");
- auto unsupportedAlgorithm = BUFFER_VIEW("\x26");
- auto missingParameter = BUFFER_VIEW("\x14");
- auto operationDenied = BUFFER_VIEW("\x27");
- auto keyStoreFull = BUFFER_VIEW("\x28");
- auto userActionTimeout = BUFFER_VIEW("\x2F");
- auto pinBlocked = BUFFER_VIEW("\x32");
- auto credentialExcluded = BUFFER_VIEW("\x19");
+ auto cborUnexpectedType = BUFFER_VIEW("\x11"); // NOLINT(modernize-raw-string-literal)
+ auto errorProcessing = BUFFER_VIEW("\x21"); // NOLINT(modernize-raw-string-literal)
+ auto unsupportedAlgorithm = BUFFER_VIEW("\x26"); // NOLINT(modernize-raw-string-literal)
+ auto missingParameter = BUFFER_VIEW("\x14"); // NOLINT(modernize-raw-string-literal)
+ auto operationDenied = BUFFER_VIEW("\x27"); // NOLINT(modernize-raw-string-literal)
+ auto keyStoreFull = BUFFER_VIEW("\x28"); // NOLINT(modernize-raw-string-literal)
+ auto userActionTimeout = BUFFER_VIEW("\x2F"); // NOLINT(modernize-raw-string-literal)
+ auto pinBlocked = BUFFER_VIEW("\x32"); // NOLINT(modernize-raw-string-literal)
+ auto credentialExcluded = BUFFER_VIEW("\x19"); // NOLINT(modernize-raw-string-literal)
EXPECT_THROW(msg.Deserialize(cborUnexpectedType), Exception::EncodingFailed);
EXPECT_THROW(msg.Deserialize(errorProcessing), Exception::InvalidState);
EXPECT_THROW(msg.Deserialize(unsupportedAlgorithm), Exception::NotSupported);