public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/8] CryptoPkg updates for openssl 3.0
@ 2022-01-17 10:52 Gerd Hoffmann
  2022-01-17 10:52 ` [PATCH 1/8] CryptoPkg/CrtLibSupport: add fcntl.h Gerd Hoffmann
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-01-17 10:52 UTC (permalink / raw)
  To: devel
  Cc: Xiaoyu Lu, Pawel Polawski, Guomin Jiang, Jiewen Yao, Jian J Wang,
	Gerd Hoffmann

First batch of patches which update CrtLibSupport so it has everything
needed to build openssl3.  Also a testcase update for openssl3.

This does not update the openssl submodule, that'll happen in a
followup patch series.

Gerd Hoffmann (8):
  CryptoPkg/CrtLibSupport: add fcntl.h
  CryptoPkg/CrtLibSupport: add strstr()
  CryptoPkg/CrtLibSupport: add INT_MIN
  CryptoPkg/CrtLibSupport: add UINT_MAX
  CryptoPkg/CrtLibSupport: add MODULESDIR
  CryptoPkg/CrtLibSupport: add off_t
  CryptoPkg/CrtLibSupport: fix strcpy
  CryptoPkg/UnitTest: fix DH testcase

 CryptoPkg/Library/Include/CrtLibSupport.h        | 16 +++++++++++++++-
 CryptoPkg/Library/Include/fcntl.h                |  9 +++++++++
 .../Test/UnitTest/Library/BaseCryptLib/DhTests.c |  6 +++---
 3 files changed, 27 insertions(+), 4 deletions(-)
 create mode 100644 CryptoPkg/Library/Include/fcntl.h

-- 
2.34.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/8] CryptoPkg/CrtLibSupport: add fcntl.h
  2022-01-17 10:52 [PATCH 0/8] CryptoPkg updates for openssl 3.0 Gerd Hoffmann
@ 2022-01-17 10:52 ` Gerd Hoffmann
  2022-01-17 11:07   ` Gerd Hoffmann
  2022-01-17 10:52 ` [PATCH 2/8] CryptoPkg/CrtLibSupport: add strstr() Gerd Hoffmann
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 10+ messages in thread
From: Gerd Hoffmann @ 2022-01-17 10:52 UTC (permalink / raw)
  To: devel
  Cc: Xiaoyu Lu, Pawel Polawski, Guomin Jiang, Jiewen Yao, Jian J Wang,
	Gerd Hoffmann

Add fcntl.h header file.
Will be needed by openssl 3.0.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 CryptoPkg/Library/Include/fcntl.h | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 CryptoPkg/Library/Include/fcntl.h

diff --git a/CryptoPkg/Library/Include/fcntl.h b/CryptoPkg/Library/Include/fcntl.h
new file mode 100644
index 000000000000..040ecfa5193d
--- /dev/null
+++ b/CryptoPkg/Library/Include/fcntl.h
@@ -0,0 +1,9 @@
+/** @file
+  Include file to support building the third-party cryptographic library.
+
+Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <CrtLibSupport.h>
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/8] CryptoPkg/CrtLibSupport: add strstr()
  2022-01-17 10:52 [PATCH 0/8] CryptoPkg updates for openssl 3.0 Gerd Hoffmann
  2022-01-17 10:52 ` [PATCH 1/8] CryptoPkg/CrtLibSupport: add fcntl.h Gerd Hoffmann
@ 2022-01-17 10:52 ` Gerd Hoffmann
  2022-01-17 10:52 ` [PATCH 3/8] CryptoPkg/CrtLibSupport: add INT_MIN Gerd Hoffmann
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-01-17 10:52 UTC (permalink / raw)
  To: devel
  Cc: Xiaoyu Lu, Pawel Polawski, Guomin Jiang, Jiewen Yao, Jian J Wang,
	Gerd Hoffmann

Add #define for strstr().
Will be needed by openssl 3.0.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 CryptoPkg/Library/Include/CrtLibSupport.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h b/CryptoPkg/Library/Include/CrtLibSupport.h
index d257dca8fa9b..8907f1f13788 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -405,6 +405,7 @@ inet_pton   (
 #define strcat(strDest, strSource)          AsciiStrCatS(strDest,MAX_STRING_SIZE,strSource)
 #define strncmp(string1, string2, count)    (int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))
 #define strcasecmp(str1, str2)              (int)AsciiStriCmp(str1,str2)
+#define strstr(s1, s2)                      AsciiStrStr(s1,s2)
 #define sprintf(buf, ...)                   AsciiSPrint(buf,MAX_STRING_SIZE,__VA_ARGS__)
 #define localtime(timer)                    NULL
 #define assert(expression)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/8] CryptoPkg/CrtLibSupport: add INT_MIN
  2022-01-17 10:52 [PATCH 0/8] CryptoPkg updates for openssl 3.0 Gerd Hoffmann
  2022-01-17 10:52 ` [PATCH 1/8] CryptoPkg/CrtLibSupport: add fcntl.h Gerd Hoffmann
  2022-01-17 10:52 ` [PATCH 2/8] CryptoPkg/CrtLibSupport: add strstr() Gerd Hoffmann
@ 2022-01-17 10:52 ` Gerd Hoffmann
  2022-01-17 10:52 ` [PATCH 4/8] CryptoPkg/CrtLibSupport: add UINT_MAX Gerd Hoffmann
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-01-17 10:52 UTC (permalink / raw)
  To: devel
  Cc: Xiaoyu Lu, Pawel Polawski, Guomin Jiang, Jiewen Yao, Jian J Wang,
	Gerd Hoffmann

Add #define for INT_MIN.
Will be needed by openssl 3.0.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 CryptoPkg/Library/Include/CrtLibSupport.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h b/CryptoPkg/Library/Include/CrtLibSupport.h
index 8907f1f13788..c1f4e0187693 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -79,6 +79,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define EINVAL        22              /* Invalid argument */
 #define EAFNOSUPPORT  47              /* Address family not supported by protocol family */
 #define INT_MAX       0x7FFFFFFF      /* Maximum (signed) int value */
