~/bend-docscommunity

tls12.bend checks

raw source on the hub · import element-tls13@0.1.0.0/tls12.bend as Tls12

7 imports
import Base
import element-crypto@0.1.0.0/suite.bend as Suite
import element-crypto@0.1.0.0/hmac.bend as Hmac
import element-crypto@0.1.0.0/sha256.bend as Sha256
import element-crypto@0.1.0.0/poly1305.bend as Poly
import element-crypto@0.1.0.0/gcm.bend as Gcm
import ./tls13.bend as T

Definitions

def is_suite source · line 19 · raw

@+s:U32 -> Bool

def is_gcm source · line 22 · raw

@+s:U32 -> Bool

def key_len source · line 25 · raw

@+s:U32 -> U32

def iv_len source · line 29 · raw

@+s:U32 -> U32

GCM's implicit nonce part is 4 bytes; ChaCha20's whole nonce is 12

def p_hash source · line 35 · raw

@n:Nat -> @+secret:List<&2, U32> -> @+seed:List<&2, U32> -> @+a:List<&2, U32> -> List<&2, U32>

P_SHA256: HMAC(secret, A(i) | seed) for A(i) = HMAC(secret, A(i-1)), A(0) = seed

def prf source · line 43 · raw

@+secret:List<&2, U32> -> @+label:String -> @+seed:List<&2, U32> -> @+n:U32 -> List<&2, U32>

def master_secret source · line 49 · raw

@ems:Bool -> @+pms:List<&2, U32> -> @+cr:List<&2, U32> -> @+sr:List<&2, U32> -> @+transcript:List<&2, U32> -> List<&2, U32>

8.1, or RFC 7627 4 when the server echoed extended_master_secret: the session hash covers every handshake message through ClientKeyExchange.

def key_block source · line 57 · raw

@+ms:List<&2, U32> -> @+cr:List<&2, U32> -> @+sr:List<&2, U32> -> @+suite:U32 -> List<&2, U32>

6.3: client key, server key, client IV, server IV (AEAD suites have no MAC keys)

def client_key source · line 62 · raw

@+kb:List<&2, U32> -> @+suite:U32 -> List<&2, U32>

def server_key source · line 65 · raw

@+kb:List<&2, U32> -> @+suite:U32 -> List<&2, U32>

def client_iv source · line 68 · raw

@+kb:List<&2, U32> -> @+suite:U32 -> List<&2, U32>

def server_iv source · line 72 · raw

@+kb:List<&2, U32> -> @+suite:U32 -> List<&2, U32>

def verify_data source · line 78 · raw

@+ms:List<&2, U32> -> @+label:String -> @+transcript:List<&2, U32> -> List<&2, U32>

7.4.9: Finished is PRF(master, label, Hash(handshake messages))[0..12]

def entries source · line 84 · raw

@fuel:Nat -> @+bs:List<&2, U32> -> List<&2, List<&2, U32>>

7.4.2: certificate_list<0..2^24-1> of ASN.1Cert<1..2^24-1>, leaf first

def cert_ders source · line 93 · raw

@+m:List<&2, U32> -> List<&2, List<&2, U32>>

def ske_curve source · line 99 · raw

@+m:List<&2, U32> -> U32

ServerKeyExchange for ECDHE (RFC 8422 5.4): curve_type 3 (named_curve), the curve, the public point<1..255>, then the signature scheme and the signature<0..2^16-1>. Offsets are into the whole message (4-byte header).

def ske_named source · line 102 · raw

@+m:List<&2, U32> -> Bool

def ske_group_ok source · line 107 · raw

@+m:List<&2, U32> -> Bool

x25519 (29) with a 32-byte key, or secp256r1 (23) with a 65-byte uncompressed point; the point itself is checked when it is used.

def ske_public source · line 112 · raw

@+m:List<&2, U32> -> List<&2, U32>

def ske_params source · line 115 · raw

@+m:List<&2, U32> -> List<&2, U32>

def ske_sig_at source · line 118 · raw

@+m:List<&2, U32> -> U32

def ske_scheme source · line 121 · raw

@+m:List<&2, U32> -> U32

def ske_sig source · line 124 · raw

@+m:List<&2, U32> -> List<&2, U32>

def ske_signed source · line 129 · raw

@+cr:List<&2, U32> -> @+sr:List<&2, U32> -> @+m:List<&2, U32> -> List<&2, U32>

what the server signed: client_random | server_random | params

def client_key_exchange source · line 133 · raw

@+pub:List<&2, U32> -> List<&2, U32>

ClientKeyExchange (RFC 8422 5.7): the client's public point<1..255>

def downgraded source · line 138 · raw

@+sr:List<&2, U32> -> Bool

RFC 8446 4.1.3: a TLS 1.3 client that is answered with TLS 1.2 must check that the server random does not end in "DOWNGRD" 01 (a downgrade attack).

def seq64 source · line 143 · raw

@+seq:U32 -> List<&2, U32>

def aad source · line 147 · raw

@+seq:U32 -> @+typ:U32 -> @+n:U32 -> List<&2, U32>

additional_data = seq_num | type | version | length (of the plaintext)

def seal_go source · line 150 · raw

@gcm:Bool -> @+key:List<&2, U32> -> @+iv:List<&2, U32> -> @+seq:U32 -> @+typ:U32 -> @+content:List<&2, U32> -> List<&2, U32>

def protect source · line 159 · raw

@+key:List<&2, U32> -> @+iv:List<&2, U32> -> @+seq:U32 -> @+typ:U32 -> @+content:List<&2, U32> -> List<&2, U32>

A whole protected record of type typ (the type stays visible in 1.2).

def inner source · line 162 · raw

@+typ:U32 -> @m:Maybe<&2, List<&2, U32>> -> Maybe<&2, 0xb50db566077215d442e9798060f35e33/tls13.Inner>

def open_go source · line 169 · raw

@gcm:Bool -> @+key:List<&2, U32> -> @+iv:List<&2, U32> -> @+seq:U32 -> @+typ:U32 -> @+body:List<&2, U32> -> Maybe<&2, List<&2, U32>>

def opened_if source · line 177 · raw

@long:Bool -> @gcm:Bool -> @+key:List<&2, U32> -> @+iv:List<&2, U32> -> @+seq:U32 -> @+typ:U32 -> @+body:List<&2, U32> -> Maybe<&2, List<&2, U32>>

def unprotect source · line 186 · raw

@+key:List<&2, U32> -> @+iv:List<&2, U32> -> @+seq:U32 -> @+typ:U32 -> @+body:List<&2, U32> -> Maybe<&2, 0xb50db566077215d442e9798060f35e33/tls13.Inner>

The fragment of a protected record (after its 5-byte header); None when it is too short or its tag does not verify.