191 detail::rapidjson::Reader reader;
192 detail::rapidjson::StringStream ss(c.client_json.c_str());
193 FC_ASSERT(reader.Parse<detail::rapidjson::kParseIterativeFlag>(ss, handler),
"Failed to parse client data JSON");
195 FC_ASSERT(handler.
found_type ==
"webauthn.get",
"webauthn signature type not an assertion");
200 char required_origin_scheme[] =
"https://";
201 size_t https_len = strlen(required_origin_scheme);
202 FC_ASSERT(handler.
found_origin.compare(0, https_len, required_origin_scheme) == 0,
"webauthn origin must begin with https://");
205 constexpr static size_t min_auth_data_size = 37;
206 FC_ASSERT(c.auth_data.size() >= min_auth_data_size,
"auth_data not as large as required");
207 if(c.auth_data[32] & 0x01)
209 if(c.auth_data[32] & 0x04)
212 static_assert(min_auth_data_size >=
sizeof(
fc::sha256),
"auth_data min size not enough to store a sha256");
219 e.
write((
char*)c.auth_data.data(), c.auth_data.size());
224 int nV = c.compact_signature.
data[0];
227 ecdsa_sig sig = ECDSA_SIG_new();
228 BIGNUM *
r = BN_new(), *
s = BN_new();
229 BN_bin2bn(&c.compact_signature.
data[1],32,
r);
230 BN_bin2bn(&c.compact_signature.
data[33],32,
s);
233 fc::ec_key key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
237 const EC_POINT*
point = EC_KEY_get0_public_key(key);
238 const EC_GROUP* group = EC_KEY_get0_group(key);
239 size_t sz = EC_POINT_point2oct(group,
point, POINT_CONVERSION_COMPRESSED, (
uint8_t*)public_key_data.
data, public_key_data.
size(), NULL);
240 if(sz == public_key_data.
size())