1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-06-16 11:58:16 +00:00
Commit Graph

282 Commits

Author SHA1 Message Date
Tom Li
538d26900b
hash.h: fix std::vector access violation.
Signed-off-by: Tom Li <tomli@tomli.me>
2019-01-04 01:52:54 +08:00
Tom Li
a5a1d6190c
keyring.cpp: fix std::vector access violation
Signed-off-by: Tom Li <tomli@tomli.me>
2019-01-04 01:50:17 +08:00
Tom Li
025a958a20
cube_hash.h: finalize CubeHash if there's no incomplete block.
Previously, we assume the existence of a incomplete block at
end of the input. However, it's possible that input's an exact
multiple of block size. In this case, the first argument of
process_final_incomplete_block() will be one-past-the-last
element, the second argument will be zero. This' an ill-defined
call, and it will trigger an assertion failure of std::vector

Assertion '__builtin_expect(__n < this->size(), true)' failed.

This commit introduced a check. If we see the length of the last
incomplete block is zero, we call

    process_final_incomplete_block(NULL, 0);

which immediately finalizes CubeHash without hashing additional
data.

Signed-off-by: Tom Li <tomli@tomli.me>
2019-01-03 21:32:11 +08:00
Tom Li
29f7826b1e
cubehash_impl.h: finalize without an incomplete block.
Currently, process_final_incomplete_block() will perform the round
R calculation with the remaining data, then finalize CubeHash. It
is not possible to finalize CubeHash if there's no incomplete block.

Here, we define the call of process_final_incomplete_block(NULL, 0)
as a way to directly finalize CubeHash when input is a multiple of
block size and there is no remaining data for round R.

Also, in this case, any call of process_final_incomplete_block(),
but only with a single NULL pointer, or only with n == 0, is an
indication of bug. We assert both to be zero/nonzero.

Signed-off-by: Tom Li <tomli@tomli.me>
2019-01-03 21:18:21 +08:00
Tom Li
7021f6c734
sc.h: correct access violation in load_key_vector(), close #2.
In load_key_vector(), the program passes a std::vector<byte> to
a C-style function, load_key (const byte*begin, const byte*end)
by creating references

    load_key (& (K[0]), & (K[K.size()]));

However, accessing the one-past-the-last element in a std::vector
via [] is not allowed in C++, it triggers an assertion failure.

    Assertion '__builtin_expect(__n < this->size(), true)' failed.

In this commit, we use K.data() and K.data() + K.size() to expose
the underlying pointers and pass them to the C function.

Signed-off-by: Tom Li <tomli@tomli.me>
2019-01-02 11:42:04 +08:00
Mirek Kratochvil
66d5488133 privfile: add forgotten sources 2017-10-31 21:34:38 +01:00
Mirek Kratochvil
798de9f70a update docs 2017-10-23 14:56:02 +02:00
Mirek Kratochvil
76fb3b059d main: default -u from CCR_USER env 2017-10-23 14:33:47 +02:00
Mirek Kratochvil
c27285e750 actions: only show 40 bits of keyID by default
It must be enough for everyone! It also copypastes better and is short enough
not to provide a false feeling of security.
2017-10-23 14:32:10 +02:00
Mirek Kratochvil
5dceb7c07d styleup 2017-10-23 14:17:35 +02:00
Mirek Kratochvil
4f2680134e privfile: common sk/pk file creation/saving code 2017-10-23 14:14:26 +02:00
Mirek Kratochvil
7ec0823834 keyring: fix forgotten check 2017-10-23 14:13:49 +02:00
Mirek Kratochvil
104ee12951 implement private key locking
Included:
- gazillion changes in actions
- keyring decodes privkey structures lazily, if not needed they will
  pass by as strings
2017-10-22 23:10:23 +02:00
Mirek Kratochvil
7b0bc06d45 add forgotten seclock files
whew boy.
2017-10-22 21:12:57 +02:00
Mirek Kratochvil
578691f45e secret-locking on symmetric keys 2017-10-22 21:00:58 +02:00
Mirek Kratochvil
4f4e4f4df9 minor typos and styles
Actually, debian lintian told me that:

I: codecrypt: spelling-error-in-manpage
   usr/share/man/man1/ccr.1.gz overriden overridden

Isn't that cute?
2017-07-12 16:10:59 +02:00
Mirek Kratochvil
cc9b6b5858 base64: simplify debase64ing a bit 2017-07-10 11:17:34 +02:00
Mirek Kratochvil
be8c3faa55 arcfour: register keyword is deprecated now 2017-07-10 11:13:10 +02:00
Mirek Kratochvil
ad40fbe5dc keyring: write backup before actually touching keys 2017-06-26 14:30:07 +02:00
Mirek Kratochvil
dc3a874cd5 generator: allow own PRNG seed source 2017-06-26 14:28:54 +02:00
Mirek Kratochvil
d53586d582 remove obsolete qd_utils header 2017-04-25 12:15:06 +02:00
Mirek Kratochvil
0bd9ab6d54 hashfile: avoid being fine with informative-grade hashes only 2016-04-28 21:58:52 +02:00
Mirek Kratochvil
8e608b4d8d mce_qd: remove obsolete MCE-QD encryption 2016-04-28 13:14:24 +02:00
Mirek Kratochvil
213331903e cubehash_impl: fix cubehash implementation mistake
Well, there's a reason for that test vectors are published on wikipedia.

