]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/IpSecDxe/IpSecCryptIo.c
NetworkPkg: Clean up source files
[mirror_edk2.git] / NetworkPkg / IpSecDxe / IpSecCryptIo.c
index 31fa4fb447859407979102e3e48f8aa9c074a42f..e0e210bcadc81347560893be5655f9007bb1248f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Common interfaces to call Security library.\r
 \r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -19,7 +19,7 @@
 //\r
 GLOBAL_REMOVE_IF_UNREFERENCED ENCRYPT_ALGORITHM mIpsecEncryptAlgorithmList[IPSEC_ENCRYPT_ALGORITHM_LIST_SIZE] = {\r
   {IKE_EALG_NULL, 0, 0, 1, NULL, NULL, NULL, NULL},\r
-  {IKE_EALG_NONE, 0, 0, 1, NULL, NULL, NULL, NULL},  \r
+  {IKE_EALG_NONE, 0, 0, 1, NULL, NULL, NULL, NULL},\r
   {IKE_EALG_3DESCBC, 24, 8, 8, TdesGetContextSize, TdesInit, TdesCbcEncrypt, TdesCbcDecrypt},\r
   {IKE_EALG_AESCBC, 16, 16, 16, AesGetContextSize, AesInit, AesCbcEncrypt, AesCbcDecrypt}\r
 };\r
