]> www.wagner.pp.ru Git - openssl-gost/engine.git/log
openssl-gost/engine.git
2 weeks agoMerge pull request #455 from arx11/magma_ctracpkm_omac master
Ilya Shipitsin [Wed, 28 May 2025 10:31:54 +0000 (12:31 +0200)]
Merge pull request #455 from arx11/magma_ctracpkm_omac

Added support for magma-ctracpkm-omac

2 weeks agoMerge pull request #454 from arx11/missing_buffer_cleanses
Ilya Shipitsin [Wed, 28 May 2025 09:35:42 +0000 (11:35 +0200)]
Merge pull request #454 from arx11/missing_buffer_cleanses

Added missing buffer cleanses for some sensitive buffers

2 weeks agoMerge pull request #453 from arx11/raw_ec_keys
Ilya Shipitsin [Wed, 28 May 2025 09:34:45 +0000 (11:34 +0200)]
Merge pull request #453 from arx11/raw_ec_keys

Added support for raw public key export and import

2 weeks agoMerge pull request #462 from yanovich/infer
Ilya Shipitsin [Tue, 27 May 2025 21:47:48 +0000 (23:47 +0200)]
Merge pull request #462 from yanovich/infer

Fix static analysis (Infer) complains

2 weeks agoMerge pull request #469 from adrien-n/master
Ilya Shipitsin [Tue, 27 May 2025 21:46:28 +0000 (23:46 +0200)]
Merge pull request #469 from adrien-n/master

test: parallel testsuite runs failed due to reused filenames

2 weeks agoMerge pull request #477 from chipitsine/master
Ilya Shipitsin [Tue, 27 May 2025 21:24:52 +0000 (23:24 +0200)]
Merge pull request #477 from chipitsine/master

update submodule: libprov

2 weeks agoupdate submodule: libprov 477/head
Ilya Shipitsin [Tue, 27 May 2025 20:47:26 +0000 (22:47 +0200)]
update submodule: libprov

8 weeks agoMerge pull request #476 from chipitsine/master
Ilya Shipitsin [Sun, 20 Apr 2025 17:38:19 +0000 (19:38 +0200)]
Merge pull request #476 from chipitsine/master

modernize macos images

8 weeks agomodernize macos images 476/head
Ilia Shipitsin [Sun, 20 Apr 2025 17:31:19 +0000 (19:31 +0200)]
modernize macos images

8 weeks agoMerge pull request #474 from chipitsine/master
Ilya Shipitsin [Sun, 20 Apr 2025 16:15:33 +0000 (18:15 +0200)]
Merge pull request #474 from chipitsine/master

CI: use the latest actions/cache

8 weeks agoCI: use the latest actions/cache 474/head
Ilia Shipitsin [Sun, 20 Apr 2025 15:30:33 +0000 (17:30 +0200)]
CI: use the latest actions/cache

8 weeks agoMerge pull request #473 from chipitsine/master
Ilya Shipitsin [Sun, 20 Apr 2025 15:21:51 +0000 (17:21 +0200)]
Merge pull request #473 from chipitsine/master

update ubuntu image in CI

8 weeks agoupdate ubuntu image in CI 473/head
Ilia Shipitsin [Sun, 20 Apr 2025 15:12:26 +0000 (17:12 +0200)]
update ubuntu image in CI

8 weeks agoMerge pull request #472 from chipitsine/master
Ilya Shipitsin [Sun, 20 Apr 2025 14:20:48 +0000 (16:20 +0200)]
Merge pull request #472 from chipitsine/master

modernize coverity scan a bit

8 weeks agomodernize coverity scan a bit 472/head
Ilia Shipitsin [Sun, 20 Apr 2025 14:19:51 +0000 (16:19 +0200)]
modernize coverity scan a bit

2 months agoupdate to latest version of libprov 470/head
Neil Horman [Tue, 1 Apr 2025 12:49:01 +0000 (08:49 -0400)]
update to latest version of libprov

Recently, we saw a failure in openssl tests when building gost-engine:
https://github.com/openssl/openssl/actions/runs/14192630435/job/39768534802

It occurs because a gost-engine dependency (libprov) requires a minimum
cmake version of 3.0.  Recent distro updates have moved to cmake 4.0,
which error out if a CMakeLists.txt file requires a version less than
3.5.

The libprov tree has been updated to require 3.18 now (matching the
requirement for gost-engine), so we need to update the libprov submodule
here to pull that update in.

2 months agotcl_tests: ca.try: Ignore multi-space indentation in openssl crl output
Vitaly Chikunov [Fri, 28 Mar 2025 15:53:14 +0000 (18:53 +0300)]
tcl_tests: ca.try: Ignore multi-space indentation in openssl crl output

