Browse Source

clean code

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/65/head
R4SAS 4 years ago
parent
commit
5f45990dff
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 2
      b33address.cpp
  2. 6
      famtool.cpp
  3. 3
      i2pbase64.cpp
  4. 18
      keyinfo.cpp
  5. 4
      regaddralias.cpp
  6. 4
      vanity.hpp
  7. 66
      vanitygen.cpp

2
b33address.cpp

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
int main(int argc, char * argv[])
{
// base64 input, b33 and store key output, 11->11 only
std::cout << "Waiting for base64 from stdin..." << std::endl;
std::string base64;
std::getline (std::cin, base64);
auto ident = std::make_shared<i2p::data::IdentityEx>();
@ -27,4 +28,3 @@ int main(int argc, char * argv[]) @@ -27,4 +28,3 @@ int main(int argc, char * argv[])
return 0;
}

6
famtool.cpp

@ -277,13 +277,13 @@ int main(int argc, char * argv[]) @@ -277,13 +277,13 @@ int main(int argc, char * argv[])
if (sign) {
// sign
if (!infile.size()) {
// no router info specififed
// no router info specified
std::cerr << "no router keys file specified" << std::endl;
return 1;
}
if (!privkey.size()) {
// no private key specified
std::cerr << "no private key specififed" << std::endl;
std::cerr << "no private key specified" << std::endl;
return 1;
}
@ -345,7 +345,7 @@ int main(int argc, char * argv[]) @@ -345,7 +345,7 @@ int main(int argc, char * argv[])
return 1;
}
if(!certfile.size()) {
std::cout << "no family cerifiticate specified" << std::endl;
std::cout << "no family certificate specified" << std::endl;
return 1;
}
auto v = LoadCertificate(certfile);

3
i2pbase64.cpp

