Skip to content

Commit

Permalink
Copy head(r18255) from main trunk excluding UNI files.
Browse files Browse the repository at this point in the history
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <[email protected]>
Signed-off-by: Hao Wu <[email protected]>

git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2010.SR1@18304 6f19259b-4bc3-4df7-8a09-765794883524
  • Loading branch information
vanjeff authored and vanjeff committed Aug 25, 2015
1 parent dcfa39f commit 669f2b5
Show file tree
Hide file tree
Showing 48 changed files with 3,811 additions and 1,354 deletions.
2 changes: 2 additions & 0 deletions CryptoPkg/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Include/openssl
Library/OpensslLib/openssl-*/
11 changes: 8 additions & 3 deletions CryptoPkg/Application/Cryptest/Cryptest.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
/** @file
Application for Cryptographic Primitives Validation.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2009 - 2014, 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
Expand Down Expand Up @@ -73,6 +73,11 @@ CryptestMain (
return Status;
}

Status = ValidateTSCounterSignature ();
if (EFI_ERROR (Status)) {
return Status;
}

Status = ValidateCryptDh ();
if (EFI_ERROR (Status)) {
return Status;
Expand All @@ -84,4 +89,4 @@ CryptestMain (
}

return EFI_SUCCESS;
}
}
18 changes: 15 additions & 3 deletions CryptoPkg/Application/Cryptest/Cryptest.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
/** @file
Application for Cryptographic Primitives Validation.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2009 - 2014, 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
Expand Down Expand Up @@ -108,6 +108,18 @@ ValidateAuthenticode (
VOID
);

/**
Validate UEFI-OpenSSL RFC3161 Timestamp CounterSignature Verification Interfaces.
@retval EFI_SUCCESS Validation succeeded.
@retval EFI_ABORTED Validation failed.
**/
EFI_STATUS
ValidateTSCounterSignature (
VOID
);

/**
Validate UEFI-OpenSSL DH Interfaces.
Expand All @@ -132,4 +144,4 @@ ValidateCryptPrng (
VOID
);

#endif
#endif
1 change: 1 addition & 0 deletions CryptoPkg/Application/Cryptest/Cryptest.inf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
RsaVerify.c
RsaVerify2.c
AuthenticodeVerify.c
TSVerify.c
DhVerify.c
RandVerify.c

Expand Down
14 changes: 11 additions & 3 deletions CryptoPkg/Application/Cryptest/DhVerify.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
/** @file
Application for Diffie-Hellman Primitives Validation.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2014, 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
Expand Down Expand Up @@ -41,6 +41,14 @@ ValidateCryptDh (

Print (L"\nUEFI-OpenSSL DH Engine Testing:\n");

//
// Initialize Key Length
//
PublicKey1Length = sizeof (PublicKey1);
PublicKey2Length = sizeof (PublicKey2);
Key1Length = sizeof (Key1);
Key2Length = sizeof (Key2);

//
// Generate & Initialize DH Context
//
Expand Down Expand Up @@ -114,4 +122,4 @@ ValidateCryptDh (
Print (L"[Pass]\n");

return EFI_SUCCESS;
}
}
107 changes: 103 additions & 4 deletions CryptoPkg/Application/Cryptest/HashVerify.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
/** @file
Application for Hash Primitives Validation.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2014, 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
Expand Down Expand Up @@ -54,6 +54,25 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 Sha256Digest[SHA256_DIGEST_SIZE] = {
0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad
};

//
// Result for SHA-384("abc"). (From "D.1 SHA-384 Example" of NIST FIPS 180-2)
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 Sha384Digest[SHA384_DIGEST_SIZE] = {
0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b, 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63, 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23, 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7
};

//
// Result for SHA-512("abc"). (From "C.1 SHA-512 Example" of NIST FIPS 180-2)
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 Sha512Digest[SHA512_DIGEST_SIZE] = {
0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba, 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2, 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8, 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e, 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f
};

/**
Validate UEFI-OpenSSL Digest Interfaces.
Expand All @@ -76,7 +95,7 @@ ValidateCryptDigest (
DataSize = AsciiStrLen (HashData);

Print (L"- MD4: ");

//
// MD4 Digest Validation
//
Expand Down Expand Up @@ -234,6 +253,86 @@ ValidateCryptDigest (
}

Print (L"[Pass]\n");


Print (L"- SHA384: ");

//
// SHA384 Digest Validation
//
ZeroMem (Digest, MAX_DIGEST_SIZE);
CtxSize = Sha384GetContextSize ();
HashCtx = AllocatePool (CtxSize);

Print (L"Init... ");
Status = Sha384Init (HashCtx);
if (!Status) {
Print (L"[Fail]");
return EFI_ABORTED;
}

Print (L"Update... ");
Status = Sha384Update (HashCtx, HashData, DataSize);
if (!Status) {
Print (L"[Fail]");
return EFI_ABORTED;
}

Print (L"Finalize... ");
Status = Sha384Final (HashCtx, Digest);
if (!Status) {
Print (L"[Fail]");
return EFI_ABORTED;
}

FreePool (HashCtx);

Print (L"Check Value... ");
if (CompareMem (Digest, Sha384Digest, SHA384_DIGEST_SIZE) != 0) {
Print (L"[Fail]");
return EFI_ABORTED;
}

Print (L"[Pass]\n");

Print (L"- SHA512: ");

//
// SHA512 Digest Validation
//
ZeroMem (Digest, MAX_DIGEST_SIZE);
CtxSize = Sha512GetContextSize ();
HashCtx = AllocatePool (CtxSize);

Print (L"Init... ");
Status = Sha512Init (HashCtx);
if (!Status) {
Print (L"[Fail]");
return EFI_ABORTED;
}

Print (L"Update... ");
Status = Sha512Update (HashCtx, HashData, DataSize);
if (!Status) {
Print (L"[Fail]");
return EFI_ABORTED;
}

Print (L"Finalize... ");
Status = Sha512Final (HashCtx, Digest);
if (!Status) {
Print (L"[Fail]");
return EFI_ABORTED;
}

FreePool (HashCtx);

Print (L"Check Value... ");
if (CompareMem (Digest, Sha512Digest, SHA512_DIGEST_SIZE) != 0) {
Print (L"[Fail]");
return EFI_ABORTED;
}

Print (L"[Pass]\n");

return EFI_SUCCESS;
}
Loading

0 comments on commit 669f2b5

Please sign in to comment.