Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ if [ "${PATCH_OPENSSL}" == "1" ]; then
git apply patches/openssl-tls1.3.patch
git apply patches/openssl-asn1_item_verify_ctx.patch
git apply patches/openssl-x509_sig_info_init.patch
git apply patches/openssl-aes_cfb128_vaes_x64.patch
fi

# pkcs12 RFC 9337/9548 libcrypto fallbacks (see patches/pkcs12/README.md).
Expand Down
31 changes: 16 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: CI
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 2 * * 0'

Expand Down Expand Up @@ -156,21 +157,21 @@ jobs:
- run: .github/before_script.sh
- run: .github/script.sh

# gcc-openssl-3-6-0-x86:
# runs-on: ubuntu-latest
# if: ${{ github.event_name == 'schedule' }}
# env:
# CFLAGS: -m32
# LDFLAGS: -m32
# SETARCH: "setarch i386"
# APT_INSTALL: gcc-multilib
# PATCH_OPENSSL: 1
# steps:
# - uses: actions/checkout@v2
# with:
# submodules: true
# - run: .github/before_script.sh
# - run: .github/script.sh
gcc-openssl-3-6-0-x86:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
env:
CFLAGS: -m32
LDFLAGS: -m32
SETARCH: "setarch i386"
APT_INSTALL: gcc-multilib
PATCH_OPENSSL: 1
steps:
- uses: actions/checkout@v2
with:
submodules: true
- run: .github/before_script.sh
- run: .github/script.sh

gcc-openssl-4-0-0-x86:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion cmake/tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ if (NOT MSVC)
${CMAKE_CURRENT_SOURCE_DIR}/test/engine.cnf
${CMAKE_CURRENT_SOURCE_DIR}/test/provider.cnf)
set_tests_properties(test_pkcs12_rfc9337_cross_mode
PROPERTIES ENVIRONMENT "${TEST_ENVIRONMENT_COMMON}")
PROPERTIES ENVIRONMENT "${TEST_ENVIRONMENT_ENGINE}")
endif()

