Don't hardcode the signature length to RSA-2048 (#1872)

This commit is contained in:
Cameron Gutman 2023-11-30 23:51:45 -06:00 committed by GitHub
commit 3b9e37e1dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 16 deletions

View file

@ -380,11 +380,15 @@ namespace nvhttp {
auto &client = sess.client;
auto pairingsecret = util::from_hex_vec(get_arg(args, "clientpairingsecret"), true);
if (pairingsecret.size() <= 16) {
tree.put("root.paired", 0);
tree.put("root.<xmlattr>.status_code", 400);
tree.put("root.<xmlattr>.status_message", "Clientpairingsecret too short");
return;
}
std::string_view secret { pairingsecret.data(), 16 };
std::string_view sign { pairingsecret.data() + secret.size(), crypto::digest_size };
assert((secret.size() + sign.size()) == pairingsecret.size());
std::string_view sign { pairingsecret.data() + secret.size(), pairingsecret.size() - secret.size() };
auto x509 = crypto::x509(client.cert);
auto x509_sign = crypto::signature(x509);