Skip to content

Commit c3902e6

Browse files
aglekr
authored andcommitted
Specify padding and context strings for signatures
The TLS 1.2 ServerKeyExchange signature never included enough context and it was possible to lift a signature for one ciphersuite into a handshake for a different one. TLS 1.2 only avoided signature repurposing attacks because of luck[1]. Additionally, TLS 1.2 allows an attacker to obtain a signature of a message with a chosen, 32-byte prefix. Because of this, this change causes TLS 1.3 to include 64 bytes of padding at the begining of signed messages in order to easily clear the chosen-prefix and also context strings to ensure that signatures cannot be repurposed. For more context, see https://www.ietf.org/mail-archive/web/tls/current/msg14734.html [1] https://www.cosic.esat.kuleuven.be/publications/article-2216.pdf
1 parent 1c897d5 commit c3902e6

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

draft-ietf-tls-tls13.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ draft-04
322322

323323
- Remove renegotiation.
324324

325+
- Update format of signatures with context.
326+
325327
draft-03
326328

327329
- Remove GMT time.
@@ -623,6 +625,20 @@ using those algorithms over the contents of the element. The contents
623625
themselves do not appear on the wire but are simply calculated. The length of
624626
the signature is specified by the signing algorithm and key.
625627

628+
In previous versions of TLS, the ServerKeyExchange format meant that attackers
629+
can obtain a signature of a message with a chosen, 32-byte prefix. Because TLS
630+
1.3 servers are likely to also implement prior versions, the contents of the
631+
element always start with 64 bytes of octet 32 in order to clear that
632+
chosen-prefix.
633+
634+
Following that padding is a NUL-terminated context string in order to
635+
disambiguate signatures for different purposes. The context string will be
636+
specified whenever a digitally-signed element is used.
637+
638+
Finally, the specified contents of the digitally-signed structure follow the
639+
NUL at the end of the context string. (See the example at the end of this
640+
section.)
641+
626642
In RSA signing, the opaque vector contains the signature generated using the
627643
RSASSA-PKCS1-v1_5 signature scheme defined in {{RFC3447}}. As discussed in
628644
{{RFC3447}}, the DigestInfo MUST be DER-encoded {{X680}} {{X690}}. For hash
@@ -679,8 +695,16 @@ In the following example
679695
};
680696
} UserType;
681697

682-
The contents of the inner struct (field3 and field4) are used as input for the
683-
signature/hash algorithm. The length of the structure, in bytes, would be equal to two
698+
Assume that the context string for the signature was specified as "Example".
699+
The input for the signature/hash algorithm would be:
700+
701+
2020202020202020202020202020202020202020202020202020202020202020
702+
2020202020202020202020202020202020202020202020202020202020202020
703+
4578616d706c6500
704+
705+
followed by the encoding of the inner struct (field3 and field4).
706+
707+
The length of the structure, in bytes, would be equal to two
684708
bytes for field1 and field2, plus two bytes for the signature and hash
685709
algorithm, plus two bytes for the length of the signature, plus the length of
686710
the output of the signing algorithm. The length of the signature is known
@@ -2569,6 +2593,8 @@ time of the CertificateVerify computation. Servers can minimize this
25692593
computation cost by offering a restricted set of digest algorithms in the
25702594
CertificateRequest message.
25712595

2596+
The context string for the signature is "TLS 1.3, server CertificateVerify".
2597+
25722598
>If the client has offered the "signature_algorithms" extension, the signature
25732599
algorithm and hash algorithm MUST be a pair listed in that extension. Note that
25742600
there is a possibility for inconsistencies here. For instance, the client might
@@ -3124,6 +3150,8 @@ This section describes protocol types and constants.
31243150
}
31253151
} CertificateVerify;
31263152

3153+
The context string for the signature is "TLS 1.3, client CertificateVerify".
3154+
31273155
### Handshake Finalization Message
31283156

31293157
struct {

0 commit comments

Comments
 (0)