summaryrefslogtreecommitdiffstats
path: root/CryptoPkg/Library/BaseCryptLib/SysCall
diff options
context:
space:
mode:
authorQin Long <qin.long@intel.com>2017-03-23 20:19:39 +0800
committerQin Long <qin.long@intel.com>2017-03-29 16:13:58 +0800
commitfc9fa685d689cad52046bc301fd1bdf7e9fd8843 (patch)
treefda318b8aa816b56f6bb744c41ed85ad3e8f17fd /CryptoPkg/Library/BaseCryptLib/SysCall
parent420e508397c7775667f6935405bbd4accecd232e (diff)
downloadedk2-fc9fa685d689cad52046bc301fd1bdf7e9fd8843.tar.gz
edk2-fc9fa685d689cad52046bc301fd1bdf7e9fd8843.tar.bz2
edk2-fc9fa685d689cad52046bc301fd1bdf7e9fd8843.zip
CryptoPkg: Clean-up CRT Library Wrapper.
Cleaning-up CRT Library Wrapper for the third-party cryptography library building. The changes includes 1. Rename OpenSslSupport.h to CrtLibSupport.h for future alternative crypto provider support. 2. Remove all un-referenced CRT APIs and headers. (NOTE: More cleans-up could be possible after OpenSSL integrate the extra PR request: https://github.com/openssl/openssl/pull/2961) Cc: Ting Ye <ting.ye@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Gary Lin <glin@suse.com> Cc: Ronald Cron <ronald.cron@arm.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.long@intel.com> Reviewed-by: Ting Ye <ting.ye@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Gary Lin <glin@suse.com>
Diffstat (limited to 'CryptoPkg/Library/BaseCryptLib/SysCall')
-rw-r--r--CryptoPkg/Library/BaseCryptLib/SysCall/BaseMemAllocation.c5
-rw-r--r--CryptoPkg/Library/BaseCryptLib/SysCall/ConstantTimeClock.c6
-rw-r--r--CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c185
-rw-r--r--CryptoPkg/Library/BaseCryptLib/SysCall/HelperWrapper.c54
-rw-r--r--CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c3
-rw-r--r--CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c4
6 files changed, 103 insertions, 154 deletions
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/BaseMemAllocation.c b/CryptoPkg/Library/BaseCryptLib/SysCall/BaseMemAllocation.c
index 964545f143..f390e0d449 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/BaseMemAllocation.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/BaseMemAllocation.c
@@ -2,7 +2,7 @@
Base Memory Allocation Routines Wrapper for Crypto library over OpenSSL
during PEI & DXE phases.
-Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -13,7 +13,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-#include <OpenSslSupport.h>
+#include <CrtLibSupport.h>
+#include <Library/MemoryAllocationLib.h>
//
// -- Memory-Allocation Routines --
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/ConstantTimeClock.c b/CryptoPkg/Library/BaseCryptLib/SysCall/ConstantTimeClock.c
index 0a19a69533..7f20164999 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/ConstantTimeClock.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/ConstantTimeClock.c
@@ -12,7 +12,7 @@
5) DhGenerateParameter
6) DhGenerateKey
-Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -23,7 +23,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-#include <OpenSslSupport.h>
+#include <CrtLibSupport.h>
//
// -- Time Management Routines --
@@ -38,4 +38,4 @@ time_t time (time_t *timer)
struct tm * gmtime (const time_t *timer)
{
return NULL;
-} \ No newline at end of file
+}
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
index a2386bc073..20c96563d2 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
@@ -2,7 +2,7 @@
C Run-Time Libraries (CRT) Wrapper Implementation for OpenSSL-based
Cryptographic Library.
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-#include <OpenSslSupport.h>
+#include <CrtLibSupport.h>
int errno = 0;
@@ -136,6 +136,30 @@ char *strrchr (const char *str, int c)
}
}
+/* Compare first n bytes of string s1 with string s2, ignoring case */
+int strncasecmp (const char *s1, const char *s2, size_t n)
+{
+ int Val;
+
+ ASSERT(s1 != NULL);
+ ASSERT(s2 != NULL);
+
+ if (n != 0) {
+ do {
+ Val = tolower(*s1) - tolower(*s2);
+ if (Val != 0) {
+ return Val;
+ }
+ ++s1;
+ ++s2;
+ if (*s1 == '\0') {
+ break;
+ }
+ } while (--n != 0);
+ }
+ return 0;
+}
+
/* Read formatted data from a string */
int sscanf (const char *buffer, const char *format, ...)
{
@@ -146,6 +170,70 @@ int sscanf (const char *buffer, const char *format, ...)
return 0;
}
+/* Maps errnum to an error-message string */
+char * strerror (int errnum)
+{
+ return NULL;
+}
+
+/* Computes the length of the maximum initial segment of the string pointed to by s1
+ which consists entirely of characters from the string pointed to by s2. */
+size_t strspn (const char *s1 , const char *s2)
+{
+ UINT8 Map[32];
+ UINT32 Index;
+ size_t Count;
+
+ for (Index = 0; Index < 32; Index++) {
+ Map[Index] = 0;
+ }
+
+ while (*s2) {
+ Map[*s2 >> 3] |= (1 << (*s2 & 7));
+ s2++;
+ }
+
+ if (*s1) {
+ Count = 0;
+ while (Map[*s1 >> 3] & (1 << (*s1 & 7))) {
+ Count++;
+ s1++;
+ }
+
+ return Count;
+ }
+
+ return 0;
+}
+
+/* Computes the length of the maximum initial segment of the string pointed to by s1
+ which consists entirely of characters not from the string pointed to by s2. */
+size_t strcspn (const char *s1, const char *s2)
+{
+ UINT8 Map[32];
+ UINT32 Index;
+ size_t Count;
+
+ for (Index = 0; Index < 32; Index++) {
+ Map[Index] = 0;
+ }
+
+ while (*s2) {
+ Map[*s2 >> 3] |= (1 << (*s2 & 7));
+ s2++;
+ }
+
+ Map[0] |= 1;
+
+ Count = 0;
+ while (!(Map[*s1 >> 3] & (1 << (*s1 & 7)))) {
+ Count ++;
+ s1++;
+ }
+
+ return Count;
+}
+
//
// -- Character Classification Routines --
//
@@ -277,12 +365,6 @@ char *getenv (const char *varname)
// -- Stream I/O Routines --
//
-/* Write formatted output using a pointer to a list of arguments */
-int vfprintf (FILE *stream, const char *format, VA_LIST arg)
-{
- return 0;
-}
-
/* Write data to a stream */
size_t fwrite (const void *buffer, size_t size, size_t count, FILE *stream)
{
@@ -303,36 +385,6 @@ int BIO_snprintf(char *buf, size_t n, const char *format, ...)
return 0;
}
-void *UI_OpenSSL(void)
-{
- return NULL;
-}
-
-int X509_load_cert_file (VOID *ctx, const char *file, int type)
-{
- return 0;
-}
-
-int X509_load_crl_file (VOID *ctx, const char *file, int type)
-{
- return 0;
-}
-
-int chmod (const char *c, mode_t m)
-{
- return -1;
-}
-
-int close (int f)
-{
- return -1;
-}
-
-void closelog (void)
-{
-
-}
-
#ifdef __GNUC__
typedef
@@ -341,7 +393,6 @@ VOID
VOID
) __attribute__((__noreturn__));
-
STATIC
VOID
EFIAPI
@@ -351,8 +402,7 @@ NopFunction (
{
}
-
-void exit (int e)
+void abort (void)
{
NoReturnFuncPtr NoReturnFunc;
@@ -363,8 +413,9 @@ void exit (int e)
#else
-void exit (int e)
+void abort (void)
{
+ // Do nothing
}
#endif
@@ -384,16 +435,6 @@ size_t fread (void *b, size_t c, size_t i, FILE *f)
return 0;
}
-int fputs (const char *s, FILE *f)
-{
- return 0;
-}
-
-int fprintf (FILE *f, const char *s, ...)
-{
- return 0;
-}
-
uid_t getuid (void)
{
return 0;
@@ -414,46 +455,6 @@ gid_t getegid (void)
return 0;
}
-off_t lseek (int a, off_t o, int d)
-{
- return 0;
-}
-
-void openlog (const char *c, int a, int b)
-{
-
-}
-
-ssize_t read (int f, void *b, size_t c)
-{
- return 0;
-}
-
-int stat (const char *c, struct stat *s)
-{
- return -1;
-}
-
-int strcasecmp (const char *c, const char *s)
-{
- return 0;
-}
-
-int strncasecmp (const char *c, const char *s, size_t l)
-{
- return 0;
-}
-
-void syslog (int a, const char *c, ...)
-{
-
-}
-
-ssize_t write (int f, const void *b, size_t l)
-{
- return 0;
-}
-
int printf (char const *fmt, ...)
{
return 0;
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/HelperWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/HelperWrapper.c
deleted file mode 100644
index bf4399ca08..0000000000
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/HelperWrapper.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/** @file
- Wrapper Implementation of Helper Routines produced by the C Compiler
- for the OpenSSL-based Cryptographic Library.
-
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <OpenSslSupport.h>
-
-//---------------------------------------------------------
-// Helper Routines Wrapper
-//---------------------------------------------------------
-
-/* Divides a 64-bit signed value with a 64-bit signed value and returns
- a 64-bit signed quotient and reminder */
-void _aulldvrm ()
-{
- //
- // Null _aulldvrm() Math function implementation to satisfy the linker, since
- // there is no direct functionality logic dependency in present UEFI cases.
- //
- return;
-}
-
-
-/* Converts a scalar double-precision floating point value to a 32-bit integer */
-long _ftol2_sse (double dblSource)
-{
- //
- // OpenSSL uses this function due to using floating-point inside it.
- // It is only present in 32-bit versions of the compiler.
- // Null _ftol2_sse() function implementation to satisfy the linker, since
- // there is no direct functionality logic dependency in present UEFI cases.
- //
- return 0;
-}
-
-/* Converts a scalar double-precision floating point value to a 32-bit integer */
-long _ftol2 (double dblSource)
-{
- //
- // Null _ftol2() function implementation to satisfy the linker, since
- // there is no direct functionality logic dependency in present UEFI cases.
- //
- return 0;
-}
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c b/CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c
index feaa37145e..463f2bf855 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c
@@ -13,9 +13,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-#include <OpenSslSupport.h>
+#include <CrtLibSupport.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
+#include <Library/MemoryAllocationLib.h>
#include <Guid/EventGroup.h>
//----------------------------------------------------------------
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
index 93e487dcef..581b8fb028 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
@@ -2,7 +2,7 @@
C Run-Time Libraries (CRT) Time Management Routines Wrapper Implementation
for OpenSSL-based Cryptographic Library (used in DXE & RUNTIME).
-Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Uefi.h>
-#include <OpenSslSupport.h>
+#include <CrtLibSupport.h>
#include <Library/UefiRuntimeServicesTableLib.h>
//