Indentation is changing from 8 to 4 chars in new version of openssl[1]. Make the
test forward and backward compatible with variable indentation of openssl crl
output.

Link: https://github.com/openssl/openssl/pull/27124
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
2 months agotest: parallel testsuite runs failed due to reused filenames 469/head
Adrien Nader [Tue, 25 Mar 2025 09:07:50 +0000 (10:07 +0100)]
test: parallel testsuite runs failed due to reused filenames

Cmake can run tests in parallel and does so for the perl tests. These
are actually the same tests twice but in "engine" and "provider"
variants.

These tests contain something like the following:
- create testdata.dat
- write to it
- use the file
- unlink the file

When two of these run in parallel, a likely scenario is the file is
unlinked by one while still being needed by the second.

This commit simply prefixes the filenames with "$ARGV[0]-" which is
either "engine-" or "provider-". With unique names, there are no more
overlaps.

PS: I had first looked for ways to disable parallel test execution (when
I thought it was perl running tests in parallel rather than cmake) but
found no way to do that in CMakeLists.txt, only through an environment
variable or by changing the command-line invocation, both of which where
far less appropriate both for distribution patches and upstreaming.

10 months agoFix double initialization 462/head
Sergei Ianovich [Tue, 30 Jul 2024 15:04:04 +0000 (15:04 +0000)]
Fix double initialization

Infer correctly complains that `ptr` is initialized twice before first
use. The fix is trivial.
```
gost12sum.c:253: error: Dead Store
  The value written to `&ptr` is never used.
  251. {
  252.     int i, len;
  253.     char *ptr = filename;
           ^
  254.     char *spacepos = NULL;
  255.
```

10 months agoFix false positive static analysis issue #2
Sergei Ianovich [Tue, 30 Jul 2024 14:55:22 +0000 (14:55 +0000)]
Fix false positive static analysis issue #2

Infer complains:
```
test_digest.c:662: error: Dead Store
  The value written to `&p` is never used.
  660.     if (t->truncate) {
  661.         outsize = t->truncate;
  662.  params[p++] = OSSL_PARAM_construct_size_t("size", &outsize);
               ^
  663.     }
  664.     else
```

Altough the complain is false positive, fixing it will allow for future
use of the tools in automated tests.

10 months agoFix false positive static analysis issue
Sergei Ianovich [Tue, 30 Jul 2024 14:33:18 +0000 (14:33 +0000)]
Fix false positive static analysis issue

Infer complains:
```
test_tls.c:172: error: Uninitialized Value
  `_.cert` is read without initialization.
  170.
  171.     T(sctx = SSL_CTX_new(TLS_server_method()));
  172.     T(SSL_CTX_use_certificate(sctx, ck.cert));
           ^
  173.     T(SSL_CTX_use_PrivateKey(sctx, ck.pkey));
  174.     T(SSL_CTX_check_private_key(sctx));

test_tls.c:173: error: Uninitialized Value
  `_.pkey` is read without initialization.
  171.     T(sctx = SSL_CTX_new(TLS_server_method()));
  172.     T(SSL_CTX_use_certificate(sctx, ck.cert));
  173.     T(SSL_CTX_use_PrivateKey(sctx, ck.pkey));
           ^
  174.     T(SSL_CTX_check_private_key(sctx));
  175.
```

Altough the complain is false positive, fixing it will allow for future
use of the tools in automated tests.

14 months agoFix another "openssl engine" check 455/head
arx11 [Wed, 27 Mar 2024 18:14:40 +0000 (14:14 -0400)]
Fix another "openssl engine" check

14 months agoFix "openssl engine" check (again)
arx11 [Tue, 26 Mar 2024 18:31:56 +0000 (14:31 -0400)]
Fix "openssl engine" check (again)

14 months agoFix "openssl engine" check
arx11 [Tue, 26 Mar 2024 10:47:06 +0000 (06:47 -0400)]
Fix "openssl engine" check

14 months agoFixed algorithm detection between magma and kuznyechik in OMAC.
arx11 [Mon, 25 Mar 2024 19:02:47 +0000 (15:02 -0400)]
Fixed algorithm detection between magma and kuznyechik in OMAC.

14 months agoAdded missing buffer cleanse 454/head
arx11 [Sat, 23 Mar 2024 10:28:28 +0000 (06:28 -0400)]
Added missing buffer cleanse

14 months agoAdded support for magma-ctracpkm-omac.
arx11 [Sun, 24 Mar 2024 10:33:44 +0000 (06:33 -0400)]
Added support for magma-ctracpkm-omac.

Magma OMAC is implemented the same way as NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac. And with test vectors.

14 months agoAdded support for raw public key export and import 453/head
arx11 [Sat, 23 Mar 2024 10:13:59 +0000 (06:13 -0400)]
Added support for raw public key export and import

