diff --git a/src/keymgmt.h b/src/algos_sig.cpp similarity index 93% rename from src/keymgmt.h rename to src/algos_sig.cpp index e00d293..1a6b24e 100644 --- a/src/keymgmt.h +++ b/src/algos_sig.cpp @@ -16,8 +16,7 @@ * along with Codecrypt. If not, see . */ -#ifndef _ccr_keys_h_ -#define _ccr_keys_h_ +#include "algos_enc.h" -#endif +#include "fmtseq.h" diff --git a/src/algos_sig.h b/src/algos_sig.h new file mode 100644 index 0000000..4bf9666 --- /dev/null +++ b/src/algos_sig.h @@ -0,0 +1,69 @@ + +/* + * This file is part of Codecrypt. + * + * Codecrypt is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Codecrypt is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Codecrypt. If not, see . + */ + +#ifndef _ccr_sig_algs_h_ +#define _ccr_sig_algs_h_ + +#include "algorithm.h" + +class algo_fmtseq128 : public algorithm +{ +public: + bool provides_signatures() { + return true; + } + + bool provides_encryption() { + return false; + } + + std::string get_alg_id() { + return "FMTSEQ128-SHA256-SHA256HALF"; + } + + virtual int sign (const bvector&msg, bvector&sig, + sencode* privkey, bool&dirty, prng&rng); + virtual int verify (const bvector&sig, const bvector&msg, + sencode* pubkey); + int create_keypair (sencode**pub, sencode**priv, prng&rng); +}; + +class algo_fmtseq256 : public algorithm +{ +public: + bool provides_signatures() { + return true; + } + + bool provides_encryption() { + return false; + } + + std::string get_alg_id() { + return "FMTSEQ256-SHA512-SHA256"; + } + + virtual int sign (const bvector&msg, bvector&sig, + sencode* privkey, bool&dirty, prng&rng); + virtual int verify (const bvector&sig, const bvector&msg, + sencode* pubkey); + int create_keypair (sencode**pub, sencode**priv, prng&rng); +}; + +#endif + diff --git a/src/keyring.cpp b/src/keyring.cpp index 102ca91..64bf126 100644 --- a/src/keyring.cpp +++ b/src/keyring.cpp @@ -18,12 +18,6 @@ #include "keyring.h" -bool keyring::disk_sync() -{ - - return false; -} - sencode* keyring::get_pubkey (const std::string&key_id) { @@ -54,3 +48,40 @@ bool keyring::store_privkey (const std::string&key_id, sencode*) } +/* + * DISK KEYRING STORAGE + * + * Whole thing is stored in two files just like in GnuPG: + * + * ~/.ccr/pubkeys + * ~/.ccr/private_keyring + * + * format of the files is raw sencode. + * + * Public key file is organized as follows: + * + * ( + * "ccr public key storage" + * ( "public-key-id" pubkey_as_embedded_sencode ) + * ( "public-key-id" pubkey_as_embedded_sencode ) + * ( "public-key-id" pubkey_as_embedded_sencode ) + * ... + * ) + * + * Private keys are stored together with their pubkeys, so that they don't have + * to be generated everytime user asks for them: + * + * ( + * "ccr private keyring" + * ( "public-key-id" privkey pubkey ) + * ( "public-key-id" privkey pubkey ) + * ( "public-key-id" privkey pubkey ) + * ... + * ) + * + */ + +bool keyring::disk_sync() +{ + return false; +} diff --git a/src/keyring.h b/src/keyring.h index 0f37fd3..c174a98 100644 --- a/src/keyring.h +++ b/src/keyring.h @@ -20,11 +20,17 @@ #define _ccr_keys_h_ #include +#include #include "sencode.h" +/* TODO privkeys are actually keypairs! */ + class keyring { + std::multimap + priv_cache, priv_dirty, + pub_cache, pub_dirty; public: bool disk_sync();