189                                                                       {
  190   detail::webauthn_json_handler handler;
  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");
 
  194 
  195   FC_ASSERT(handler.found_type == 
"webauthn.get", 
"webauthn signature type not an assertion");
 
  196 
  199 
  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://");
 
  203   rpid = handler.found_origin.substr(https_len, handler.found_origin.rfind(':')-https_len);
  204 
  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)
  211 
  212   static_assert(min_auth_data_size >= 
sizeof(
fc::sha256), 
"auth_data min size not enough to store a sha256");
 
  214 
  215   
  216   
  219   e.
write((
char*)c.auth_data.data(), c.auth_data.size());
 
  222 
  223   
  224   int nV = c.compact_signature.
data[0];
 
  225   if (nV<31 || nV>=35)
  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);
 
  232 
  233   fc::ec_key key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
  234   nV -= 4;
  235 
  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())
 
  241         return;
  242   }
  244}
void write(const char *d, uint32_t dlen)
static sha256 hash(const char *d, uint32_t dlen)
const char * data() const
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
static const Segment ss(Segment::ss)
int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned char *msg, int msglen, int recid, int check)
fc::sha256 digest(const T &value)
std::string base64url_decode(const std::string &encoded_string)
int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s)