]> git.proxmox.com Git - mirror_edk2.git/blame - CryptoPkg/Library/BaseCryptLibNull/Pk/CryptRsaBasicNull.c
CryptoPkg: add new X509 function definition.
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLibNull / Pk / CryptRsaBasicNull.c
CommitLineData
d95de082
SB
1/** @file\r
2 RSA Asymmetric Cipher Wrapper Null Implementation.\r
3\r
4 This file implements following APIs which provide basic capabilities for RSA:\r
5 1) RsaNew\r
6 2) RsaFree\r
7 3) RsaSetKey\r
8 4) RsaPkcs1Verify\r
9\r
10Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
11SPDX-License-Identifier: BSD-2-Clause-Patent\r
12\r
13**/\r
14\r
15#include "InternalCryptLib.h"\r
16\r
17/**\r
18 Allocates and initializes one RSA context for subsequent use.\r
19\r
20 @return Pointer to the RSA context that has been initialized.\r
21 If the allocations fails, RsaNew() returns NULL.\r
22\r
23**/\r
24VOID *\r
25EFIAPI\r
26RsaNew (\r
27 VOID\r
28 )\r
29{\r
30 //\r
31 // Allocates & Initializes RSA Context\r
32 //\r
33 ASSERT (FALSE);\r
34 return NULL;\r
35}\r
36\r
37/**\r
38 Release the specified RSA context.\r
39\r
40 @param[in] RsaContext Pointer to the RSA context to be released.\r
41\r
42**/\r
43VOID\r
44EFIAPI\r
45RsaFree (\r
46 IN VOID *RsaContext\r
47 )\r
48{\r
49 //\r
50 // Free RSA Context\r
51 //\r
52 ASSERT (FALSE);\r
53}\r
54\r
55/**\r
56 Sets the tag-designated key component into the established RSA context.\r
57\r
58 This function sets the tag-designated RSA key component into the established\r
59 RSA context from the user-specified non-negative integer (octet string format\r
60 represented in RSA PKCS#1).\r
61 If BigNumber is NULL, then the specified key component in RSA context is cleared.\r
62\r
63 If RsaContext is NULL, then return FALSE.\r
64\r
65 @param[in, out] RsaContext Pointer to RSA context being set.\r
66 @param[in] KeyTag Tag of RSA key component being set.\r
67 @param[in] BigNumber Pointer to octet integer buffer.\r
68 If NULL, then the specified key component in RSA\r
69 context is cleared.\r
70 @param[in] BnSize Size of big number buffer in bytes.\r
71 If BigNumber is NULL, then it is ignored.\r
72\r
73 @retval TRUE RSA key component was set successfully.\r
74 @retval FALSE Invalid RSA key component tag.\r
75\r
76**/\r
77BOOLEAN\r
78EFIAPI\r
79RsaSetKey (\r
80 IN OUT VOID *RsaContext,\r
81 IN RSA_KEY_TAG KeyTag,\r
82 IN CONST UINT8 *BigNumber,\r
83 IN UINTN BnSize\r
84 )\r
85{\r
86 ASSERT (FALSE);\r
87 return FALSE;\r
88}\r
89\r
90/**\r
91 Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in\r
92 RSA PKCS#1.\r
93\r
94 If RsaContext is NULL, then return FALSE.\r
95 If MessageHash is NULL, then return FALSE.\r
96 If Signature is NULL, then return FALSE.\r
97 If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.\r
98\r
99 @param[in] RsaContext Pointer to RSA context for signature verification.\r
100 @param[in] MessageHash Pointer to octet message hash to be checked.\r
101 @param[in] HashSize Size of the message hash in bytes.\r
102 @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.\r
103 @param[in] SigSize Size of signature in bytes.\r
104\r
105 @retval TRUE Valid signature encoded in PKCS1-v1_5.\r
106 @retval FALSE Invalid signature or invalid RSA context.\r
107\r
108**/\r
109BOOLEAN\r
110EFIAPI\r
111RsaPkcs1Verify (\r
112 IN VOID *RsaContext,\r
113 IN CONST UINT8 *MessageHash,\r
114 IN UINTN HashSize,\r
115 IN CONST UINT8 *Signature,\r
116 IN UINTN SigSize\r
117 )\r
118{\r
119 ASSERT (FALSE);\r
120 return FALSE;\r
121}\r