]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/BaseCryptLibNull/Pk/CryptDhNull.c
CryptoPkg: Add Null instance of the BaseCryptLib class
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLibNull / Pk / CryptDhNull.c
1 /** @file
2 Diffie-Hellman Wrapper Implementation which does not provide
3 real capabilities.
4
5 Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include "InternalCryptLib.h"
11
12 /**
13 Allocates and Initializes one Diffie-Hellman Context for subsequent use.
14
15 @return Pointer to the Diffie-Hellman Context that has been initialized.
16 If the interface is not supported, DhNew() returns NULL.
17
18 **/
19 VOID *
20 EFIAPI
21 DhNew (
22 VOID
23 )
24 {
25 ASSERT (FALSE);
26 return NULL;
27 }
28
29 /**
30 Release the specified DH context.
31
32 If the interface is not supported, then ASSERT().
33
34 @param[in] DhContext Pointer to the DH context to be released.
35
36 **/
37 VOID
38 EFIAPI
39 DhFree (
40 IN VOID *DhContext
41 )
42 {
43 ASSERT (FALSE);
44 }
45
46 /**
47 Generates DH parameter.
48
49 Return FALSE to indicate this interface is not supported.
50
51 @param[in, out] DhContext Pointer to the DH context.
52 @param[in] Generator Value of generator.
53 @param[in] PrimeLength Length in bits of prime to be generated.
54 @param[out] Prime Pointer to the buffer to receive the generated prime number.
55
56 @retval FALSE This interface is not supported.
57
58 **/
59 BOOLEAN
60 EFIAPI
61 DhGenerateParameter (
62 IN OUT VOID *DhContext,
63 IN UINTN Generator,
64 IN UINTN PrimeLength,
65 OUT UINT8 *Prime
66 )
67 {
68 ASSERT (FALSE);
69 return FALSE;
70 }
71
72 /**
73 Sets generator and prime parameters for DH.
74
75 Return FALSE to indicate this interface is not supported.
76
77 @param[in, out] DhContext Pointer to the DH context.
78 @param[in] Generator Value of generator.
79 @param[in] PrimeLength Length in bits of prime to be generated.
80 @param[in] Prime Pointer to the prime number.
81
82 @retval FALSE This interface is not supported.
83
84 **/
85 BOOLEAN
86 EFIAPI
87 DhSetParameter (
88 IN OUT VOID *DhContext,
89 IN UINTN Generator,
90 IN UINTN PrimeLength,
91 IN CONST UINT8 *Prime
92 )
93 {
94 ASSERT (FALSE);
95 return FALSE;
96 }
97
98 /**
99 Generates DH public key.
100
101 Return FALSE to indicate this interface is not supported.
102
103 @param[in, out] DhContext Pointer to the DH context.
104 @param[out] PublicKey Pointer to the buffer to receive generated public key.
105 @param[in, out] PublicKeySize On input, the size of PublicKey buffer in bytes.
106 On output, the size of data returned in PublicKey buffer in bytes.
107
108 @retval FALSE This interface is not supported.
109
110 **/
111 BOOLEAN
112 EFIAPI
113 DhGenerateKey (
114 IN OUT VOID *DhContext,
115 OUT UINT8 *PublicKey,
116 IN OUT UINTN *PublicKeySize
117 )
118 {
119 ASSERT (FALSE);
120 return FALSE;
121 }
122
123 /**
124 Computes exchanged common key.
125
126 Return FALSE to indicate this interface is not supported.
127
128 @param[in, out] DhContext Pointer to the DH context.
129 @param[in] PeerPublicKey Pointer to the peer's public key.
130 @param[in] PeerPublicKeySize Size of peer's public key in bytes.
131 @param[out] Key Pointer to the buffer to receive generated key.
132 @param[in, out] KeySize On input, the size of Key buffer in bytes.
133 On output, the size of data returned in Key buffer in bytes.
134
135 @retval FALSE This interface is not supported.
136
137 **/
138 BOOLEAN
139 EFIAPI
140 DhComputeKey (
141 IN OUT VOID *DhContext,
142 IN CONST UINT8 *PeerPublicKey,
143 IN UINTN PeerPublicKeySize,
144 OUT UINT8 *Key,
145 IN OUT UINTN *KeySize
146 )
147 {
148 ASSERT (FALSE);
149 return FALSE;
150 }