In total there are 3 new functions to export/import raw values of public and private keys.
Public key functions are used to handle ASN1_PKEY_CTRL_GET1_TLS_ENCPT and ASN1_PKEY_CTRL_SET1_TLS_ENCPT control codes used by SSL stack during key exchange.
Private key export function is just a convenient way to get the key value (EVP_PKEY_new_raw_private_key does not provide paramset to use for key import).

14 months agotcl_tests: ca.try: Ignore openssl crl exit status for 'corrupted CRL' test
Vitaly Chikunov [Fri, 22 Mar 2024 02:20:50 +0000 (05:20 +0300)]
tcl_tests: ca.try: Ignore openssl crl exit status for 'corrupted CRL' test

Older `openssl crl` exits with 0 in regard to verify no matter actual verify
status, newer `openssl crl` could exit with 1 on verify failure. Make the test
backward-compatible comparing only an output.

Fixes: https://github.com/gost-engine/engine/issues/452
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
14 months agotcl_tests: Introduce new exitStatus -1 to ignore exit codes
Vitaly Chikunov [Fri, 22 Mar 2024 02:12:53 +0000 (05:12 +0300)]
tcl_tests: Introduce new exitStatus -1 to ignore exit codes

It's proposed[1] that crl and req change exit code making it unreliable for some
commands. Allow tests to ignore exit codes by specifying expected exit code `-1`.

This will also make such tests to always use regexp match mode.

Also, slightly fix the logic of applying regexp. Commentary says test
_parameter_ (`exitStatus`) 1 is used to trigger regexp matching but in fact
actual command exit code (`status`) 1 is used for that. This change did not
cause any test result difference.

Link: https://github.com/openssl/openssl/pull/23773
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
18 months agoBig-Endian platforms magma-mgm fix v3.0.3
Dmitry Belyavskiy [Fri, 17 Nov 2023 15:36:18 +0000 (16:36 +0100)]
Big-Endian platforms magma-mgm fix

22 months agoAdjust CA test according to new wording v3.0.2
Dmitry Belyavskiy [Fri, 28 Jul 2023 09:51:36 +0000 (11:51 +0200)]
Adjust CA test according to new wording

2 years agoFix gcc13 error: writing 1 byte into a region of size 0
Vitaly Chikunov [Wed, 14 Jun 2023 14:12:51 +0000 (17:12 +0300)]
Fix gcc13 error: writing 1 byte into a region of size 0

gcc-13 thinks `bl` can take negative value (when returned from
EVP_CIPHER_CTX_block_size). Do simple sanity checking to workaround this.
Also, add error propagation up to EVP_DigestFinal_ex, so this sanity checking
is not in vain.

Error message:

  In function 'make_kn',
      inlined from 'CMAC_ACPKM_Final' at /builddir/build/BUILD/engine-3.0.0/gost_omac_acpkm.c:274:5,
      inlined from 'omac_acpkm_imit_final' at /builddir/build/BUILD/engine-3.0.0/gost_omac_acpkm.c:354:5:
  /builddir/build/BUILD/engine-3.0.0/gost_omac_acpkm.c:55:20: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
     55 |         k1[bl - 1] ^= bl == 16 ? 0x87 : 0x1b;
        |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
  /builddir/build/BUILD/engine-3.0.0/gost_omac_acpkm.c: In function 'omac_acpkm_imit_final':
  /builddir/build/BUILD/engine-3.0.0/gost_omac_acpkm.c:260:24: note: at offset [-2147483649, -1] into destination object 'k2' of size 32
    260 |     unsigned char *k1, k2[EVP_MAX_BLOCK_LENGTH];
        |                        ^~

Fixes: https://github.com/gost-engine/engine/issues/436
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
2 years agoCorrect CMake files installation path
Craig Andrews [Tue, 3 Jan 2023 22:42:02 +0000 (17:42 -0500)]
Correct CMake files installation path

install(EXPORT GostEngineConfig DESTINATION share/cmake/GostEngine) will to a path like this:
/usr/GostEngine/share/cmake/GostEngine/GostEngineConfig.cmake
which is not standard or expected. These files should be installed to:
/usr/share/cmake/GostEngine/GostEngineConfig.cmake
which can be done by changing the installation line to:
install(EXPORT GostEngineConfig DESTINATION share/cmake/GostEngine)

2 years agoprovider wrapping for -mgm ciphers
Sergei Ianovich [Sat, 24 Sep 2022 15:11:26 +0000 (18:11 +0300)]
provider wrapping for -mgm ciphers

Signed-off-by: Sergei Ianovich <sergei.ianovich@ya.ru>
2 years agoImplementation of the MGM mode for magma/kuznyechik
igrkir [Fri, 23 Sep 2022 12:32:21 +0000 (15:32 +0300)]
Implementation of the MGM mode for magma/kuznyechik

