src/HOL/SET_Protocol/Cardholder_Registration.thy
author wenzelm
Sat Jul 18 22:58:50 2015 +0200 (2015-07-18)
changeset 60758 d8d85a8172b5
parent 60754 02924903a6fd
child 61984 cdea44c775fa
permissions -rw-r--r--
isabelle update_cartouches;
wenzelm@33028
     1
(*  Title:      HOL/SET_Protocol/Cardholder_Registration.thy
wenzelm@32960
     2
    Author:     Giampaolo Bella
wenzelm@32960
     3
    Author:     Fabio Massacci
wenzelm@32960
     4
    Author:     Lawrence C Paulson
wenzelm@32960
     5
    Author:     Piero Tramontano
paulson@14199
     6
*)
paulson@14199
     7
wenzelm@58889
     8
section{*The SET Cardholder Registration Protocol*}
paulson@14199
     9
wenzelm@33028
    10
theory Cardholder_Registration
wenzelm@33028
    11
imports Public_SET
wenzelm@33028
    12
begin
paulson@14199
    13
paulson@14199
    14
text{*Note: nonces seem to consist of 20 bytes.  That includes both freshness
paulson@14199
    15
challenges (Chall-EE, etc.) and important secrets (CardSecret, PANsecret)
paulson@14199
    16
*}
paulson@14199
    17
paulson@14199
    18
text{*Simplifications involving @{text analz_image_keys_simps} appear to
paulson@14199
    19
have become much slower. The cause is unclear. However, there is a big blow-up
paulson@14199
    20
and the rewriting is very sensitive to the set of rewrite rules given.*}
paulson@14199
    21
paulson@14199
    22
subsection{*Predicate Formalizing the Encryption Association between Keys *}
paulson@14199
    23
haftmann@39758
    24
primrec KeyCryptKey :: "[key, key, event list] => bool"
haftmann@39758
    25
where
haftmann@39758
    26
  KeyCryptKey_Nil:
haftmann@39758
    27
    "KeyCryptKey DK K [] = False"
haftmann@39758
    28
| KeyCryptKey_Cons:
paulson@14199
    29
      --{*Says is the only important case.
wenzelm@32960
    30
        1st case: CR5, where KC3 encrypts KC2.
wenzelm@32960
    31
        2nd case: any use of priEK C.
wenzelm@32960
    32
        Revision 1.12 has a more complicated version with separate treatment of
wenzelm@32960
    33
          the dependency of KC1, KC2 and KC3 on priEK (CA i.)  Not needed since
wenzelm@32960
    34
          priEK C is never sent (and so can't be lost except at the start). *}
haftmann@39758
    35
    "KeyCryptKey DK K (ev # evs) =
haftmann@39758
    36
     (KeyCryptKey DK K evs |
haftmann@39758
    37
      (case ev of
haftmann@39758
    38
        Says A B Z =>
haftmann@39758
    39
         ((\<exists>N X Y. A \<noteq> Spy &
wenzelm@32960
    40
                 DK \<in> symKeys &
wenzelm@32960
    41
                 Z = {|Crypt DK {|Agent A, Nonce N, Key K, X|}, Y|}) |
haftmann@39758
    42
          (\<exists>C. DK = priEK C))
haftmann@39758
    43
      | Gets A' X => False
haftmann@39758
    44
      | Notes A' X => False))"
paulson@14199
    45
paulson@14199
    46
paulson@14199
    47
subsection{*Predicate formalizing the association between keys and nonces *}
paulson@14199
    48
haftmann@39758
    49
primrec KeyCryptNonce :: "[key, key, event list] => bool"
haftmann@39758
    50
where
haftmann@39758
    51
  KeyCryptNonce_Nil:
haftmann@39758
    52
    "KeyCryptNonce EK K [] = False"
haftmann@39758
    53
| KeyCryptNonce_Cons:
paulson@14199
    54
  --{*Says is the only important case.
paulson@14199
    55
    1st case: CR3, where KC1 encrypts NC2 (distinct from CR5 due to EXH);
paulson@14199
    56
    2nd case: CR5, where KC3 encrypts NC3;
paulson@14199
    57
    3rd case: CR6, where KC2 encrypts NC3;
paulson@14199
    58
    4th case: CR6, where KC2 encrypts NonceCCA;
paulson@14199
    59
    5th case: any use of @{term "priEK C"} (including CardSecret).
paulson@14199
    60
    NB the only Nonces we need to keep secret are CardSecret and NonceCCA.
paulson@14199
    61
    But we can't prove @{text Nonce_compromise} unless the relation covers ALL
wenzelm@32960
    62
        nonces that the protocol keeps secret.
paulson@14199
    63
  *}
paulson@14199
    64
  "KeyCryptNonce DK N (ev # evs) =
paulson@14199
    65
   (KeyCryptNonce DK N evs |
paulson@14199
    66
    (case ev of
paulson@14199
    67
      Says A B Z =>
paulson@14199
    68
       A \<noteq> Spy &
paulson@14199
    69
       ((\<exists>X Y. DK \<in> symKeys &
wenzelm@32960
    70
               Z = (EXHcrypt DK X {|Agent A, Nonce N|} Y)) |
wenzelm@32960
    71
        (\<exists>X Y. DK \<in> symKeys &
wenzelm@32960
    72
               Z = {|Crypt DK {|Agent A, Nonce N, X|}, Y|}) |
wenzelm@32960
    73
        (\<exists>K i X Y.
wenzelm@32960
    74
          K \<in> symKeys &
paulson@14199
    75
          Z = Crypt K {|sign (priSK (CA i)) {|Agent B, Nonce N, X|}, Y|} &
wenzelm@32960
    76
          (DK=K | KeyCryptKey DK K evs)) |
wenzelm@32960
    77
        (\<exists>K C NC3 Y.
wenzelm@32960
    78
          K \<in> symKeys &
paulson@14199
    79
          Z = Crypt K
wenzelm@32960
    80
                {|sign (priSK C) {|Agent B, Nonce NC3, Agent C, Nonce N|},
paulson@14199
    81
                  Y|} &
wenzelm@32960
    82
          (DK=K | KeyCryptKey DK K evs)) |
wenzelm@32960
    83
        (\<exists>C. DK = priEK C))
paulson@14199
    84
    | Gets A' X => False
paulson@14199
    85
    | Notes A' X => False))"
paulson@14199
    86
paulson@14199
    87
paulson@14199
    88
subsection{*Formal protocol definition *}
paulson@14199
    89
berghofe@23755
    90
inductive_set
berghofe@23755
    91
  set_cr :: "event list set"
berghofe@23755
    92
where
paulson@14199
    93
paulson@14199
    94
  Nil:    --{*Initial trace is empty*}
wenzelm@32960
    95
          "[] \<in> set_cr"
paulson@14199
    96
berghofe@23755
    97
| Fake:    --{*The spy MAY say anything he CAN say.*}
wenzelm@32960
    98
           "[| evsf \<in> set_cr; X \<in> synth (analz (knows Spy evsf)) |]
wenzelm@32960
    99
            ==> Says Spy B X  # evsf \<in> set_cr"
paulson@14199
   100
berghofe@23755
   101
| Reception: --{*If A sends a message X to B, then B might receive it*}
wenzelm@32960
   102
             "[| evsr \<in> set_cr; Says A B X \<in> set evsr |]
paulson@14199
   103
              ==> Gets B X  # evsr \<in> set_cr"
paulson@14199
   104
berghofe@23755
   105
| SET_CR1: --{*CardCInitReq: C initiates a run, sending a nonce to CCA*}
wenzelm@32960
   106
             "[| evs1 \<in> set_cr;  C = Cardholder k;  Nonce NC1 \<notin> used evs1 |]
wenzelm@32960
   107
              ==> Says C (CA i) {|Agent C, Nonce NC1|} # evs1 \<in> set_cr"
paulson@14199
   108
berghofe@23755
   109
| SET_CR2: --{*CardCInitRes: CA responds sending NC1 and its certificates*}
wenzelm@32960
   110
             "[| evs2 \<in> set_cr;
wenzelm@32960
   111
                 Gets (CA i) {|Agent C, Nonce NC1|} \<in> set evs2 |]
wenzelm@32960
   112
              ==> Says (CA i) C
wenzelm@32960
   113
                       {|sign (priSK (CA i)) {|Agent C, Nonce NC1|},
wenzelm@32960
   114
                         cert (CA i) (pubEK (CA i)) onlyEnc (priSK RCA),
wenzelm@32960
   115
                         cert (CA i) (pubSK (CA i)) onlySig (priSK RCA)|}
wenzelm@32960
   116
                    # evs2 \<in> set_cr"
paulson@14199
   117
berghofe@23755
   118
| SET_CR3:
paulson@14199
   119
   --{*RegFormReq: C sends his PAN and a new nonce to CA.
paulson@14199
   120
   C verifies that
paulson@14199
   121
    - nonce received is the same as that sent;
paulson@14199
   122
    - certificates are signed by RCA;
paulson@14199
   123
    - certificates are an encryption certificate (flag is onlyEnc) and a
paulson@14199
   124
      signature certificate (flag is onlySig);
paulson@14199
   125
    - certificates pertain to the CA that C contacted (this is done by
paulson@14199
   126
      checking the signature).
paulson@14199
   127
   C generates a fresh symmetric key KC1.
paulson@14199
   128
   The point of encrypting @{term "{|Agent C, Nonce NC2, Hash (Pan(pan C))|}"}
paulson@14199
   129
   is not clear. *}
paulson@14199
   130
"[| evs3 \<in> set_cr;  C = Cardholder k;
paulson@14199
   131
    Nonce NC2 \<notin> used evs3;
paulson@14199
   132
    Key KC1 \<notin> used evs3; KC1 \<in> symKeys;
paulson@14199
   133
    Gets C {|sign (invKey SKi) {|Agent X, Nonce NC1|},
wenzelm@32960
   134
             cert (CA i) EKi onlyEnc (priSK RCA),
wenzelm@32960
   135
             cert (CA i) SKi onlySig (priSK RCA)|}
paulson@14199
   136
       \<in> set evs3;
paulson@14199
   137
    Says C (CA i) {|Agent C, Nonce NC1|} \<in> set evs3|]
paulson@14199
   138
 ==> Says C (CA i) (EXHcrypt KC1 EKi {|Agent C, Nonce NC2|} (Pan(pan C)))
paulson@14199
   139
       # Notes C {|Key KC1, Agent (CA i)|}
paulson@14199
   140
       # evs3 \<in> set_cr"
paulson@14199
   141
berghofe@23755
   142
| SET_CR4:
paulson@14199
   143
    --{*RegFormRes:
paulson@14199
   144
    CA responds sending NC2 back with a new nonce NCA, after checking that
paulson@14199
   145
     - the digital envelope is correctly encrypted by @{term "pubEK (CA i)"}
paulson@14199
   146
     - the entire message is encrypted with the same key found inside the
paulson@14199
   147
       envelope (here, KC1) *}
paulson@14199
   148
"[| evs4 \<in> set_cr;
paulson@14199
   149
    Nonce NCA \<notin> used evs4;  KC1 \<in> symKeys;
paulson@14199
   150
    Gets (CA i) (EXHcrypt KC1 EKi {|Agent C, Nonce NC2|} (Pan(pan X)))
paulson@14199
   151
       \<in> set evs4 |]
paulson@14199
   152
  ==> Says (CA i) C
wenzelm@32960
   153
          {|sign (priSK (CA i)) {|Agent C, Nonce NC2, Nonce NCA|},
wenzelm@32960
   154
            cert (CA i) (pubEK (CA i)) onlyEnc (priSK RCA),
wenzelm@32960
   155
            cert (CA i) (pubSK (CA i)) onlySig (priSK RCA)|}
paulson@14199
   156
       # evs4 \<in> set_cr"
paulson@14199
   157
berghofe@23755
   158
| SET_CR5:
paulson@14199
   159
   --{*CertReq: C sends his PAN, a new nonce, its proposed public signature key
paulson@14199
   160
       and its half of the secret value to CA.
paulson@14199
   161
       We now assume that C has a fixed key pair, and he submits (pubSK C).
paulson@14199
   162
       The protocol does not require this key to be fresh.
paulson@14199
   163
       The encryption below is actually EncX.*}
paulson@14199
   164
"[| evs5 \<in> set_cr;  C = Cardholder k;
paulson@14199
   165
    Nonce NC3 \<notin> used evs5;  Nonce CardSecret \<notin> used evs5; NC3\<noteq>CardSecret;
paulson@14199
   166
    Key KC2 \<notin> used evs5; KC2 \<in> symKeys;
paulson@14199
   167
    Key KC3 \<notin> used evs5; KC3 \<in> symKeys; KC2\<noteq>KC3;
paulson@14199
   168
    Gets C {|sign (invKey SKi) {|Agent C, Nonce NC2, Nonce NCA|},
paulson@14199
   169
             cert (CA i) EKi onlyEnc (priSK RCA),
paulson@14199
   170
             cert (CA i) SKi onlySig (priSK RCA) |}
paulson@14199
   171
        \<in> set evs5;
paulson@14199
   172
    Says C (CA i) (EXHcrypt KC1 EKi {|Agent C, Nonce NC2|} (Pan(pan C)))
paulson@14199
   173
         \<in> set evs5 |]
paulson@14199
   174
==> Says C (CA i)
paulson@14199
   175
         {|Crypt KC3
wenzelm@32960
   176
             {|Agent C, Nonce NC3, Key KC2, Key (pubSK C),
wenzelm@32960
   177
               Crypt (priSK C)
wenzelm@32960
   178
                 (Hash {|Agent C, Nonce NC3, Key KC2,
wenzelm@32960
   179
                         Key (pubSK C), Pan (pan C), Nonce CardSecret|})|},
paulson@14199
   180
           Crypt EKi {|Key KC3, Pan (pan C), Nonce CardSecret|} |}
paulson@14199
   181
    # Notes C {|Key KC2, Agent (CA i)|}
paulson@14199
   182
    # Notes C {|Key KC3, Agent (CA i)|}
paulson@14199
   183
    # evs5 \<in> set_cr"
paulson@14199
   184
paulson@14199
   185
paulson@14199
   186
  --{* CertRes: CA responds sending NC3 back with its half of the secret value,
paulson@14199
   187
   its signature certificate and the new cardholder signature
paulson@14199
   188
   certificate.  CA checks to have never certified the key proposed by C.
paulson@14199
   189
   NOTE: In Merchant Registration, the corresponding rule (4)
paulson@14199
   190
   uses the "sign" primitive. The encryption below is actually @{term EncK}, 
paulson@14199
   191
   which is just @{term "Crypt K (sign SK X)"}.
paulson@14199
   192
*}
paulson@14199
   193
berghofe@23755
   194
| SET_CR6:
paulson@14199
   195
"[| evs6 \<in> set_cr;
paulson@14199
   196
    Nonce NonceCCA \<notin> used evs6;
paulson@14199
   197
    KC2 \<in> symKeys;  KC3 \<in> symKeys;  cardSK \<notin> symKeys;
paulson@14199
   198
    Notes (CA i) (Key cardSK) \<notin> set evs6;
paulson@14199
   199
    Gets (CA i)
paulson@14199
   200
      {|Crypt KC3 {|Agent C, Nonce NC3, Key KC2, Key cardSK,
paulson@14199
   201
                    Crypt (invKey cardSK)
paulson@14199
   202
                      (Hash {|Agent C, Nonce NC3, Key KC2,
wenzelm@32960
   203
                              Key cardSK, Pan (pan C), Nonce CardSecret|})|},
paulson@14199
   204
        Crypt (pubEK (CA i)) {|Key KC3, Pan (pan C), Nonce CardSecret|} |}
paulson@14199
   205
      \<in> set evs6 |]
paulson@14199
   206
==> Says (CA i) C
paulson@14199
   207
         (Crypt KC2
wenzelm@32960
   208
          {|sign (priSK (CA i))
wenzelm@32960
   209
                 {|Agent C, Nonce NC3, Agent(CA i), Nonce NonceCCA|},
wenzelm@32960
   210
            certC (pan C) cardSK (XOR(CardSecret,NonceCCA)) onlySig (priSK (CA i)),
wenzelm@32960
   211
            cert (CA i) (pubSK (CA i)) onlySig (priSK RCA)|})
paulson@14199
   212
      # Notes (CA i) (Key cardSK)
paulson@14199
   213
      # evs6 \<in> set_cr"
paulson@14199
   214
paulson@14199
   215
paulson@14199
   216
declare Says_imp_knows_Spy [THEN parts.Inj, dest]
paulson@14199
   217
declare parts.Body [dest]
paulson@14199
   218
declare analz_into_parts [dest]
paulson@14199
   219
declare Fake_parts_insert_in_Un [dest]
paulson@14199
   220
paulson@14199
   221
text{*A "possibility property": there are traces that reach the end.
paulson@14199
   222
      An unconstrained proof with many subgoals.*}
paulson@14199
   223
paulson@14199
   224
lemma Says_to_Gets:
paulson@14199
   225
     "Says A B X # evs \<in> set_cr ==> Gets B X # Says A B X # evs \<in> set_cr"
paulson@14199
   226
by (rule set_cr.Reception, auto)
paulson@14199
   227
paulson@14199
   228
text{*The many nonces and keys generated, some simultaneously, force us to
paulson@14199
   229
  introduce them explicitly as shown below.*}
paulson@14199
   230
lemma possibility_CR6:
paulson@14199
   231
     "[|NC1 < (NC2::nat);  NC2 < NC3;  NC3 < NCA ;
paulson@14199
   232
        NCA < NonceCCA;  NonceCCA < CardSecret;
paulson@14199
   233
        KC1 < (KC2::key);  KC2 < KC3;
paulson@14199
   234
        KC1 \<in> symKeys;  Key KC1 \<notin> used [];
paulson@14199
   235
        KC2 \<in> symKeys;  Key KC2 \<notin> used [];
paulson@14199
   236
        KC3 \<in> symKeys;  Key KC3 \<notin> used [];
paulson@14199
   237
        C = Cardholder k|]
paulson@14199
   238
   ==> \<exists>evs \<in> set_cr.
paulson@14199
   239
       Says (CA i) C
paulson@14199
   240
            (Crypt KC2
paulson@14199
   241
             {|sign (priSK (CA i))
paulson@14199
   242
                    {|Agent C, Nonce NC3, Agent(CA i), Nonce NonceCCA|},
paulson@14199
   243
               certC (pan C) (pubSK (Cardholder k)) (XOR(CardSecret,NonceCCA))
paulson@14199
   244
                     onlySig (priSK (CA i)),
paulson@14199
   245
               cert (CA i) (pubSK (CA i)) onlySig (priSK RCA)|})
paulson@14199
   246
          \<in> set evs"
paulson@14199
   247
apply (intro exI bexI)
paulson@14206
   248
apply (rule_tac [2] 
paulson@14206
   249
       set_cr.Nil 
paulson@14206
   250
        [THEN set_cr.SET_CR1 [of concl: C i NC1], 
paulson@14206
   251
         THEN Says_to_Gets, 
wenzelm@32960
   252
         THEN set_cr.SET_CR2 [of concl: i C NC1], 
wenzelm@32960
   253
         THEN Says_to_Gets,  
wenzelm@32960
   254
         THEN set_cr.SET_CR3 [of concl: C i KC1 _ NC2], 
wenzelm@32960
   255
         THEN Says_to_Gets,  
wenzelm@32960
   256
         THEN set_cr.SET_CR4 [of concl: i C NC2 NCA], 
wenzelm@32960
   257
         THEN Says_to_Gets,  
wenzelm@32960
   258
         THEN set_cr.SET_CR5 [of concl: C i KC3 NC3 KC2 CardSecret],
wenzelm@32960
   259
         THEN Says_to_Gets,  
wenzelm@32960
   260
         THEN set_cr.SET_CR6 [of concl: i C KC2]])