@@ -186,7 +186,7 @@ IpSecGenerateIv (
   if (IvSize != 0) {\r
     return IpSecCryptoIoGenerateRandomBytes (IvBuffer, IvSize);\r
   }\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -196,7 +196,7 @@ IpSecGenerateIv (
   @param[in]  AlgorithmId          The encryption algorithm ID.\r
 \r
   @return the index.\r
-  \r
+\r
 **/\r
 UINTN\r
 IpSecGetIndexFromEncList (\r
@@ -204,13 +204,13 @@ IpSecGetIndexFromEncList (
   )\r
 {\r
   UINT8 Index;\r
-  \r
+\r
   for (Index = 0; Index < IPSEC_ENCRYPT_ALGORITHM_LIST_SIZE; Index++) {\r
     if (AlgorithmId == mIpsecEncryptAlgorithmList[Index].AlgorithmId) {\r
       return Index;\r
     }\r
   }\r
-  \r
+\r
   return (UINTN) -1;\r
 }\r
 \r
@@ -220,7 +220,7 @@ IpSecGetIndexFromEncList (
   @param[in]  AlgorithmId          The encryption algorithm ID.\r
 \r
   @return the index.\r
-  \r
+\r
 **/\r
 UINTN\r
 IpSecGetIndexFromAuthList (\r
@@ -228,7 +228,7 @@ IpSecGetIndexFromAuthList (
   )\r
 {\r
   UINT8 Index;\r
-  \r
+\r
   for (Index = 0; Index < IPSEC_AUTH_ALGORITHM_LIST_SIZE; Index++) {\r
     if (AlgorithmId == mIpsecAuthAlgorithmList[Index].AlgorithmId) {\r
       //\r
@@ -237,7 +237,7 @@ IpSecGetIndexFromAuthList (
       return Index;\r
     }\r
   }\r
-  \r
+\r
   return (UINTN) -1;\r
 }\r
 \r
@@ -275,14 +275,14 @@ IpSecCryptoIoEncrypt (
   IN       UINTN      InDataLength,\r
      OUT   UINT8      *OutData\r
   )\r
-{  \r
+{\r
   UINTN         Index;\r
   UINTN         ContextSize;\r
   UINT8         *Context;\r
   EFI_STATUS    Status;\r
-  \r
+\r
   Status = EFI_UNSUPPORTED;\r
-  \r
+\r
   switch (AlgorithmId) {\r
 \r
   case IKE_EALG_NULL:\r
@@ -323,7 +323,7 @@ IpSecCryptoIoEncrypt (
   if (Context != NULL) {\r
     FreePool (Context);\r
   }\r
-  \r
+\r
   return Status;\r
 }\r
 \r
@@ -361,7 +361,7 @@ IpSecCryptoIoDecrypt (
   IN       UINTN      InDataLength,\r
      OUT   UINT8      *OutData\r
   )\r
-{  \r
+{\r
   UINTN         Index;\r
   UINTN         ContextSize;\r
   UINT8         *Context;\r
@@ -397,7 +397,7 @@ IpSecCryptoIoDecrypt (
     //\r
     if (mIpsecEncryptAlgorithmList[Index].CipherInitiate (Context, Key, KeyBits)) {\r
       if (mIpsecEncryptAlgorithmList[Index].CipherDecrypt (Context, InData, InDataLength, Ivec, OutData)) {\r
-        Status = EFI_SUCCESS;      \r
+        Status = EFI_SUCCESS;\r
       }\r
     }\r
     break;\r
@@ -420,7 +420,7 @@ IpSecCryptoIoDecrypt (
   the input algorithm ID. It computes all datas from InDataFragment and output\r
   the result into the OutData buffer. If the OutDataSize is larger than the related\r
   HMAC algorithm output size, return EFI_INVALID_PARAMETER.\r
-  \r
+\r
   @param[in]      AlgorithmId     The authentication Identification.\r
   @param[in]      Key             Pointer of the authentication key.\r
   @param[in]      KeyLength       The length of the Key in bytes.\r
@@ -519,8 +519,8 @@ IpSecCryptoIoHmac (
       }\r
 \r
       goto Exit;\r
-    }    \r
-      \r
+    }\r
+\r
   default:\r
     return Status;\r
   }\r
@@ -577,11 +577,11 @@ IpSecCryptoIoHash (
 \r
   Status      = EFI_UNSUPPORTED;\r
   OutHashData = NULL;\r
-  \r
+\r
   OutHashSize = IpSecGetHmacDigestLength (AlgorithmId);\r
   //\r
   // If the expected hash data size is larger than the related Hash algorithm\r
-  // output length, return EFI_INVALID_PARAMETER.  \r
+  // output length, return EFI_INVALID_PARAMETER.\r
   //\r
   if (OutDataSize > OutHashSize) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -590,7 +590,7 @@ IpSecCryptoIoHash (
   if (OutHashData == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
-  \r
+\r
   switch (AlgorithmId) {\r
 \r
   case IKE_AALG_NONE:\r
@@ -611,7 +611,7 @@ IpSecCryptoIoHash (
       Status = EFI_OUT_OF_RESOURCES;\r
       goto Exit;\r
     }\r
-    \r
+\r
     //\r
     // Initiate Hash context and hash the input data.\r
     //\r
@@ -631,13 +631,13 @@ IpSecCryptoIoHash (
         // In some cases, like the Icv computing, the Icv size might be less than\r
         // the key length size, so copy the part of hash data to the OutData.\r
         //\r
-        CopyMem (OutData, OutHashData, OutDataSize);            \r
+        CopyMem (OutData, OutHashData, OutDataSize);\r
         Status = EFI_SUCCESS;\r
       }\r
-      \r
-      goto Exit;        \r
-    }    \r
-    \r
+\r
+      goto Exit;\r
+    }\r
+\r
   default:\r
     return Status;\r
   }\r
@@ -685,10 +685,10 @@ IpSecCryptoIoDhGetPublicKey (
   IN CONST UINT8  *Prime,\r
      OUT   UINT8  *PublicKey,\r
   IN OUT   UINTN  *PublicKeySize\r
-  ) \r
+  )\r
 {\r
   EFI_STATUS   Status;\r
-  \r
+\r
   *DhContext = DhNew ();\r
   ASSERT (*DhContext != NULL);\r
   if (!DhSetParameter (*DhContext, Generator, PrimeLength, Prime)) {\r
@@ -707,7 +707,7 @@ Exit:
     DhFree (*DhContext);\r
     DhContext = NULL;\r
   }\r
-  \r
+\r
   return Status;\r
 }\r
 \r
@@ -731,7 +731,7 @@ Exit:
 **/\r
 EFI_STATUS\r
 IpSecCryptoIoDhComputeKey (\r
-  IN   OUT   UINT8  *DhContext,     \r
+  IN   OUT   UINT8  *DhContext,\r
   IN   CONST UINT8  *PeerPublicKey,\r
   IN         UINTN  PeerPublicKeySize,\r
        OUT   UINT8  *Key,\r
@@ -752,13 +752,13 @@ IpSecCryptoIoDhComputeKey (
 \r
   @retval EFI_SUCCESS              The operation performs successfully.\r
   @retval EFI_INVALID_PARAMETER    The DhContext is NULL.\r
-  \r
+\r
 **/\r
 EFI_STATUS\r
 IpSecCryptoIoFreeDh (\r
   IN   OUT   UINT8  **DhContext\r
   )\r
-{ \r
+{\r
   if (*DhContext == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -807,7 +807,7 @@ IpSecCryptoIoGenerateRandomBytes (
   @param[in]      KeyPwdSize      The size of Key Password in bytes.\r
   @param[out]     OutData         The pointer to the signed data.\r
   @param[in, out] OutDataSize     Pointer to contain the size of out data.\r
\r
+\r
 **/\r
 VOID\r
 IpSecCryptoIoAuthDataWithCertificate (\r
@@ -824,7 +824,7 @@ IpSecCryptoIoAuthDataWithCertificate (
   UINT8         *RsaContext;\r
   UINT8         *Signature;\r
   UINTN         SigSize;\r
-   \r
+\r
   SigSize   = 0;\r
   RsaContext = NULL;\r
 \r
@@ -844,12 +844,12 @@ IpSecCryptoIoAuthDataWithCertificate (
   //\r
   // Sign data\r
   //\r
-  Signature = NULL;  \r
+  Signature = NULL;\r
   if (!RsaPkcs1Sign (RsaContext, InData, InDataSize, Signature, &SigSize)) {\r
     Signature = AllocateZeroPool (SigSize);\r
   } else {\r
     return;\r
-  } \r
+  }\r
 \r
   RsaPkcs1Sign (RsaContext, InData, InDataSize, Signature, &SigSize);\r
 \r
@@ -876,7 +876,7 @@ IpSecCryptoIoAuthDataWithCertificate (
 \r
   @retval  TRUE   Valid signature encoded in PKCS1-v1_5.\r
   @retval  FALSE  Invalid signature or invalid RSA context.\r
\r
+\r
 **/\r
 BOOLEAN\r
 IpSecCryptoIoVerifySignDataByCertificate (\r
@@ -912,7 +912,7 @@ IpSecCryptoIoVerifySignDataByCertificate (
   // Retrieve the RSA public Key from Certificate\r
   //\r
   RsaGetPublicKeyFromX509 ((CONST UINT8 *)InCert, CertLen, (VOID **)&RsaContext);\r
\r
+\r
   //\r
   // Verify data\r
   //\r
@@ -964,9 +964,9 @@ IpSecCryptoIoGetPublicKeyFromCert (
   }\r
 \r
   *PublicKeyLen = 0;\r
\r
+\r
   RsaGetKey (RsaContext, RsaKeyN, NULL, PublicKeyLen);\r
\r
+\r
   *PublicKey = AllocateZeroPool (*PublicKeyLen);\r
   if (*PublicKey == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
@@ -992,10 +992,10 @@ EXIT:
   @param[in]     CertSize          The size of the X509 certificate in bytes.\r
   @param[out]    CertSubject       Pointer to the retrieved certificate subject.\r
   @param[out]    SubjectSize       The size of Certificate Subject in bytes.\r
-  \r
+\r
   @retval  EFI_SUCCESS            Retrieved the certificate subject successfully.\r
   @retval  EFI_INVALID_PARAMETER  The certificate is malformed.\r
\r
+\r
 **/\r
 EFI_STATUS\r
 IpSecCryptoIoGetSubjectFromCert (\r