src/HOL/Auth/TLS.thy
author paulson
Fri Jul 04 17:34:55 1997 +0200 (1997-07-04)
changeset 3500 0d8ad2f192d8
parent 3480 d59bbf053258
child 3506 a36e0a49d2cd
permissions -rw-r--r--
New constant "certificate"--just an abbreviation
paulson@3474
     1
(*  Title:      HOL/Auth/TLS
paulson@3474
     2
    ID:         $Id$
paulson@3474
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@3474
     4
    Copyright   1997  University of Cambridge
paulson@3474
     5
paulson@3474
     6
Inductive relation "tls" for the baby TLS (Transport Layer Security) protocol.
paulson@3474
     7
paulson@3474
     8
An RSA cryptosystem is assumed, and X.509v3 certificates are abstracted down
paulson@3474
     9
to the trivial form {A, publicKey(A)}privateKey(Server), where Server is a
paulson@3474
    10
global signing authority.
paulson@3474
    11
paulson@3474
    12
A is the client and B is the server, not to be confused with the constant
paulson@3474
    13
Server, who is in charge of all public keys.
paulson@3474
    14
paulson@3480
    15
The model assumes that no fraudulent certificates are present, but it does
paulson@3480
    16
assume that some private keys are lost to the spy.
paulson@3474
    17
paulson@3480
    18
Abstracted from "The TLS Protocol, Version 1.0" by Tim Dierks and Christopher
paulson@3480
    19
Allen, Transport Layer Security Working Group, 21 May 1997,
paulson@3480
    20
INTERNET-DRAFT draft-ietf-tls-protocol-03.txt
paulson@3500
    21
paulson@3500
    22
paulson@3500
    23
FOR CertVerify
paulson@3500
    24
;
paulson@3500
    25
	     Says A B {|certificate A (pubK A),
paulson@3500
    26
			 Crypt KB (Nonce M)|} : set evs
paulson@3500
    27
paulson@3474
    28
*)
paulson@3474
    29
paulson@3474
    30
TLS = Public + 
paulson@3474
    31
paulson@3474
    32
consts
paulson@3474
    33
  (*Client, server write keys.  They implicitly include the MAC secrets.*)
paulson@3474
    34
  clientK, serverK :: "nat*nat*nat => key"
paulson@3500
    35
  certificate      :: "[agent,key] => msg"
paulson@3500
    36
paulson@3500
    37
defs
paulson@3500
    38
  certificate_def
paulson@3500
    39
    "certificate A KA == Crypt (priK Server) {|Agent A, Key KA|}"
paulson@3474
    40
paulson@3474
    41
rules
paulson@3474
    42
  (*clientK is collision-free and makes symmetric keys*)
paulson@3474
    43
  inj_clientK   "inj clientK"	
paulson@3474
    44
  isSym_clientK "isSymKey (clientK x)"	(*client write keys are symmetric*)
paulson@3474
    45
paulson@3480
    46
  (*serverK is similar*)
paulson@3474
    47
  inj_serverK   "inj serverK"	
paulson@3474
    48
  isSym_serverK "isSymKey (serverK x)"	(*server write keys are symmetric*)
paulson@3474
    49
paulson@3480
    50
  (*Clashes with pubK and priK are impossible, but this axiom is needed.*)
paulson@3480
    51
  clientK_range "range clientK <= Compl (range serverK)"
paulson@3480
    52
paulson@3474
    53
  (*Spy has access to his own key for spoof messages, but Server is secure*)
paulson@3474
    54
  Spy_in_lost     "Spy: lost"
paulson@3474
    55
  Server_not_lost "Server ~: lost"
paulson@3474
    56
paulson@3474
    57
paulson@3474
    58
consts  lost :: agent set        (*No need for it to be a variable*)
paulson@3474
    59
	tls  :: event list set
paulson@3474
    60
paulson@3474
    61
inductive tls
paulson@3474
    62
  intrs 
paulson@3474
    63
    Nil  (*Initial trace is empty*)
paulson@3474
    64
         "[]: tls"
paulson@3474
    65
paulson@3474
    66
    Fake (*The spy, an active attacker, MAY say anything he CAN say.*)
paulson@3474
    67
         "[| evs: tls;  B ~= Spy;  
paulson@3474
    68
             X: synth (analz (sees lost Spy evs)) |]
paulson@3480
    69
          ==> Says Spy B X # evs : tls"
paulson@3480
    70
paulson@3480
    71
    SpyKeys (*The spy may apply clientK & serverK to nonces he's found*)
paulson@3480
    72
         "[| evs: tls;
paulson@3480
    73
	     Says Spy B {|Nonce NA, Nonce NB, Nonce M|} : set evs |]
paulson@3480
    74
          ==> Says Spy B {| Key (clientK(NA,NB,M)),
paulson@3480
    75
			    Key (serverK(NA,NB,M)) |} # evs : tls"
paulson@3474
    76
paulson@3474
    77
    ClientHello
paulson@3474
    78
	 (*XA represents CLIENT_VERSION, CIPHER_SUITES and COMPRESSION_METHODS.
paulson@3474
    79
	   It is uninterpreted but will be confirmed in the FINISHED messages.
paulson@3474
    80
	   As an initial simplification, SESSION_ID is identified with NA
paulson@3474
    81
           and reuse of sessions is not supported.*)
