#include <TokenBindingConstructor.h>
Definition at line 17 of file TokenBindingConstructor.h.
void fizz::extensions::TokenBindingConstructor::addBignumToSignature |
( |
const Buf & |
signature, |
|
|
BIGNUM * |
bigNum |
|
) |
| |
|
staticprivate |
Definition at line 87 of file TokenBindingConstructor.cpp.
90 auto length = BN_num_bytes(bigNum);
92 throw std::runtime_error(
"ECDSA sig bignum is of incorrect size");
97 std::memset(signature->writableTail(), 0x00, padding);
98 signature->append(padding);
100 auto lenActual = BN_bn2bin(bigNum, signature->writableTail());
101 signature->append(lenActual);
102 if (lenActual != length) {
103 throw std::runtime_error(
"bn2bin returned unexpected value");
static constexpr uint8_t kP256EcKeySize
Definition at line 24 of file TokenBindingConstructor.cpp.
References folly::IOBuf::create(), fizz::extensions::TokenBinding::extensions, fizz::extensions::TokenBindingID::key_parameters, folly::gen::move, fizz::extensions::TokenBinding::signature, fizz::extensions::TokenBinding::tokenbinding_type, fizz::extensions::TokenBinding::tokenbindingid, and type.
30 throw std::runtime_error(folly::to<std::string>(
31 "key params not implemented: ", negotiatedParameters));
36 throw std::runtime_error(
"Unable to retrieve EC Key");
40 binding.tokenbinding_type =
type;
48 id.key_parameters = negotiatedParameters;
static Buf constructMessage(const TokenBindingType &type, const TokenBindingKeyParameters &keyParams, const Buf &ekm)
static std::unique_ptr< IOBuf > create(std::size_t capacity)
constexpr detail::Map< Move > move
static Buf signWithEcKey(const folly::ssl::EcKeyUniquePtr &key, const Buf &message)
std::unique_ptr< EC_KEY, EcKeyDeleter > EcKeyUniquePtr
static Buf encodeEcKey(const folly::ssl::EcKeyUniquePtr &ecKey)
Definition at line 71 of file TokenBindingConstructor.cpp.
References folly::IOBuf::create(), folly::portability::ssl::ECDSA_SIG_get0(), and s.
75 ECDSA_SIG_get0(signature.get(), (
const BIGNUM**)&r, (
const BIGNUM**)&
s);
77 throw std::runtime_error(
"Unable to retrieve Bignum from ECDSA sig");
80 Buf encodedSignature =
84 return encodedSignature;
void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps)
static std::unique_ptr< IOBuf > create(std::size_t capacity)
static constexpr uint8_t kP256EcKeySize
static void addBignumToSignature(const Buf &signature, BIGNUM *bigNum)
std::unique_ptr< folly::IOBuf > Buf
Definition at line 107 of file TokenBindingConstructor.cpp.
References fizz::detail::encodeECPublicKey().
109 if (ecKeyBuf->isChained() ||
111 throw std::runtime_error(
"Incorrect encoded EC Key Length");
static constexpr uint8_t kP256EcKeySize
std::unique_ptr< folly::IOBuf > encodeECPublicKey(const folly::ssl::EvpPkeyUniquePtr &key)
Definition at line 54 of file TokenBindingConstructor.cpp.
References fizz::Sha< Sha256 >::hash().
57 std::array<uint8_t, fizz::Sha256::HashLen> hashedMessage;
63 ECDSA_do_sign(hashedMessage.data(), hashedMessage.size(), key.get()));
64 if (!ecSignature.get()) {
65 throw std::runtime_error(
"Unable to sign message with EC Key");
static Buf encodeEcdsaSignature(const folly::ssl::EcdsaSigUniquePtr &signature)
std::unique_ptr< ECDSA_SIG, EcdsaSigDeleter > EcdsaSigUniquePtr
static void hash(const folly::IOBuf &in, folly::MutableByteRange out)
The documentation for this class was generated from the following files: