tools/squashfskit4: drop unused tool
[openwrt/staging/jow.git] / package / libs / openssl / patches / 430-e_devcrypto-make-the-dev-crypto-engine-dynamic.patch
index b6d274ad1264f333f505495ecf0a92bcd171e2ee..00c74972ab86fc33d2c1dc21893078e96b85677e 100644 (file)
@@ -1,7 +1,7 @@
-From 37a5c14aad5051201e4bd18faf1a4b25a824cc30 Mon Sep 17 00:00:00 2001
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: Eneas U de Queiroz <cote2004-github@yahoo.com>
 Date: Tue, 6 Nov 2018 10:57:03 -0200
-Subject: [PATCH 4/4] e_devcrypto: make the /dev/crypto engine dynamic
+Subject: e_devcrypto: make the /dev/crypto engine dynamic
 
 Engine has been moved from crypto/engine/eng_devcrypto.c to
 engines/e_devcrypto.c.
@@ -19,7 +19,7 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
 -ENDIF
 --- a/crypto/init.c
 +++ b/crypto/init.c
-@@ -330,18 +330,6 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_engine_
+@@ -328,18 +328,6 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_engine_
      engine_load_openssl_int();
      return 1;
  }
@@ -38,7 +38,7 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
  
  # ifndef OPENSSL_NO_RDRAND
  static CRYPTO_ONCE engine_rdrand = CRYPTO_ONCE_STATIC_INIT;
-@@ -366,6 +354,18 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_engine_
+@@ -364,6 +352,18 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_engine_
      return 1;
  }
  # ifndef OPENSSL_NO_STATIC_ENGINE
@@ -57,7 +57,7 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
  #  if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_PADLOCK)
  static CRYPTO_ONCE engine_padlock = CRYPTO_ONCE_STATIC_INIT;
  DEFINE_RUN_ONCE_STATIC(ossl_init_engine_padlock)