paulson@3474
    82
         "[| evs: tls;  A ~= B;  Nonce NA ~: used evs |]
paulson@3474
    83
          ==> Says A B {|Agent A, Nonce NA, Agent XA|} # evs  :  tls"
paulson@3474
    84
paulson@3474
    85
    ServerHello
paulson@3474
    86
         (*XB represents CLIENT_VERSION, CIPHER_SUITE and COMPRESSION_METHOD.
paulson@3474
    87
	   Na is returned in its role as SESSION_ID.  A CERTIFICATE_REQUEST is
paulson@3474
    88
	   implied and a SERVER CERTIFICATE is always present.*)
paulson@3474
    89
         "[| evs: tls;  A ~= B;  Nonce NB ~: used evs;
paulson@3474
    90
             Says A' B {|Agent A, Nonce NA, Agent XA|} : set evs |]
paulson@3474
    91
          ==> Says B A {|Nonce NA, Nonce NB, Agent XB,
paulson@3500
    92
			 certificate B (pubK B)|}
paulson@3474
    93
                # evs  :  tls"
paulson@3474
    94
paulson@3474
    95
    ClientCertKeyEx
paulson@3474
    96
         (*CLIENT CERTIFICATE and KEY EXCHANGE.  M is the pre-master-secret.
paulson@3474
    97
           Note that A encrypts using the supplied KB, not pubK B.*)
paulson@3474
    98
         "[| evs: tls;  A ~= B;  Nonce M ~: used evs;
paulson@3474
    99
             Says B' A {|Nonce NA, Nonce NB, Agent XB,
paulson@3500
   100
			 certificate B KB|} : set evs |]
paulson@3500
   101
          ==> Says A B {|certificate A (pubK A),
paulson@3474
   102
			 Crypt KB (Nonce M)|}
paulson@3474
   103
                # evs  :  tls"
paulson@3474
   104
paulson@3474
   105
    CertVerify
paulson@3474
   106
	(*The optional CERTIFICATE VERIFY message contains the specific
paulson@3474
   107
          components listed in the security analysis, Appendix F.1.1.2.
paulson@3474
   108
          By checking the signature, B is assured of A's existence:
paulson@3474
   109
          the only use of A's certificate.*)
paulson@3474
   110
         "[| evs: tls;  A ~= B;  
paulson@3474
   111
             Says B' A {|Nonce NA, Nonce NB, Agent XB,
paulson@3500
   112
			 certificate B KB|} : set evs |]
paulson@3474
   113
          ==> Says A B (Crypt (priK A)
paulson@3474
   114
			(Hash{|Nonce NB,
paulson@3500
   115
	 		       certificate B KB|}))
paulson@3474
   116
                # evs  :  tls"
paulson@3474
   117
paulson@3474
   118
	(*Finally come the FINISHED messages, confirming XA and XB among
paulson@3474
   119
          other things.  The master-secret is the hash of NA, NB and M.
paulson@3474
   120
          Either party may sent its message first.*)
paulson@3474
   121
paulson@3474
   122
    ClientFinished
paulson@3474
   123
         "[| evs: tls;  A ~= B;
paulson@3474
   124
	     Says A  B {|Agent A, Nonce NA, Agent XA|} : set evs;
paulson@3474
   125
             Says B' A {|Nonce NA, Nonce NB, Agent XB, 
paulson@3500
   126
			 certificate B KB|} : set evs;
paulson@3500
   127
             Says A  B {|certificate A (pubK A),
paulson@3474
   128
		         Crypt KB (Nonce M)|} : set evs |]
paulson@3474
   129
          ==> Says A B (Crypt (clientK(NA,NB,M))
paulson@3474
   130
			(Hash{|Hash{|Nonce NA, Nonce NB, Nonce M|},
paulson@3474
   131
			       Nonce NA, Agent XA,
paulson@3500
   132
			       certificate A (pubK A), 
paulson@3474
   133
			       Nonce NB, Agent XB, Agent B|}))
paulson@3474
   134
                # evs  :  tls"
paulson@3474
   135
paulson@3474
   136
	(*Keeping A' and A'' distinct means B cannot even check that the
paulson@3474
   137
          two messages originate from the same source.*)
paulson@3474
   138
paulson@3474
   139
    ServerFinished
paulson@3474
   140
         "[| evs: tls;  A ~= B;
paulson@3474
   141
	     Says A' B  {|Agent A, Nonce NA, Agent XA|} : set evs;
paulson@3474
   142
	     Says B  A  {|Nonce NA, Nonce NB, Agent XB,
paulson@3500
   143
		 	  certificate B (pubK B)|}
paulson@3474
   144
	       : set evs;
paulson@3474
   145
	     Says A'' B {|CERTA, Crypt (pubK B) (Nonce M)|} : set evs |]
paulson@3474
   146
          ==> Says B A (Crypt (serverK(NA,NB,M))
paulson@3474
   147
			(Hash{|Hash{|Nonce NA, Nonce NB, Nonce M|},
paulson@3474
   148
			       Nonce NA, Agent XA, Agent A, 
paulson@3474
   149
			       Nonce NB, Agent XB,
paulson@3500
   150
			       certificate B (pubK B)|}))
paulson@3474
   151
                # evs  :  tls"
paulson@3474
   152
paulson@3474
   153
  (**Oops message??**)
paulson@3474
   154
paulson@3474
   155
end