@ -36,9 +36,6 @@ static int operate(std::function<std::size_t(const InCh *, size_t, OutCh *, size @@ -36,9 +36,6 @@ static int operate(std::function<std::size_t(const InCh *, size_t, OutCh *, size
return errno;
}
int main(int argc, char * argv[])
{
int opt;

18
keyinfo.cpp

@ -9,6 +9,11 @@ @@ -9,6 +9,11 @@
#include <time.h>
#include "common/key.hpp"
static int printHelp(const char * exe, int exitcode)
{
std::cout << "usage: " << exe << " [-v] [-d] privatekey.dat" << std::endl;
return exitcode;
}
std::string ConvertTime (time_t t)
{
@ -21,14 +26,16 @@ std::string ConvertTime (time_t t) @@ -21,14 +26,16 @@ std::string ConvertTime (time_t t)
int main(int argc, char * argv[])
{
if(argc == 1) {
std::cout << "usage: " << argv[0] << " [-v] [-d] privatekey.dat" << std::endl;
return -1;
return printHelp(argv[0], -1);
}
int opt;
bool print_full = false;
bool verbose = false;
while((opt = getopt(argc, argv, "vd"))!=-1) {
while((opt = getopt(argc, argv, "hvd")) != -1) {
switch(opt){
case 'h':
return printHelp(argv[0], 0);
case 'v':
verbose = true;
break;
@ -36,10 +43,10 @@ int main(int argc, char * argv[]) @@ -36,10 +43,10 @@ int main(int argc, char * argv[])
print_full = true;
break;
default:
std::cout << "usage: " << argv[0] << " [-v] [-d] privatekey.dat" << std::endl;
return -1;
return printHelp(argv[0], -1);
}
}
std::string fname(argv[optind]);
i2p::data::PrivateKeys keys;
{
@ -60,6 +67,7 @@ int main(int argc, char * argv[]) @@ -60,6 +67,7 @@ int main(int argc, char * argv[])
return 3;
}
}
auto dest = keys.GetPublic();
if(!dest) {
std::cout << "failed to extract public key" << std::endl;

4
regaddralias.cpp

@ -33,7 +33,7 @@ int main (int argc, char * argv[]) @@ -33,7 +33,7 @@ int main (int argc, char * argv[])
}
else
{
std::cout << "Cab't open keyfile " << argv[1] << std::endl;
std::cout << "Can't open keyfile " << argv[1] << std::endl;
return -1;
}
}
@ -56,7 +56,7 @@ int main (int argc, char * argv[]) @@ -56,7 +56,7 @@ int main (int argc, char * argv[])
}
else
{
std::cout << "Cab't open keyfile " << argv[2] << std::endl;
std::cout << "Can't open keyfile " << argv[2] << std::endl;
return -1;
}
}

4
vanity.hpp

@ -54,7 +54,7 @@ static unsigned long long hashescounter; @@ -54,7 +54,7 @@ static unsigned long long hashescounter;
unsigned int count_cpu;
const uint8_t lastBlock[64] =
{
{
0x05, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x80, // 7 bytes EdDSA certificate
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -63,5 +63,5 @@ const uint8_t lastBlock[64] = @@ -63,5 +63,5 @@ const uint8_t lastBlock[64] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x38 // 3128 bits (391 bytes)
};
};

66
vanitygen.cpp

@ -3,21 +3,21 @@ @@ -3,21 +3,21 @@
#include<getopt.h>
static struct{
static struct
{
bool reg=false;
int threads=-1;
i2p::data::SigningKeyType signature;
std::string outputpath="";
std::regex regex;
}options;
} options;
static void inline CalculateW (const uint8_t block[64], uint32_t W[64])
{
/*
implementation of orignal
*/
/**
* implementation of orignal
*/
for (int i = 0; i < 16; i++)
#ifdef _WIN32
W[i] = htobe32(((uint32_t *)(block))[i]);
@ -31,9 +31,9 @@ implementation of orignal @@ -31,9 +31,9 @@ implementation of orignal
static void inline TransformBlock (uint32_t state[8], const uint32_t W[64])
{
/*
implementation of orignal
*/
/**
* implementation of orignal
*/
uint32_t S[8];
memcpy(S, state, 32);
@ -60,9 +60,9 @@ implementation of orignal @@ -60,9 +60,9 @@ implementation of orignal
void inline HashNextBlock (uint32_t state[8], const uint8_t * block)
{
/*
implementation of orignal
*/
/**
* implementation of orignal
*/
uint32_t W[64];
CalculateW (block, W);
TransformBlock (state, W);
@ -126,11 +126,11 @@ static inline bool NotThat(const char * a, const char *b) @@ -126,11 +126,11 @@ static inline bool NotThat(const char * a, const char *b)
static inline bool thread_find(uint8_t * buf, const char * prefix, int id_thread, unsigned long long throughput)
{
/*
Thanks to orignal ^-^
For idea and example ^-^
Orignal is sensei of crypto ;)
*/
/**
* Thanks to orignal ^-^
* For idea and example ^-^
* Orignal is sensei of crypto ;)
*/
std::cout << "Thread " << id_thread << " binded" << std::endl;
/*
union
@ -181,10 +181,10 @@ Orignal is sensei of crypto ;) @@ -181,10 +181,10 @@ Orignal is sensei of crypto ;)
ByteStreamToBase32 ((uint8_t*)hash, 32, addr, len);
// std::cout << addr << std::endl;
//bool result = options.reg ? !NotThat(addr, &options.regex) : !NotThat(addr,prefix);
// bool result = options.reg ? !NotThat(addr, &options.regex) : !NotThat(addr,prefix);
if( ( options.reg ? !NotThat(addr, options.regex) : !NotThat(addr,prefix) ) )
// if(result)
// if(result)
{
ByteStreamToBase32 ((uint8_t*)hash, 32, addr, 52);
std::cout << "Address found " << addr << " in " << id_thread << std::endl;
@ -204,14 +204,10 @@ Orignal is sensei of crypto ;) @@ -204,14 +204,10 @@ Orignal is sensei of crypto ;)
// free(b);
break;
}
}//while
} // while
return true;
}
void usage(void){
const constexpr char * help="vain [text-pattern|regex-pattern] [options]\n"
"-h --help, help menu\n"
@ -220,12 +216,11 @@ void usage(void){ @@ -220,12 +216,11 @@ void usage(void){
"--signature -s, (signature type)\n"
"-o --output output file (default private.dat)\n"
"--usage usage\n"
//"--prefix -p\n"
// "--prefix -p\n"
"";
puts(help);
}
void parsing(int argc, char ** args){
int option_index;
static struct option long_options[]={
@ -274,10 +269,6 @@ void parsing(int argc, char ** args){ @@ -274,10 +269,6 @@ void parsing(int argc, char ** args){
int main (int argc, char * argv[])
{
if ( argc < 2 )
{
usage();
@ -320,7 +311,7 @@ int main (int argc, char * argv[]) @@ -320,7 +311,7 @@ int main (int argc, char * argv[])
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA384_3072:
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA512_4096:
case i2p::data::SIGNING_KEY_TYPE_GOSTR3410_TC26_A_512_GOSTR3411_512:
std::cout << "Sorry, i don't can generate adress for this signature type" << std::endl;
std::cout << "Sorry, i don't can generate address for this signature type" << std::endl;
return 0;
break;
}
@ -371,8 +362,8 @@ int main (int argc, char * argv[]) @@ -371,8 +362,8 @@ int main (int argc, char * argv[])
unsigned short attempts = 0;
while(!found)
{//while
{//stack(for destructors(vector/thread))
{ // while
{ // stack(for destructors(vector/thread))
std::vector<std::thread> threads(options.threads);
unsigned long long thoughtput = 0x4F4B5A37;
@ -381,7 +372,7 @@ int main (int argc, char * argv[]) @@ -381,7 +372,7 @@ int main (int argc, char * argv[])
{
threads[j] = std::thread(thread_find,KeyBuf,argv[1],j,thoughtput);
thoughtput+=1000;
}//for
} // for
for(unsigned int j = 0; j < (unsigned int)options.threads;j++)
threads[j].join();
@ -392,8 +383,8 @@ int main (int argc, char * argv[]) @@ -392,8 +383,8 @@ int main (int argc, char * argv[])
std::cout << "Attempts #" << ++attempts << std::endl;
}
}//stack
}//while
} // stack
} // while
memcpy (KeyBuf + MutateByte, &FoundNonce, 4);
std::cout << "Hashes: " << hashescounter << std::endl;
@ -413,6 +404,3 @@ int main (int argc, char * argv[]) @@ -413,6 +404,3 @@ int main (int argc, char * argv[])
return 0;
}
//

Loading…
Cancel
Save