wenzelm@30607
   261
apply basic_possibility
paulson@14199
   262
apply (simp_all (no_asm_simp) add: symKeys_neq_imp_neq)
paulson@14199
   263
done
paulson@14199
   264
paulson@14199
   265
text{*General facts about message reception*}
paulson@14199
   266
lemma Gets_imp_Says:
paulson@14199
   267
     "[| Gets B X \<in> set evs; evs \<in> set_cr |] ==> \<exists>A. Says A B X \<in> set evs"
paulson@14199
   268
apply (erule rev_mp)
paulson@14199
   269
apply (erule set_cr.induct, auto)
paulson@14199
   270
done
paulson@14199
   271
paulson@14199
   272
lemma Gets_imp_knows_Spy:
paulson@14199
   273
     "[| Gets B X \<in> set evs; evs \<in> set_cr |]  ==> X \<in> knows Spy evs"
paulson@14199
   274
by (blast dest!: Gets_imp_Says Says_imp_knows_Spy)
paulson@14199
   275
declare Gets_imp_knows_Spy [THEN parts.Inj, dest]
paulson@14199
   276
paulson@14199
   277
paulson@14199
   278
subsection{*Proofs on keys *}
paulson@14199
   279
paulson@14199
   280
text{*Spy never sees an agent's private keys! (unless it's bad at start)*}
paulson@14199
   281
paulson@14199
   282
lemma Spy_see_private_Key [simp]:
paulson@14199
   283
     "evs \<in> set_cr
paulson@14199
   284
      ==> (Key(invKey (publicKey b A)) \<in> parts(knows Spy evs)) = (A \<in> bad)"
paulson@14199
   285
by (erule set_cr.induct, auto)
paulson@14199
   286
paulson@14199
   287
lemma Spy_analz_private_Key [simp]:
paulson@14199
   288
     "evs \<in> set_cr ==>
paulson@14199
   289
     (Key(invKey (publicKey b A)) \<in> analz(knows Spy evs)) = (A \<in> bad)"
paulson@14199
   290
by auto
paulson@14199
   291
paulson@14199
   292
declare Spy_see_private_Key [THEN [2] rev_iffD1, dest!]
paulson@14199
   293
declare Spy_analz_private_Key [THEN [2] rev_iffD1, dest!]
paulson@14199
   294
paulson@14199
   295
paulson@14199
   296
subsection{*Begin Piero's Theorems on Certificates*}
paulson@14199
   297
text{*Trivial in the current model, where certificates by RCA are secure *}
paulson@14199
   298
paulson@14199
   299
lemma Crypt_valid_pubEK:
paulson@14199
   300
     "[| Crypt (priSK RCA) {|Agent C, Key EKi, onlyEnc|}
paulson@14199
   301
           \<in> parts (knows Spy evs);
paulson@14199
   302
         evs \<in> set_cr |] ==> EKi = pubEK C"
paulson@14199
   303
apply (erule rev_mp)
paulson@14199
   304
apply (erule set_cr.induct, auto)
paulson@14199
   305
done
paulson@14199
   306
paulson@14199
   307
lemma certificate_valid_pubEK:
paulson@14199
   308
    "[| cert C EKi onlyEnc (priSK RCA) \<in> parts (knows Spy evs);
paulson@14199
   309
        evs \<in> set_cr |]
paulson@14199
   310
     ==> EKi = pubEK C"
paulson@14199
   311
apply (unfold cert_def signCert_def)
paulson@14199
   312
apply (blast dest!: Crypt_valid_pubEK)
paulson@14199
   313
done
paulson@14199
   314
paulson@14199
   315
lemma Crypt_valid_pubSK:
paulson@14199
   316
     "[| Crypt (priSK RCA) {|Agent C, Key SKi, onlySig|}
paulson@14199
   317
           \<in> parts (knows Spy evs);
paulson@14199
   318
         evs \<in> set_cr |] ==> SKi = pubSK C"
paulson@14199
   319
apply (erule rev_mp)
paulson@14199
   320
apply (erule set_cr.induct, auto)
paulson@14199
   321
done
paulson@14199
   322
paulson@14199
   323
lemma certificate_valid_pubSK:
paulson@14199
   324
    "[| cert C SKi onlySig (priSK RCA) \<in> parts (knows Spy evs);
paulson@14199
   325
        evs \<in> set_cr |] ==> SKi = pubSK C"
paulson@14199
   326
apply (unfold cert_def signCert_def)
paulson@14199
   327
apply (blast dest!: Crypt_valid_pubSK)
paulson@14199
   328
done
paulson@14199
   329
paulson@14199
   330
lemma Gets_certificate_valid:
paulson@14199
   331
     "[| Gets A {| X, cert C EKi onlyEnc (priSK RCA),
paulson@14199
   332
                      cert C SKi onlySig (priSK RCA)|} \<in> set evs;
paulson@14199
   333
         evs \<in> set_cr |]
paulson@14199
   334
      ==> EKi = pubEK C & SKi = pubSK C"
paulson@14199
   335
by (blast dest: certificate_valid_pubEK certificate_valid_pubSK)
paulson@14199
   336
paulson@14199
   337
text{*Nobody can have used non-existent keys!*}
paulson@14199
   338
lemma new_keys_not_used:
paulson@14199
   339
     "[|K \<in> symKeys; Key K \<notin> used evs; evs \<in> set_cr|]
paulson@14199
   340
      ==> K \<notin> keysFor (parts (knows Spy evs))"
paulson@14199
   341
apply (erule rev_mp)
paulson@14199
   342
apply (erule rev_mp)
paulson@14199
   343
apply (erule set_cr.induct)
paulson@14199
   344
apply (frule_tac [8] Gets_certificate_valid)
paulson@14199
   345
apply (frule_tac [6] Gets_certificate_valid, simp_all)
paulson@14218
   346
apply (force dest!: usedI keysFor_parts_insert) --{*Fake*}
paulson@14218
   347
apply (blast,auto)  --{*Others*}
paulson@14199
   348
done
paulson@14199
   349
paulson@14199
   350
paulson@14199
   351
subsection{*New versions: as above, but generalized to have the KK argument *}
paulson@14199
   352
paulson@14199
   353
lemma gen_new_keys_not_used:
paulson@14199
   354
     "[|Key K \<notin> used evs; K \<in> symKeys; evs \<in> set_cr |]
paulson@14199
   355
      ==> Key K \<notin> used evs --> K \<in> symKeys -->
paulson@14199
   356
          K \<notin> keysFor (parts (Key`KK Un knows Spy evs))"
paulson@14199
   357
by (auto simp add: new_keys_not_used)
paulson@14199
   358
paulson@14199
   359
lemma gen_new_keys_not_analzd:
paulson@14199
   360
     "[|Key K \<notin> used evs; K \<in> symKeys; evs \<in> set_cr |]
paulson@14199
   361
      ==> K \<notin> keysFor (analz (Key`KK Un knows Spy evs))"
paulson@14199
   362
by (blast intro: keysFor_mono [THEN [2] rev_subsetD]
paulson@14199
   363
          dest: gen_new_keys_not_used)
paulson@14199
   364
paulson@14199
   365
lemma analz_Key_image_insert_eq:
paulson@14199
   366
     "[|K \<in> symKeys; Key K \<notin> used evs; evs \<in> set_cr |]
paulson@14199
   367
      ==> analz (Key ` (insert K KK) \<union> knows Spy evs) =
paulson@14199
   368
          insert (Key K) (analz (Key ` KK \<union> knows Spy evs))"
paulson@14199
   369
by (simp add: gen_new_keys_not_analzd)
paulson@14199
   370
paulson@14199
   371
lemma Crypt_parts_imp_used:
paulson@14199
   372
     "[|Crypt K X \<in> parts (knows Spy evs);
paulson@14199
   373
        K \<in> symKeys; evs \<in> set_cr |] ==> Key K \<in> used evs"
paulson@14199
   374
apply (rule ccontr)
paulson@14199
   375
apply (force dest: new_keys_not_used Crypt_imp_invKey_keysFor)
paulson@14199
   376
done
paulson@14199
   377
paulson@14199
   378
lemma Crypt_analz_imp_used:
paulson@14199
   379
     "[|Crypt K X \<in> analz (knows Spy evs);
paulson@14199
   380
        K \<in> symKeys; evs \<in> set_cr |] ==> Key K \<in> used evs"
paulson@14199
   381
by (blast intro: Crypt_parts_imp_used)
paulson@14199
   382
paulson@14199
   383
paulson@14218
   384
(*<*) 
paulson@14199
   385
subsection{*Messages signed by CA*}
paulson@14199
   386
paulson@14199
   387
text{*Message @{text SET_CR2}: C can check CA's signature if he has received
paulson@14199
   388
     CA's certificate.*}
paulson@14199
   389
lemma CA_Says_2_lemma:
paulson@14199
   390
     "[| Crypt (priSK (CA i)) (Hash{|Agent C, Nonce NC1|})
paulson@14199
   391
           \<in> parts (knows Spy evs);
paulson@14199
   392
         evs \<in> set_cr; (CA i) \<notin> bad |]
paulson@14199
   393
     ==> \<exists>Y. Says (CA i) C {|sign (priSK (CA i)) {|Agent C, Nonce NC1|}, Y|}
paulson@14199
   394
                 \<in> set evs"
paulson@14199
   395
apply (erule rev_mp)
paulson@14199
   396
