mirror of
https://github.com/PurpleI2P/i2pd-tools.git
synced 2025-01-22 13:27:17 +01:00
clean code
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
07c5391b92
commit
5f45990dff
|
@ -8,6 +8,7 @@
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
// base64 input, b33 and store key output, 11->11 only
|
// base64 input, b33 and store key output, 11->11 only
|
||||||
|
std::cout << "Waiting for base64 from stdin..." << std::endl;
|
||||||
std::string base64;
|
std::string base64;
|
||||||
std::getline (std::cin, base64);
|
std::getline (std::cin, base64);
|
||||||
auto ident = std::make_shared<i2p::data::IdentityEx>();
|
auto ident = std::make_shared<i2p::data::IdentityEx>();
|
||||||
|
@ -27,4 +28,3 @@ int main(int argc, char * argv[])
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -277,13 +277,13 @@ int main(int argc, char * argv[])
|
||||||
if (sign) {
|
if (sign) {
|
||||||
// sign
|
// sign
|
||||||
if (!infile.size()) {
|
if (!infile.size()) {
|
||||||
// no router info specififed
|
// no router info specified
|
||||||
std::cerr << "no router keys file specified" << std::endl;
|
std::cerr << "no router keys file specified" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!privkey.size()) {
|
if (!privkey.size()) {
|
||||||
// no private key specified
|
// no private key specified
|
||||||
std::cerr << "no private key specififed" << std::endl;
|
std::cerr << "no private key specified" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ int main(int argc, char * argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(!certfile.size()) {
|
if(!certfile.size()) {
|
||||||
std::cout << "no family cerifiticate specified" << std::endl;
|
std::cout << "no family certificate specified" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
auto v = LoadCertificate(certfile);
|
auto v = LoadCertificate(certfile);
|
||||||
|
|
|
@ -36,9 +36,6 @@ static int operate(std::function<std::size_t(const InCh *, size_t, OutCh *, size
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
int opt;
|
int opt;
|
||||||
|
|
18
keyinfo.cpp
18
keyinfo.cpp
|
@ -9,6 +9,11 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "common/key.hpp"
|
#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)
|
std::string ConvertTime (time_t t)
|
||||||
{
|
{
|
||||||
|
@ -21,14 +26,16 @@ std::string ConvertTime (time_t t)
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
if(argc == 1) {
|
if(argc == 1) {
|
||||||
std::cout << "usage: " << argv[0] << " [-v] [-d] privatekey.dat" << std::endl;
|
return printHelp(argv[0], -1);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
bool print_full = false;
|
bool print_full = false;
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
while((opt = getopt(argc, argv, "vd"))!=-1) {
|
while((opt = getopt(argc, argv, "hvd")) != -1) {
|
||||||
switch(opt){
|
switch(opt){
|
||||||
|
case 'h':
|
||||||
|
return printHelp(argv[0], 0);
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose = true;
|
verbose = true;
|
||||||
break;
|
break;
|
||||||
|
@ -36,10 +43,10 @@ int main(int argc, char * argv[])
|
||||||
print_full = true;
|
print_full = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
std::cout << "usage: " << argv[0] << " [-v] [-d] privatekey.dat" << std::endl;
|
return printHelp(argv[0], -1);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string fname(argv[optind]);
|
std::string fname(argv[optind]);
|
||||||
i2p::data::PrivateKeys keys;
|
i2p::data::PrivateKeys keys;
|
||||||
{
|
{
|
||||||
|
@ -60,6 +67,7 @@ int main(int argc, char * argv[])
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dest = keys.GetPublic();
|
auto dest = keys.GetPublic();
|
||||||
if(!dest) {
|
if(!dest) {
|
||||||
std::cout << "failed to extract public key" << std::endl;
|
std::cout << "failed to extract public key" << std::endl;
|
||||||
|
|
|
@ -33,7 +33,7 @@ int main (int argc, char * argv[])
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Cab't open keyfile " << argv[1] << std::endl;
|
std::cout << "Can't open keyfile " << argv[1] << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ int main (int argc, char * argv[])
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Cab't open keyfile " << argv[2] << std::endl;
|
std::cout << "Can't open keyfile " << argv[2] << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,20 +3,20 @@
|
||||||
#include<getopt.h>
|
#include<getopt.h>
|
||||||
|
|
||||||
|
|
||||||
static struct{
|
static struct
|
||||||
|
{
|
||||||
bool reg=false;
|
bool reg=false;
|
||||||
int threads=-1;
|
int threads=-1;
|
||||||
i2p::data::SigningKeyType signature;
|
i2p::data::SigningKeyType signature;
|
||||||
std::string outputpath="";
|
std::string outputpath="";
|
||||||
std::regex regex;
|
std::regex regex;
|
||||||
|
|
||||||
} options;
|
} options;
|
||||||
|
|
||||||
|
|
||||||
static void inline CalculateW (const uint8_t block[64], uint32_t W[64])
|
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++)
|
for (int i = 0; i < 16; i++)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -31,8 +31,8 @@ implementation of orignal
|
||||||
|
|
||||||
static void inline TransformBlock (uint32_t state[8], const uint32_t W[64])
|
static void inline TransformBlock (uint32_t state[8], const uint32_t W[64])
|
||||||
{
|
{
|
||||||
/*
|
/**
|
||||||
implementation of orignal
|
* implementation of orignal
|
||||||
*/
|
*/
|
||||||
uint32_t S[8];
|
uint32_t S[8];
|
||||||
memcpy(S, state, 32);
|
memcpy(S, state, 32);
|
||||||
|
@ -60,8 +60,8 @@ implementation of orignal
|
||||||
|
|
||||||
void inline HashNextBlock (uint32_t state[8], const uint8_t * block)
|
void inline HashNextBlock (uint32_t state[8], const uint8_t * block)
|
||||||
{
|
{
|
||||||
/*
|
/**
|
||||||
implementation of orignal
|
* implementation of orignal
|
||||||
*/
|
*/
|
||||||
uint32_t W[64];
|
uint32_t W[64];
|
||||||
CalculateW (block, W);
|
CalculateW (block, W);
|
||||||
|
@ -126,10 +126,10 @@ 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)
|
static inline bool thread_find(uint8_t * buf, const char * prefix, int id_thread, unsigned long long throughput)
|
||||||
{
|
{
|
||||||
/*
|
/**
|
||||||
Thanks to orignal ^-^
|
* Thanks to orignal ^-^
|
||||||
For idea and example ^-^
|
* For idea and example ^-^
|
||||||
Orignal is sensei of crypto ;)
|
* Orignal is sensei of crypto ;)
|
||||||
*/
|
*/
|
||||||
std::cout << "Thread " << id_thread << " binded" << std::endl;
|
std::cout << "Thread " << id_thread << " binded" << std::endl;
|
||||||
/*
|
/*
|
||||||
|
@ -208,10 +208,6 @@ Orignal is sensei of crypto ;)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void usage(void){
|
void usage(void){
|
||||||
const constexpr char * help="vain [text-pattern|regex-pattern] [options]\n"
|
const constexpr char * help="vain [text-pattern|regex-pattern] [options]\n"
|
||||||
"-h --help, help menu\n"
|
"-h --help, help menu\n"
|
||||||
|
@ -225,7 +221,6 @@ void usage(void){
|
||||||
puts(help);
|
puts(help);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void parsing(int argc, char ** args){
|
void parsing(int argc, char ** args){
|
||||||
int option_index;
|
int option_index;
|
||||||
static struct option long_options[]={
|
static struct option long_options[]={
|
||||||
|
@ -274,10 +269,6 @@ void parsing(int argc, char ** args){
|
||||||
|
|
||||||
int main (int argc, char * argv[])
|
int main (int argc, char * argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ( argc < 2 )
|
if ( argc < 2 )
|
||||||
{
|
{
|
||||||
usage();
|
usage();
|
||||||
|
@ -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_SHA384_3072:
|
||||||
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA512_4096:
|
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA512_4096:
|
||||||
case i2p::data::SIGNING_KEY_TYPE_GOSTR3410_TC26_A_512_GOSTR3411_512:
|
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;
|
return 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -413,6 +404,3 @@ int main (int argc, char * argv[])
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
Loading…
Reference in a new issue