first implemented in ossl_patched branch
uses dynamic NIDs

Signed-off-by: Sergei Ianovich <sergei.ianovich@ya.ru>
2 years agoengine: create missing NIDs
Sergei Ianovich [Sun, 25 Sep 2022 11:35:14 +0000 (14:35 +0300)]
engine: create missing NIDs

Signed-off-by: Sergei Ianovich <sergei.ianovich@ya.ru>
2 years agoMerge pull request #421 from chipitsine/master
Ilya Shipitsin [Wed, 2 Nov 2022 16:46:18 +0000 (21:46 +0500)]
Merge pull request #421 from chipitsine/master

CI: cirrus: bump image to freebsd 13.1

2 years agoCI: cirrus: bump image to freebsd 13.1 421/head
Ilya Shipitsin [Wed, 2 Nov 2022 16:32:00 +0000 (21:32 +0500)]
CI: cirrus: bump image to freebsd 13.1

2 years agoupdating CA constraints
Dmitry Belyavskiy [Sun, 25 Sep 2022 09:39:55 +0000 (11:39 +0200)]
updating CA constraints

2 years agoAdd magma-ecb mode. Fixes #410
Mark Fedorov [Thu, 11 Aug 2022 12:27:11 +0000 (12:27 +0000)]
Add magma-ecb mode. Fixes #410

2 years agoWe need to init submodule explicitly
Dmitry Belyavskiy [Fri, 22 Jul 2022 15:13:27 +0000 (17:13 +0200)]
We need to init submodule explicitly

Thanks to Matt Caswell for pointing on it

2 years agoRefactored acpkm_magma_key_meshing
Mark Fedorov [Sat, 9 Jul 2022 16:00:26 +0000 (16:00 +0000)]
Refactored acpkm_magma_key_meshing

2 years agoRefactor little-to-big-endian subroutine for magma
Mark Fedorov [Fri, 1 Jul 2022 12:29:12 +0000 (15:29 +0300)]
Refactor little-to-big-endian subroutine for magma

3 years agogost_ec_sign: Fix sig verify step 1 range checks
Vitaly Chikunov [Fri, 22 Apr 2022 00:02:36 +0000 (03:02 +0300)]
gost_ec_sign: Fix sig verify step 1 range checks

Ensure 0 < r < q, 0 < s < q. (34.10-2021 6.2).

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoOn unpacking key blob output buffer size should be fixed v3.0.1
Dmitry Belyavskiy [Sat, 21 May 2022 18:20:20 +0000 (20:20 +0200)]
On unpacking key blob output buffer size should be fixed

Related: CVE-2022-29242

3 years agoFix buffer overrun in creating key transport blob according to RFC 9189, 4.2.4.2
Dmitry Belyavskiy [Sat, 21 May 2022 18:06:47 +0000 (20:06 +0200)]
Fix buffer overrun in creating key transport blob according to RFC 9189, 4.2.4.2

Resolves: CVE-2022-29242

3 years agoFix buffer overrun in creating key transport blob according to RFC 9189, 4.2.4.1
Dmitry Belyavskiy [Fri, 20 May 2022 16:13:50 +0000 (18:13 +0200)]
Fix buffer overrun in creating key transport blob according to RFC 9189, 4.2.4.1

Resolves: CVE-2022-29242

3 years agoMake TLS tests on SECLEVEL 0
Dmitry Belyavskiy [Wed, 4 May 2022 16:19:02 +0000 (18:19 +0200)]
Make TLS tests on SECLEVEL 0

As https://github.com/openssl/openssl/pull/18236 is going to
ban SSL3, TLS1, TLS1.1 and DTLS1.0 at security level one and above,
we have to adjust GOST TLS tests.

3 years agoGet rid of irrelevant examples
Dmitry Belyavskiy [Tue, 8 Feb 2022 13:41:44 +0000 (14:41 +0100)]
Get rid of irrelevant examples

3 years agoFix gcc12 -fanalyzer warning
Vitaly Chikunov [Tue, 8 Feb 2022 08:31:54 +0000 (11:31 +0300)]
Fix gcc12 -fanalyzer warning

GCC do not understand that `algname` cannot be NULL. Add dummy default case to
cover all execution paths.

Fixes https://github.com/gost-engine/engine/issues/389
Tested-by: Ilya Shipitsin <chipitsine@gmail.com>
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoEnsure that CMAC_ACPKM_CTX_copy works with 2 non-NULL pointers - fixup
Dmitry Belyavskiy [Mon, 7 Feb 2022 17:31:04 +0000 (18:31 +0100)]
Ensure that CMAC_ACPKM_CTX_copy works with 2 non-NULL pointers - fixup

