summaryrefslogtreecommitdiff
path: root/Include/PPI/CryptoPPI.h
blob: 669a6d2fb53f33278e09f20cd33d9bdeac25581c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**        5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093         **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************
//**********************************************************************
// $Header: /Alaska/BIN/Modules/CryptoPkg/PPI/CryptoPPI.h 2     11/13/12 11:47a Alexp $
//
// $Revision: 2 $
//
// $Date: 11/13/12 11:47a $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/BIN/Modules/CryptoPkg/PPI/CryptoPPI.h $
// 
// 2     11/13/12 11:47a Alexp
// EIP#105015
// Add GUID defines for x509 Public Key file type and 
// Pkcs#7 Cert verification function in Crypto PPI
// 
// 1     6/13/11 5:19p Alexp
// 
// 1     5/06/11 6:11p Alexp
// initial module release
// 
// 3     4/11/11 12:53p Alexp
// remove Verify Capsule from Crypto PPI.
// 
// 2     3/10/11 4:53p Alexp
// 
// 1     2/28/11 6:46p Alexp
// 
//**********************************************************************
//<AMI_FHDR_START>
//
// Name:  CryptoPPI.h
//
// Description:	AMI Digital Signature Protocol Definition
//
//<AMI_FHDR_END>
//**********************************************************************
#ifndef ___AMI_DIGITAL_SIGNATURE_PEI__H__
#define ___AMI_DIGITAL_SIGNATURE_PEI__H__

#ifdef __cplusplus
extern "C" {
#endif

// Flags to define type of signature to process
#define EFI_CRYPT_RSASSA_PKCS1V15     1
#define EFI_CRYPT_RSASSA_PSS          2

///
/// SHA-1 digest size in bytes.
///
#define SHA1_DIGEST_SIZE    20
///
/// SHA-256 digest size in bytes
///
#define SHA256_DIGEST_SIZE  32

#define DEFAULT_RSA_KEY_MODULUS_LEN 256 // 2048 bits
#define DEFAULT_RSA_SIG_LEN DEFAULT_RSA_KEY_MODULUS_LEN // This is true as long as > data

#define AMI_DIGITAL_SIGNATURE_PPI_GUID \
    { 0x86c29aa5, 0xdb0, 0x4343, 0xbd, 0x52, 0x7a, 0x72, 0x9f, 0x37, 0xc9, 0x6d }

GUID_VARIABLE_DECLARATION(gAmiDigitalSignaturePPIGuid, AMI_DIGITAL_SIGNATURE_PPI_GUID);

typedef struct _AMI_CRYPT_DIGITAL_SIGNATURE_PPI AMI_CRYPT_DIGITAL_SIGNATURE_PPI;

typedef struct{
    EFI_GUID   AlgGuid;
    UINT32     BlobSize;
    UINT8      *Blob;
} PEI_CRYPT_HANDLE;

typedef 
EFI_STATUS
(EFIAPI *PEI_CRYPT_DS_VERIFY_SIG) (
  IN CONST AMI_CRYPT_DIGITAL_SIGNATURE_PPI *This,
  IN PEI_CRYPT_HANDLE        *PublicKey,
  IN PEI_CRYPT_HANDLE        *Hash,
  IN VOID                    *Signature,
  IN UINTN                    SignatureSize,
  IN UINT32                   Flags
  );

typedef 
EFI_STATUS
(EFIAPI *PEI_CRYPT_DS_VERIFY_PKCS7SIG) (
  IN CONST AMI_CRYPT_DIGITAL_SIGNATURE_PPI *This,
  IN CONST UINT8 *P7Data,
  IN UINTN        P7Size,
  IN CONST UINT8 *TrustedCert,
  IN UINTN        CertSize,
  IN OUT UINT8  **Data,
  IN OUT UINTN   *DataSize
  );

typedef 
EFI_STATUS
(EFIAPI *PEI_CRYPT_DS_GET_KEY) (
  IN CONST AMI_CRYPT_DIGITAL_SIGNATURE_PPI *This,
  IN CONST EFI_GUID          *KeyAlgorithm, // supported PKPUB_KEY_GUID only
  IN PEI_CRYPT_HANDLE        *PublicKey
  );

typedef 
EFI_STATUS
(EFIAPI *PEI_CRYPT_DS_VERIFY_KEY) (
  IN CONST AMI_CRYPT_DIGITAL_SIGNATURE_PPI *This,
  IN CONST EFI_GUID          *KeyAlgorithm, // supported PKPUB_KEY_GUID only
  IN PEI_CRYPT_HANDLE        *PublicKey
  );

typedef
EFI_STATUS
(EFIAPI *PEI_CRYPT_DS_HASH)(
  IN CONST AMI_CRYPT_DIGITAL_SIGNATURE_PPI *This,
  IN CONST EFI_GUID          *HashAlgorithm,
  IN UINTN                    num_elem,
  IN CONST UINT8             *addr[],
  IN CONST UINTN             *len,
  OUT UINT8                  *Hash
  );    

typedef struct _AMI_CRYPT_DIGITAL_SIGNATURE_PPI  {
  PEI_CRYPT_DS_HASH           Hash;
  PEI_CRYPT_DS_VERIFY_KEY     VerifyKey; // compares Key with Platform Signing key(PKpub)
  PEI_CRYPT_DS_VERIFY_SIG     VerifySig; // Rsa2048_sha256 Pkcs1v1.5
  PEI_CRYPT_DS_GET_KEY        GetKey;  
  PEI_CRYPT_DS_VERIFY_PKCS7SIG   VerifyPkcs7Sig;
};
/****** DO NOT WRITE BELOW THIS LINE *******/
#ifdef __cplusplus
}
#endif

#endif // ___AMI_DIGITAL_SIGNATURE_PEI__H__
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**        5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093         **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************