apply (erule set_cr.induct, auto)
paulson@14199
   397
done
paulson@14199
   398
paulson@14199
   399
text{*Ever used?*}
paulson@14199
   400
lemma CA_Says_2:
paulson@14199
   401
     "[| Crypt (invKey SK) (Hash{|Agent C, Nonce NC1|})
paulson@14199
   402
           \<in> parts (knows Spy evs);
paulson@14199
   403
         cert (CA i) SK onlySig (priSK RCA) \<in> parts (knows Spy evs);
paulson@14199
   404
         evs \<in> set_cr; (CA i) \<notin> bad |]
paulson@14199
   405
      ==> \<exists>Y. Says (CA i) C {|sign (priSK (CA i)) {|Agent C, Nonce NC1|}, Y|}
paulson@14199
   406
                  \<in> set evs"
paulson@14199
   407
by (blast dest!: certificate_valid_pubSK intro!: CA_Says_2_lemma)
paulson@14199
   408
paulson@14199
   409
paulson@14199
   410
text{*Message @{text SET_CR4}: C can check CA's signature if he has received
paulson@14199
   411
      CA's certificate.*}
paulson@14199
   412
lemma CA_Says_4_lemma:
paulson@14199
   413
     "[| Crypt (priSK (CA i)) (Hash{|Agent C, Nonce NC2, Nonce NCA|})
paulson@14199
   414
           \<in> parts (knows Spy evs);
paulson@14199
   415
         evs \<in> set_cr; (CA i) \<notin> bad |]
paulson@14199
   416
      ==> \<exists>Y. Says (CA i) C {|sign (priSK (CA i))
paulson@14199
   417
                     {|Agent C, Nonce NC2, Nonce NCA|}, Y|} \<in> set evs"
paulson@14199
   418
apply (erule rev_mp)
paulson@14199
   419
apply (erule set_cr.induct, auto)
paulson@14199
   420
done
paulson@14199
   421
paulson@14199
   422
text{*NEVER USED*}
paulson@14199
   423
lemma CA_Says_4:
paulson@14199
   424
     "[| Crypt (invKey SK) (Hash{|Agent C, Nonce NC2, Nonce NCA|})
paulson@14199
   425
           \<in> parts (knows Spy evs);
paulson@14199
   426
         cert (CA i) SK onlySig (priSK RCA) \<in> parts (knows Spy evs);
paulson@14199
   427
         evs \<in> set_cr; (CA i) \<notin> bad |]
paulson@14199
   428
      ==> \<exists>Y. Says (CA i) C {|sign (priSK (CA i))
paulson@14199
   429
                   {|Agent C, Nonce NC2, Nonce NCA|}, Y|} \<in> set evs"
paulson@14199
   430
by (blast dest!: certificate_valid_pubSK intro!: CA_Says_4_lemma)
paulson@14199
   431
paulson@14199
   432
paulson@14199
   433
text{*Message @{text SET_CR6}: C can check CA's signature if he has
paulson@14199
   434
      received CA's certificate.*}
paulson@14199
   435
lemma CA_Says_6_lemma:
paulson@14199
   436
     "[| Crypt (priSK (CA i)) 
paulson@14199
   437
               (Hash{|Agent C, Nonce NC3, Agent (CA i), Nonce NonceCCA|})
paulson@14199
   438
           \<in> parts (knows Spy evs);
paulson@14199
   439
         evs \<in> set_cr; (CA i) \<notin> bad |]
paulson@14199
   440
      ==> \<exists>Y K. Says (CA i) C (Crypt K {|sign (priSK (CA i))
paulson@14199
   441
      {|Agent C, Nonce NC3, Agent (CA i), Nonce NonceCCA|}, Y|}) \<in> set evs"
paulson@14199
   442
apply (erule rev_mp)
paulson@14199
   443
apply (erule set_cr.induct, auto)
paulson@14199
   444
done
paulson@14199
   445
paulson@14199
   446
text{*NEVER USED*}
paulson@14199
   447
lemma CA_Says_6:
paulson@14199
   448
     "[| Crypt (invKey SK) (Hash{|Agent C, Nonce NC3, Agent (CA i), Nonce NonceCCA|})
paulson@14199
   449
           \<in> parts (knows Spy evs);
paulson@14199
   450
         cert (CA i) SK onlySig (priSK RCA) \<in> parts (knows Spy evs);
paulson@14199
   451
         evs \<in> set_cr; (CA i) \<notin> bad |]
paulson@14199
   452
      ==> \<exists>Y K. Says (CA i) C (Crypt K {|sign (priSK (CA i))
paulson@14199
   453
                    {|Agent C, Nonce NC3, Agent (CA i), Nonce NonceCCA|}, Y|}) \<in> set evs"
paulson@14199
   454
by (blast dest!: certificate_valid_pubSK intro!: CA_Says_6_lemma)
paulson@14218
   455
(*>*)
paulson@14199
   456
paulson@14199
   457
paulson@14199
   458
subsection{*Useful lemmas *}
paulson@14199
   459
paulson@14199
   460
text{*Rewriting rule for private encryption keys.  Analogous rewriting rules
paulson@14199
   461
for other keys aren't needed.*}
paulson@14199
   462
paulson@14199
   463
lemma parts_image_priEK:
paulson@14199
   464
     "[|Key (priEK C) \<in> parts (Key`KK Un (knows Spy evs));
paulson@14199
   465
        evs \<in> set_cr|] ==> priEK C \<in> KK | C \<in> bad"
paulson@14199
   466
by auto
paulson@14199
   467
paulson@14199
   468
text{*trivial proof because (priEK C) never appears even in (parts evs)*}
paulson@14199
   469
lemma analz_image_priEK:
paulson@14199
   470
     "evs \<in> set_cr ==>
paulson@14199
   471
          (Key (priEK C) \<in> analz (Key`KK Un (knows Spy evs))) =
paulson@14199
   472
          (priEK C \<in> KK | C \<in> bad)"
paulson@14199
   473
by (blast dest!: parts_image_priEK intro: analz_mono [THEN [2] rev_subsetD])
paulson@14199
   474
paulson@14199
   475
paulson@14199
   476
subsection{*Secrecy of Session Keys *}
paulson@14199
   477
paulson@14199
   478
subsubsection{*Lemmas about the predicate KeyCryptKey *}
paulson@14199
   479
paulson@14199
   480
text{*A fresh DK cannot be associated with any other
paulson@14199
   481
  (with respect to a given trace). *}
paulson@14199
   482
lemma DK_fresh_not_KeyCryptKey:
paulson@14199
   483
     "[| Key DK \<notin> used evs; evs \<in> set_cr |] ==> ~ KeyCryptKey DK K evs"
paulson@14199
   484
apply (erule rev_mp)
paulson@14199
   485
apply (erule set_cr.induct)
paulson@14199
   486
apply (simp_all (no_asm_simp))
paulson@14199
   487
apply (blast dest: Crypt_analz_imp_used)+
paulson@14199
   488
done
paulson@14199
   489
paulson@14199
   490
text{*A fresh K cannot be associated with any other.  The assumption that
paulson@14199
   491
  DK isn't a private encryption key may be an artifact of the particular
paulson@14199
   492
  definition of KeyCryptKey.*}
paulson@14199
   493
lemma K_fresh_not_KeyCryptKey:
paulson@14199
   494
     "[|\<forall>C. DK \<noteq> priEK C; Key K \<notin> used evs|] ==> ~ KeyCryptKey DK K evs"
paulson@14199
   495
apply (induct evs)
paulson@14199
   496
apply (auto simp add: parts_insert2 split add: event.split)
paulson@14199
   497
done
paulson@14199
   498
paulson@14199
   499
paulson@14199
   500
text{*This holds because if (priEK (CA i)) appears in any traffic then it must
paulson@14199
   501
  be known to the Spy, by @{term Spy_see_private_Key}*}
paulson@14199
   502
lemma cardSK_neq_priEK:
paulson@14199
   503
     "[|Key cardSK \<notin> analz (knows Spy evs);
paulson@14199
   504
        Key cardSK : parts (knows Spy evs);
paulson@14199
   505
        evs \<in> set_cr|] ==> cardSK \<noteq> priEK C"
paulson@14199
   506
by blast
paulson@14199
   507
paulson@14199
   508
lemma not_KeyCryptKey_cardSK [rule_format (no_asm)]:
paulson@14199
   509
     "[|cardSK \<notin> symKeys;  \<forall>C. cardSK \<noteq> priEK C;  evs \<in> set_cr|] ==>
paulson@14199
   510
      Key cardSK \<notin> analz (knows Spy evs) --> ~ KeyCryptKey cardSK K evs"
paulson@14199
   511
by (erule set_cr.induct, analz_mono_contra, auto)
paulson@14199
   512
paulson@14199
   513
text{*Lemma for message 5: pubSK C is never used to encrypt Keys.*}
paulson@14199
   514
lemma pubSK_not_KeyCryptKey [simp]: "~ KeyCryptKey (pubSK C) K evs"
paulson@14199
   515
apply (induct_tac "evs")
paulson@14199
   516
apply (auto simp add: parts_insert2 split add: event.split)
paulson@14199
   517
done
paulson@14199
   518
paulson@14199
   519
text{*Lemma for message 6: either cardSK is compromised (when we don't care)
paulson@14199
   520
  or else cardSK hasn't been used to encrypt K.  Previously we treated
paulson@14199
   521
  message 5 in the same way, but the current model assumes that rule
paulson@14199
   522
  @{text SET_CR5} is executed only by honest agents.*}
paulson@14199
   523
lemma msg6_KeyCryptKey_disj:
paulson@14199
   524
     "[|Gets B {|Crypt KC3 {|Agent C, Nonce N, Key KC2, Key cardSK, X|}, Y|}
paulson@14199
   525
          \<in> set evs;
paulson@14199
   526
        cardSK \<notin> symKeys;  evs \<in> set_cr|]
paulson@14199
   527
      ==> Key cardSK \<in> analz (knows Spy evs) |
paulson@14199
   528
          (\<forall>K. ~ KeyCryptKey cardSK K evs)"
paulson@14199
   529
by (blast dest: not_KeyCryptKey_cardSK intro: cardSK_neq_priEK)
paulson@14199
   530
paulson@14199
   531
text{*As usual: we express the property as a logical equivalence*}
paulson@14199
   532
lemma Key_analz_image_Key_lemma:
paulson@14199
   533
     "P --> (Key K \<in> analz (Key`KK Un H)) --> (K \<in> KK | Key K \<in> analz H)
paulson@14199
   534
      ==>
paulson@14199
   535
      P --> (Key K \<in> analz (Key`KK Un H)) = (K \<in> KK | Key K \<in> analz H)"
paulson@14199
   536
by (blast intro: analz_mono [THEN [2] rev_subsetD])
paulson@14199
   537
wenzelm@24123
   538
method_setup valid_certificate_tac = {*
wenzelm@51798
   539
  Args.goal_spec >> (fn quant => fn ctxt => SIMPLE_METHOD'' quant
wenzelm@30549
   540
    (fn i =>
wenzelm@59499
   541
      EVERY [forward_tac ctxt @{thms Gets_certificate_valid} i,
wenzelm@58963
   542
             assume_tac ctxt i,
wenzelm@60754
   543
             eresolve_tac ctxt [conjE] i, REPEAT (hyp_subst_tac ctxt i)]))
wenzelm@42814
   544
*}
paulson@14199
   545
paulson@14199
   546
text{*The @{text "(no_asm)"} attribute is essential, since it retains
paulson@14199
   547
  the quantifier and allows the simprule's condition to itself be simplified.*}
paulson@14199
   548
lemma symKey_compromise [rule_format (no_asm)]:
paulson@14199
   549
     "evs \<in> set_cr ==>
paulson@14199
   550
      (\<forall>SK KK. SK \<in> symKeys \<longrightarrow> (\<forall>K \<in> KK. ~ KeyCryptKey K SK evs)   -->
paulson@14199
   551
               (Key SK \<in> analz (Key`KK Un (knows Spy evs))) =
paulson@14199
   552
               (SK \<in> KK | Key SK \<in> analz (knows Spy evs)))"
paulson@14199
   553
apply (erule set_cr.induct)
paulson@14199
   554
apply (rule_tac [!] allI) +
paulson@14199
   555
apply (rule_tac [!] impI [THEN Key_analz_image_Key_lemma, THEN impI])+
wenzelm@24123
   556
apply (valid_certificate_tac [8]) --{*for message 5*}
wenzelm@24123
   557
apply (valid_certificate_tac [6]) --{*for message 5*}
paulson@14199
   558
apply (erule_tac [9] msg6_KeyCryptKey_disj [THEN disjE])
paulson@14199
   559
apply (simp_all
paulson@14199
   560
         del: image_insert image_Un imp_disjL
paulson@14199
   561
         add: analz_image_keys_simps analz_knows_absorb
paulson@14199
   562
              analz_Key_image_insert_eq notin_image_iff
paulson@14199
   563
              K_fresh_not_KeyCryptKey
paulson@14199
   564
              DK_fresh_not_KeyCryptKey ball_conj_distrib
paulson@14199
   565
              analz_image_priEK disj_simps)
wenzelm@24123
   566
  --{*9 seconds on a 1.6GHz machine*}
paulson@14199
   567
apply spy_analz
paulson@14218
   568
apply blast  --{*3*}
paulson@14218
   569
apply blast  --{*5*}
paulson@14199
   570
done
paulson@14199
   571
paulson@14199
   572
text{*The remaining quantifiers seem to be essential.
paulson@14199
   573
  NO NEED to assume the cardholder's OK: bad cardholders don't do anything
paulson@14199
   574
  wrong!!*}
paulson@14199
   575
lemma symKey_secrecy [rule_format]:
paulson@14199
   576
     "[|CA i \<notin> bad;  K \<in> symKeys;  evs \<in> set_cr|]
paulson@14199
   577
      ==> \<forall>X c. Says (Cardholder c) (CA i) X \<in> set evs -->
paulson@14199
   578
                Key K \<in> parts{X} -->
paulson@14199
   579
                Cardholder c \<notin> bad -->
paulson@14199
   580
                Key K \<notin> analz (knows Spy evs)"
paulson@14199
   581
apply (erule set_cr.induct)
paulson@14199
   582
apply (frule_tac [8] Gets_certificate_valid) --{*for message 5*}
paulson@14199
   583
apply (frule_tac [6] Gets_certificate_valid) --{*for message 3*}
paulson@14199
   584
apply (erule_tac [11] msg6_KeyCryptKey_disj [THEN disjE])
paulson@14199
   585
apply (simp_all del: image_insert image_Un imp_disjL
paulson@14199
   586
         add: symKey_compromise fresh_notin_analz_knows_Spy
paulson@14199
   587
              analz_image_keys_simps analz_knows_absorb
paulson@14199
   588
              analz_Key_image_insert_eq notin_image_iff
paulson@14199
   589
              K_fresh_not_KeyCryptKey
paulson@14199
   590
              DK_fresh_not_KeyCryptKey
paulson@14199
   591
              analz_image_priEK)
wenzelm@24123
   592
  --{*2.5 seconds on a 1.6GHz machine*}
paulson@14218
   593
apply spy_analz  --{*Fake*}
paulson@14199
   594
apply (auto intro: analz_into_parts [THEN usedI] in_parts_Says_imp_used)
paulson@14199
   595
done
paulson@14199
   596
paulson@14199
   597
paulson@14199
   598
subsection{*Primary Goals of Cardholder Registration *}
paulson@14199
   599
paulson@14199
   600
text{*The cardholder's certificate really was created by the CA, provided the
paulson@14199
   601
    CA is uncompromised *}
paulson@14199
   602
paulson@14199
   603
text{*Lemma concerning the actual signed message digest*}
paulson@14199
   604
lemma cert_valid_lemma:
paulson@14199
   605
     "[|Crypt (priSK (CA i)) {|Hash {|Nonce N, Pan(pan C)|}, Key cardSK, N1|}
paulson@14199
   606
          \<in> parts (knows Spy evs);
paulson@14199
   607
        CA i \<notin> bad; evs \<in> set_cr|]
paulson@14199
   608
  ==> \<exists>KC2 X Y. Says (CA i) C
paulson@14199
   609
                     (Crypt KC2 
paulson@14199
   610
                       {|X, certC (pan C) cardSK N onlySig (priSK (CA i)), Y|})
paulson@14199
   611
                  \<in> set evs"
paulson@14199
   612
apply (erule rev_mp)
paulson@14199
   613
apply (erule set_cr.induct)
paulson@14199
   614
apply (simp_all (no_asm_simp))
paulson@14199
   615
apply auto
paulson@14199
   616
done
paulson@14199
   617
paulson@14199
   618
text{*Pre-packaged version for cardholder.  We don't try to confirm the values
paulson@14199
   619
  of KC2, X and Y, since they are not important.*}
paulson@14199
   620
lemma certificate_valid_cardSK:
paulson@14199
   621
    "[|Gets C (Crypt KC2 {|X, certC (pan C) cardSK N onlySig (invKey SKi),
paulson@14199
   622
                              cert (CA i) SKi onlySig (priSK RCA)|}) \<in> set evs;
paulson@14199
   623
        CA i \<notin> bad; evs \<in> set_cr|]
paulson@14199
   624
  ==> \<exists>KC2 X Y. Says (CA i) C
paulson@14199
   625
                     (Crypt KC2 
paulson@14199
   626
                       {|X, certC (pan C) cardSK N onlySig (priSK (CA i)), Y|})
paulson@14199
   627
                   \<in> set evs"
paulson@14199
   628
by (force dest!: Gets_imp_knows_Spy [THEN parts.Inj, THEN parts.Body]
paulson@14199
   629
                    certificate_valid_pubSK cert_valid_lemma)
paulson@14199
   630
paulson@14199
   631
paulson@14199
   632
lemma Hash_imp_parts [rule_format]:
paulson@14199
   633
     "evs \<in> set_cr
paulson@14199
   634
      ==> Hash{|X, Nonce N|} \<in> parts (knows Spy evs) -->
paulson@14199
   635
          Nonce N \<in> parts (knows Spy evs)"
paulson@14199
   636
apply (erule set_cr.induct, force)
paulson@14199
   637
apply (simp_all (no_asm_simp))
paulson@14199
   638
apply (blast intro: parts_mono [THEN [2] rev_subsetD])
paulson@14199
   639
done
paulson@14199
   640
paulson@14199
   641
lemma Hash_imp_parts2 [rule_format]:
paulson@14199
   642
     "evs \<in> set_cr
paulson@14199
   643
      ==> Hash{|X, Nonce M, Y, Nonce N|} \<in> parts (knows Spy evs) -->
paulson@14199
   644
          Nonce M \<in> parts (knows Spy evs) & Nonce N \<in> parts (knows Spy evs)"
paulson@14199
   645
apply (erule set_cr.induct, force)
paulson@14199
   646
apply (simp_all (no_asm_simp))
paulson@14199
   647
apply (blast intro: parts_mono [THEN [2] rev_subsetD])
paulson@14199
   648
done
paulson@14199
   649
paulson@14199
   650
paulson@14199
   651
subsection{*Secrecy of Nonces*}
paulson@14199
   652
paulson@14199
   653
subsubsection{*Lemmas about the predicate KeyCryptNonce *}
paulson@14199
   654
paulson@14199
   655
text{*A fresh DK cannot be associated with any other
paulson@14199
   656
  (with respect to a given trace). *}
paulson@14199
   657