Related: #387

3 years agoEnsure that CMAC_ACPKM_CTX_copy works with 2 non-NULL pointers.
Dmitry Belyavskiy [Sun, 6 Feb 2022 13:41:15 +0000 (14:41 +0100)]
Ensure that CMAC_ACPKM_CTX_copy works with 2 non-NULL pointers.

Related: #387

3 years agogost_prov: OPENSSL_free what is OPENSSL_zalloc'd
Vitaly Chikunov [Mon, 10 Jan 2022 01:27:00 +0000 (04:27 +0300)]
gost_prov: OPENSSL_free what is OPENSSL_zalloc'd

  *** CID 345254:  API usage errors  (ALLOC_FREE_MISMATCH)
  /gost_prov.c: 71 in provider_ctx_new()
  65             && populate_gost_engine(ctx->e)) {
  66             ctx->core_handle = core;
  67
  68             /* Ugly hack */
  69             err_handle = ctx->proverr_handle;
  70         } else {
  >>>     CID 345254:  API usage errors  (ALLOC_FREE_MISMATCH)
  >>>     Calling "provider_ctx_free" frees "ctx" using "free" but it should have been freed using "CRYPTO_free".
  71             provider_ctx_free(ctx);
  72             ctx = NULL;
  73         }
  74         return ctx;
  75     }

Fixes: f5a3951 ("gost_prov: Avoid access to unallocated memory")
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agogost_prov: Avoid access to unallocated memory
Vitaly Chikunov [Sat, 8 Jan 2022 23:34:57 +0000 (02:34 +0300)]
gost_prov: Avoid access to unallocated memory

This should fix Coverity warning:

  *** CID 345245:    (UNINIT)
  /gost_prov.c: 71 in provider_ctx_new()
  65             && populate_gost_engine(ctx->e)) {
  66             ctx->core_handle = core;
  67
  68             /* Ugly hack */
  69             err_handle = ctx->proverr_handle;
  70         } else {
  >>>     CID 345245:    (UNINIT)
  >>>     Using uninitialized value "ctx->e" when calling "provider_ctx_free".
  71             provider_ctx_free(ctx);
  72             ctx = NULL;
  73         }
  74         return ctx;
  75     }

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
Issue: #380

3 years agogost_ec_keyx: Check CTX data before it's really used
Vitaly Chikunov [Sat, 8 Jan 2022 23:25:31 +0000 (02:25 +0300)]
gost_ec_keyx: Check CTX data before it's really used

This should fix Coverity warning:

  *** CID 345243:  Null pointer dereferences  (REVERSE_INULL)
  /gost_ec_keyx.c: 681 in pkey_gost2018_decrypt()
  675        o  Q_eph is on the same curve as server public key;
  676
  677        o  Q_eph is not equal to zero point;
  678
  679        o  q * Q_eph is not equal to zero point.
  680     */
  >>>     CID 345243:  Null pointer dereferences  (REVERSE_INULL)
  >>>     Null-checking "data" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
  681         if (eph_key == NULL || priv == NULL || data == NULL) {
  682            GOSTerr(GOST_F_PKEY_GOST2018_DECRYPT,
  683                    GOST_R_ERROR_COMPUTING_EXPORT_KEYS);
  684            ret = 0;
  685            goto err;
  686         }

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
Issue: #380

3 years agoMerge pull request #379 from chipitsine/master
Ilya Shipitsin [Sat, 8 Jan 2022 08:31:14 +0000 (11:31 +0300)]
Merge pull request #379 from chipitsine/master

CI: add daily Coverity scan job

3 years agoCI: add daily Coverity scan job 379/head
Ilya Shipitsin [Thu, 6 Jan 2022 21:48:19 +0000 (02:48 +0500)]
CI: add daily Coverity scan job

3 years agotest_tls: Rework test to be single process
Vitaly Chikunov [Wed, 15 Dec 2021 01:23:22 +0000 (04:23 +0300)]
test_tls: Rework test to be single process

Rework the test to be similar to sslapitest.c. Using BIO only connections
and non-blocking IO instead of socketpair and separate processes.
This will allow it to compile and work on Windows.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Fix casting warning C4057
Vitaly Chikunov [Sun, 19 Dec 2021 22:40:39 +0000 (01:40 +0300)]
MSVC: Fix casting warning C4057

test_tls.c(103,5): warning C4057: 'function': 'const unsigned char *' differs in indirection to slightly different base types from 'char [8]'
test_tls.c(104,5): warning C4057: 'function': 'const unsigned char *' differs in indirection to slightly different base types from 'char [9]'

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: CI: Specify explicitly OpenSSL build target
Vitaly Chikunov [Sun, 19 Dec 2021 21:58:23 +0000 (00:58 +0300)]
MSVC: CI: Specify explicitly OpenSSL build target

