MCPcopy Create free account
hub / github.com/apple/foundationdb / getJwkBigNumMember

Function getJwkBigNumMember

fdbrpc/JsonWebKeySet.cpp:122–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120
121template <bool Required, class AutoPtr>
122bool getJwkBigNumMember(Arena& arena,
123 std::conditional_t<Required, StringRef, Optional<StringRef>> const& b64Member,
124 AutoPtr& ptr,
125 char const* memberName,
126 char const* algorithm,
127 int keyIndex) {
128 if constexpr (!Required) {
129 if (!b64Member.present())
130 return true;
131 }
132 auto data = StringRef();
133 if constexpr (Required) {
134 data = b64Member;
135 } else {
136 data = b64Member.get();
137 }
138 auto decoded = base64url::decode(arena, data);
139 if (!decoded.present()) {
140 JWK_PARSE_ERROR("Base64URL decoding for parameter failed")
141 .detail("Algorithm", algorithm)
142 .detail("Parameter", memberName);
143 return false;
144 }
145 data = decoded.get();
146 auto bn = ::BN_bin2bn(data.begin(), data.size(), nullptr);
147 if (!bn) {
148 JWK_PARSE_ERROR_OSSL("BN_bin2bn");
149 return false;
150 }
151 ptr.reset(bn);
152 return true;
153}
154
155#define DECL_DECODED_BN_MEMBER_REQUIRED(member, algo) \
156 auto member = AutoCPointer(nullptr, &::BN_free); \

Callers

nothing calls this directly

Calls 8

decodeFunction · 0.85
detailMethod · 0.80
getMethod · 0.65
StringRefClass · 0.50
presentMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected