Implemented config and crypto infrastructure (#2)

Added config file read/write infrastructure with RapidJSON.
Added key pair generation and sign/verify helper with libsodium.
This commit is contained in:
Ravin Perera
2019-09-26 19:05:23 +05:30
committed by GitHub
parent d7eac1a1f1
commit 0382475de1
46 changed files with 16929 additions and 4 deletions

View File

@@ -4,11 +4,31 @@
#include <cstdio>
#include <iostream>
#include "conf.h"
#include "crypto.h"
using namespace std;
int main(int argc, char** argv) {
int main(int argc, char **argv)
{
if (!conf::init() || !crypto::init())
{
cerr << "Init error\n";
return -1;
}
//Example sign and verification.
unsigned char msg[10] = "hotpocket";
unsigned char *sig = new unsigned char[crypto::get_sig_len()];
crypto::sign(msg, 10, sig);
bool isValid = crypto::verify(msg, 10, sig);
if (isValid)
cout << "Signature verified.\n";
else
cout << "Invalid signature.\n";
cout << "exited normally\n";
return 0;
}
}