Useful to copy-paste for manual builds.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoOutput provider info
Vitaly Chikunov [Sun, 19 Dec 2021 22:35:58 +0000 (01:35 +0300)]
Output provider info

Output something in `openssl list -providers` so it's merrier.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoCMake: Set default build type to RelWithDebInfo
Vitaly Chikunov [Wed, 15 Dec 2021 00:46:26 +0000 (03:46 +0300)]
CMake: Set default build type to RelWithDebInfo

To maintain backward compatibility for users already familiar with older engine
build type (basically restores `-O2 -g').

Fixes: 5ad6c77 ("Adapt C flags for the cmake build type")
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Add dllexport to OSSL_provider_init
Vitaly Chikunov [Fri, 10 Dec 2021 14:46:18 +0000 (17:46 +0300)]
MSVC: Add dllexport to OSSL_provider_init

`OSSL_provider_init' requires dllexport attribute to be visible (and thus
loadable) in DLL.

Link: https://github.com/openssl/openssl/issues/17203
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoCMake: Add CONFIG to the output dir if MSVC
Vitaly Chikunov [Tue, 7 Dec 2021 09:14:48 +0000 (12:14 +0300)]
CMake: Add CONFIG to the output dir if MSVC

This will fix setting of OPENSSL_ENGINES in ctest on Windows.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoCMake: Test presence of prove for perl tests
Vitaly Chikunov [Tue, 7 Dec 2021 09:33:41 +0000 (12:33 +0300)]
CMake: Test presence of prove for perl tests

This will skip tests on Windows, due to prove being `.bat' file and cmake will
be unable to run it.

Also, `HAVE_TEST2_V0' is renamed to be more meaningful.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Do not build in library form
Vitaly Chikunov [Mon, 6 Dec 2021 03:09:27 +0000 (06:09 +0300)]
MSVC: Do not build in library form

Library form overwrites module form due to both having the same name `gost.dll'.
As temporary workaround do not build library form on Windows, until we invent
how to solve it properly. Currently, there is no known need of engine in the
library form on Windows.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Fix 'no OPENSSL_Applink' error
Vitaly Chikunov [Sun, 5 Dec 2021 08:07:11 +0000 (11:07 +0300)]
MSVC: Fix 'no OPENSSL_Applink' error

Error message:

  OPENSSL_Uplink(00007FF9FB00F600,08): no OPENSSL_Applink

Link: https://www.openssl.org/docs/faq.html#PROG3
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Skip building Linux-only binaries
Vitaly Chikunov [Sat, 4 Dec 2021 09:35:46 +0000 (12:35 +0300)]
MSVC: Skip building Linux-only binaries

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Fix absence of 'setenv'
Vitaly Chikunov [Sat, 4 Dec 2021 08:09:52 +0000 (11:09 +0300)]
MSVC: Fix absence of 'setenv'

Error message:

  test_keyexpimp.c(111,11): warning C4013: 'setenv' undefined; assuming extern returning int

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Fix include files
Vitaly Chikunov [Sat, 4 Dec 2021 09:37:39 +0000 (12:37 +0300)]
MSVC: Fix include files

Error message:

  gost12sum.c(13,10): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
  gost12sum.c(80,23): warning C4013: 'getopt' undefined; assuming extern returning int
  test_keyexpimp.c(7,10): fatal error C1083: Cannot open include file: 'arpa/inet.h': No such file or directory

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Fix signed/unsigned mismatch errors
Vitaly Chikunov [Sat, 4 Dec 2021 07:25:38 +0000 (10:25 +0300)]
MSVC: Fix signed/unsigned mismatch errors

  test_digest.c(513,2): warning C4389: '==': signed/unsigned mismatch
  test_digest.c(820,5): warning C4389: '==': signed/unsigned mismatch
  test_sign.c(241,22): warning C4389: '==': signed/unsigned mismatch
  test_params.c(1131,16): warning C4018: '<': signed/unsigned mismatch
  test_sign.c(241,22): warning C4389: '==': signed/unsigned mismatch

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: No support for GCC's compound statement expressions
Vitaly Chikunov [Sat, 4 Dec 2021 06:55:55 +0000 (09:55 +0300)]
MSVC: No support for GCC's compound statement expressions

Error messages:

  test_ciphers.c(329,5): error C2059: syntax error: '{'
  test_ciphers.c(329,5): error C2059: syntax error: '}'
  test_ciphers.c(329,5): error C2059: syntax error: ')'

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Replace variable-length automatic arrays with alloca
Vitaly Chikunov [Sat, 4 Dec 2021 06:13:14 +0000 (09:13 +0300)]
MSVC: Replace variable-length automatic arrays with alloca

MSVC is not C99 compatible[1]. Errors:

  test_ciphers.c(312,25): error C2057: expected constant expression
  test_ciphers.c(312,25): error C2466: cannot allocate an array of constant size 0
  test_ciphers.c(312,26): error C2133: 'c': unknown size

Link: https://docs.microsoft.com/en-us/cpp/c-language/ansi-conformance
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Ifdef GCC pragmas
Vitaly Chikunov [Sat, 4 Dec 2021 06:00:47 +0000 (09:00 +0300)]
MSVC: Ifdef GCC pragmas

Error message:

  test_ciphers.c(37,9): warning C4068: unknown pragma 'GCC'

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Avoid use `htonl' since it requires linking with Winsock
Vitaly Chikunov [Fri, 3 Dec 2021 09:38:19 +0000 (12:38 +0300)]
MSVC: Avoid use `htonl' since it requires linking with Winsock

No need external library (Ws2_32.lib) if we can easily implement it.
Error messages:

  gost_core.lib(gost_keyexpimp.obj) : error LNK2019: unresolved external symbol htonl referenced in function gost_kdftree2012_256
  gost.dll : fatal error LNK1120: 1 unresolved externals

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Remove GCC pragma messages
Vitaly Chikunov [Fri, 3 Dec 2021 09:32:35 +0000 (12:32 +0300)]
MSVC: Remove GCC pragma messages

These planned to be removed later anyway. Error message:

  gosthash2012_ref.h(15,18): warning C4081: expected '('; found 'string'

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Replace tentative arrays with pointers
Vitaly Chikunov [Fri, 3 Dec 2021 09:14:53 +0000 (12:14 +0300)]
MSVC: Replace tentative arrays with pointers

Error message example:

  gost_prov_cipher.c(237,63): error C2059: syntax error: '}'

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Fix unresolved externals (cipher_gost_grasshopper_ctracpkm)
Vitaly Chikunov [Fri, 3 Dec 2021 09:10:33 +0000 (12:10 +0300)]
MSVC: Fix unresolved externals (cipher_gost_grasshopper_ctracpkm)

Un-inline `cipher_gost_grasshopper_ctracpkm'. Error message:

  gost_core.lib(gost_omac_acpkm.obj) : error LNK2019: unresolved external symbol cipher_gost_grasshopper_ctracpkm referenced in function CMAC_ACPKM_Init
  gost.dll : fatal error LNK1120: 1 unresolved externals

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Fix Elvis operator
Vitaly Chikunov [Fri, 3 Dec 2021 09:06:25 +0000 (12:06 +0300)]
MSVC: Fix Elvis operator

