Import Upstream version 0.9+1474479173.6c180c60

parents
.*.sw?
certdb
shim_cert.h
*.a
*.cer
*.crl
*.crt
*.csr
*.db
*.db.attr
*.db.attr.old
*.db.old
*.domain.txt
*.efi
*.efi.debug
*.efi.signed
*.key
*.key
*.o
*.pem
*.p12
*.so
*.srl
*.srl.old
*.tar.*
version.c
Copyright 2012 Red Hat, Inc <mjg@redhat.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
Significant portions of this code are derived from Tianocore
(http://tianocore.sf.net) and are Copyright 2009-2012 Intel
Corporation.
This diff is collapsed.
/** @file
ARC4 Wrapper Implementation over OpenSSL.
Copyright (c) 2010 - 2012, 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 "InternalCryptLib.h"
#include <openssl/rc4.h>
/**
Retrieves the size, in bytes, of the context buffer required for ARC4 operations.
@return The size, in bytes, of the context buffer required for ARC4 operations.
**/
UINTN
EFIAPI
Arc4GetContextSize (
VOID
)
{
//
// Memory for 2 copies of RC4_KEY is allocated, one for working copy, and the other
// for backup copy. When Arc4Reset() is called, we can use the backup copy to restore
// the working copy to the initial state.
//
return (UINTN) (2 * sizeof (RC4_KEY));
}
/**
Initializes user-supplied memory as ARC4 context for subsequent use.
This function initializes user-supplied memory pointed by Arc4Context as ARC4 context.
In addition, it sets up all ARC4 key materials for subsequent encryption and decryption
operations.
If Arc4Context is NULL, then return FALSE.
If Key is NULL, then return FALSE.
If KeySize does not in the range of [5, 256] bytes, then return FALSE.
@param[out] Arc4Context Pointer to ARC4 context being initialized.
@param[in] Key Pointer to the user-supplied ARC4 key.
@param[in] KeySize Size of ARC4 key in bytes.
@retval TRUE ARC4 context initialization succeeded.
@retval FALSE ARC4 context initialization failed.
**/
BOOLEAN
EFIAPI
Arc4Init (
OUT VOID *Arc4Context,
IN CONST UINT8 *Key,
IN UINTN KeySize
)
{
RC4_KEY *Rc4Key;
//
// Check input parameters.
//
if (Arc4Context == NULL || Key == NULL || (KeySize < 5 || KeySize > 256)) {
return FALSE;
}
Rc4Key = (RC4_KEY *) Arc4Context;
RC4_set_key (Rc4Key, (UINT32) KeySize, Key);
CopyMem (Rc4Key + 1, Rc4Key, sizeof (RC4_KEY));
return TRUE;
}
/**
Performs ARC4 encryption on a data buffer of the specified size.
This function performs ARC4 encryption on data buffer pointed by Input, of specified
size of InputSize.
Arc4Context should be already correctly initialized by Arc4Init(). Behavior with
invalid ARC4 context is undefined.
If Arc4Context is NULL, then return FALSE.
If Input is NULL, then return FALSE.
If Output is NULL, then return FALSE.
@param[in, out] Arc4Context Pointer to the ARC4 context.
@param[in] Input Pointer to the buffer containing the data to be encrypted.
@param[in] InputSize Size of the Input buffer in bytes.
@param[out] Output Pointer to a buffer that receives the ARC4 encryption output.
@retval TRUE ARC4 encryption succeeded.
@retval FALSE ARC4 encryption failed.
**/
BOOLEAN
EFIAPI
Arc4Encrypt (
IN OUT VOID *Arc4Context,
IN CONST UINT8 *Input,
IN UINTN InputSize,
OUT UINT8 *Output
)
{
RC4_KEY *Rc4Key;
//
// Check input parameters.
//
if (Arc4Context == NULL || Input == NULL || Output == NULL || InputSize > INT_MAX) {
return FALSE;
}
Rc4Key = (RC4_KEY *) Arc4Context;
RC4 (Rc4Key, (UINT32) InputSize, Input, Output);
return TRUE;
}
/**
Performs ARC4 decryption on a data buffer of the specified size.
This function performs ARC4 decryption on data buffer pointed by Input, of specified
size of InputSize.
Arc4Context should be already correctly initialized by Arc4Init(). Behavior with
invalid ARC4 context is undefined.
If Arc4Context is NULL, then return FALSE.
If Input is NULL, then return FALSE.
If Output is NULL, then return FALSE.
@param[in, out] Arc4Context Pointer to the ARC4 context.
@param[in] Input Pointer to the buffer containing the data to be decrypted.
@param[in] InputSize Size of the Input buffer in bytes.
@param[out] Output Pointer to a buffer that receives the ARC4 decryption output.
@retval TRUE ARC4 decryption succeeded.
@retval FALSE ARC4 decryption failed.
**/
BOOLEAN
EFIAPI
Arc4Decrypt (
IN OUT VOID *Arc4Context,
IN UINT8 *Input,
IN UINTN InputSize,
OUT UINT8 *Output
)
{
RC4_KEY *Rc4Key;
//
// Check input parameters.
//
if (Arc4Context == NULL || Input == NULL || Output == NULL || InputSize > INT_MAX) {
return FALSE;
}
Rc4Key = (RC4_KEY *) Arc4Context;
RC4 (Rc4Key, (UINT32) InputSize, Input, Output);
return TRUE;
}
/**
Resets the ARC4 context to the initial state.
The function resets the ARC4 context to the state it had immediately after the
ARC4Init() function call.
Contrary to ARC4Init(), Arc4Reset() requires no secret key as input, but ARC4 context
should be already correctly initialized by ARC4Init().
If Arc4Context is NULL, then return FALSE.
@param[in, out] Arc4Context Pointer to the ARC4 context.
@retval TRUE ARC4 reset succeeded.
@retval FALSE ARC4 reset failed.
**/
BOOLEAN
EFIAPI
Arc4Reset (
IN OUT VOID *Arc4Context
)
{
RC4_KEY *Rc4Key;
//
// Check input parameters.
//
if (Arc4Context == NULL) {
return FALSE;
}
Rc4Key = (RC4_KEY *) Arc4Context;
CopyMem (Rc4Key, Rc4Key + 1, sizeof (RC4_KEY));
return TRUE;
}
This diff is collapsed.
diff --git a/Cryptlib/SysCall/BaseMemAllocation.c b/Cryptlib/SysCall/BaseMemAllocation.c
index 68bc25a..1abe78e 100644
--- a/Cryptlib/SysCall/BaseMemAllocation.c
+++ b/Cryptlib/SysCall/BaseMemAllocation.c
@@ -32,7 +32,7 @@ void *realloc (void *ptr, size_t size)
// BUG: hardcode OldSize == size! We have no any knowledge about
// memory size of original pointer ptr.
//
- return ReallocatePool ((UINTN) size, (UINTN) size, ptr);
+ return ReallocatePool (ptr, (UINTN) size, (UINTN) size);
}
/* De-allocates or frees a memory block */
diff --git a/Cryptlib/SysCall/TimerWrapper.c b/Cryptlib/SysCall/TimerWrapper.c
index 805e6b4..bb7bcba 100644
--- a/Cryptlib/SysCall/TimerWrapper.c
+++ b/Cryptlib/SysCall/TimerWrapper.c
@@ -13,9 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-#include <Uefi.h>
#include <OpenSslSupport.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
//
// -- Time Management Routines --
@@ -78,7 +76,7 @@ time_t time (time_t *timer)
//
// Get the current time and date information
//
- gRT->GetTime (&Time, NULL);
+ uefi_call_wrapper(RT->GetTime, 2, &Time, NULL);
//
// Years Handling
diff --git a/Cryptlib/SysCall/CrtWrapper.c b/Cryptlib/SysCall/CrtWrapper.c
index fb446b6..5a8322d 100644
--- a/Cryptlib/SysCall/CrtWrapper.c
+++ b/Cryptlib/SysCall/CrtWrapper.c
@@ -293,16 +293,6 @@ size_t fwrite (const void *buffer, size_t size, size_t count, FILE *stream)
// -- Dummy OpenSSL Support Routines --
//
-int BIO_printf (void *bio, const char *format, ...)
-{
- return 0;
-}
-
-int BIO_snprintf(char *buf, size_t n, const char *format, ...)
-{
- return 0;
-}
-
void *UI_OpenSSL(void)
{
return NULL;
/** @file
MD4 Digest Wrapper Implementation over OpenSSL.
Copyright (c) 2010 - 2012, 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 "InternalCryptLib.h"
#include <openssl/md4.h>
/**
Retrieves the size, in bytes, of the context buffer required for MD4 hash operations.
@return The size, in bytes, of the context buffer required for MD4 hash operations.
**/
UINTN
EFIAPI
Md4GetContextSize (
VOID
)
{
//
// Retrieves the OpenSSL MD4 Context Size
//
return (UINTN) (sizeof (MD4_CTX));
}
/**
Initializes user-supplied memory pointed by Md4Context as MD4 hash context for
subsequent use.
If Md4Context is NULL, then return FALSE.
@param[out] Md4Context Pointer to MD4 context being initialized.
@retval TRUE MD4 context initialization succeeded.
@retval FALSE MD4 context initialization failed.
**/
BOOLEAN
EFIAPI
Md4Init (
OUT VOID *Md4Context
)
{
//
// Check input parameters.
//
if (Md4Context == NULL) {
return FALSE;
}
//
// OpenSSL MD4 Context Initialization
//
return (BOOLEAN) (MD4_Init ((MD4_CTX *) Md4Context));
}
/**
Makes a copy of an existing MD4 context.
If Md4Context is NULL, then return FALSE.
If NewMd4Context is NULL, then return FALSE.
@param[in] Md4Context Pointer to MD4 context being copied.
@param[out] NewMd4Context Pointer to new MD4 context.
@retval TRUE MD4 context copy succeeded.
@retval FALSE MD4 context copy failed.
**/
BOOLEAN
EFIAPI
Md4Duplicate (
IN CONST VOID *Md4Context,
OUT VOID *NewMd4Context
)
{
//
// Check input parameters.
//
if (Md4Context == NULL || NewMd4Context == NULL) {
return FALSE;
}
CopyMem (NewMd4Context, Md4Context, sizeof (MD4_CTX));
return TRUE;
}
/**
Digests the input data and updates MD4 context.
This function performs MD4 digest on a data buffer of the specified size.
It can be called multiple times to compute the digest of long or discontinuous data streams.
MD4 context should be already correctly intialized by Md4Init(), and should not be finalized
by Md4Final(). Behavior with invalid context is undefined.
If Md4Context is NULL, then return FALSE.