lemma DK_fresh_not_KeyCryptNonce:
paulson@14199
   658
     "[| DK \<in> symKeys; Key DK \<notin> used evs; evs \<in> set_cr |]
paulson@14199
   659
      ==> ~ KeyCryptNonce DK K evs"
paulson@14199
   660
apply (erule rev_mp)
paulson@14199
   661
apply (erule rev_mp)
paulson@14199
   662
apply (erule set_cr.induct)
paulson@14199
   663
apply (simp_all (no_asm_simp))
paulson@14199
   664
apply blast
paulson@14199
   665
apply blast
paulson@14199
   666
apply (auto simp add: DK_fresh_not_KeyCryptKey)
paulson@14199
   667
done
paulson@14199
   668
paulson@14199
   669
text{*A fresh N cannot be associated with any other
paulson@14199
   670
      (with respect to a given trace). *}
paulson@14199
   671
lemma N_fresh_not_KeyCryptNonce:
paulson@14199
   672
     "\<forall>C. DK \<noteq> priEK C ==> Nonce N \<notin> used evs --> ~ KeyCryptNonce DK N evs"
paulson@14199
   673
apply (induct_tac "evs")
blanchet@55417
   674
apply (rename_tac [2] a evs')
paulson@14199
   675
apply (case_tac [2] "a")
paulson@14199
   676
apply (auto simp add: parts_insert2)
paulson@14199
   677
done
paulson@14199
   678
paulson@14199
   679
lemma not_KeyCryptNonce_cardSK [rule_format (no_asm)]:
paulson@14199
   680
     "[|cardSK \<notin> symKeys;  \<forall>C. cardSK \<noteq> priEK C;  evs \<in> set_cr|] ==>
paulson@14199
   681
      Key cardSK \<notin> analz (knows Spy evs) --> ~ KeyCryptNonce cardSK N evs"
paulson@14199
   682
apply (erule set_cr.induct, analz_mono_contra, simp_all)
paulson@14218
   683
apply (blast dest: not_KeyCryptKey_cardSK)  --{*6*}
paulson@14199
   684
done
paulson@14199
   685
paulson@14199
   686
subsubsection{*Lemmas for message 5 and 6:
paulson@14199
   687
  either cardSK is compromised (when we don't care)
paulson@14199
   688
  or else cardSK hasn't been used to encrypt K. *}
paulson@14199
   689
paulson@14199
   690
text{*Lemma for message 5: pubSK C is never used to encrypt Nonces.*}
paulson@14199
   691
lemma pubSK_not_KeyCryptNonce [simp]: "~ KeyCryptNonce (pubSK C) N evs"
paulson@14199
   692
apply (induct_tac "evs")
paulson@14199
   693
apply (auto simp add: parts_insert2 split add: event.split)
paulson@14199
   694
done
paulson@14199
   695
paulson@14199
   696
text{*Lemma for message 6: either cardSK is compromised (when we don't care)
paulson@14199
   697
  or else cardSK hasn't been used to encrypt K.*}
paulson@14199
   698
lemma msg6_KeyCryptNonce_disj:
paulson@14199
   699
     "[|Gets B {|Crypt KC3 {|Agent C, Nonce N, Key KC2, Key cardSK, X|}, Y|}
paulson@14199
   700
          \<in> set evs;
paulson@14199
   701
        cardSK \<notin> symKeys;  evs \<in> set_cr|]
paulson@14199
   702
      ==> Key cardSK \<in> analz (knows Spy evs) |
paulson@14199
   703
          ((\<forall>K. ~ KeyCryptKey cardSK K evs) &
paulson@14199
   704
           (\<forall>N. ~ KeyCryptNonce cardSK N evs))"
paulson@14199
   705
by (blast dest: not_KeyCryptKey_cardSK not_KeyCryptNonce_cardSK
paulson@14199
   706
          intro: cardSK_neq_priEK)
paulson@14199
   707
paulson@14199
   708
paulson@14199
   709
text{*As usual: we express the property as a logical equivalence*}
paulson@14199
   710
lemma Nonce_analz_image_Key_lemma:
paulson@14199
   711
     "P --> (Nonce N \<in> analz (Key`KK Un H)) --> (Nonce N \<in> analz H)
paulson@14199
   712
      ==> P --> (Nonce N \<in> analz (Key`KK Un H)) = (Nonce N \<in> analz H)"
paulson@14199
   713
by (blast intro: analz_mono [THEN [2] rev_subsetD])
paulson@14199
   714
paulson@32404
   715
paulson@14199
   716
text{*The @{text "(no_asm)"} attribute is essential, since it retains
paulson@14199
   717
  the quantifier and allows the simprule's condition to itself be simplified.*}
paulson@14199
   718
lemma Nonce_compromise [rule_format (no_asm)]:
paulson@14199
   719
     "evs \<in> set_cr ==>
paulson@14199
   720
      (\<forall>N KK. (\<forall>K \<in> KK. ~ KeyCryptNonce K N evs)   -->
paulson@14199
   721
               (Nonce N \<in> analz (Key`KK Un (knows Spy evs))) =
paulson@14199
   722
               (Nonce N \<in> analz (knows Spy evs)))"
paulson@14199
   723
apply (erule set_cr.induct)
paulson@14199
   724
apply (rule_tac [!] allI)+
paulson@14199
   725
apply (rule_tac [!] impI [THEN Nonce_analz_image_Key_lemma])+
paulson@14199
   726
apply (frule_tac [8] Gets_certificate_valid) --{*for message 5*}
paulson@14199
   727
apply (frule_tac [6] Gets_certificate_valid) --{*for message 3*}
paulson@14199
   728
apply (frule_tac [11] msg6_KeyCryptNonce_disj)
paulson@14199
   729
apply (erule_tac [13] disjE)
paulson@14199
   730
apply (simp_all del: image_insert image_Un
paulson@14199
   731
         add: symKey_compromise
paulson@14199
   732
              analz_image_keys_simps analz_knows_absorb
paulson@14199
   733
              analz_Key_image_insert_eq notin_image_iff
paulson@14199
   734
              N_fresh_not_KeyCryptNonce
paulson@14199
   735
              DK_fresh_not_KeyCryptNonce K_fresh_not_KeyCryptKey
paulson@14199
   736
              ball_conj_distrib analz_image_priEK)
wenzelm@24123
   737
  --{*14 seconds on a 1.6GHz machine*}
paulson@14218
   738
apply spy_analz  --{*Fake*}
paulson@14218
   739
apply blast  --{*3*}
paulson@14218
   740
apply blast  --{*5*}
paulson@14218
   741
txt{*Message 6*}
paulson@32404
   742
apply (metis symKey_compromise)
paulson@14218
   743
  --{*cardSK compromised*}
paulson@14199
   744
txt{*Simplify again--necessary because the previous simplification introduces
paulson@32404
   745
  some logical connectives*} 
paulson@32404
   746
apply (force simp del: image_insert image_Un imp_disjL
paulson@14199
   747
          simp add: analz_image_keys_simps symKey_compromise)
paulson@14218
   748
done
paulson@14199
   749
paulson@14199
   750
paulson@14199
   751
subsection{*Secrecy of CardSecret: the Cardholder's secret*}
paulson@14199
   752
paulson@14199
   753
lemma NC2_not_CardSecret:
paulson@14199
   754
     "[|Crypt EKj {|Key K, Pan p, Hash {|Agent D, Nonce N|}|}
paulson@14199
   755
          \<in> parts (knows Spy evs);
paulson@14199
   756
        Key K \<notin> analz (knows Spy evs);
paulson@14199
   757
        Nonce N \<notin> analz (knows Spy evs);
paulson@14199
   758
       evs \<in> set_cr|]
paulson@14199
   759
      ==> Crypt EKi {|Key K', Pan p', Nonce N|} \<notin> parts (knows Spy evs)"
paulson@14199
   760
apply (erule rev_mp)
paulson@14199
   761
apply (erule rev_mp)
paulson@14199
   762
apply (erule rev_mp)
paulson@14199
   763
apply (erule set_cr.induct, analz_mono_contra, simp_all)
paulson@14199
   764
apply (blast dest: Hash_imp_parts)+
paulson@14199
   765
done
paulson@14199
   766
paulson@14199
   767
lemma KC2_secure_lemma [rule_format]:
paulson@14199
   768
     "[|U = Crypt KC3 {|Agent C, Nonce N, Key KC2, X|};
paulson@14199
   769
        U \<in> parts (knows Spy evs);
paulson@14199
   770
        evs \<in> set_cr|]
paulson@14199
   771
  ==> Nonce N \<notin> analz (knows Spy evs) -->
paulson@14199
   772
      (\<exists>k i W. Says (Cardholder k) (CA i) {|U,W|} \<in> set evs & 
paulson@14199
   773
               Cardholder k \<notin> bad & CA i \<notin> bad)"
wenzelm@59807
   774
apply (erule_tac P = "U \<in> H" for H in rev_mp)
paulson@14199
   775
apply (erule set_cr.induct)
wenzelm@24123
   776
apply (valid_certificate_tac [8])  --{*for message 5*}
paulson@14199
   777
apply (simp_all del: image_insert image_Un imp_disjL
paulson@14199
   778
         add: analz_image_keys_simps analz_knows_absorb
paulson@14199
   779
              analz_knows_absorb2 notin_image_iff)
wenzelm@24123
   780
  --{*4 seconds on a 1.6GHz machine*}
paulson@14199
   781
apply (simp_all (no_asm_simp)) --{*leaves 4 subgoals*}
paulson@14199
   782
apply (blast intro!: analz_insertI)+
paulson@14199
   783
done
paulson@14199
   784
paulson@14199
   785
lemma KC2_secrecy:
paulson@14199
   786
     "[|Gets B {|Crypt K {|Agent C, Nonce N, Key KC2, X|}, Y|} \<in> set evs;
paulson@14199
   787
        Nonce N \<notin> analz (knows Spy evs);  KC2 \<in> symKeys;
paulson@14199
   788
        evs \<in> set_cr|]
paulson@14199
   789
       ==> Key KC2 \<notin> analz (knows Spy evs)"
paulson@14199
   790
by (force dest!: refl [THEN KC2_secure_lemma] symKey_secrecy)
paulson@14199
   791
paulson@14199
   792
paulson@14199
   793
text{*Inductive version*}
paulson@14199
   794
lemma CardSecret_secrecy_lemma [rule_format]:
paulson@14199
   795
     "[|CA i \<notin> bad;  evs \<in> set_cr|]
paulson@14199
   796
      ==> Key K \<notin> analz (knows Spy evs) -->
paulson@14199
   797
          Crypt (pubEK (CA i)) {|Key K, Pan p, Nonce CardSecret|}
paulson@14199
   798
             \<in> parts (knows Spy evs) -->
paulson@14199
   799
          Nonce CardSecret \<notin> analz (knows Spy evs)"
paulson@14199
   800
apply (erule set_cr.induct, analz_mono_contra)
wenzelm@24123
   801
apply (valid_certificate_tac [8]) --{*for message 5*}
wenzelm@24123
   802
apply (valid_certificate_tac [6]) --{*for message 5*}
paulson@14199
   803
apply (frule_tac [9] msg6_KeyCryptNonce_disj [THEN disjE])
paulson@14199
   804
apply (simp_all
paulson@14199
   805
         del: image_insert image_Un imp_disjL
paulson@14199
   806
         add: analz_image_keys_simps analz_knows_absorb
paulson@14199
   807
              analz_Key_image_insert_eq notin_image_iff
paulson@14199
   808
              EXHcrypt_def Crypt_notin_image_Key
paulson@14199
   809
              N_fresh_not_KeyCryptNonce DK_fresh_not_KeyCryptNonce
paulson@14199
   810
              ball_conj_distrib Nonce_compromise symKey_compromise
paulson@14199
   811
              analz_image_priEK)
wenzelm@24123
   812
  --{*2.5 seconds on a 1.6GHz machine*}
paulson@14218
   813
apply spy_analz  --{*Fake*}
paulson@14199
   814
apply (simp_all (no_asm_simp))
paulson@14218
   815
apply blast  --{*1*}
paulson@14218
   816
apply (blast dest!: Gets_imp_knows_Spy [THEN analz.Inj])  --{*2*}
paulson@14218
   817
apply blast  --{*3*}
paulson@14218
   818
apply (blast dest: NC2_not_CardSecret Gets_imp_knows_Spy [THEN analz.Inj] analz_symKeys_Decrypt)  --{*4*}
paulson@14218
   819
apply blast  --{*5*}
paulson@14218
   820
apply (blast dest: KC2_secrecy)+  --{*Message 6: two cases*}
paulson@14199
   821
done
paulson@14199
   822
paulson@14199
   823
paulson@14199
   824
text{*Packaged version for cardholder*}
paulson@14199
   825
lemma CardSecret_secrecy:
paulson@14199
   826
     "[|Cardholder k \<notin> bad;  CA i \<notin> bad;
paulson@14199
   827
        Says (Cardholder k) (CA i)
paulson@14199
   828
           {|X, Crypt EKi {|Key KC3, Pan p, Nonce CardSecret|}|} \<in> set evs;
paulson@14199
   829
        Gets A {|Z, cert (CA i) EKi onlyEnc (priSK RCA),
paulson@14199
   830
                    cert (CA i) SKi onlySig (priSK RCA)|} \<in> set evs;
paulson@14199
   831
        KC3 \<in> symKeys;  evs \<in> set_cr|]
