[edk2-devel] setting TLS ciphers is broken (openssl 3?)

Gerd Hoffmann kraxel at redhat.com
Thu Sep 28 14:25:58 UTC 2023


  Hi,

> > Test case: try http boot from https server, set ciphers on the qemu
> > command line using:
> >     -object tls-cipher-suites,id=tls-cipher0,priority=@SYSTEM
> >     -fw_cfg name=etc/edk2/https/ciphers,gen_id=tls-cipher0

> For a successful handshake, we need the intersection of the following
> sets not to be empty:
> 
> (1) the ciphers enabled in your system-wide crypto policy (likely
> DEFAULT)
> 
> (2) TlsCipherMappingTable [CryptoPkg/Library/TlsLib/TlsConfig.c]
> 
> (3) the ciphers supported by the openssl library linked into the
> firmware
> 
> (4) the ciphers supported by the HTTPS server

(1) + (4) should be the same (default system configuration).
The https server is standard python http module with ssl module
(see below).

> The OpenSSL3 update may have restricted set (3), causing the grand
> intersection to be empty.

That seems to be the case.  Maybe (2) needs an update to enable newer
ciphers, when logging the mappings I see there are quite a few IDs which
don't get mapped:

TlsDxe:TlsSetCipherList: skipping CipherId=0x1302
TlsDxe:TlsSetCipherList: skipping CipherId=0x1303
TlsDxe:TlsSetCipherList: skipping CipherId=0x1301
TlsDxe:TlsSetCipherList: skipping CipherId=0x1304
TlsDxe:TlsSetCipherList: CipherId=0xC030 -> ECDHE-RSA-AES256-GCM-SHA384
TlsDxe:TlsSetCipherList: skipping CipherId=0xCCA8
TlsDxe:TlsSetCipherList: skipping CipherId=0xC014
TlsDxe:TlsSetCipherList: skipping CipherId=0xC02F
TlsDxe:TlsSetCipherList: skipping CipherId=0xC013
TlsDxe:TlsSetCipherList: skipping CipherId=0xC012
TlsDxe:TlsSetCipherList: CipherId=0xC02C -> ECDHE-ECDSA-AES256-GCM-SHA384
TlsDxe:TlsSetCipherList: skipping CipherId=0xC0AD
TlsDxe:TlsSetCipherList: skipping CipherId=0xCCA9
TlsDxe:TlsSetCipherList: skipping CipherId=0xC00A
TlsDxe:TlsSetCipherList: CipherId=0xC02B -> ECDHE-ECDSA-AES128-GCM-SHA256
TlsDxe:TlsSetCipherList: skipping CipherId=0xC0AC
TlsDxe:TlsSetCipherList: skipping CipherId=0xC009
TlsDxe:TlsSetCipherList: skipping CipherId=0xC008
TlsDxe:TlsSetCipherList: skipping CipherId=0x009D
TlsDxe:TlsSetCipherList: skipping CipherId=0xC09D
TlsDxe:TlsSetCipherList: CipherId=0x0035 -> AES256-SHA
TlsDxe:TlsSetCipherList: skipping CipherId=0x009C
TlsDxe:TlsSetCipherList: skipping CipherId=0xC09C
TlsDxe:TlsSetCipherList: CipherId=0x002F -> AES128-SHA
TlsDxe:TlsSetCipherList: CipherId=0x000A -> DES-CBC3-SHA
TlsDxe:TlsSetCipherList: CipherId=0x009F -> DHE-RSA-AES256-GCM-SHA384
TlsDxe:TlsSetCipherList: skipping CipherId=0xC09F
TlsDxe:TlsSetCipherList: skipping CipherId=0xCCAA
TlsDxe:TlsSetCipherList: CipherId=0x0039 -> DHE-RSA-AES256-SHA
TlsDxe:TlsSetCipherList: skipping CipherId=0x009E
TlsDxe:TlsSetCipherList: skipping CipherId=0xC09E
TlsDxe:TlsSetCipherList: CipherId=0x0033 -> DHE-RSA-AES128-SHA
TlsDxe:TlsSetCipherList: CipherId=0x0016 -> DHE-RSA-DES-CBC3-SHA
TlsDxe:TlsSetCipherList: skipping CipherId=0x00A3
TlsDxe:TlsSetCipherList: skipping CipherId=0x0038
TlsDxe:TlsSetCipherList: skipping CipherId=0x00A2
TlsDxe:TlsSetCipherList: skipping CipherId=0x0032
TlsDxe:TlsSetCipherList: skipping CipherId=0x0013

> Can you perhaps relax your crypto policy -- i.e., widen set (1) -- to
> LEGACY with "update-crypto-policies", to see if that makes a difference?
> 
> (Or else, on the QEMU command line, use a different priority from
> @SYSTEM; but I'm not sure how that works.)

https://gnutls.org/manual/html_node/Priority-Strings.html

Tried @SYSTEM, DEFAULT and LEGACY, none of them work.

Not setting ciphers works.

take care,
  Gerd

----------------------------- cut here ---------------------------
#!/usr/bin/python
import os
import ssl
import socket
import optparse

from http.server import SimpleHTTPRequestHandler
try:
    from http.server import ThreadingHTTPServer as HTTPServer
except ImportError:
    from http.server import HTTPServer

class HTTPServerV6(HTTPServer):
    address_family = socket.AF_INET6

parser = optparse.OptionParser()
parser.add_option('-d', '--directory', dest = 'directory', type = 'string', default = '.',
                  help = 'server files from DIR', metavar = 'DIR')
parser.add_option('-p', '--port', dest = 'port', type = 'int', default = 8080,
                  help = 'bind to tcp port PORT', metavar = 'PORT')
parser.add_option('-b', '--bind', dest = 'bind', type = 'string', default ='',
                  help = 'bind to tcp addr ADDR', metavar = 'ADDR')
parser.add_option('--tls', dest = 'tls', action = 'store_true', default = False,
                  help = 'enable https mode')
parser.add_option('--cert', dest = 'certfile',
                  help = 'use tls certificate file CERT', metavar = 'CERT')
parser.add_option('--key', dest = 'keyfile',
                  help = 'use tls certificate key file KEY', metavar = 'KEY')
(options, args) = parser.parse_args()

print(f'config: dir="{options.directory}", addr="{options.bind}", port={options.port}, tls={options.tls}')
if options.tls:
    print(f'config: certfile="{options.certfile}", keyfile="{options.keyfile}"')

handler = SimpleHTTPRequestHandler
handler.protocol_version = "HTTP/1.1"
server = None
if ':' in options.bind:
    server = HTTPServerV6((options.bind, options.port), handler)
else:
    server = HTTPServer((options.bind, options.port), handler)
if options.tls:
    context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
    context.load_cert_chain(options.certfile, options.keyfile)
    server.socket = context.wrap_socket(server.socket,
                                        server_side = True)

os.chdir(options.directory)
server.serve_forever()



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109147): https://edk2.groups.io/g/devel/message/109147
Mute This Topic: https://groups.io/mt/101613778/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list