-@@ -714,11 +714,6 @@ int OPENSSL_init_crypto(uint64_t opts, c
+@@ -704,11 +704,6 @@ int OPENSSL_init_crypto(uint64_t opts, c
      if ((opts & OPENSSL_INIT_ENGINE_OPENSSL)
              && !RUN_ONCE(&engine_openssl, ossl_init_engine_openssl))
          return 0;
@@ -69,7 +69,7 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
  # ifndef OPENSSL_NO_RDRAND
      if ((opts & OPENSSL_INIT_ENGINE_RDRAND)
              && !RUN_ONCE(&engine_rdrand, ossl_init_engine_rdrand))
-@@ -728,6 +723,11 @@ int OPENSSL_init_crypto(uint64_t opts, c
+@@ -718,6 +713,11 @@ int OPENSSL_init_crypto(uint64_t opts, c
              && !RUN_ONCE(&engine_dynamic, ossl_init_engine_dynamic))
          return 0;
  # ifndef OPENSSL_NO_STATIC_ENGINE
@@ -83,7 +83,7 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
              && !RUN_ONCE(&engine_padlock, ossl_init_engine_padlock))
 --- a/engines/build.info
 +++ b/engines/build.info
-@@ -10,6 +10,9 @@ IF[{- !$disabled{"engine"} -}]
+@@ -11,6 +11,9 @@ IF[{- !$disabled{"engine"} -}]
      IF[{- !$disabled{afalgeng} -}]
        SOURCE[../libcrypto]=e_afalg.c
      ENDIF
@@ -91,9 +91,9 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
 +      SOURCE[../libcrypto]=e_devcrypto.c
 +    ENDIF
    ELSE
-     ENGINES=padlock
-     SOURCE[padlock]=e_padlock.c {- $target{padlock_asm_src} -}
-@@ -27,6 +30,12 @@ IF[{- !$disabled{"engine"} -}]
+     IF[{- !$disabled{hw} && !$disabled{'hw-padlock'} -}]
+       ENGINES=padlock
+@@ -30,6 +33,12 @@ IF[{- !$disabled{"engine"} -}]
        DEPEND[afalg]=../libcrypto
        INCLUDE[afalg]= ../include
      ENDIF
@@ -108,9 +108,9 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
      SOURCE[dasync]=e_dasync.c
 --- a/crypto/engine/eng_devcrypto.c
 +++ /dev/null
-@@ -1,1264 +0,0 @@
+@@ -1,1277 +0,0 @@
 -/*
-- * Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
+- * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
 - *
 - * Licensed under the OpenSSL license (the "License").  You may not use
 - * this file except in compliance with the License.  You can obtain a copy
@@ -134,11 +134,11 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
 -#include <openssl/objects.h>
 -#include <crypto/cryptodev.h>
 -
--#include "internal/engine.h"
+-#include "crypto/engine.h"
 -
 -/* #define ENGINE_DEVCRYPTO_DEBUG */
 -
--#ifdef CRYPTO_ALGORITHM_MIN
+-#if CRYPTO_ALGORITHM_MIN < CRYPTO_ALGORITHM_MAX
 -# define CHECK_BSD_STYLE_MACROS
 -#endif
 -
@@ -1295,8 +1295,9 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
 -void engine_load_devcrypto_int()
 -{
 -    ENGINE *e = NULL;
+-    int fd;
 -
--    if ((cfd = open("/dev/crypto", O_RDWR, 0)) < 0) {
+-    if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) {
 -#ifndef ENGINE_DEVCRYPTO_DEBUG
 -        if (errno != ENOENT)
 -#endif
@@ -1304,6 +1305,18 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
 -        return;
 -    }
 -
+-#ifdef CRIOGET
+-    if (ioctl(fd, CRIOGET, &cfd) < 0) {
+-        fprintf(stderr, "Could not create crypto fd: %s\n", strerror(errno));
+-        close(fd);
+-        cfd = -1;
+-        return;
+-    }
+-    close(fd);
+-#else
+-    cfd = fd;
+-#endif
+-
 -    if ((e = ENGINE_new()) == NULL
 -        || !ENGINE_set_destroy_function(e, devcrypto_unload)) {
 -        ENGINE_free(e);
@@ -1375,9 +1388,9 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
 -}
 --- /dev/null
 +++ b/engines/e_devcrypto.c
-@@ -0,0 +1,1315 @@
+@@ -0,0 +1,1327 @@
 +/*
-+ * Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
++ * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
 + *
 + * Licensed under the OpenSSL license (the "License").  You may not use
 + * this file except in compliance with the License.  You can obtain a copy
@@ -1401,9 +1414,11 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
 +#include <openssl/objects.h>
 +#include <crypto/cryptodev.h>
 +
++#include "crypto/engine.h"
++
 +/* #define ENGINE_DEVCRYPTO_DEBUG */
 +
-+#ifdef CRYPTO_ALGORITHM_MIN
++#if CRYPTO_ALGORITHM_MIN < CRYPTO_ALGORITHM_MAX
 +# define CHECK_BSD_STYLE_MACROS
 +#endif
 +
@@ -1444,10 +1459,6 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
 +    char *driver_name;
 +};
 +
-+#ifdef OPENSSL_NO_DYNAMIC_ENGINE
-+void engine_load_devcrypto_int(void);
-+#endif
-+
 +static int clean_devcrypto_session(struct session_op *sess) {
 +    if (ioctl(cfd, CIOCFSESSION, &sess->ses) < 0) {
 +        SYSerr(SYS_F_IOCTL, errno);
@@ -1723,7 +1734,6 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
 +    struct cipher_ctx *to_cipher_ctx;
 +
 +    switch (type) {
-+
 +    case EVP_CTRL_COPY:
 +        if (cipher_ctx == NULL)
 +            return 1;
@@ -2085,6 +2095,7 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
 +        SYSerr(SYS_F_IOCTL, errno);
 +        return 0;
 +    }
++
 +    return 1;
 +}
 +
@@ -2553,10 +2564,12 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
 + */
 +static int open_devcrypto(void)
 +{
++    int fd;
++
 +    if (cfd >= 0)
 +        return 1;
 +
-+    if ((cfd = open("/dev/crypto", O_RDWR, 0)) < 0) {
++    if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) {
 +#ifndef ENGINE_DEVCRYPTO_DEBUG
 +        if (errno != ENOENT)
 +#endif
@@ -2564,6 +2577,18 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
 +        return 0;
 +    }
 +
++#ifdef CRIOGET
++    if (ioctl(fd, CRIOGET, &cfd) < 0) {
++        fprintf(stderr, "Could not create crypto fd: %s\n", strerror(errno));
++        close(fd);
++        cfd = -1;
++        return 0;
++    }
++    close(fd);
++#else
++    cfd = fd;
++#endif
++
 +    return 1;
 +}
 +