Error example:

  gost_md.c(54,45): error C2059: syntax error: ':'
  gost_md.c(67,5): error C2059: syntax error: 'if'
  gost_md.c(69,6): error C2143: syntax error: missing '{' before '->'
  gost_md.c(69,6): error C2059: syntax error: '->'
  gost_md.c(70,5): error C2059: syntax error: 'return'
  gost_md.c(71,1): error C2059: syntax error: '}'

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Fix unreachable code warning
Vitaly Chikunov [Fri, 3 Dec 2021 09:04:06 +0000 (12:04 +0300)]
MSVC: Fix unreachable code warning

Errors are like this:

  gost_pmeth.c(188): warning C4702: unreachable code
  gost_grasshopper_cipher.c(909): warning C4702: unreachable code

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Fix signedness in comparison
Vitaly Chikunov [Fri, 3 Dec 2021 09:02:32 +0000 (12:02 +0300)]
MSVC: Fix signedness in comparison

Error message:

  gost_crypt.c(652,36): warning C4018: '<': signed/unsigned mismatch

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Undo adding `-Wno-error=deprecated-declarations`
Vitaly Chikunov [Fri, 3 Dec 2021 08:54:40 +0000 (11:54 +0300)]
MSVC: Undo adding `-Wno-error=deprecated-declarations`

Since they are now global. Error message:

  cl : command line error D8021: invalid numeric argument '/Wno-error=deprecated-declarations'

Fixes: 5dfb598 ("CMakeLists.txt: Workaround openssl deprecation of HMAC and CMAC primitives")
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoMSVC: Disable deprecated declarations (C4996) warning
Vitaly Chikunov [Fri, 3 Dec 2021 08:53:17 +0000 (11:53 +0300)]
MSVC: Disable deprecated declarations (C4996) warning

`/wd4996' disables deprecated declarations warning, this is analogous to
`-Wno-error=deprecated-declarations'. Error example:

  gost_pmeth.c(39,17): warning C4996: 'EVP_PKEY_get0': Since OpenSSL 3.0

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoCI: Build and test on Windows (MSVC)
Vitaly Chikunov [Thu, 2 Dec 2021 00:38:27 +0000 (03:38 +0300)]
CI: Build and test on Windows (MSVC)

