1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:17:34 +00:00

Everywhere: Replace a bundle of dbg with dbgln.

These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
This commit is contained in:
asynts 2021-01-11 13:32:26 +01:00 committed by Andreas Kling
parent 6fa42af567
commit 843ebbd2c3
15 changed files with 46 additions and 21 deletions

View file

@ -51,7 +51,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in)
ASN1::set(pubkey[0], ASN1::Kind::Sequence, &pubkey_hash_oid, 2);
ASN1::set(pubkey[1], ASN1::Kind::Null, nullptr, 0);
dbg() << "we were offered " << in.size() << " bytes of input";
dbgln("we were offered {} bytes of input", in.size());
if (der_decode_sequence(in.data(), in.size(), pubkey, 2)) {
// yay, now we have to reassemble the bitstring to a bytestring
@ -72,7 +72,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in)
ASN1::Kind::Integer, 1, &n,
ASN1::Kind::Integer, 1, &e)) {
// something was fucked up
dbg() << "bad pubkey: " << e << " in " << n;
dbgln("bad pubkey: e={} n={}", e, n);
return keypair;
}
// correct public key
@ -97,7 +97,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes in)
ASN1::Kind::Integer, 1, &n,
ASN1::Kind::Integer, 1, &e,
ASN1::Kind::Integer, 1, &d)) {
dbg() << "bad privkey " << n << " " << e << " " << d;
dbgln("bad privkey n={} e={} d={}", n, e, d);
return keypair;
}
keypair.private_key.set(n, d, e);
@ -128,7 +128,7 @@ void RSA::encrypt(ReadonlyBytes in, Bytes& out)
auto size = exp.export_data(out);
auto outsize = out.size();
if (size != outsize) {
dbg() << "POSSIBLE RSA BUG!!! Size mismatch: " << outsize << " requested but " << size << " bytes generated";
dbgln("POSSIBLE RSA BUG!!! Size mismatch: {} requested but {} bytes generated", outsize, size);
out = out.slice(outsize - size, size);
}
}
@ -275,7 +275,7 @@ void RSA_PKCS1_EME::decrypt(ReadonlyBytes in, Bytes& out)
{
auto mod_len = (m_public_key.modulus().trimmed_length() * sizeof(u32) * 8 + 7) / 8;
if (in.size() != mod_len) {
dbg() << "decryption error: wrong amount of data: " << in.size();
dbgln("decryption error: wrong amount of data: {}", in.size());
out = out.trim(0);
return;
}
@ -283,18 +283,18 @@ void RSA_PKCS1_EME::decrypt(ReadonlyBytes in, Bytes& out)
RSA::decrypt(in, out);
if (out.size() < RSA::output_size()) {
dbg() << "decryption error: not enough data after decryption: " << out.size();
dbgln("decryption error: not enough data after decryption: {}", out.size());
out = out.trim(0);
return;
}
if (out[0] != 0x00) {
dbg() << "invalid padding byte 0 : " << out[0];
dbgln("invalid padding byte 0 : {}", out[0]);
return;
}
if (out[1] != 0x02) {
dbg() << "invalid padding byte 1" << out[1];
dbgln("invalid padding byte 1 : {}", out[1]);
return;
}