paulson@14199
   832
      ==> Nonce CardSecret \<notin> analz (knows Spy evs)"
paulson@14199
   833
apply (frule Gets_certificate_valid, assumption)
paulson@14199
   834
apply (subgoal_tac "Key KC3 \<notin> analz (knows Spy evs) ")
paulson@14199
   835
apply (blast dest: CardSecret_secrecy_lemma)
paulson@14199
   836
apply (rule symKey_secrecy)
paulson@14199
   837
apply (auto simp add: parts_insert2)
paulson@14199
   838
done
paulson@14199
   839
paulson@14199
   840
paulson@14199
   841
subsection{*Secrecy of NonceCCA [the CA's secret] *}
paulson@14199
   842
paulson@14199
   843
lemma NC2_not_NonceCCA:
paulson@14199
   844
     "[|Hash {|Agent C', Nonce N', Agent C, Nonce N|}
paulson@14199
   845
          \<in> parts (knows Spy evs);
paulson@14199
   846
        Nonce N \<notin> analz (knows Spy evs);
paulson@14199
   847
       evs \<in> set_cr|]
paulson@14199
   848
      ==> Crypt KC1 {|{|Agent B, Nonce N|}, Hash p|} \<notin> parts (knows Spy evs)"
paulson@14199
   849
apply (erule rev_mp)
paulson@14199
   850
apply (erule rev_mp)
paulson@14199
   851
apply (erule set_cr.induct, analz_mono_contra, simp_all)
paulson@14199
   852
apply (blast dest: Hash_imp_parts2)+
paulson@14199
   853
done
paulson@14199
   854
paulson@14199
   855
paulson@14199
   856
text{*Inductive version*}
paulson@14199
   857
lemma NonceCCA_secrecy_lemma [rule_format]:
paulson@14199
   858
     "[|CA i \<notin> bad;  evs \<in> set_cr|]
paulson@14199
   859
      ==> Key K \<notin> analz (knows Spy evs) -->
paulson@14199
   860
          Crypt K
paulson@14199
   861
            {|sign (priSK (CA i))
paulson@14199
   862
                   {|Agent C, Nonce N, Agent(CA i), Nonce NonceCCA|},
paulson@14199
   863
              X, Y|}
paulson@14199
   864
             \<in> parts (knows Spy evs) -->
paulson@14199
   865
          Nonce NonceCCA \<notin> analz (knows Spy evs)"
paulson@14199
   866
apply (erule set_cr.induct, analz_mono_contra)
wenzelm@24123
   867
apply (valid_certificate_tac [8]) --{*for message 5*}
wenzelm@24123
   868
apply (valid_certificate_tac [6]) --{*for message 5*}
paulson@14199
   869
apply (frule_tac [9] msg6_KeyCryptNonce_disj [THEN disjE])
paulson@14199
   870
apply (simp_all
paulson@14199
   871
         del: image_insert image_Un imp_disjL
paulson@14199
   872
         add: analz_image_keys_simps analz_knows_absorb sign_def
paulson@14199
   873
              analz_Key_image_insert_eq notin_image_iff
paulson@14199
   874
              EXHcrypt_def Crypt_notin_image_Key
paulson@14199
   875
              N_fresh_not_KeyCryptNonce DK_fresh_not_KeyCryptNonce
paulson@14199
   876
              ball_conj_distrib Nonce_compromise symKey_compromise
paulson@14199
   877
              analz_image_priEK)
wenzelm@24123
   878
  --{*3 seconds on a 1.6GHz machine*}
paulson@14218
   879
apply spy_analz  --{*Fake*}
paulson@14218
   880
apply blast  --{*1*}
paulson@14218
   881
apply (blast dest!: Gets_imp_knows_Spy [THEN analz.Inj])  --{*2*}
paulson@14218
   882
apply blast  --{*3*}
paulson@14218
   883
apply (blast dest: NC2_not_NonceCCA)  --{*4*}
paulson@14218
   884
apply blast  --{*5*}
paulson@14218
   885
apply (blast dest: KC2_secrecy)+  --{*Message 6: two cases*}
paulson@14199
   886
done
paulson@14199
   887
paulson@14199
   888
paulson@14199
   889
text{*Packaged version for cardholder*}
paulson@14199
   890
lemma NonceCCA_secrecy:
paulson@14199
   891
     "[|Cardholder k \<notin> bad;  CA i \<notin> bad;
paulson@14199
   892
        Gets (Cardholder k)
paulson@14199
   893
           (Crypt KC2
paulson@14199
   894
            {|sign (priSK (CA i)) {|Agent C, Nonce N, Agent(CA i), Nonce NonceCCA|},
paulson@14199
   895
              X, Y|}) \<in> set evs;
paulson@14199
   896
        Says (Cardholder k) (CA i)
paulson@14199
   897
           {|Crypt KC3 {|Agent C, Nonce NC3, Key KC2, X'|}, Y'|} \<in> set evs;
paulson@14199
   898
        Gets A {|Z, cert (CA i) EKi onlyEnc (priSK RCA),
paulson@14199
   899
                    cert (CA i) SKi onlySig (priSK RCA)|} \<in> set evs;
paulson@14199
   900
        KC2 \<in> symKeys;  evs \<in> set_cr|]
paulson@14199
   901
      ==> Nonce NonceCCA \<notin> analz (knows Spy evs)"
paulson@14199
   902
apply (frule Gets_certificate_valid, assumption)
paulson@14199
   903
apply (subgoal_tac "Key KC2 \<notin> analz (knows Spy evs) ")
paulson@14199
   904
apply (blast dest: NonceCCA_secrecy_lemma)
paulson@14199
   905
apply (rule symKey_secrecy)
paulson@14199
   906
apply (auto simp add: parts_insert2)
paulson@14199
   907
done
paulson@14199
   908
paulson@14199
   909
text{*We don't bother to prove guarantees for the CA.  He doesn't care about
paulson@14199
   910
  the PANSecret: it isn't his credit card!*}
paulson@14199
   911
paulson@14199
   912
paulson@14199
   913
subsection{*Rewriting Rule for PANs*}
paulson@14199
   914
paulson@14199
   915
text{*Lemma for message 6: either cardSK isn't a CA's private encryption key,
paulson@14199
   916
  or if it is then (because it appears in traffic) that CA is bad,
paulson@14199
   917
  and so the Spy knows that key already.  Either way, we can simplify
paulson@14199
   918
  the expression @{term "analz (insert (Key cardSK) X)"}.*}
paulson@14199
   919
lemma msg6_cardSK_disj:
paulson@14199
   920
     "[|Gets A {|Crypt K {|c, n, k', Key cardSK, X|}, Y|}
paulson@14199
   921
          \<in> set evs;  evs \<in> set_cr |]
paulson@14199
   922
      ==> cardSK \<notin> range(invKey o pubEK o CA) | Key cardSK \<in> knows Spy evs"
paulson@14199
   923
by auto
paulson@14199
   924
paulson@14199
   925
lemma analz_image_pan_lemma:
paulson@14199
   926
     "(Pan P \<in> analz (Key`nE Un H)) --> (Pan P \<in> analz H)  ==>
paulson@14199
   927
      (Pan P \<in> analz (Key`nE Un H)) =   (Pan P \<in> analz H)"
paulson@14199
   928
by (blast intro: analz_mono [THEN [2] rev_subsetD])
paulson@14199
   929
paulson@14199
   930
lemma analz_image_pan [rule_format]:
paulson@14199
   931
     "evs \<in> set_cr ==>
paulson@14199
   932
       \<forall>KK. KK <= - invKey ` pubEK ` range CA -->
paulson@14199
   933
            (Pan P \<in> analz (Key`KK Un (knows Spy evs))) =
paulson@14199
   934
            (Pan P \<in> analz (knows Spy evs))"
paulson@14199
   935
apply (erule set_cr.induct)
paulson@14199
   936
apply (rule_tac [!] allI impI)+
paulson@14199
   937
apply (rule_tac [!] analz_image_pan_lemma)
wenzelm@24123
   938
apply (valid_certificate_tac [8]) --{*for message 5*}
wenzelm@24123
   939
apply (valid_certificate_tac [6]) --{*for message 5*}
paulson@14199
   940
apply (erule_tac [9] msg6_cardSK_disj [THEN disjE])
paulson@14199
   941
apply (simp_all
paulson@14199
   942
         del: image_insert image_Un
paulson@14199
   943
         add: analz_image_keys_simps disjoint_image_iff
paulson@14199
   944
              notin_image_iff analz_image_priEK)
wenzelm@24123
   945
  --{*6 seconds on a 1.6GHz machine*}
paulson@14199
   946
apply spy_analz
paulson@14218
   947
apply (simp add: insert_absorb)  --{*6*}
paulson@14199
   948
done
paulson@14199
   949
paulson@14199
   950
lemma analz_insert_pan:
paulson@14199
   951
     "[| evs \<in> set_cr;  K \<notin> invKey ` pubEK ` range CA |] ==>
paulson@14199
   952
          (Pan P \<in> analz (insert (Key K) (knows Spy evs))) =
paulson@14199
   953
          (Pan P \<in> analz (knows Spy evs))"
paulson@14199
   954
by (simp del: image_insert image_Un
paulson@14199
   955
         add: analz_image_keys_simps analz_image_pan)
paulson@14199
   956
paulson@14199
   957
paulson@14199
   958
text{*Confidentiality of the PAN\@.  Maybe we could combine the statements of
paulson@14199
   959
  this theorem with @{term analz_image_pan}, requiring a single induction but
paulson@14199
   960
  a much more difficult proof.*}
paulson@14199
   961
lemma pan_confidentiality:
paulson@14199
   962
     "[| Pan (pan C) \<in> analz(knows Spy evs); C \<noteq>Spy; evs :set_cr|]
paulson@14199
   963
    ==> \<exists>i X K HN.
paulson@14199
   964
        Says C (CA i) {|X, Crypt (pubEK (CA i)) {|Key K, Pan (pan C), HN|} |}
paulson@14199
   965
           \<in> set evs
paulson@14199
   966
      & (CA i) \<in> bad"
paulson@14199
   967
apply (erule rev_mp)
paulson@14199
   968
apply (erule set_cr.induct)
wenzelm@24123
   969
apply (valid_certificate_tac [8]) --{*for message 5*}
wenzelm@24123
   970
apply (valid_certificate_tac [6]) --{*for message 5*}
paulson@14199
   971
apply (erule_tac [9] msg6_cardSK_disj [THEN disjE])
paulson@14199
   972
apply (simp_all
paulson@14199
   973
         del: image_insert image_Un
paulson@14199
   974
         add: analz_image_keys_simps analz_insert_pan analz_image_pan
paulson@14199
   975
              notin_image_iff analz_image_priEK)
wenzelm@24123
   976
  --{*3.5 seconds on a 1.6GHz machine*}
paulson@14218
   977
apply spy_analz  --{*fake*}
paulson@14218
   978
apply blast  --{*3*}
paulson@14218
   979
apply blast  --{*5*}
paulson@14218
   980
apply (simp (no_asm_simp) add: insert_absorb)  --{*6*}
paulson@14199
   981
done
paulson@14199
   982
paulson@14199
   983
paulson@14199
   984
subsection{*Unicity*}
paulson@14199
   985
paulson@14199
   986
lemma CR6_Says_imp_Notes:
paulson@14199
   987
     "[|Says (CA i) C (Crypt KC2
paulson@14199
   988
          {|sign (priSK (CA i)) {|Agent C, Nonce NC3, Agent (CA i), Nonce Y|},
paulson@14199
   989
            certC (pan C) cardSK X onlySig (priSK (CA i)),
paulson@14199
   990
            cert (CA i) (pubSK (CA i)) onlySig (priSK RCA)|})  \<in> set evs;