Uses actions/cache to speed up engine rebuilds.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
3 years agoAdd .editorconfig
Vitaly Chikunov [Wed, 1 Dec 2021 03:07:08 +0000 (06:07 +0300)]
Add .editorconfig

Noticed that there is some misindentation (also fix it).

3 years agoUse frpintf(stderr, ...) instead of printf(...)
Anton Fadeev [Thu, 25 Nov 2021 17:31:03 +0000 (20:31 +0300)]
Use frpintf(stderr, ...) instead of printf(...)

When we use git cli in OS Linux, with enabled gost engine
git utility we got fatal erro

3 years agoProperly set expected digest size for mac in provider
Dmitry Belyavskiy [Sun, 14 Nov 2021 10:46:20 +0000 (11:46 +0100)]
Properly set expected digest size for mac in provider

3 years agoDocument the current state of the GOST provider
Richard Levitte [Mon, 11 Oct 2021 13:10:45 +0000 (15:10 +0200)]
Document the current state of the GOST provider

3 years agolibprov: update to latest
Richard Levitte [Mon, 30 Aug 2021 11:44:22 +0000 (13:44 +0200)]
libprov: update to latest

3 years agoMaking a gost provider - installation instructions
Richard Levitte [Sat, 13 Feb 2021 14:01:02 +0000 (15:01 +0100)]
Making a gost provider - installation instructions

3 years agoMaking a gost provider - Adapt test_context.c for providers
Richard Levitte [Wed, 12 May 2021 11:44:05 +0000 (13:44 +0200)]
Making a gost provider - Adapt test_context.c for providers

3 years agoMaking a gost provider - Adapt test_ciphers.c for providers
Richard Levitte [Wed, 12 May 2021 11:36:15 +0000 (13:36 +0200)]
Making a gost provider - Adapt test_ciphers.c for providers

3 years agoMaking a gost provider - Adapt test_digest.c for providers
Richard Levitte [Tue, 11 May 2021 08:09:10 +0000 (10:09 +0200)]
Making a gost provider - Adapt test_digest.c for providers

3 years agoMaking a gost provider - Adapt the grasshopper OMACs for providers
Richard Levitte [Tue, 11 May 2021 07:39:30 +0000 (09:39 +0200)]
Making a gost provider - Adapt the grasshopper OMACs for providers

They needed to be modified to handled EVP_CIPHERs implemented by a
provider.

3 years agoMaking a gost provider - Add the macs
Richard Levitte [Mon, 5 Apr 2021 06:08:10 +0000 (08:08 +0200)]
Making a gost provider - Add the macs

We add the macs for the provider as wrappers around the EVP_MD
implementations designed for ENGINEs.  This is not the most elegant,
but it does the job.

When an algorithm has an OID, it's included in the OSSL_ALGORITHM name
as an alias.  This is the way to avoid having to register the OIDs in
OpenSSL proper.

3 years agoMaking a gost provider - Add the digests
Richard Levitte [Sat, 13 Feb 2021 13:56:17 +0000 (14:56 +0100)]
Making a gost provider - Add the digests

We add the digests for the provider as wrappers around the routines
designed for ENGINEs.  This is not the most elegant, but it does the
job.

When an algorithm has an OID, it's included in the OSSL_ALGORITHM name
as an aliase.  This is the way to avoid having to register the OIDs in
OpenSSL proper.

test/01-digest.t is modified to test the provider as well.

3 years agoMaking a gost provider - Add the ciphers
Richard Levitte [Sat, 13 Feb 2021 13:52:39 +0000 (14:52 +0100)]
Making a gost provider - Add the ciphers

We add the ciphers for the provider as wrappers around the routines
designed for ENGINEs.  This is not the most elegant, but it does the
job.

When an algorithm has an OID, it's included in the OSSL_ALGORITHM name
as an aliase.  This is the way to avoid having to register the OIDs in
OpenSSL proper.

test/03-encrypt.t is modified to test the provider as well.

3 years agoMaking a gost provider - Refactor the testing foundation
Richard Levitte [Mon, 10 May 2021 07:06:04 +0000 (09:06 +0200)]
Making a gost provider - Refactor the testing foundation

This makes space for provider tests.

As a beginning, test/00-provider.t is added.  It corresponds to
test/00-engine.t.

All other test/*.t are currently skipped unless the engine is tested.
They will be re-enabled as support for each algorithm type is added in
the provider code.

3 years agoMaking a gost provider - Add the provider foundation
Richard Levitte [Sat, 13 Feb 2021 13:50:49 +0000 (14:50 +0100)]
Making a gost provider - Add the provider foundation

This adds the source to get a minimal provider that provides...
nothing.