]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/RuntimeDxeIpfCryptLib.c
CryptoPkg/TlsLib: rewrite TlsSetCipherList()
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLibRuntimeCryptProtocol / RuntimeDxeIpfCryptLib.c
index 7f893b91df1771f9e81b650fb2e66b4717a4da82..9babc7e95252b00af965d70577625a297ae3f79a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of The runtime cryptographic library instance (for IPF).\r
 \r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -195,7 +195,7 @@ Sha256GetContextSize (
   Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for\r
   subsequent use.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to SHA-256 Context being initialized.\r
 \r
@@ -217,11 +217,34 @@ Sha256Init (
 }\r
 \r
 \r
+/**\r
+  Makes a copy of an existing SHA-256 context.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  Sha256Context     Pointer to SHA-256 context being copied.\r
+  @param[out] NewSha256Context  Pointer to new SHA-256 context.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Sha256Duplicate (\r
+  IN   CONST VOID  *Sha256Context,\r
+  OUT  VOID        *NewSha256Context\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+\r
 /**\r
   Performs SHA-256 digest on a data buffer of the specified length. This function can\r
   be called multiple times to compute the digest of long or discontinuous data streams.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to the SHA-256 context.\r
   @param[in]       Data           Pointer to the buffer containing the data to be hashed.\r
@@ -251,8 +274,8 @@ Sha256Update (
   Completes SHA-256 hash computation and retrieves the digest value into the specified\r
   memory. After this function has been called, the SHA-256 context cannot be used again.\r
 \r
-  If Sha256Context is NULL, then ASSERT().\r
-  If HashValue is NULL, then ASSERT().\r
+  If Sha256Context is NULL, then return FALSE.\r
+  If HashValue is NULL, then return FALSE.\r
 \r
   @param[in, out]  Sha256Context  Pointer to SHA-256 context\r
   @param[out]      HashValue      Pointer to a buffer that receives the SHA-256 digest\r
@@ -277,9 +300,9 @@ Sha256Final (
 }\r
 \r
 /**\r
-  Allocates and Initializes one RSA Context for subsequent use.\r
+  Allocates and initializes one RSA context for subsequent use.\r
 \r
-  @return  Pointer to the RSA Context that has been initialized.\r
+  @return  Pointer to the RSA context that has been initialized.\r
            If the allocations fails, RsaNew() returns NULL.\r
 \r
 **/\r
@@ -297,7 +320,7 @@ RsaNew (
 }\r
 \r
 /**\r
-  Release the specified RSA Context.\r
+  Release the specified RSA context.\r
 \r
   @param[in]  RsaContext  Pointer to the RSA context to be released.\r
 \r
@@ -316,54 +339,60 @@ RsaFree (
 }\r
 \r
 /**\r
-  Sets the tag-designated RSA key component into the established RSA context from\r
-  the user-specified nonnegative integer (octet string format represented in RSA\r
-  PKCS#1).\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 ASSERT().\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
-  @param[in]       BnLength    Length of big number buffer in bytes.\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
-  @return  TRUE   RSA key component was set successfully.\r
-  @return  FALSE  Invalid RSA key component tag.\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        BnLength\r
+  IN OUT  VOID         *RsaContext,\r
+  IN      RSA_KEY_TAG  KeyTag,\r
+  IN      CONST UINT8  *BigNumber,\r
+  IN      UINTN        BnSize\r
   )\r
 {\r
   if (!InternalIsCryptServiveAvailable ()) {\r
     return FALSE;\r
   }\r
 \r
-  return mCryptProtocol->RsaSetKey (RsaContext, KeyTag, BigNumber, BnLength);\r
+  return mCryptProtocol->RsaSetKey (RsaContext, KeyTag, BigNumber, BnSize);\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 ASSERT().\r
-  If MessageHash is NULL, then ASSERT().\r
-  If Signature is NULL, then ASSERT().\r
-  If HashLength is not equal to the size of MD5, SHA-1 or SHA-256 digest, then ASSERT().\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]  HashLength   Length of the message hash in bytes.\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]  SigLength    Length of signature in bytes.\r
+  @param[in]  SigSize      Size of signature in bytes.\r
 \r
-  @return  TRUE   Valid signature encoded in PKCS1-v1_5.\r
-  @return  FALSE  Invalid signature or invalid RSA context.\r
+  @retval  TRUE   Valid signature encoded in PKCS1-v1_5.\r
+  @retval  FALSE  Invalid signature or invalid RSA context.\r
 \r
 **/\r
 BOOLEAN\r
@@ -371,9 +400,9 @@ EFIAPI
 RsaPkcs1Verify (\r
   IN  VOID         *RsaContext,\r
   IN  CONST UINT8  *MessageHash,\r
-  IN  UINTN        HashLength,\r
-  IN  UINT8        *Signature,\r
-  IN  UINTN        SigLength\r
+  IN  UINTN        HashSize,\r
+  IN  CONST UINT8  *Signature,\r
+  IN  UINTN        SigSize\r
   )\r
 {\r
   if (!InternalIsCryptServiveAvailable ()) {\r
@@ -383,8 +412,8 @@ RsaPkcs1Verify (
   return mCryptProtocol->RsaPkcs1Verify (\r
                            RsaContext,\r
                            MessageHash,\r
-                           HashLength,\r
+                           HashSize,\r
                            Signature,\r
-                           SigLength\r
+                           SigSize\r
                            );\r
 }\r