NetworkPkg: Update Ipsecconfig Application to print the keys of SAD in concise way.
If the SAD is set manually, print its keys in Ascci string format. If the SAD is created by IKE, print its keys in Hex format. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11226 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
		| @@ -1,7 +1,7 @@ | |||||||
| /** @file | /** @file | ||||||
|   The implementation of dump policy entry function in IpSecConfig application. |   The implementation of dump policy entry function in IpSecConfig application. | ||||||
|  |  | ||||||
|   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR> |   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR> | ||||||
|  |  | ||||||
|   This program and the accompanying materials |   This program and the accompanying materials | ||||||
|   are licensed and made available under the terms and conditions of the BSD License |   are licensed and made available under the terms and conditions of the BSD License | ||||||
| @@ -70,9 +70,30 @@ DumpAsciiString ( | |||||||
|   ) |   ) | ||||||
| { | { | ||||||
|   UINTN    Index; |   UINTN    Index; | ||||||
|  |   Print (L"\""); | ||||||
|   for (Index = 0; Index < Length; Index++) { |   for (Index = 0; Index < Length; Index++) { | ||||||
|     Print (L"%c", (CHAR16) Str[Index]); |     Print (L"%c", (CHAR16) Str[Index]); | ||||||
|   } |   } | ||||||
|  |   Print (L"\""); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   Private function called to print a buffer in Hex format. | ||||||
|  |  | ||||||
|  |   @param[in] Data      The pointer to the buffer. | ||||||
|  |   @param[in] Length    The size of the buffer. | ||||||
|  |  | ||||||
|  | **/ | ||||||
|  | VOID | ||||||
|  | DumpBuf ( | ||||||
|  |   IN UINT8    *Data, | ||||||
|  |   IN UINTN    Length | ||||||
|  |   ) | ||||||
|  | { | ||||||
|  |   UINTN    Index; | ||||||
|  |   for (Index = 0; Index < Length; Index++) { | ||||||
|  |     Print (L"%02x ", Data[Index]);  | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -365,13 +386,9 @@ DumpSadEntry ( | |||||||
|   BOOLEAN    HasPre; |   BOOLEAN    HasPre; | ||||||
|   CHAR16     *AuthAlgoStr; |   CHAR16     *AuthAlgoStr; | ||||||
|   CHAR16     *EncAlgoStr; |   CHAR16     *EncAlgoStr; | ||||||
|   CHAR8      *AuthKeyAsciiStr; |  | ||||||
|   CHAR8      *EncKeyAsciiStr; |  | ||||||
|  |  | ||||||
|   AuthAlgoStr      = NULL; |   AuthAlgoStr      = NULL; | ||||||
|   EncAlgoStr       = NULL; |   EncAlgoStr       = NULL; | ||||||
|   AuthKeyAsciiStr  = NULL; |  | ||||||
|   EncKeyAsciiStr   = NULL; |  | ||||||
|  |  | ||||||
|   // |   // | ||||||
|   // SPI:1234 ESP Destination:xxx.xxx.xxx.xxx |   // SPI:1234 ESP Destination:xxx.xxx.xxx.xxx | ||||||
| @@ -433,30 +450,35 @@ DumpSadEntry ( | |||||||
|     AuthAlgoStr = MapIntegerToString (Data->AlgoInfo.EspAlgoInfo.AuthAlgoId, mMapAuthAlgo); |     AuthAlgoStr = MapIntegerToString (Data->AlgoInfo.EspAlgoInfo.AuthAlgoId, mMapAuthAlgo); | ||||||
|     EncAlgoStr  = MapIntegerToString (Data->AlgoInfo.EspAlgoInfo.EncAlgoId, mMapEncAlgo); |     EncAlgoStr  = MapIntegerToString (Data->AlgoInfo.EspAlgoInfo.EncAlgoId, mMapEncAlgo); | ||||||
|  |  | ||||||
|     AuthKeyAsciiStr    = AllocateZeroPool (Data->AlgoInfo.EspAlgoInfo.AuthKeyLength + 1); |     if (Data->ManualSet) { | ||||||
|     ASSERT (AuthKeyAsciiStr != NULL); |       // | ||||||
|     CopyMem (AuthKeyAsciiStr, Data->AlgoInfo.EspAlgoInfo.AuthKey, Data->AlgoInfo.EspAlgoInfo.AuthKeyLength); |       // if the SAD is set manually the key is a Ascii string in most of time. | ||||||
|     AuthKeyAsciiStr[Data->AlgoInfo.EspAlgoInfo.AuthKeyLength] = '\0'; |       // Print the Key in Ascii string format. | ||||||
|  |       // | ||||||
|     EncKeyAsciiStr  = AllocateZeroPool (Data->AlgoInfo.EspAlgoInfo.EncKeyLength + 1); |       Print (L"  Auth:%s/",AuthAlgoStr); | ||||||
|     ASSERT (EncKeyAsciiStr != NULL) ; |       DumpAsciiString ( | ||||||
|     CopyMem (EncKeyAsciiStr, Data->AlgoInfo.EspAlgoInfo.EncKey, Data->AlgoInfo.EspAlgoInfo.EncKeyLength); |         Data->AlgoInfo.EspAlgoInfo.AuthKey,  | ||||||
|     EncKeyAsciiStr[Data->AlgoInfo.EspAlgoInfo.EncKeyLength] = '\0'; |         Data->AlgoInfo.EspAlgoInfo.AuthKeyLength | ||||||
|  |  | ||||||
|     Print ( |  | ||||||
|       L"  Auth:%s/%a Encrypt:%s/%a\n", |  | ||||||
|       AuthAlgoStr,       |  | ||||||
|       AuthKeyAsciiStr, |  | ||||||
|       EncAlgoStr, |  | ||||||
|       EncKeyAsciiStr |  | ||||||
|         ); |         ); | ||||||
|  |       Print (L"\n  Encrypt:%s/",EncAlgoStr); | ||||||
|  |       DumpAsciiString ( | ||||||
|  |         Data->AlgoInfo.EspAlgoInfo.EncKey,  | ||||||
|  |         Data->AlgoInfo.EspAlgoInfo.EncKeyLength | ||||||
|  |         ); | ||||||
|  |     } else { | ||||||
|  |       // | ||||||
|  |       // if the SAD is created by IKE, the key is a set of hex value in buffer. | ||||||
|  |       // Print the Key in Hex format. | ||||||
|  |       // | ||||||
|  |       Print (L"  Auth:%s/",AuthAlgoStr); | ||||||
|  |       DumpBuf ((UINT8 *)(Data->AlgoInfo.EspAlgoInfo.AuthKey), Data->AlgoInfo.EspAlgoInfo.AuthKeyLength); | ||||||
|        |        | ||||||
|     FreePool (AuthKeyAsciiStr); |       Print (L"\n  Encrypt:%s/",EncAlgoStr); | ||||||
|     FreePool (EncKeyAsciiStr); |       DumpBuf ((UINT8 *)(Data->AlgoInfo.EspAlgoInfo.EncKey), Data->AlgoInfo.EspAlgoInfo.EncKeyLength);       | ||||||
|  |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   if (Data->SpdSelector != NULL) { |   if (Data->SpdSelector != NULL) { | ||||||
|     Print (L"  "); |     Print (L"\n  "); | ||||||
|     DumpSpdSelector (Data->SpdSelector); |     DumpSpdSelector (Data->SpdSelector); | ||||||
|     Print (L"\n"); |     Print (L"\n"); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| /** @file | /** @file | ||||||
|   The implementation of match policy entry function in IpSecConfig application. |   The implementation of match policy entry function in IpSecConfig application. | ||||||
|  |  | ||||||
|   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR> |   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR> | ||||||
|  |  | ||||||
|   This program and the accompanying materials |   This program and the accompanying materials | ||||||
|   are licensed and made available under the terms and conditions of the BSD License |   are licensed and made available under the terms and conditions of the BSD License | ||||||
| @@ -82,7 +82,7 @@ MatchSpdEntry ( | |||||||
|   Find the matching SAD with Indexer. |   Find the matching SAD with Indexer. | ||||||
|  |  | ||||||
|   @param[in] SaId       The pointer to the EFI_IPSEC_SA_ID structure. |   @param[in] SaId       The pointer to the EFI_IPSEC_SA_ID structure. | ||||||
|   @param[in] Data       The pointer to the EFI_IPSEC_SA_DATA structure. |   @param[in] Data       The pointer to the EFI_IPSEC_SA_DATA2 structure. | ||||||
|   @param[in] Indexer    The pointer to the SPD_ENTRY_INDEXER structure. |   @param[in] Indexer    The pointer to the SPD_ENTRY_INDEXER structure. | ||||||
|  |  | ||||||
|   @retval TRUE     The matched SAD is found. |   @retval TRUE     The matched SAD is found. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user