Fixed bug when acpkm key meshing didn't apply at appropriate time
during TLS secure exchange.
Unify usage of 'num' variable of EVP_CIPHER_CTX for kuznetchik and
magma.
* correct define variable dependency
add optional compiling setting for EVP_CTRL_TLS1_2_TLSTREE variable
Co-authored-by: Igor Kirillov <i.kirillov@kryptonite.ru>
gost_crypt: process full available block in CFB and CNT mode
If at the input of the encryption function in the CFB mode we have
an integer number of blocks, then in the main loop all blocks will be
processed, except for the last one due to an incorrect border check.
The last block will be fully processed as a "partial" remainder, but
the initialization vector will not be updated. And, thus, the value
of IV will always be incorrect in this case.
This breaks stateless protocols due to an invalid initialization vector:
all messages except the first cannot be decrypted. (Naturally, we are
talking about a case with disabled key meshing, which does not allow
context recovery due to an erroneous implementation.)
It is worth noting here that the code for processing partial blocks
(both at the input of the encryption functions and at the output) is
a historically unnecessary artifact, since we do not set the
EVP_CIPH_FLAG_CUSTOM_CIPHER flag and, as a result, OpenSSL processes
partial blocks for us.
This patch corrects the checking of the main loop boundary.
A similar error is present in the code for the CNT mode, but there it
does not manifest itself in any way, because the restoration of the
state in this mode is impossible: even after disabling key meshing, we
still have the state-dependent transformation of the IV.
As an extra result of this fix, the code for processing partial blocks
can be completely removed now.
Provide cmake test if alignment requirement is strict
This is based on AX_CHECK_ALIGNED_ACCESS_REQUIRED from autoconf-archive.
Note, that on some arches unaligned access behavior could be changed at
runtime via prctl(1). Also, unaligned memory access is still slower (and
very slow on some arches) even if it's not strictly required.
Nikolay Morozov [Thu, 27 Feb 2020 11:28:07 +0000 (14:28 +0300)]
cppcheck: Variable is reassigned a value before the old one has been used.
Plus some minor chnages
- function defenition doen't match function declaration
- Consecutive break statement is unnecessary.
- Type missmatch in format string
Vitaly Chikunov [Thu, 6 Feb 2020 15:11:00 +0000 (18:11 +0300)]
gosthash2012_const: Remove unused arrays with constants
This probably would reduce size of the library. And remove
some 'not used' warnings (-Wunused-const-variable).
Previously `Ax' is generated dynamically from `A` and `Pi` in
`GOST3411Init', but in 2013 it is moved into `gosthash2012_precalc.h`.
`Tau' is unrolled and eliminated in 2013 too.
Vitaly Chikunov [Thu, 6 Feb 2020 13:53:01 +0000 (16:53 +0300)]
gosthash2012: Issue EMMS on 32-bit SIMD implementation
`_mm_empty' is not needed on x86_64, because we only using SSE2.
But, I didn't notice that EXTRACT32 (32-bit version of EXTRACT) is
using MMX registers and intrinsics, so complete removing of
`_mm_empty' (EMMS) was mistake.
Vitaly Chikunov [Sun, 2 Feb 2020 18:23:04 +0000 (21:23 +0300)]
travis-ci: Optimize and rearrange .travis.yml
- Remove redundant 'os: linux', 'compiler: gcc' tags.
- Order jobs: x86_64 builds, analysers, other arches, other OSes.
- Mark openssl-master build as 'allow_failures' for PRs.
- Build all jobs against 'OpenSSL_1_1_1-stable' by default.
- Do not include 'linux/arch' in the job name, because Travis show
them already.
- Split name by ' | ' instead of '/' so it's easier to understand.
Vitaly Chikunov [Sun, 2 Feb 2020 19:04:45 +0000 (22:04 +0300)]
travis-ci: Fix build on 'OpenSSL_1_1_1-stable'
It's turned out that 'OpenSSL_1_1_1-stable' does not have 'build_sw'
make target. But both 'OpenSSL_1_1_1-stable' and 'master' have
'build_libs' and 'build_programs'.
dmitry dulesov [Thu, 30 Jan 2020 02:30:49 +0000 (05:30 +0300)]
gosthash2012: Change some byte (pointers) to union uint512_u
Introduce byte `.B' union type to `union uint512_u'.
Change `CTX.buffer' type from `unsigned char' to `union uint512_u'.
Change `data' argument of `stage2()' to `union uint512_u *'.
Change `g()' arguments to `union uint512_u *' with `RESTRICT'
allowing compiler to optimize more.
Vitaly Chikunov [Sun, 5 Jan 2020 20:24:50 +0000 (23:24 +0300)]
travis-ci: Fix quietness of building of openssl
No need for `build.log' as `make -s' will output any failure.
Also, redirection was broken anyway since splitting make into two makes
with separate `-j' and install phase.
Add `travis_wait' to make traves not time-out on slow arches. Reference:
https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received
Fixes: c38ec7587 ("travis: speed up Travis build")
Vitaly Chikunov [Sun, 5 Jan 2020 20:51:09 +0000 (23:51 +0300)]
tcl_tests: Abbreviate output when run under CI
To make CI output not too long - output only header of every test set
and output only relevant log entries on test failures.
When `CI' env is defined. Which should be defined for both Travis and
Cirrus. Reference:
https://docs.travis-ci.com/user/environment-variables/
https://cirrus-ci.org/guide/writing-tasks/#environment-variables
Vitaly Chikunov [Sun, 5 Jan 2020 20:14:29 +0000 (23:14 +0300)]
tcl_tests: Rearrange runtest.sh to run from dirrerent env
Add more debug output to fix Travis-CI issues. Move definition of
OPENSSL_CONF above first tcl test run. Define OPENSSL_ENGINES from
ENGINE_DIR by default.
Vitaly Chikunov [Wed, 13 Nov 2019 21:40:18 +0000 (00:40 +0300)]
tcl_tests: Fix and update enc test
- Set expected default value for CRYPT_PARAMS.
- Disable `RIC 1' params tests.
- Disable `Magma-ACPKM' test.
- Update test descriptions to include cipher name.
Vitaly Chikunov [Sun, 10 Nov 2019 01:34:01 +0000 (04:34 +0300)]
tcl_tests: Make utf-8 encoding work
- Remove emacs coding: cp1251 tag
- Change stats file encoding to utf-8
- Change packages source to have -encoding utf-8
- Run tclsh with -encoding utf-8
- Make `proc rus' noop.
This will make Tcl automatically translate scripts output from utf-8 to
system encoding.
ameth: fill digestParamSet for the sake of backwards compatibility
Even though it is not recommended by R 1323565.1.023-2018 fill
digestParamSet field for 512-bit curves Test, TC26-A, TC26-B because old
cryptoproviders expect this field to be present.