+#define INT_MIN       (-INT_MAX-1)    /* Minimum (signed) int value */
 #define LONG_MAX      0X7FFFFFFFL     /* max value for a long */
 #define LONG_MIN      (-LONG_MAX-1)   /* min value for a long */
 #define ULONG_MAX     0xFFFFFFFF      /* Maximum unsigned long value */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/8] CryptoPkg/CrtLibSupport: add UINT_MAX
  2022-01-17 10:52 [PATCH 0/8] CryptoPkg updates for openssl 3.0 Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2022-01-17 10:52 ` [PATCH 3/8] CryptoPkg/CrtLibSupport: add INT_MIN Gerd Hoffmann
@ 2022-01-17 10:52 ` Gerd Hoffmann
  2022-01-17 10:52 ` [PATCH 5/8] CryptoPkg/CrtLibSupport: add MODULESDIR Gerd Hoffmann
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-01-17 10:52 UTC (permalink / raw)
  To: devel
  Cc: Xiaoyu Lu, Pawel Polawski, Guomin Jiang, Jiewen Yao, Jian J Wang,
	Gerd Hoffmann

Add define for UINT_MAX.
Will be needed by openssl 3.0.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 CryptoPkg/Library/Include/CrtLibSupport.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h b/CryptoPkg/Library/Include/CrtLibSupport.h
index c1f4e0187693..45db46cf8bee 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -82,6 +82,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define INT_MIN       (-INT_MAX-1)    /* Minimum (signed) int value */
 #define LONG_MAX      0X7FFFFFFFL     /* max value for a long */
 #define LONG_MIN      (-LONG_MAX-1)   /* min value for a long */
+#define UINT_MAX      0xFFFFFFFF      /* Maximum unsigned int value */
 #define ULONG_MAX     0xFFFFFFFF      /* Maximum unsigned long value */
 #define CHAR_BIT      8               /* Number of bits in a char */
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/8] CryptoPkg/CrtLibSupport: add MODULESDIR
  2022-01-17 10:52 [PATCH 0/8] CryptoPkg updates for openssl 3.0 Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2022-01-17 10:52 ` [PATCH 4/8] CryptoPkg/CrtLibSupport: add UINT_MAX Gerd Hoffmann
@ 2022-01-17 10:52 ` Gerd Hoffmann
  2022-01-17 10:52 ` [PATCH 6/8] CryptoPkg/CrtLibSupport: add off_t Gerd Hoffmann
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-01-17 10:52 UTC (permalink / raw)
  To: devel
  Cc: Xiaoyu Lu, Pawel Polawski, Guomin Jiang, Jiewen Yao, Jian J Wang,
	Gerd Hoffmann

Add dummy MODULESDIR #define
Will be needed by openssl 3.0.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 CryptoPkg/Library/Include/CrtLibSupport.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h b/CryptoPkg/Library/Include/CrtLibSupport.h
index 45db46cf8bee..aff9daaee809 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -18,6 +18,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #define OPENSSLDIR  ""
 #define ENGINESDIR  ""
