Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bruteforce-crc.cc: Fix errors with initial & example implementation #6

Merged
merged 2 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions bf_crc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,19 @@ std::string bitset_to_byte_array(boost::dynamic_bitset<> const & message) {
std::string ret;

uint8_t byte = 0;

// for the first byte
for(size_t j = 0; j < 8; j++) {
byte <<= 1;
byte |= (message[j] == true ? 1 : 0);
}

boost::format f("0x%02x");
f % static_cast<int>(byte);
ret.append(f.str());

for(size_t i = 0; i < message.size(); i+=8) {
// for all subsequent bytes
for(size_t i = 8; i < message.size(); i+=8) {

byte = 0;

Expand All @@ -121,17 +131,12 @@ std::string bitset_to_byte_array(boost::dynamic_bitset<> const & message) {
byte |= (message[i + j] == true ? 1 : 0);
}

boost::format f("0x%02x, ");
boost::format f(", 0x%02x");
f % static_cast<int>(byte);
ret.append(f.str());

}

boost::format f("0x%02x");
f % static_cast<int>(byte);

ret.append(f.str());

return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions bruteforce-crc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) {
bool reflected_output = false;

uint32_t initial = 0;
bool probe_initial = true;
bool probe_initial = false;

uint32_t final_xor = 0;
bool probe_final_xor = false;
Expand Down Expand Up @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) {
("poly-end", po::value<uint32_t>(), "End of polynomial search space (default (2^width - 1))")

("threads", po::value<unsigned int >(), "Number of threads (default: 4)")
("initial", po::value<size_t>(), "Set intial value (default: 0)")
("initial", po::value<uint32_t>(), "Set intial value (default: 0)")

("probe-initial", po::value<bool>(), "Bruteforce the intial, overrides initial (default: true)")
("final-xor", po::value<uint32_t>(), "Final xor (default: 0)")
Expand Down