/** @file\r
The implementation of dump policy entry function in IpSecConfig application.\r
\r
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2011, 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
)\r
{\r
UINTN Index;\r
+ Print (L"\"");\r
for (Index = 0; Index < Length; Index++) {\r
Print (L"%c", (CHAR16) Str[Index]);\r
}\r
+ Print (L"\"");\r
+}\r
+\r
+/**\r
+ Private function called to print a buffer in Hex format.\r
+\r
+ @param[in] Data The pointer to the buffer.\r
+ @param[in] Length The size of the buffer.\r
+\r
+**/\r
+VOID\r
+DumpBuf (\r
+ IN UINT8 *Data,\r
+ IN UINTN Length\r
+ )\r
+{\r
+ UINTN Index;\r
+ for (Index = 0; Index < Length; Index++) {\r
+ Print (L"%02x ", Data[Index]); \r
+ }\r
}\r
\r
/**\r
BOOLEAN HasPre;\r
CHAR16 *AuthAlgoStr;\r
CHAR16 *EncAlgoStr;\r
- CHAR8 *AuthKeyAsciiStr;\r
- CHAR8 *EncKeyAsciiStr;\r
\r
AuthAlgoStr = NULL;\r
EncAlgoStr = NULL;\r
- AuthKeyAsciiStr = NULL;\r
- EncKeyAsciiStr = NULL;\r
\r
//\r
// SPI:1234 ESP Destination:xxx.xxx.xxx.xxx\r
Print (L"TunnelSourceAddress:");\r
DumpIpAddress (&Data->TunnelSourceAddress);\r
Print (L"\n");\r
- Print (L"TunnelDestination:");\r
+ Print (L" TunnelDestination:");\r
DumpIpAddress (&Data->TunnelDestinationAddress);\r
Print (L"\n");\r
}\r
AuthAlgoStr = MapIntegerToString (Data->AlgoInfo.EspAlgoInfo.AuthAlgoId, mMapAuthAlgo);\r
EncAlgoStr = MapIntegerToString (Data->AlgoInfo.EspAlgoInfo.EncAlgoId, mMapEncAlgo);\r
\r
- AuthKeyAsciiStr = AllocateZeroPool (Data->AlgoInfo.EspAlgoInfo.AuthKeyLength + 1);\r
- ASSERT (AuthKeyAsciiStr != NULL);\r
- CopyMem (AuthKeyAsciiStr, Data->AlgoInfo.EspAlgoInfo.AuthKey, Data->AlgoInfo.EspAlgoInfo.AuthKeyLength);\r
- AuthKeyAsciiStr[Data->AlgoInfo.EspAlgoInfo.AuthKeyLength] = '\0';\r
-\r
- EncKeyAsciiStr = AllocateZeroPool (Data->AlgoInfo.EspAlgoInfo.EncKeyLength + 1);\r
- ASSERT (EncKeyAsciiStr != NULL) ;\r
- CopyMem (EncKeyAsciiStr, Data->AlgoInfo.EspAlgoInfo.EncKey, Data->AlgoInfo.EspAlgoInfo.EncKeyLength);\r
- EncKeyAsciiStr[Data->AlgoInfo.EspAlgoInfo.EncKeyLength] = '\0';\r
-\r
- Print (\r
- L" Auth:%s/%a Encrypt:%s/%a\n",\r
- AuthAlgoStr, \r
- AuthKeyAsciiStr,\r
- EncAlgoStr,\r
- EncKeyAsciiStr\r
- );\r
- \r
- FreePool (AuthKeyAsciiStr);\r
- FreePool (EncKeyAsciiStr);\r
+ if (Data->ManualSet) {\r
+ //\r
+ // if the SAD is set manually the key is a Ascii string in most of time.\r
+ // Print the Key in Ascii string format.\r
+ //\r
+ Print (L" Auth:%s/",AuthAlgoStr);\r
+ DumpAsciiString (\r
+ Data->AlgoInfo.EspAlgoInfo.AuthKey, \r
+ Data->AlgoInfo.EspAlgoInfo.AuthKeyLength\r
+ );\r
+ Print (L"\n Encrypt:%s/",EncAlgoStr);\r
+ DumpAsciiString (\r
+ Data->AlgoInfo.EspAlgoInfo.EncKey, \r
+ Data->AlgoInfo.EspAlgoInfo.EncKeyLength\r
+ );\r
+ } else {\r
+ //\r
+ // if the SAD is created by IKE, the key is a set of hex value in buffer.\r
+ // Print the Key in Hex format.\r
+ //\r
+ Print (L" Auth:%s/",AuthAlgoStr);\r
+ DumpBuf ((UINT8 *)(Data->AlgoInfo.EspAlgoInfo.AuthKey), Data->AlgoInfo.EspAlgoInfo.AuthKeyLength);\r
+ \r
+ Print (L"\n Encrypt:%s/",EncAlgoStr);\r
+ DumpBuf ((UINT8 *)(Data->AlgoInfo.EspAlgoInfo.EncKey), Data->AlgoInfo.EspAlgoInfo.EncKeyLength); \r
+ }\r
}\r
-\r
if (Data->SpdSelector != NULL) {\r
- Print (L" ");\r
+ Print (L"\n ");\r
DumpSpdSelector (Data->SpdSelector);\r
Print (L"\n");\r
}\r