]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CryptoPkg/BaseCryptLib.h: Add PKCS1v2 (RSAES-OAEP) support.
authorBret Barkelew <Bret.Barkelew@microsoft.com>
Mon, 25 Mar 2019 04:01:12 +0000 (12:01 +0800)
committerJian J Wang <jian.j.wang@intel.com>
Thu, 18 Apr 2019 05:11:21 +0000 (13:11 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1403

Add prototype of new API Pkcs1v2Encrypt in header file to
support PKCS1v2 (RSAES-OAEP) encrypt.

Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Cc: Gang Wei <gang.wei@intel.com>
Cc: Wang Jian J <jian.j.wang@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
CryptoPkg/Include/Library/BaseCryptLib.h

index f9191f6e96d33d2e0c0a2d666e79fa992ca93f9c..84374b283b7aea9295cafc120da41f4b4e712f86 100644 (file)
@@ -4,7 +4,7 @@
   primitives (Hash Serials, HMAC, RSA, Diffie-Hellman, etc) for UEFI security\r
   functionality enabling.\r
 \r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -2405,6 +2405,48 @@ Pkcs5HashPassword (
   OUT UINT8        *OutKey\r
   );\r
 \r
+/**\r
+  Encrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the\r
+  encrypted message in a newly allocated buffer.\r
+\r
+  Things that can cause a failure include:\r
+  - X509 key size does not match any known key size.\r
+  - Fail to parse X509 certificate.\r
+  - Fail to allocate an intermediate buffer.\r
+  - Null pointer provided for a non-optional parameter.\r
+  - Data size is too large for the provided key size (max size is a function of key size\r
+    and hash digest size).\r
+\r
+  @param[in]  PublicKey           A pointer to the DER-encoded X509 certificate that\r
+                                  will be used to encrypt the data.\r
+  @param[in]  PublicKeySize       Size of the X509 cert buffer.\r
+  @param[in]  InData              Data to be encrypted.\r
+  @param[in]  InDataSize          Size of the data buffer.\r
+  @param[in]  PrngSeed            [Optional] If provided, a pointer to a random seed buffer\r
+                                  to be used when initializing the PRNG. NULL otherwise.\r
+  @param[in]  PrngSeedSize        [Optional] If provided, size of the random seed buffer.\r
+                                  0 otherwise.\r
+  @param[out] EncryptedData       Pointer to an allocated buffer containing the encrypted\r
+                                  message.\r
+  @param[out] EncryptedDataSize   Size of the encrypted message buffer.\r
+\r
+  @retval     TRUE                Encryption was successful.\r
+  @retval     FALSE               Encryption failed.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs1v2Encrypt (\r
+  IN   CONST UINT8  *PublicKey,\r
+  IN   UINTN        PublicKeySize,\r
+  IN   UINT8        *InData,\r
+  IN   UINTN        InDataSize,\r
+  IN   CONST UINT8  *PrngSeed,  OPTIONAL\r
+  IN   UINTN        PrngSeedSize,  OPTIONAL\r
+  OUT  UINT8        **EncryptedData,\r
+  OUT  UINTN        *EncryptedDataSize\r
+  );\r
+\r
 /**\r
   The 3rd parameter of Pkcs7GetSigners will return all embedded\r
   X.509 certificate in one given PKCS7 signature. The format is:\r