+#define MODULESDIR  ""
 
 #define MAX_STRING_SIZE  0x1000
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/8] CryptoPkg/CrtLibSupport: add off_t
  2022-01-17 10:52 [PATCH 0/8] CryptoPkg updates for openssl 3.0 Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2022-01-17 10:52 ` [PATCH 5/8] CryptoPkg/CrtLibSupport: add MODULESDIR Gerd Hoffmann
@ 2022-01-17 10:52 ` Gerd Hoffmann
  2022-01-17 10:52 ` [PATCH 7/8] CryptoPkg/CrtLibSupport: fix strcpy Gerd Hoffmann
  2022-01-17 10:52 ` [PATCH 8/8] CryptoPkg/UnitTest: fix DH testcase Gerd Hoffmann
  7 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-01-17 10:52 UTC (permalink / raw)
  To: devel
  Cc: Xiaoyu Lu, Pawel Polawski, Guomin Jiang, Jiewen Yao, Jian J Wang,
	Gerd Hoffmann

Add typedef for off_t.
Will be needed by openssl 3.0.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 CryptoPkg/Library/Include/CrtLibSupport.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h b/CryptoPkg/Library/Include/CrtLibSupport.h
index aff9daaee809..fd8e8e1a938b 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -104,6 +104,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 // Basic types mapping
 //
 typedef UINTN   size_t;
+typedef UINTN   off_t;
 typedef UINTN   u_int;
 typedef INTN    ptrdiff_t;
 typedef INTN    ssize_t;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/8] CryptoPkg/CrtLibSupport: fix strcpy
  2022-01-17 10:52 [PATCH 0/8] CryptoPkg updates for openssl 3.0 Gerd Hoffmann
                   ` (5 preceding siblings ...)
  2022-01-17 10:52 ` [PATCH 6/8] CryptoPkg/CrtLibSupport: add off_t Gerd Hoffmann
@ 2022-01-17 10:52 ` Gerd Hoffmann
  2022-01-17 10:52 ` [PATCH 8/8] CryptoPkg/UnitTest: fix DH testcase Gerd Hoffmann
  7 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-01-17 10:52 UTC (permalink / raw)
  To: devel
  Cc: Xiaoyu Lu, Pawel Polawski, Guomin Jiang, Jiewen Yao, Jian J Wang,
	Gerd Hoffmann

strcpy() returns a pointer to the destination string, AsciiStrCpyS()
does not.  So a simple #define does not work.  Create a inline function
instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 CryptoPkg/Library/Include/CrtLibSupport.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h b/CryptoPkg/Library/Include/CrtLibSupport.h
index fd8e8e1a938b..981ed3097b24 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -395,6 +395,16 @@ inet_pton   (
   void *
   );
 
+static inline char *
+strcpy (
+  char *restrict  strDest,
+  const char      *strSource
+  )
+{
+  AsciiStrCpyS (strDest, MAX_STRING_SIZE, strSource);
+  return strDest;
+}
+
 //
 // Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
 //