Although this looks scary (like writing past array bounds), cubehash B
parameter is in all cases smaller than 63 (which is the first B value where
this would write behind the array), so no harm is done. For similar reason, the
"misimplemented" cubehash was cryptographically correct (i.e. without
cryptographic weakness), only implemented differently and producing different
results than those prescribed by the standard.

Practical implications of changing the hash functions are:
- everyone gets a new KeyID
- FMTSeq keys that used cubehash are invalid now, users are forced to generate
  new ones
2016-04-28 12:49:13 +02:00
Mirek Kratochvil
f3f1a805ce cubehash_impl: support non-little-endian architectures 2016-04-28 12:49:13 +02:00
Mirek Kratochvil
a09344f034 add proper copyright notices 2016-04-17 15:48:09 +02:00
Mirek Kratochvil
f07f4027a2 clarify the `-g help' option better 2016-04-17 15:09:26 +02:00
Mirek Kratochvil
e7521cdc86 mce_qd: make the warning louder 2016-04-17 15:09:10 +02:00
Mirek Kratochvil
d8f358e8ed mce_qcmdpc: decrease decoding failure rate
The `online' modification of unsatisfied eqn counts caused increased rate of
decoding failures (verified experimentally). Use the variant that doesn't
modify the counts until next round.
2016-02-06 12:46:40 +01:00
Mirek Kratochvil
035fef4882 mce_qcmdpc: improve decoding logic a bit 2016-02-06 12:46:34 +01:00
Mirek Kratochvil
c1800500cf oh look, year changed 2016-01-20 22:54:35 +01:00
Mirek Kratochvil
dbce46b48a better configuration of crypto++ library
This fixes issues on unixes without /usr/include/crypto++ and makes use of
pkgconfig to configure the package correctly.
2016-01-13 10:07:57 +01:00
Mirek Kratochvil
abf0ea26b0 support redirecting to -
just noticed that possibility in the docs...
2016-01-12 23:20:22 +01:00
Mirek Kratochvil
b3f8f32cb1 documentation/help update 2016-01-12 23:20:07 +01:00
Mirek Kratochvil
46f68fdc93 main: provide -E option to redirect stderr to file 2016-01-11 16:33:15 +01:00
Mirek Kratochvil
5b2bc564d1 iohelpers: forgotten styleup 2015-12-05 18:55:09 +01:00
Mirek Kratochvil
dabb8fe1a1 prevent mangling user output by correct escapes
+ some code cleaning
2015-12-05 18:34:50 +01:00
Mirek Kratochvil
1d2197ca02 symkey: change default key size to 512 bits 2015-12-05 18:31:36 +01:00
Mirek Kratochvil
bad79f05a0 mce_qcmdpc: code cleaniness 2015-11-17 17:07:05 +01:00
Mirek Kratochvil
aaa8c9ae9d cleaned-up version bump 2015-11-15 20:43:30 +01:00
Mirek Kratochvil
de4ee8aa39 algos_enc: fixup the padding for non-byte-aligned keys 2015-11-15 20:38:30 +01:00
Mirek Kratochvil
78a00ae3ce mce_qcmdpc: implement faster decoding
This replaces the periodic recalculation of error correlations and the syndrome
by in-place modification. Bit flip is therefore a bit slower, but overall
decoding of the 256-bit secure variant fits in 200ms, and 128-bit variant
decodes under 20ms.

There still could be some (blatantly nondeterministic) method to do this using
FFT, research underway.
2015-11-15 20:35:03 +01:00
Mirek Kratochvil
f06372d874 mce_qcmdpc: fixup comments 2015-11-15 11:06:34 +01:00
Mirek Kratochvil
3f625e3690 implement circulant multiplication by FFT +tooling
The thing in now used in mce_qcmdpc where possible.
Also, some parameter tuning.
2015-11-15 11:05:44 +01:00
Mirek Kratochvil
23cd287372 documentation updates 2015-11-07 23:52:16 +01:00
Mirek Kratochvil
a7ffdbdee0 bvector: use faster to/from string/byte conversion 2015-11-07 23:17:09 +01:00
Mirek Kratochvil
bbca109f8b mce_qcmdpc: remove debug output 2015-11-07 19:53:42 +01:00
Mirek Kratochvil
8b4e0ba4ea massive code cleanup and removal of dead code 2015-11-07 19:38:08 +01:00
Mirek Kratochvil
17f77e16a4 mce_qcmdpc: QC-MDPC McEliece 2015-11-07 19:37:30 +01:00
Mirek Kratochvil
878d326859 bvector: faster implementation with 64bit ints 2015-11-07 19:33:47 +01:00