paulson@14199
   991
        evs \<in> set_cr |]
paulson@14199
   992
      ==> Notes (CA i) (Key cardSK) \<in> set evs"
paulson@14199
   993
apply (erule rev_mp)
paulson@14199
   994
apply (erule set_cr.induct)
paulson@14199
   995
apply (simp_all (no_asm_simp))
paulson@14199
   996
done
paulson@14199
   997
paulson@14199
   998
text{*Unicity of cardSK: it uniquely identifies the other components.  
paulson@14199
   999
      This holds because a CA accepts a cardSK at most once.*}
paulson@14199
  1000
lemma cardholder_key_unicity:
paulson@14199
  1001
     "[|Says (CA i) C (Crypt KC2
paulson@14199
  1002
          {|sign (priSK (CA i)) {|Agent C, Nonce NC3, Agent (CA i), Nonce Y|},
paulson@14199
  1003
            certC (pan C) cardSK X onlySig (priSK (CA i)),
paulson@14199
  1004
            cert (CA i) (pubSK (CA i)) onlySig (priSK RCA)|})
paulson@14199
  1005
          \<in> set evs;
paulson@14199
  1006
        Says (CA i) C' (Crypt KC2'
paulson@14199
  1007
          {|sign (priSK (CA i)) {|Agent C', Nonce NC3', Agent (CA i), Nonce Y'|},
paulson@14199
  1008
            certC (pan C') cardSK X' onlySig (priSK (CA i)),
paulson@14199
  1009
            cert (CA i) (pubSK (CA i)) onlySig (priSK RCA)|})
paulson@14199
  1010
          \<in> set evs;
paulson@14199
  1011
        evs \<in> set_cr |] ==> C=C' & NC3=NC3' & X=X' & KC2=KC2' & Y=Y'"
paulson@14199
  1012
apply (erule rev_mp)
paulson@14199
  1013
apply (erule rev_mp)
paulson@14199
  1014
apply (erule set_cr.induct)
paulson@14199
  1015
apply (simp_all (no_asm_simp))
paulson@14199
  1016
apply (blast dest!: CR6_Says_imp_Notes)
paulson@14199
  1017
done
paulson@14199
  1018
paulson@14199
  1019
paulson@14218
  1020
(*<*)
paulson@14199
  1021
text{*UNUSED unicity result*}
paulson@14199
  1022
lemma unique_KC1:
paulson@14199
  1023
     "[|Says C B {|Crypt KC1 X, Crypt EK {|Key KC1, Y|}|}
paulson@14199
  1024
          \<in> set evs;
paulson@14199
  1025
        Says C B' {|Crypt KC1 X', Crypt EK' {|Key KC1, Y'|}|}
paulson@14199
  1026
          \<in> set evs;
paulson@14199
  1027
        C \<notin> bad;  evs \<in> set_cr|] ==> B'=B & Y'=Y"
paulson@14199
  1028
apply (erule rev_mp)
paulson@14199
  1029
apply (erule rev_mp)
paulson@14199
  1030
apply (erule set_cr.induct, auto)
paulson@14199
  1031
done
paulson@14199
  1032
paulson@14199
  1033
text{*UNUSED unicity result*}
paulson@14199
  1034
lemma unique_KC2:
paulson@14199
  1035
     "[|Says C B {|Crypt K {|Agent C, nn, Key KC2, X|}, Y|} \<in> set evs;
paulson@14199
  1036
        Says C B' {|Crypt K' {|Agent C, nn', Key KC2, X'|}, Y'|} \<in> set evs;
paulson@14199
  1037
        C \<notin> bad;  evs \<in> set_cr|] ==> B'=B & X'=X"
paulson@14199
  1038
apply (erule rev_mp)
paulson@14199
  1039
apply (erule rev_mp)
paulson@14199
  1040
apply (erule set_cr.induct, auto)
paulson@14199
  1041
done
paulson@14218
  1042
(*>*)
paulson@14218
  1043
paulson@14199
  1044
paulson@14199
  1045
text{*Cannot show cardSK to be secret because it isn't assumed to be fresh
paulson@14199
  1046
  it could be a previously compromised cardSK [e.g. involving a bad CA]*}
paulson@14199
  1047
paulson@14199
  1048
paulson@14199
  1049
end