Commit df413313 authored by Stephan Hartmann's avatar Stephan Hartmann Committed by Commit Bot

GCC: fix decltype to get a valid function pointer

The decltype(<func>) passed as template parameter to
CBBFunctionToVector does not return a function pointer
and GCC complains like this:

../../device/fido/virtual_fido_device.cc:104:68: error:
 'int(struct cbb_st*, const struct evp_pkey_st*)' is not a valid type
 for a template non-type parameter
  104 |                         EVP_marshal_private_key>(pkey_.get());
      |                                                           ^

Fix this by passing decltype(&<func>).

Bug: 819294
Change-Id: I8114c3d75c9865779d58c0b6a6c48e6affd3175b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217414Reviewed-by: default avatarAdam Langley <agl@chromium.org>
Commit-Queue: Adam Langley <agl@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772283}
parent 3e9d1cc6
......@@ -51,7 +51,7 @@ constexpr uint8_t kAttestationKey[]{
// CBBFunctionToVector converts a BoringSSL function that writes to a CBB to one
// that returns a std::vector. Invoke for a function, f, with:
// CBBFunctionToVector<decltype(f), f>(args, to, f);
// CBBFunctionToVector<decltype(&f), f>(args, to, f);
template <typename F, F function, typename... Args>
std::vector<uint8_t> CBBFunctionToVector(Args&&... args) {
uint8_t* der = nullptr;
......@@ -102,7 +102,7 @@ class EVPBackedPrivateKey : public VirtualFidoDevice::PrivateKey {
}
std::vector<uint8_t> GetPKCS8PrivateKey() const override {
return CBBFunctionToVector<decltype(EVP_marshal_private_key),
return CBBFunctionToVector<decltype(&EVP_marshal_private_key),
EVP_marshal_private_key>(pkey_.get());
}
......@@ -122,7 +122,7 @@ class P256PrivateKey : public EVPBackedPrivateKey {
std::vector<uint8_t> GetX962PublicKey() const override {
const EC_KEY* ec_key = EVP_PKEY_get0_EC_KEY(pkey_.get());
return CBBFunctionToVector<decltype(EC_POINT_point2cbb),
return CBBFunctionToVector<decltype(&EC_POINT_point2cbb),
EC_POINT_point2cbb>(
EC_KEY_get0_group(ec_key), EC_KEY_get0_public_key(ec_key),
POINT_CONVERSION_UNCOMPRESSED, /*ctx=*/nullptr);
......@@ -172,7 +172,7 @@ class RSAPrivateKey : public EVPBackedPrivateKey {
cbor::Writer::Write(cbor::Value(std::move(map))));
std::vector<uint8_t> der_bytes(
CBBFunctionToVector<decltype(EVP_marshal_public_key),
CBBFunctionToVector<decltype(&EVP_marshal_public_key),
EVP_marshal_public_key>(pkey_.get()));
return std::make_unique<PublicKey>(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment