Compare commits

..

No commits in common. "08e8bd6f164565f5926ffbb0a4516f766c74773e" and "c3f926b7593131c8275cca63e068b023e6ff259a" have entirely different histories.

9 changed files with 33 additions and 37 deletions

View file

@ -3,9 +3,6 @@
The post-quantum cryptography tool. The post-quantum cryptography tool.
Codecrypt is currently unmaintained, although I still successfully use it. If
you are interested in developing/maintaining it, ping me.
#### About #### About
This is a GnuPG-like unix program for encryption and signing that uses only This is a GnuPG-like unix program for encryption and signing that uses only
@ -34,10 +31,6 @@ Go read http://pqcrypto.org/
- Arch linux: see https://aur.archlinux.org/packages/codecrypt/ - Arch linux: see https://aur.archlinux.org/packages/codecrypt/
- *Windows port* is maintained separately here: https://github.com/mike805/codecrypt-win32 - *Windows port* is maintained separately here: https://github.com/mike805/codecrypt-win32
Language wrappers:
- Python bindings: https://github.com/mike805/codecrypt-python/
#### Documentation #### Documentation
There is a complete, UNIXy manual page supplied with the package. You can view There is a complete, UNIXy manual page supplied with the package. You can view

View file

@ -37,14 +37,12 @@ public:
state.init(); state.init();
for (i = 0; i + B <= a.size(); i += B) for (i = 0; i + B <= a.size(); i += B)
state.process_block (a.data() + i); state.process_block (& (a[i]));
state.process_final_incomplete_block (a.data() + i,
a.size() - i);
state.process_final_incomplete_block (& (a[i]), a.size() - i);
std::vector<byte> result; std::vector<byte> result;
result.resize (H, 0); result.resize (H, 0);
state.get_hash (result.data()); state.get_hash (& (result[0]));
return result; return result;
} }
}; };
@ -77,7 +75,7 @@ public:
} }
} }
while (apos + B <= asize) { while (apos + B <= asize) {
state.process_block (a + apos); state.process_block (& (a[apos]));
apos += B; apos += B;
} }
for (; apos < asize; ++apos, ++bpos) for (; apos < asize; ++apos, ++bpos)
@ -88,7 +86,7 @@ public:
state.process_final_incomplete_block (buf, bpos); state.process_final_incomplete_block (buf, bpos);
std::vector<byte> result; std::vector<byte> result;
result.resize (H, 0); result.resize (H, 0);
state.get_hash (result.data()); state.get_hash (& (result[0]));
return result; return result;
} }
}; };

View file

@ -48,7 +48,7 @@ public:
virtual ~hash_proc() {} virtual ~hash_proc() {}
void eat (const std::vector<byte>&a) { void eat (const std::vector<byte>&a) {
return eat (a.data(), a.data() + a.size()); return eat (& (a[0]), & (a[a.size()]));
} }
typedef std::map<std::string, factoryof<hash_proc>*> suite_t; typedef std::map<std::string, factoryof<hash_proc>*> suite_t;

View file

