]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CryptoPkg/TlsLib: replace TlsGetCipherString() with TlsGetCipherMapping()
authorLaszlo Ersek <lersek@redhat.com>
Sun, 1 Apr 2018 10:53:23 +0000 (12:53 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Fri, 13 Apr 2018 12:06:14 +0000 (14:06 +0200)
In the following patches it will be useful if the IANA CipherId lookup
returns a pointer to the whole matching IANA-to-OpenSSL mapping structure,
not just the OpenSSL cipher suite name. Rename TLS_CIPHER_PAIR and
TlsGetCipherString() to TLS_CIPHER_MAPPING and TlsGetCipherMapping()
respectively, and make the function return a pointer to
TLS_CIPHER_MAPPING.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Qin Long <qin.long@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=915
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
CryptoPkg/Library/TlsLib/TlsConfig.c

index 2ffe58ad29a23f4389e80a01591db1c669278668..507489386b8e53c8289b1a7caaf65224f3b320e0 100644 (file)
@@ -24,13 +24,13 @@ typedef struct {
   // OpenSSL-used Cipher Suite String\r
   //\r
   CONST CHAR8                     *OpensslCipher;\r
-} TLS_CIPHER_PAIR;\r
+} TLS_CIPHER_MAPPING;\r
 \r
 //\r
 // The mapping table between IANA/IETF Cipher Suite definitions and\r
 // OpenSSL-used Cipher Suite name.\r
 //\r
-STATIC CONST TLS_CIPHER_PAIR TlsCipherMappingTable[] = {\r
+STATIC CONST TLS_CIPHER_MAPPING TlsCipherMappingTable[] = {\r
   { 0x0001, "NULL-MD5" },                 /// TLS_RSA_WITH_NULL_MD5\r
   { 0x0002, "NULL-SHA" },                 /// TLS_RSA_WITH_NULL_SHA\r
   { 0x0004, "RC4-MD5" },                  /// TLS_RSA_WITH_RC4_128_MD5\r
@@ -57,26 +57,26 @@ STATIC CONST TLS_CIPHER_PAIR TlsCipherMappingTable[] = {
 };\r
 \r
 /**\r
-  Gets the OpenSSL cipher suite string for the supplied IANA TLS cipher suite.\r
+  Gets the OpenSSL cipher suite mapping for the supplied IANA TLS cipher suite.\r
 \r
   @param[in]  CipherId    The supplied IANA TLS cipher suite ID.\r
 \r
-  @return  The corresponding OpenSSL cipher suite string if found,\r
+  @return  The corresponding OpenSSL cipher suite mapping if found,\r
            NULL otherwise.\r
 \r
 **/\r
 STATIC\r
-CONST CHAR8 *\r
-TlsGetCipherString (\r
+CONST TLS_CIPHER_MAPPING *\r
+TlsGetCipherMapping (\r
   IN     UINT16                   CipherId\r
   )\r
 {\r
-  CONST TLS_CIPHER_PAIR  *CipherEntry;\r
-  UINTN                  TableSize;\r
-  UINTN                  Index;\r
+  CONST TLS_CIPHER_MAPPING  *CipherEntry;\r
+  UINTN                     TableSize;\r
+  UINTN                     Index;\r
 \r
   CipherEntry = TlsCipherMappingTable;\r
-  TableSize = sizeof (TlsCipherMappingTable) / sizeof (TLS_CIPHER_PAIR);\r
+  TableSize = sizeof (TlsCipherMappingTable) / sizeof (TLS_CIPHER_MAPPING);\r
 \r
   //\r
   // Search Cipher Mapping Table for IANA-OpenSSL Cipher Translation\r
@@ -86,7 +86,7 @@ TlsGetCipherString (
     // Translate IANA cipher suite name to OpenSSL name.\r
     //\r
     if (CipherEntry->IanaCipher == CipherId) {\r
-      return CipherEntry->OpensslCipher;\r
+      return CipherEntry;\r
     }\r
   }\r
 \r
@@ -229,16 +229,18 @@ TlsSetCipherList (
   IN     UINTN                    CipherNum\r
   )\r
 {\r
-  TLS_CONNECTION  *TlsConn;\r
-  UINTN           Index;\r
-  CONST CHAR8     *MappingName;\r
-  CHAR8           CipherString[500];\r
+  TLS_CONNECTION           *TlsConn;\r
+  UINTN                    Index;\r
+  CONST TLS_CIPHER_MAPPING *Mapping;\r
+  CONST CHAR8              *MappingName;\r
+  CHAR8                    CipherString[500];\r
 \r
   TlsConn = (TLS_CONNECTION *) Tls;\r
   if (TlsConn == NULL || TlsConn->Ssl == NULL || CipherId == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  Mapping     = NULL;\r
   MappingName = NULL;\r
 \r
   memset (CipherString, 0, sizeof (CipherString));\r
@@ -247,10 +249,11 @@ TlsSetCipherList (
     //\r
     // Handling OpenSSL / RFC Cipher name mapping.\r
     //\r
-    MappingName = TlsGetCipherString (*(CipherId + Index));\r
-    if (MappingName == NULL) {\r
+    Mapping = TlsGetCipherMapping (*(CipherId + Index));\r
+    if (Mapping == NULL) {\r
       return EFI_UNSUPPORTED;\r
     }\r
+    MappingName = Mapping->OpensslCipher;\r
 \r
     if (Index != 0) {\r
       //\r