Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update openssl to 3.2.x #5765

Closed
wants to merge 14 commits into from
Closed
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
4 changes: 4 additions & 0 deletions CryptoPkg/CryptoPkg.ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@
# options defined in .pytool/Plugin/UncrustifyCheck
"UncrustifyCheck": {
"IgnoreFiles": [
"Library/OpensslLib/OpensslGen/crypto/params_idx.c",
"Library/OpensslLib/OpensslGen/include/crypto/bn_conf.h",
"Library/OpensslLib/OpensslGen/include/crypto/dso_conf.h",
"Library/OpensslLib/OpensslGen/include/internal/param_names.h",
"Library/OpensslLib/OpensslGen/include/openssl/asn1.h",
"Library/OpensslLib/OpensslGen/include/openssl/asn1t.h",
"Library/OpensslLib/OpensslGen/include/openssl/bio.h",
Expand All @@ -116,6 +118,7 @@
"Library/OpensslLib/OpensslGen/include/openssl/configuration-ec.h",
"Library/OpensslLib/OpensslGen/include/openssl/configuration-noec.h",
"Library/OpensslLib/OpensslGen/include/openssl/configuration.h",
"Library/OpensslLib/OpensslGen/include/openssl/core_names.h",
"Library/OpensslLib/OpensslGen/include/openssl/crmf.h",
"Library/OpensslLib/OpensslGen/include/openssl/crypto.h",
"Library/OpensslLib/OpensslGen/include/openssl/ct.h",
Expand All @@ -133,6 +136,7 @@
"Library/OpensslLib/OpensslGen/include/openssl/ui.h",
"Library/OpensslLib/OpensslGen/include/openssl/x509.h",
"Library/OpensslLib/OpensslGen/include/openssl/x509v3.h",
"Library/OpensslLib/OpensslGen/include/openssl/x509_acert.h",
"Library/OpensslLib/OpensslGen/include/openssl/x509_vfy.h",
"Library/OpensslLib/OpensslGen/providers/common/der/der_digests_gen.c",
"Library/OpensslLib/OpensslGen/providers/common/der/der_ecx_gen.c",
Expand Down
1 change: 1 addition & 0 deletions CryptoPkg/CryptoPkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
[Includes.Common.Private]
Private
Library/Include
Library/OpensslLib/openssl
Library/OpensslLib/openssl/include
Library/OpensslLib/openssl/providers/common/include
Library/OpensslLib/openssl/providers/implementations/include
Expand Down
29 changes: 29 additions & 0 deletions CryptoPkg/Library/BaseCryptLib/SysCall/ConstantTimeClock.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,32 @@ gmtime (
{
return NULL;
}

time_t
mktime (
struct tm *t
)
{
return 0;
}

unsigned int
sleep (
unsigned int seconds
)
{
return 0;
}

int
gettimeofday (
struct timeval *tv,
struct timezone *tz
)
{
tv->tv_sec = 0;
tv->tv_usec = 0;
return 0;
}

long timezone;
92 changes: 73 additions & 19 deletions CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent

#include <Uefi.h>
#include <CrtLibSupport.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>

//
Expand All @@ -19,6 +20,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define SECSPERHOUR (60 * 60)
#define SECSPERDAY (24 * SECSPERHOUR)

long timezone;

//
// The arrays give the cumulative number of days up to the first of the
// month number used as the index (1 -> 12) for regular and leap years.
Expand Down Expand Up @@ -79,6 +82,37 @@ IsLeap (
return (Remainder1 == 0 && (Remainder2 != 0 || Remainder3 == 0));
}

STATIC
time_t
CalculateTimeT (
EFI_TIME *Time
)
{
time_t CalTime;
UINTN Year;

//
// Years Handling
// UTime should now be set to 00:00:00 on Jan 1 of the current year.
//
for (Year = 1970, CalTime = 0; Year != Time->Year; Year++) {
CalTime = CalTime + (time_t)(CumulativeDays[IsLeap (Year)][13] * SECSPERDAY);
}

//
// Add in number of seconds for current Month, Day, Hour, Minute, Seconds, and TimeZone adjustment
//
CalTime = CalTime +
(time_t)((Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time->TimeZone * 60) : 0) +
(time_t)(CumulativeDays[IsLeap (Time->Year)][Time->Month] * SECSPERDAY) +
(time_t)(((Time->Day > 0) ? Time->Day - 1 : 0) * SECSPERDAY) +
(time_t)(Time->Hour * SECSPERHOUR) +
(time_t)(Time->Minute * 60) +
(time_t)Time->Second;

return CalTime;
}

/* Get the system time as seconds elapsed since midnight, January 1, 1970. */
// INTN time(
// INTN *timer
Expand All @@ -91,7 +125,6 @@ time (
EFI_STATUS Status;
EFI_TIME Time;
time_t CalTime;
UINTN Year;

//
// Get the current time and date information
Expand All @@ -101,24 +134,7 @@ time (
return 0;
}

//
// Years Handling
// UTime should now be set to 00:00:00 on Jan 1 of the current year.
//
for (Year = 1970, CalTime = 0; Year != Time.Year; Year++) {
CalTime = CalTime + (time_t)(CumulativeDays[IsLeap (Year)][13] * SECSPERDAY);
}

//
// Add in number of seconds for current Month, Day, Hour, Minute, Seconds, and TimeZone adjustment
//
CalTime = CalTime +
(time_t)((Time.TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time.TimeZone * 60) : 0) +
(time_t)(CumulativeDays[IsLeap (Time.Year)][Time.Month] * SECSPERDAY) +
(time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) +
(time_t)(Time.Hour * SECSPERHOUR) +
(time_t)(Time.Minute * 60) +
(time_t)Time.Second;
CalTime = CalculateTimeT (&Time);

if (timer != NULL) {
*timer = CalTime;
Expand All @@ -127,6 +143,24 @@ time (
return CalTime;
}

time_t
mktime (
struct tm *t
)
{
EFI_TIME Time = {
.Year = (UINT16)t->tm_year,
.Month = (UINT8)t->tm_mon,
.Day = (UINT8)t->tm_mday,
.Hour = (UINT8)t->tm_hour,
.Minute = (UINT8)t->tm_min,
.Second = (UINT8)t->tm_sec,
.TimeZone = EFI_UNSPECIFIED_TIMEZONE,
};

return CalculateTimeT (&Time);
}

//
// Convert a time value from type time_t to struct tm.
//
Expand Down Expand Up @@ -195,3 +229,23 @@ gmtime (

return GmTime;
}

unsigned int
sleep (
unsigned int seconds
)
{
gBS->Stall (seconds * 1000 * 1000);
return 0;
}

int
gettimeofday (
struct timeval *tv,
struct timezone *tz
)
{
tv->tv_sec = (long)time (NULL);
tv->tv_usec = 0;
return 0;
}
22 changes: 21 additions & 1 deletion CryptoPkg/Library/BaseCryptLib/SysCall/UnitTestHostCrtWrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,24 @@ getegid (
return 0;
}

int errno = 0;
unsigned int
sleep (
unsigned int seconds
)
{
return 0;
}

int
gettimeofday (
struct timeval *tv,
struct timezone *tz
)
{
tv->tv_sec = 0;
tv->tv_usec = 0;
return 0;
}

int errno = 0;
long timezone;
21 changes: 20 additions & 1 deletion CryptoPkg/Library/Include/CrtLibSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
#include <Library/TimerLib.h>

#define OPENSSLDIR ""
#define ENGINESDIR ""
Expand Down Expand Up @@ -146,6 +147,8 @@ struct timeval {
long tv_usec; /* time value, in microseconds */
};

struct timezone;

struct sockaddr {
__uint8_t sa_len; /* total length */
sa_family_t sa_family; /* address family */
Expand All @@ -157,6 +160,7 @@ struct sockaddr {
//
extern int errno;
extern FILE *stderr;
extern long timezone;

//
// Function prototypes of CRT Library routines
Expand Down Expand Up @@ -334,6 +338,22 @@ gmtime (
const time_t *
);

unsigned int
sleep (
unsigned int seconds
);

int
gettimeofday (
struct timeval *tv,
struct timezone *tz
);

time_t
mktime (
struct tm *t
);

uid_t
getuid (
void
Expand Down Expand Up @@ -433,6 +453,5 @@ strcat (
#define assert(expression)
#define offsetof(type, member) OFFSET_OF(type,member)
#define atoi(nptr) AsciiStrDecimalToUintn(nptr)
#define gettimeofday(tvp, tz) do { (tvp)->tv_sec = time(NULL); (tvp)->tv_usec = 0; } while (0)

#endif
Loading
Loading