Skip to content

Commit

Permalink
psk support in tls.py script on server side
Browse files Browse the repository at this point in the history
  • Loading branch information
tomato42 committed Mar 8, 2018
1 parent 57d97d2 commit 36edd15
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def printUsage(s=None):
server
[-k KEY] [-c CERT] [-t TACK] [-v VERIFIERDB] [-d DIR] [-l LABEL] [-L LENGTH]
[--reqcert] [--param DHFILE] HOST:PORT
[--reqcert] [--param DHFILE] [--psk PSK] [--psk-ident IDENTITY]
[--psk-sha384]
HOST:PORT
client
[-k KEY] [-c CERT] [-u USER] [-p PASS] [-l LABEL] [-L LENGTH] [-a ALPN]
Expand Down Expand Up @@ -345,8 +347,10 @@ def clientCmd(argv):

def serverCmd(argv):
(address, privateKey, certChain, tacks, verifierDB, directory, reqCert,
expLabel, expLength, dhparam) = handleArgs(argv, "kctbvdlL",
["reqcert", "param="])
expLabel, expLength, dhparam, psk, psk_ident, psk_hash) = \
handleArgs(argv, "kctbvdlL",
["reqcert", "param=", "psk=",
"psk-ident=", "psk-sha384"])


if (certChain and not privateKey) or (not certChain and privateKey):
Expand Down Expand Up @@ -391,6 +395,8 @@ def handshake(self, connection):
settings = HandshakeSettings()
settings.useExperimentalTackExtension=True
settings.dhParams = dhparam
if psk:
settings.pskConfigs = [(psk_ident, psk, psk_hash)]
connection.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY,
1)
connection.handshakeServer(certChain=certChain,
Expand Down

0 comments on commit 36edd15

Please sign in to comment.