]> git.proxmox.com Git - mirror_edk2.git/commit - CryptoPkg/Library/TlsLib/InternalTlsLib.h
CryptoPkg/TlsLib: rewrite TlsSetCipherList()
authorLaszlo Ersek <lersek@redhat.com>
Sat, 31 Mar 2018 15:33:14 +0000 (17:33 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Fri, 13 Apr 2018 12:06:24 +0000 (14:06 +0200)
commit2167c7f7a55b9964912d08aae71879357101ace1
tree9c2f2697795781f4b5ccf844b7fbbfd35233dfce
parenta347b0897384a2af6605bdd19a7740972b73f1e7
CryptoPkg/TlsLib: rewrite TlsSetCipherList()

Rewrite the TlsSetCipherList() function in order to fix the following
issues:

- Any cipher identifier in CipherId that is not recognized by
  TlsGetCipherMapping() will cause the function to return EFI_UNSUPPORTED.

  This is a problem because CipherId is an ordered preference list, and a
  caller should not get EFI_UNSUPPORTED just because it has an elaborate
  CipherId preference list. Instead, we can filter out cipher identifiers
  that we don't recognize, as long as we keep the relative order intact.

- CipherString is allocated on the stack, with 500 bytes.

  While processing a large CipherId preference list, this room may not be
  enough. Although no buffer overflow is possible, CipherString exhaustion
  can lead to a failed TLS connection, because any cipher names that don't
  fit on CipherString cannot be negotiated.

  Compute CipherStringSize first, and allocate CipherString dynamically.

- Finally, the "@STRENGTH" pseudo cipher name is appended to CipherString.
  (Assuming there is enough room left in CipherString.) This causes
  OpenSSL to sort the cipher list "in order of encryption algorithm key
  length".

  This is a bad idea. The caller specifically passes an ordered preference
  list in CipherId. Therefore TlsSetCipherList() must not ask OpenSSL to
  reorder the list, for any reason. Drop "@STRENGTH".

While at it, fix and unify the documentation of the CipherId parameter.

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/Include/Library/TlsLib.h
CryptoPkg/Library/TlsLib/InternalTlsLib.h
CryptoPkg/Library/TlsLib/TlsConfig.c
CryptoPkg/Library/TlsLib/TlsLib.inf