1 /** @file
2 Diffie-Hellman Wrapper Implementation which does not provide
3 real capabilities.
4
5 Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include "InternalCryptLib.h"
17
18 /**
19 Allocates and Initializes one Diffie-Hellman Context for subsequent use.
20
21 @return Pointer to the Diffie-Hellman Context that has been initialized.
22 If the interface is not supported, DhNew() returns NULL.
23
24 **/
25 VOID *
26 EFIAPI
DhNew(VOID)27 DhNew (
28 VOID
29 )
30 {
31 ASSERT (FALSE);
32 return NULL;
33 }
34
35 /**
36 Release the specified DH context.
37
38 If the interface is not supported, then ASSERT().
39
40 @param[in] DhContext Pointer to the DH context to be released.
41
42 **/
43 VOID
44 EFIAPI
DhFree(IN VOID * DhContext)45 DhFree (
46 IN VOID *DhContext
47 )
48 {
49 ASSERT (FALSE);
50 }
51
52 /**
53 Generates DH parameter.
54
55 Return FALSE to indicate this interface is not supported.
56
57 @param[in, out] DhContext Pointer to the DH context.
58 @param[in] Generator Value of generator.
59 @param[in] PrimeLength Length in bits of prime to be generated.
60 @param[out] Prime Pointer to the buffer to receive the generated prime number.
61
62 @retval FALSE This interface is not supported.
63
64 **/
65 BOOLEAN
66 EFIAPI
DhGenerateParameter(IN OUT VOID * DhContext,IN UINTN Generator,IN UINTN PrimeLength,OUT UINT8 * Prime)67 DhGenerateParameter (
68 IN OUT VOID *DhContext,
69 IN UINTN Generator,
70 IN UINTN PrimeLength,
71 OUT UINT8 *Prime
72 )
73 {
74 ASSERT (FALSE);
75 return FALSE;
76 }
77
78 /**
79 Sets generator and prime parameters for DH.
80
81 Return FALSE to indicate this interface is not supported.
82
83 @param[in, out] DhContext Pointer to the DH context.
84 @param[in] Generator Value of generator.
85 @param[in] PrimeLength Length in bits of prime to be generated.
86 @param[in] Prime Pointer to the prime number.
87
88 @retval FALSE This interface is not supported.
89
90 **/
91 BOOLEAN
92 EFIAPI
DhSetParameter(IN OUT VOID * DhContext,IN UINTN Generator,IN UINTN PrimeLength,IN CONST UINT8 * Prime)93 DhSetParameter (
94 IN OUT VOID *DhContext,
95 IN UINTN Generator,
96 IN UINTN PrimeLength,
97 IN CONST UINT8 *Prime
98 )
99 {
100 ASSERT (FALSE);
101 return FALSE;
102 }
103
104 /**
105 Generates DH public key.
106
107 Return FALSE to indicate this interface is not supported.
108
109 @param[in, out] DhContext Pointer to the DH context.
110 @param[out] PublicKey Pointer to the buffer to receive generated public key.
111 @param[in, out] PublicKeySize On input, the size of PublicKey buffer in bytes.
112 On output, the size of data returned in PublicKey buffer in bytes.
113
114 @retval FALSE This interface is not supported.
115
116 **/
117 BOOLEAN
118 EFIAPI
DhGenerateKey(IN OUT VOID * DhContext,OUT UINT8 * PublicKey,IN OUT UINTN * PublicKeySize)119 DhGenerateKey (
120 IN OUT VOID *DhContext,
121 OUT UINT8 *PublicKey,
122 IN OUT UINTN *PublicKeySize
123 )
124 {
125 ASSERT (FALSE);
126 return FALSE;
127 }
128
129 /**
130 Computes exchanged common key.
131
132 Return FALSE to indicate this interface is not supported.
133
134 @param[in, out] DhContext Pointer to the DH context.
135 @param[in] PeerPublicKey Pointer to the peer's public key.
136 @param[in] PeerPublicKeySize Size of peer's public key in bytes.
137 @param[out] Key Pointer to the buffer to receive generated key.
138 @param[in, out] KeySize On input, the size of Key buffer in bytes.
139 On output, the size of data returned in Key buffer in bytes.
140
141 @retval FALSE This interface is not supported.
142
143 **/
144 BOOLEAN
145 EFIAPI
DhComputeKey(IN OUT VOID * DhContext,IN CONST UINT8 * PeerPublicKey,IN UINTN PeerPublicKeySize,OUT UINT8 * Key,IN OUT UINTN * KeySize)146 DhComputeKey (
147 IN OUT VOID *DhContext,
148 IN CONST UINT8 *PeerPublicKey,
149 IN UINTN PeerPublicKeySize,
150 OUT UINT8 *Key,
151 IN OUT UINTN *KeySize
152 )
153 {
154 ASSERT (FALSE);
155 return FALSE;
156 }
157