]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLibNull/Pk/CryptRsaBasicNull.c
CryptoPkg: Add Null instance of the BaseCryptLib class
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLibNull / Pk / CryptRsaBasicNull.c
diff --git a/CryptoPkg/Library/BaseCryptLibNull/Pk/CryptRsaBasicNull.c b/CryptoPkg/Library/BaseCryptLibNull/Pk/CryptRsaBasicNull.c
new file mode 100644 (file)
index 0000000..fd352e3
--- /dev/null
@@ -0,0 +1,121 @@
+/** @file\r
+  RSA Asymmetric Cipher Wrapper Null Implementation.\r
+\r
+  This file implements following APIs which provide basic capabilities for RSA:\r
+  1) RsaNew\r
+  2) RsaFree\r
+  3) RsaSetKey\r
+  4) RsaPkcs1Verify\r
+\r
+Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Allocates and initializes one RSA context for subsequent use.\r
+\r
+  @return  Pointer to the RSA context that has been initialized.\r
+           If the allocations fails, RsaNew() returns NULL.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+RsaNew (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Allocates & Initializes RSA Context\r
+  //\r
+  ASSERT (FALSE);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Release the specified RSA context.\r
+\r
+  @param[in]  RsaContext  Pointer to the RSA context to be released.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+RsaFree (\r
+  IN  VOID  *RsaContext\r
+  )\r
+{\r
+  //\r
+  // Free RSA Context\r
+  //\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Sets the tag-designated key component into the established RSA context.\r
+\r
+  This function sets the tag-designated RSA key component into the established\r
+  RSA context from the user-specified non-negative integer (octet string format\r
+  represented in RSA PKCS#1).\r
+  If BigNumber is NULL, then the specified key component in RSA context is cleared.\r
+\r
+  If RsaContext is NULL, then return FALSE.\r
+\r
+  @param[in, out]  RsaContext  Pointer to RSA context being set.\r
+  @param[in]       KeyTag      Tag of RSA key component being set.\r
+  @param[in]       BigNumber   Pointer to octet integer buffer.\r
+                               If NULL, then the specified key component in RSA\r
+                               context is cleared.\r
+  @param[in]       BnSize      Size of big number buffer in bytes.\r
+                               If BigNumber is NULL, then it is ignored.\r
+\r
+  @retval  TRUE   RSA key component was set successfully.\r
+  @retval  FALSE  Invalid RSA key component tag.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaSetKey (\r
+  IN OUT  VOID         *RsaContext,\r
+  IN      RSA_KEY_TAG  KeyTag,\r
+  IN      CONST UINT8  *BigNumber,\r
+  IN      UINTN        BnSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in\r
+  RSA PKCS#1.\r
+\r
+  If RsaContext is NULL, then return FALSE.\r
+  If MessageHash is NULL, then return FALSE.\r
+  If Signature is NULL, then return FALSE.\r
+  If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.\r
+\r
+  @param[in]  RsaContext   Pointer to RSA context for signature verification.\r
+  @param[in]  MessageHash  Pointer to octet message hash to be checked.\r
+  @param[in]  HashSize     Size of the message hash in bytes.\r
+  @param[in]  Signature    Pointer to RSA PKCS1-v1_5 signature to be verified.\r
+  @param[in]  SigSize      Size of signature in bytes.\r
+\r
+  @retval  TRUE   Valid signature encoded in PKCS1-v1_5.\r
+  @retval  FALSE  Invalid signature or invalid RSA context.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+RsaPkcs1Verify (\r
+  IN  VOID         *RsaContext,\r
+  IN  CONST UINT8  *MessageHash,\r
+  IN  UINTN        HashSize,\r
+  IN  CONST UINT8  *Signature,\r
+  IN  UINTN        SigSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r