@ -21,7 +21,9 @@
#include "hashfile.h" #include "hashfile.h"
#include <map> #include <map>
#include <cstdint> using namespace std;
#include <stdint.h>
#include "hash.h" #include "hash.h"
#include "iohelpers.h" #include "iohelpers.h"
@ -70,7 +72,7 @@ public:
* list of hash functions available * list of hash functions available
*/ */
typedef std::map<std::string, instanceof<hash_proc> > hashmap; typedef map<string, instanceof<hash_proc> > hashmap;
void fill_hashmap (hashmap&t) void fill_hashmap (hashmap&t)
{ {
@ -87,7 +89,7 @@ void fill_hashmap (hashmap&t)
t["SIZE64"] = new size64proc; t["SIZE64"] = new size64proc;
} }
bool hashfile::create (std::istream&in) bool hashfile::create (istream&in)
{ {
hashes.clear(); hashes.clear();
@ -118,7 +120,7 @@ bool hashfile::create (std::istream&in)
} }
} }
int hashfile::verify (std::istream&in) int hashfile::verify (istream&in)
{ {
hashmap hm_all, hm; hashmap hm_all, hm;
fill_hashmap (hm_all); fill_hashmap (hm_all);

View file

@ -43,8 +43,8 @@ std::string keyring::get_keyid (const std::string&pubkey)
cube256hash hf; cube256hash hf;
std::vector<byte> tmp = std::vector<byte> tmp =
hf (std::vector<byte> hf (std::vector<byte>
(pubkey.data(), (&pubkey[0],
pubkey.data() + pubkey.length())); &pubkey[pubkey.length()]));
r.resize (tmp.size() * 2, ' '); r.resize (tmp.size() * 2, ' ');
for (size_t i = 0; i < tmp.size(); ++i) { for (size_t i = 0; i < tmp.size(); ++i) {

View file

@ -20,12 +20,11 @@
#include "mce_qcmdpc.h" #include "mce_qcmdpc.h"
#include <list> #include "fft.h"
#include <cmath> #include <cmath>
#include "fft.h"
using namespace mce_qcmdpc; using namespace mce_qcmdpc;
using namespace std;
int mce_qcmdpc::generate (pubkey&pub, privkey&priv, prng&rng, int mce_qcmdpc::generate (pubkey&pub, privkey&priv, prng&rng,
uint block_size, uint block_count, uint wi, uint block_size, uint block_count, uint wi,
@ -44,7 +43,7 @@ int mce_qcmdpc::generate (pubkey&pub, privkey&priv, prng&rng,
* (1+x^n). * (1+x^n).
*/ */
std::vector<dcx> H_last_inv; vector<dcx> H_last_inv;
for (;;) { for (;;) {
//retry generating the rightmost block until it is invertible //retry generating the rightmost block until it is invertible
@ -101,7 +100,7 @@ int mce_qcmdpc::generate (pubkey&pub, privkey&priv, prng&rng,
priv.H[i] = Hb; priv.H[i] = Hb;
//compute inv(H[last])*H[i] //compute inv(H[last])*H[i]
std::vector<dcx> H; vector<dcx> H;
fft (Hb, H); fft (Hb, H);
for (j = 0; j < block_size; ++j) for (j = 0; j < block_size; ++j)
H[j] *= H_last_inv[j]; H[j] *= H_last_inv[j];
@ -153,7 +152,7 @@ int pubkey::encrypt (const bvector&in, bvector&out, const bvector&errors)
if (G[i].size() != bs) return 1; //prevent mangled keys if (G[i].size() != bs) return 1; //prevent mangled keys
//first, the checksum part //first, the checksum part
std::vector<dcx> bcheck, Pd, Gd; vector<dcx> bcheck, Pd, Gd;
bcheck.resize (bs, dcx (0, 0)); //initially zero bcheck.resize (bs, dcx (0, 0)); //initially zero
bvector block; bvector block;
@ -190,6 +189,9 @@ int privkey::decrypt (const bvector & in, bvector & out)
return decrypt (in, out, tmp_errors); return decrypt (in, out, tmp_errors);
} }
#include <vector>
#include <list>
int privkey::decrypt (const bvector & in_orig, bvector & out, bvector & errors) int privkey::decrypt (const bvector & in_orig, bvector & out, bvector & errors)
{ {
uint i, j; uint i, j;
@ -206,7 +208,7 @@ int privkey::decrypt (const bvector & in_orig, bvector & out, bvector & errors)
* probabilistic decoding! * probabilistic decoding!
*/ */
std::vector<dcx> synd_diag, tmp, Htmp; vector<dcx> synd_diag, tmp, Htmp;
synd_diag.resize (bs, dcx (0, 0)); synd_diag.resize (bs, dcx (0, 0));
//precompute the syndrome //precompute the syndrome
@ -223,7 +225,7 @@ int privkey::decrypt (const bvector & in_orig, bvector & out, bvector & errors)
fft (synd_diag, syndrome); fft (synd_diag, syndrome);
//precompute sparse matrix indexes //precompute sparse matrix indexes
std::vector<std::list<uint> > Hsp; vector<list<uint> > Hsp;
Hsp.resize (blocks); Hsp.resize (blocks);
for (i = 0; i < blocks; ++i) for (i = 0; i < blocks; ++i)
for (j = 0; j < bs; ++j) for (j = 0; j < bs; ++j)
@ -240,7 +242,7 @@ int privkey::decrypt (const bvector & in_orig, bvector & out, bvector & errors)
* FFT would be a cool candidate. * FFT would be a cool candidate.
*/ */
std::vector<unsigned> unsat, round_unsat; vector<unsigned> unsat, round_unsat;
unsat.resize (cs, 0); unsat.resize (cs, 0);
for (uint blk = 0; blk < blocks; ++blk) for (uint blk = 0; blk < blocks; ++blk)

View file

@ -50,7 +50,7 @@ public:
} }
void load_key_vector (const std::vector<byte>&K) { void load_key_vector (const std::vector<byte>&K) {
load_key (K.data(), K.data() + K.size()); load_key (& (K[0]), & (K[K.size()]));
} }
typedef std::map<std::string, factoryof<streamcipher>*> suite_t; typedef std::map<std::string, factoryof<streamcipher>*> suite_t;

View file

@ -22,6 +22,7 @@
#include <algorithm> #include <algorithm>
#include <cctype> //for tolower() #include <cctype> //for tolower()
using namespace std;
bool algorithm_name_matches (const std::string& search, bool algorithm_name_matches (const std::string& search,
const std::string&name) const std::string&name)
@ -33,7 +34,7 @@ bool algorithm_name_matches (const std::string& search,
return true; return true;
} }
bool matches_icase (std::string name, std::string s) bool matches_icase (string name, string s)
{ {
transform (name.begin(), name.end(), name.begin(), ::tolower); transform (name.begin(), name.end(), name.begin(), ::tolower);
transform (s.begin(), s.end(), s.begin(), ::tolower); transform (s.begin(), s.end(), s.begin(), ::tolower);