15 using namespace folly;
20 namespace extensions {
27 VLOG(2) <<
"sent parameters: " 29 <<
" don't match negotiated parameters: " 35 auto message = TokenBindingUtils::constructMessage(
45 }
catch (
const std::exception& e) {
46 VLOG(1) <<
"Token Binding Verification Failed: " << e.what();
56 if (keyParams == TokenBindingKeyParameters::ecdsap256) {
57 auto pkey = constructEcKeyFromBuf(key);
58 auto ecdsa = constructECDSASig(signature);
60 std::array<uint8_t, fizz::Sha256::HashLen> hashedMessage;
69 throw std::runtime_error(folly::to<std::string>(
74 throw std::runtime_error(
75 folly::to<std::string>(
"key params not implemented: ", keyParams));
81 if (!ecdsaSignature) {
82 throw std::runtime_error(
"Unable to allocate ecdsaSignature");
84 Cursor signatureReader(signature.get());
87 signatureReader.clone(*rBytes, TokenBindingUtils::kP256EcKeySize / 2);
88 signatureReader.clone(*sBytes, TokenBindingUtils::kP256EcKeySize / 2);
89 auto rRange = rBytes->coalesce();
90 auto sRange = sBytes->coalesce();
94 rRange.data(), TokenBindingUtils::kP256EcKeySize / 2, r.get()) ||
96 sRange.data(), TokenBindingUtils::kP256EcKeySize / 2, s.get())) {
97 throw std::runtime_error(
"unable to create bnum");
102 if (
ECDSA_SIG_set0(ecdsaSignature.get(), r.release(), s.release()) != 1) {
103 throw std::runtime_error(
"unable to set bnum on ecdsa_sig");
105 return ecdsaSignature;
112 Appender keyAppender(combinedKey.get(), 20);
118 Cursor keyReader(key.get());
120 if (keyLen != TokenBindingUtils::kP256EcKeySize) {
121 throw std::runtime_error(
122 folly::to<std::string>(
"incorrect key size: ", keyLen));
124 keyAppender.push(keyReader, keyLen);
125 auto combinedRange = combinedKey->coalesce();
131 throw std::runtime_error(
"Error getting EC_key");
folly::StringPiece toString(StateEnum state)
static std::unique_ptr< IOBuf > create(std::size_t capacity)
constexpr detail::Map< Move > move
—— Concurrent Priority Queue Implementation ——
TokenBindingType tokenbinding_type
TokenBindingKeyParameters
std::unique_ptr< BIGNUM, BIGNUMDeleter > BIGNUMUniquePtr
std::unique_ptr< ECDSA_SIG, EcdsaSigDeleter > EcdsaSigUniquePtr
folly::ssl::EvpPkeyUniquePtr decodeECPublicKey(folly::ByteRange range, int curveNid)
std::unique_ptr< EC_KEY, EcKeyDeleter > EcKeyUniquePtr
int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s)
std::string getOpenSSLError()
static void hash(const folly::IOBuf &in, folly::MutableByteRange out)
TokenBindingKeyParameters key_parameters
TokenBindingID tokenbindingid
std::unique_ptr< folly::IOBuf > Buf