if (GOST_BUILD_ENGINE)
Expand Down
202 changes: 202 additions & 0 deletions patches/openssl-aes_cfb128_vaes_x64.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
diff --git a/openssl/providers/implementations/ciphers/cipher_aes_cfb_hw_aesni.inc b/openssl/providers/implementations/ciphers/cipher_aes_cfb_hw_aesni.inc
index d5577d0..0f67919 100644
--- a/openssl/providers/implementations/ciphers/cipher_aes_cfb_hw_aesni.inc
+++ b/openssl/providers/implementations/ciphers/cipher_aes_cfb_hw_aesni.inc
@@ -1,99 +1,98 @@
-/*
- * Copyright 2001-2025 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-/*-
- * AES-NI and VAES support for AES CFB mode.
- * This file is included by cipher_aes_cfb_hw.c
- */
-
-#if (defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64))
- #define cipher_hw_vaes_cfb128 aes_cfb128_vaes_encdec_wrapper
-#else
- #define cipher_hw_vaes_cfb128 ossl_cipher_hw_generic_cfb128
- int ossl_aes_cfb128_vaes_eligible() {
- return 0;
- }
-#endif
-#define cipher_hw_vaes_cfb8 ossl_cipher_hw_generic_cfb8
-#define cipher_hw_vaes_cfb1 ossl_cipher_hw_generic_cfb1
-
-#define cipher_hw_aesni_cfb128 ossl_cipher_hw_generic_cfb128
-#define cipher_hw_aesni_cfb8 ossl_cipher_hw_generic_cfb8
-#define cipher_hw_aesni_cfb1 ossl_cipher_hw_generic_cfb1
-
-static int ossl_aes_cfb8_vaes_eligible(void) { return 0; }
-static int ossl_aes_cfb1_vaes_eligible(void) { return 0; }
-
-/* active in 64-bit builds when AES-NI, AVX512F, and VAES are detected */
-static int aes_cfb128_vaes_encdec_wrapper(
- PROV_CIPHER_CTX* dat,
- unsigned char *out,
- const unsigned char *in,
- size_t len)
-{
- ossl_ssize_t num;
-
- num = (ossl_ssize_t)dat->num;
-
- if (num < 0) {
- /* behavior from CRYPTO_cfb128_encrypt */
- dat->num = -1;
- return 1;
- }
-
- if (dat->enc)
- ossl_aes_cfb128_vaes_enc(in, out, len, dat->ks, dat->iv, &num);
- else
- ossl_aes_cfb128_vaes_dec(in, out, len, dat->ks, dat->iv, &num);
-
- dat->num = (int)num;
-
- return 1;
-}
-
-/* generates AES round keys for AES-NI and VAES implementations */
-static int cipher_hw_aesni_initkey(PROV_CIPHER_CTX *dat,
- const unsigned char *key, size_t keylen)
-{
- int ret;
- PROV_AES_CTX *adat = (PROV_AES_CTX *)dat;
- AES_KEY *ks = &adat->ks.ks;
-
- dat->ks = ks;
-
- ret = aesni_set_encrypt_key(key, (int)(keylen * 8), ks);
-
- dat->block = (block128_f) aesni_encrypt;
- dat->stream.cbc = NULL;
-
- if (ret < 0) {
- ERR_raise(ERR_LIB_PROV, PROV_R_KEY_SETUP_FAILED);
- return 0;
- }
-
- return 1;
-}
-
-#define PROV_CIPHER_HW_declare(mode) \
-static const PROV_CIPHER_HW aesni_##mode = { \
- cipher_hw_aesni_initkey, \
- cipher_hw_aesni_##mode, \
- cipher_hw_aes_copyctx \
-}; \
-static const PROV_CIPHER_HW vaes_##mode = { \
- cipher_hw_aesni_initkey, \
- cipher_hw_vaes_##mode, \
- cipher_hw_aes_copyctx \
-};
-#define PROV_CIPHER_HW_select(mode) \
-if (AESNI_CAPABLE) { \
- if (ossl_aes_##mode##_vaes_eligible()) \
- return &vaes_##mode; \
- return &aesni_##mode; \
-}
+/*
+ * Copyright 2001-2025 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/*-
+ * AES-NI and VAES support for AES CFB mode.
+ * This file is included by cipher_aes_cfb_hw.c
+ */
+
+#if (defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64))
+ #define cipher_hw_vaes_cfb128 aes_cfb128_vaes_encdec_wrapper
+ /* active in 64-bit builds when AES-NI, AVX512F, and VAES are detected */
+ static int aes_cfb128_vaes_encdec_wrapper(
+ PROV_CIPHER_CTX* dat,
+ unsigned char *out,
+ const unsigned char *in,
+ size_t len)
+ {
+ ossl_ssize_t num;
+
+ num = (ossl_ssize_t)dat->num;
+
+ if (num < 0) {
+ /* behavior from CRYPTO_cfb128_encrypt */
+ dat->num = -1;
+ return 1;
+ }
+
+ if (dat->enc)
+ ossl_aes_cfb128_vaes_enc(in, out, len, dat->ks, dat->iv, &num);
+ else
+ ossl_aes_cfb128_vaes_dec(in, out, len, dat->ks, dat->iv, &num);
+
+ dat->num = (int)num;
+
+ return 1;
+ }
+#else
+ #define cipher_hw_vaes_cfb128 ossl_cipher_hw_generic_cfb128
+ int ossl_aes_cfb128_vaes_eligible() {
+ return 0;
+ }
+#endif
+#define cipher_hw_vaes_cfb8 ossl_cipher_hw_generic_cfb8
+#define cipher_hw_vaes_cfb1 ossl_cipher_hw_generic_cfb1
+
+#define cipher_hw_aesni_cfb128 ossl_cipher_hw_generic_cfb128
+#define cipher_hw_aesni_cfb8 ossl_cipher_hw_generic_cfb8
+#define cipher_hw_aesni_cfb1 ossl_cipher_hw_generic_cfb1
+
+static int ossl_aes_cfb8_vaes_eligible(void) { return 0; }
+static int ossl_aes_cfb1_vaes_eligible(void) { return 0; }
+
+/* generates AES round keys for AES-NI and VAES implementations */
+static int cipher_hw_aesni_initkey(PROV_CIPHER_CTX *dat,
+ const unsigned char *key, size_t keylen)
+{
+ int ret;
+ PROV_AES_CTX *adat = (PROV_AES_CTX *)dat;
+ AES_KEY *ks = &adat->ks.ks;
+
+ dat->ks = ks;
+
+ ret = aesni_set_encrypt_key(key, (int)(keylen * 8), ks);
+
+ dat->block = (block128_f) aesni_encrypt;
+ dat->stream.cbc = NULL;
+
+ if (ret < 0) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_KEY_SETUP_FAILED);
+ return 0;
+ }
+
+ return 1;
+}
+
+#define PROV_CIPHER_HW_declare(mode) \
+static const PROV_CIPHER_HW aesni_##mode = { \
+ cipher_hw_aesni_initkey, \
+ cipher_hw_aesni_##mode, \
+ cipher_hw_aes_copyctx \
+}; \
+static const PROV_CIPHER_HW vaes_##mode = { \
+ cipher_hw_aesni_initkey, \
+ cipher_hw_vaes_##mode, \
+ cipher_hw_aes_copyctx \
+};
+#define PROV_CIPHER_HW_select(mode) \
+if (AESNI_CAPABLE) { \
+ if (ossl_aes_##mode##_vaes_eligible()) \
+ return &vaes_##mode; \
+ return &aesni_##mode; \
+}
Loading