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