tpm2: rev155: Remove old hash related code and definitions

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2019-06-12 17:13:17 -04:00 committed by Stefan Berger
parent ddba4e3c6b
commit e5a67ccde9
5 changed files with 11 additions and 161 deletions

View File

@ -501,7 +501,6 @@ libtpms_tpm2_la_SOURCES += \
tpm2/crypto/openssl/CryptEccMain.c \
tpm2/crypto/openssl/CryptEccSignature.c \
tpm2/crypto/openssl/CryptHash.c \
tpm2/crypto/openssl/CryptHashData.c \
tpm2/crypto/openssl/CryptPrime.c \
tpm2/crypto/openssl/CryptPrimeSieve.c \
tpm2/crypto/openssl/CryptRand.c \

View File

@ -3,7 +3,7 @@
/* Hash structure definitions */
/* Written by Ken Goldman */
/* IBM Thomas J. Watson Research Center */
/* $Id: CryptHash.h 1265 2018-07-15 18:29:22Z kgoldman $ */
/* $Id: CryptHash.h 1476 2019-06-10 19:32:03Z kgoldman $ */
/* */
/* Licenses and Notices */
/* */
@ -55,7 +55,7 @@
/* arising in any way out of use or reliance upon this specification or any */
/* information herein. */
/* */
/* (c) Copyright IBM Corp. and others, 2016 - 2018 */
/* (c) Copyright IBM Corp. and others, 2016 - 2019 */
/* */
/********************************************************************************/
@ -68,14 +68,9 @@
space to be reserved for the hash state. This allows the TPM code to not have to import all of
the symbols used by the hash computations. This lets the build environment of the TPM code not to
have include the header files associated with the CryptoEngine() code. */
typedef struct
{
const TPM_ALG_ID alg;
const UINT16 digestSize;
const UINT16 blockSize;
const UINT16 derSize;
const BYTE der[20];
} HASH_INFO;
/* 10.1.3.2 Hash-related Structures */
union SMAC_STATES;
/* These definitions add the high-level methods for processing state that may be an SMAC */
@ -296,7 +291,7 @@ typedef struct _HASH_STATE
} HASH_STATE, *PHASH_STATE;
typedef const HASH_STATE *PCHASH_STATE;
/* 10.1.3.2 HMAC State Structures */
/* 10.1.3.3 HMAC State Structures */
/* This header contains the hash structure definitions used in the TPM code to define the amount of
space to be reserved for the hash state. This allows the TPM code to not have to import all of
the symbols used by the hash computations. This lets the build environment of the TPM code not to
@ -310,7 +305,6 @@ typedef struct hmacState
HASH_STATE hashState; // the hash state
TPM2B_HASH_BLOCK hmacKey; // the HMAC key
} HMAC_STATE, *PHMAC_STATE;
extern const HASH_INFO g_hashData[HASH_COUNT + 1];
/* This is for the external hash state. This implementation assumes that the size of the exported
hash state is no larger than the internal hash state. There is a run time check that makes sure
that this i. */

View File