@@ -404,7 +414,6 @@ inet_pton   (
 #define memcmp(buf1, buf2, count)           (int)(CompareMem(buf1,buf2,(UINTN)(count)))
 #define memmove(dest, source, count)        CopyMem(dest,source,(UINTN)(count))
 #define strlen(str)                         (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE))
-#define strcpy(strDest, strSource)          AsciiStrCpyS(strDest,MAX_STRING_SIZE,strSource)
 #define strncpy(strDest, strSource, count)  AsciiStrnCpyS(strDest,MAX_STRING_SIZE,strSource,(UINTN)count)
 #define strcat(strDest, strSource)          AsciiStrCatS(strDest,MAX_STRING_SIZE,strSource)
 #define strncmp(string1, string2, count)    (int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 8/8] CryptoPkg/UnitTest: fix DH testcase
  2022-01-17 10:52 [PATCH 0/8] CryptoPkg updates for openssl 3.0 Gerd Hoffmann
                   ` (6 preceding siblings ...)
  2022-01-17 10:52 ` [PATCH 7/8] CryptoPkg/CrtLibSupport: fix strcpy Gerd Hoffmann
@ 2022-01-17 10:52 ` Gerd Hoffmann
  7 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-01-17 10:52 UTC (permalink / raw)
  To: devel
  Cc: Xiaoyu Lu, Pawel Polawski, Guomin Jiang, Jiewen Yao, Jian J Wang,
	Gerd Hoffmann

openssl 3.0 wants at least 512 bytes, otherwise it throws an error:

error:0280007E:Diffie-Hellman routines::modulus too small

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/DhTests.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/DhTests.c b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/DhTests.c
index 5cfe8d70535b..29e892a1514c 100644
--- a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/DhTests.c
+++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/DhTests.c
@@ -53,7 +53,7 @@ TestVerifyDhGenerateKey (
   UNIT_TEST_CONTEXT  Context
   )
 {
-  UINT8    Prime[64];
+  UINT8    Prime[512];
   UINT8    PublicKey1[64];
   UINTN    PublicKey1Length;
   UINT8    PublicKey2[64];
@@ -72,10 +72,10 @@ TestVerifyDhGenerateKey (
   Key1Length       = sizeof (Key1);
   Key2Length       = sizeof (Key2);
 
-  Status = DhGenerateParameter (mDh1, 2, 64, Prime);
+  Status = DhGenerateParameter (mDh1, 2, sizeof (Prime), Prime);
   UT_ASSERT_TRUE (Status);
 
-  Status = DhSetParameter (mDh2, 2, 64, Prime);
+  Status = DhSetParameter (mDh2, 2, sizeof (Prime), Prime);
   UT_ASSERT_TRUE (Status);
 
   Status = DhGenerateKey (mDh1, PublicKey1, &PublicKey1Length);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/8] CryptoPkg/CrtLibSupport: add fcntl.h
  2022-01-17 10:52 ` [PATCH 1/8] CryptoPkg/CrtLibSupport: add fcntl.h Gerd Hoffmann
@ 2022-01-17 11:07   ` Gerd Hoffmann
  0 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-01-17 11:07 UTC (permalink / raw)
  To: devel; +Cc: Xiaoyu Lu, Pawel Polawski, Guomin Jiang, Jiewen Yao, Jian J Wang

On Mon, Jan 17, 2022 at 11:52:27AM +0100, Gerd Hoffmann wrote:
> Add fcntl.h header file.
> Will be needed by openssl 3.0.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  CryptoPkg/Library/Include/fcntl.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
>  create mode 100644 CryptoPkg/Library/Include/fcntl.h
> 
> diff --git a/CryptoPkg/Library/Include/fcntl.h b/CryptoPkg/Library/Include/fcntl.h
> new file mode 100644
> index 000000000000..040ecfa5193d
> --- /dev/null
> +++ b/CryptoPkg/Library/Include/fcntl.h
> @@ -0,0 +1,9 @@
> +/** @file
> +  Include file to support building the third-party cryptographic library.
> +
> +Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <CrtLibSupport.h>

Hmm, CI throws codestyle errors (see below) on this one even though it
looks identical to the stdio.h next to it.  Apparently stdio.h is
whitelisted somewhere but I can't find the place ...

Hints anyone?

thanks,
  Gerd

------------------- cut here -----------------
ERROR - 
ERROR - EFI coding style error
ERROR - *Error code: 6001
ERROR - *All include file contents should be guarded by a #ifndef statement.
ERROR - *file: //home/vsts/work/1/s/Build/.pytool/Plugin/EccCheck/CryptoPkg/Library/Include/fcntl.h
ERROR - *Line number: 1
ERROR - *
ERROR - 
ERROR - EFI coding style error
ERROR - *Error code: 8004
ERROR - *Path name does not follow the rules: 1. First character should be upper case 2. Must contain lower case characters 3. No white space characters
ERROR - *file: //home/vsts/work/1/s/Build/.pytool/Plugin/EccCheck/CryptoPkg/Library/Include/fcntl.h
ERROR - *Line number: 1
ERROR - *The file path [fcntl.h] does not follow the rules
ERROR - 


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-01-17 11:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-17 10:52 [PATCH 0/8] CryptoPkg updates for openssl 3.0 Gerd Hoffmann
2022-01-17 10:52 ` [PATCH 1/8] CryptoPkg/CrtLibSupport: add fcntl.h Gerd Hoffmann
2022-01-17 11:07   ` Gerd Hoffmann
2022-01-17 10:52 ` [PATCH 2/8] CryptoPkg/CrtLibSupport: add strstr() Gerd Hoffmann
2022-01-17 10:52 ` [PATCH 3/8] CryptoPkg/CrtLibSupport: add INT_MIN Gerd Hoffmann
2022-01-17 10:52 ` [PATCH 4/8] CryptoPkg/CrtLibSupport: add UINT_MAX Gerd Hoffmann
2022-01-17 10:52 ` [PATCH 5/8] CryptoPkg/CrtLibSupport: add MODULESDIR Gerd Hoffmann
2022-01-17 10:52 ` [PATCH 6/8] CryptoPkg/CrtLibSupport: add off_t Gerd Hoffmann
2022-01-17 10:52 ` [PATCH 7/8] CryptoPkg/CrtLibSupport: fix strcpy Gerd Hoffmann
2022-01-17 10:52 ` [PATCH 8/8] CryptoPkg/UnitTest: fix DH testcase Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox