From 8570d7f356eb08058b660221b951760ebf35cac6 Mon Sep 17 00:00:00 2001 From: restitux Date: Fri, 27 Jun 2025 01:11:44 -0600 Subject: [PATCH] add debugging --- src/nvhttp.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/nvhttp.cpp b/src/nvhttp.cpp index 52d15014..8818f07a 100644 --- a/src/nvhttp.cpp +++ b/src/nvhttp.cpp @@ -361,8 +361,19 @@ namespace nvhttp { auto salt = util::from_hex>(salt_view, true); auto key = crypto::gen_aes_key(salt, pin); + + std::ostringstream cipher_key_hex; + for (auto b = key.begin(); b != key.end(); ++b) { + cipher_key_hex << std::hex // Output in hexadecimal + << std::setw(2) // Each byte prints as two characters + << std::setfill('0') // Fill with '0' if less than two characters + << static_cast(*b); // Cast to unsigned int for correct printing + } + BOOST_LOG(debug) << "cipher_key_hex: " << cipher_key_hex.str(); + sess.cipher_key = std::make_unique(key); + tree.put("root.paired", 1); tree.put("root.plaincert", util::hex_vec(conf_intern.servercert, true)); tree.put("root..status_code", 200); @@ -471,11 +482,23 @@ namespace nvhttp { data.insert(std::end(data), std::begin(x509_sign), std::end(x509_sign)); data.insert(std::end(data), std::begin(secret), std::end(secret)); + std::ostringstream data_hex; + + for (auto d = data.begin(); d != data.end(); ++d) { + data_hex << std::hex // Output in hexadecimal + << std::setw(2) // Each byte prints as two characters + << std::setfill('0') // Fill with '0' if less than two characters + << static_cast(*d); // Cast to unsigned int for correct printing + } + BOOST_LOG(debug) << "data_hex: " << data_hex.str(); + auto hash = crypto::hash(data); // if hash not correct, probably MITM bool same_hash = hash.size() == sess.clienthash.size() && std::equal(hash.begin(), hash.end(), sess.clienthash.begin()); auto verify = crypto::verify256(crypto::x509(client.cert), secret, sign); + BOOST_LOG(debug) << "same_hash: " << same_hash; + BOOST_LOG(debug) << "verify: " << verify; if (same_hash && verify) { tree.put("root.paired", 1); add_cert->raise(crypto::x509(client.cert));