@ -3,7 +3,7 @@
/* Implementation of cryptographic functions for hashing. */
/* Written by Ken Goldman */
/* IBM Thomas J. Watson Research Center */
/* $Id: CryptHash_fp.h 1047 2017-07-20 18:27:34Z kgoldman $ */
/* $Id: CryptHash_fp.h 1478 2019-06-10 21:15:14Z kgoldman $ */
/* */
/* Licenses and Notices */
/* */
@ -91,10 +91,9 @@ LIB_EXPORT UINT16
CryptHashGetBlockSize(
TPM_ALG_ID hashAlg // IN: hash algorithm to look up
);
LIB_EXPORT UINT16
CryptHashGetDer(
TPM_ALG_ID hashAlg, // IN: the algorithm to look up
const BYTE **p
LIB_EXPORT const BYTE *
CryptHashGetOid(
TPM_ALG_ID hashAlg
);
TPM_ALG_ID
CryptHashGetContextAlg(

View File

@ -55,7 +55,7 @@
/* arising in any way out of use or reliance upon this specification or any */
/* information herein. */
/* */
/* (c) Copyright IBM Corp. and others, 2016 - 2018 */
/* (c) Copyright IBM Corp. and others, 2016 - 2019 */
/* */
/********************************************************************************/
@ -69,7 +69,6 @@
#include "CryptHash.h"
#include "OIDS.h"
#define HASH_TABLE_SIZE (HASH_COUNT + 1)
extern const HASH_INFO g_hashData[HASH_COUNT + 1];
#if ALG_SHA1
HASH_DEF_TEMPLATE(SHA1, Sha1);
#endif
@ -165,28 +164,6 @@ CryptHashIsValidAlg(
return flag;
return CryptGetHashDef(hashAlg) != &NULL_Def;
}
/* 10.2.13.4.4 GetHashInfoPointer() */
/* This function returns a pointer to the hash info for the algorithm. If the algorithm is not
supported, function returns a pointer to the data block associated with TPM_ALG_NULL. */
/* NOTE: The data structure must have a digest size of 0 for TPM_ALG_NULL. */
static
const HASH_INFO *
GetHashInfoPointer(
TPM_ALG_ID hashAlg
)
{
UINT32 i;
//
// TPM_ALG_NULL is the stop value so search up to it
for(i = 0; i < HASH_COUNT; i++)
{
if(g_hashData[i].alg == hashAlg)
return &g_hashData[i];
}
// either the input was TPM_ALG_NUL or we didn't find the requested algorithm
// in either case return a pointer to the TPM_ALG_NULL "hash" descriptor
return &g_hashData[HASH_COUNT];
}
/* 10.2.13.4.4 CryptHashGetAlgByIndex() */
/* This function is used to iterate through the hashes. TPM_ALG_NULL is returned for all indexes
that are not valid hashes. If the TPM implements 3 hashes, then an index value of 0 will return
@ -243,19 +220,6 @@ CryptHashGetOid(
{
return CryptGetHashDef(hashAlg)->OID;
}
/* 10.2.13.4.8 CryptHashGetDer */
/* This function returns a pointer to the DER string for the algorithm and indicates its size. */
LIB_EXPORT UINT16
CryptHashGetDer(
TPM_ALG_ID hashAlg, // IN: the algorithm to look up
const BYTE **p
)
{
const HASH_INFO *q;
q = GetHashInfoPointer(hashAlg);
*p = &q->der[0];
return q->derSize;
}
/* 10.2.13.4.8 CryptHashGetContextAlg() */
/* This function returns the hash algorithm associated with a hash context. */
TPM_ALG_ID

View File

@ -1,106 +0,0 @@
/********************************************************************************/
/* */
/* Hash ALgorithm Constants */
/* Written by Ken Goldman */
/* IBM Thomas J. Watson Research Center */
/* $Id: CryptHashData.c 1370 2018-11-02 19:39:07Z kgoldman $ */
/* */
/* Licenses and Notices */
/* */
/* 1. Copyright Licenses: */
/* */
/* - Trusted Computing Group (TCG) grants to the user of the source code in */
/* this specification (the "Source Code") a worldwide, irrevocable, */
/* nonexclusive, royalty free, copyright license to reproduce, create */
/* derivative works, distribute, display and perform the Source Code and */
/* derivative works thereof, and to grant others the rights granted herein. */
/* */
/* - The TCG grants to the user of the other parts of the specification */
/* (other than the Source Code) the rights to reproduce, distribute, */
/* display, and perform the specification solely for the purpose of */
/* developing products based on such documents. */
/* */
/* 2. Source Code Distribution Conditions: */
/* */
/* - Redistributions of Source Code must retain the above copyright licenses, */
/* this list of conditions and the following disclaimers. */
/* */
/* - Redistributions in binary form must reproduce the above copyright */
/* licenses, this list of conditions and the following disclaimers in the */
/* documentation and/or other materials provided with the distribution. */
/* */
/* 3. Disclaimers: */
/* */
/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */
/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */
/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */
/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */
/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */
/* information on specification licensing rights available through TCG */
/* membership agreements. */
/* */
/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */
/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */
/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */
/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */
/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */
/* */
/* - Without limitation, TCG and its members and licensors disclaim all */
/* liability, including liability for infringement of any proprietary */
/* rights, relating to use of information in this specification and to the */
/* implementation of this specification, and TCG disclaims all liability for */
/* cost of procurement of substitute goods or services, lost profits, loss */
/* of use, loss of data or any incidental, consequential, direct, indirect, */
/* or special damages, whether under contract, tort, warranty or otherwise, */
/* arising in any way out of use or reliance upon this specification or any */
/* information herein. */
/* */
/* (c) Copyright IBM Corp. and others, 2018 */
/* */
/********************************************************************************/
/* 10.2.15 CryptHashData.c */
#include "Tpm.h"
#define SHA1_DER_SIZE 15
#define SHA1_DER \
0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, \
0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14
#define SHA256_DER_SIZE 19
#define SHA256_DER \
0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, \
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, \
0x00, 0x04, 0x20
#define SHA384_DER_SIZE 19
#define SHA384_DER \
0x30, 0x41, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, \
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, \
0x00, 0x04, 0x30
#define SHA512_DER_SIZE 19
#define SHA512_DER \
0x30, 0x51, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86, \
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, \
0x00, 0x04, 0x40
const HASH_INFO g_hashData[HASH_COUNT + 1] = {
#if ALG_SHA1
{TPM_ALG_SHA1, SHA1_DIGEST_SIZE, SHA1_BLOCK_SIZE,
SHA1_DER_SIZE, {SHA1_DER}},
#endif
#if ALG_SHA256
{TPM_ALG_SHA256, SHA256_DIGEST_SIZE, SHA256_BLOCK_SIZE,
SHA256_DER_SIZE, {SHA256_DER}},
#endif
#if ALG_SHA384
{TPM_ALG_SHA384, SHA384_DIGEST_SIZE, SHA384_BLOCK_SIZE,
SHA384_DER_SIZE, {SHA384_DER}},
#endif
#if ALG_SHA512
{TPM_ALG_SHA512, SHA512_DIGEST_SIZE, SHA512_BLOCK_SIZE,
SHA512_DER_SIZE, {SHA512_DER}},
#endif
#if ALG_SM3_256
{TPM_ALG_SM3_256, SM3_256_DIGEST_SIZE, SM3_256_BLOCK_SIZE,
SM3_256_DER_SIZE, {SM3_256_DER}},
#endif
{TPM_ALG_NULL,0,0,0,{0}}
};