- Improving proof output.

This commit is contained in:
ccremers 2004-08-19 11:37:41 +00:00
parent 1180d3cf6f
commit c993e17597

View File

@ -145,8 +145,8 @@ indentPrint ()
if (i % 3 == 0) if (i % 3 == 0)
eprintf ("|"); eprintf ("|");
else else
eprintf (" "); eprintf (" ");
eprintf (" "); eprintf (" ");
} }
} }
@ -186,7 +186,7 @@ add_read_goals (const int run, const int old, const int new)
{ {
if (count == 0) if (count == 0)
{ {
indentPrint(); indentPrint ();
eprintf ("* Thus, we must also produce "); eprintf ("* Thus, we must also produce ");
} }
else else
@ -194,7 +194,7 @@ add_read_goals (const int run, const int old, const int new)
eprintf (", "); eprintf (", ");
} }
termPrint (rd->message); termPrint (rd->message);
} }
goal_add (rd->message, run, i); goal_add (rd->message, run, i);
count++; count++;
} }
@ -321,12 +321,29 @@ proof_select_goal (Binding b)
Roledef rd; Roledef rd;
rd = roledef_shift (sys->runs[b->run_to].start, b->ev_to); rd = roledef_shift (sys->runs[b->run_to].start, b->ev_to);
indentDepth--;
indentPrint (); indentPrint ();
eprintf ("Where does term "); eprintf ("Selected goal: Where does term ");
termPrint (b->term); termPrint (b->term);
eprintf (" , needed for "); eprintf (" originate first?\n");
indentPrint ();
eprintf ("* It is required for ");
roledefPrint (rd); roledefPrint (rd);
eprintf (" at index %i in run %i, originate first?\n", b->ev_to, b->run_to); eprintf (" at index %i in run %i\n", b->ev_to, b->run_to);
indentDepth++;
}
}
//! Cannot bind because of cycle
void
proof_cannot_bind (const Binding b, const int run, const int index)
{
if (sys->output == PROOF)
{
indentPrint ();
eprintf
("Cannot bind this to run %i, index %i because that introduces a cycle.\n",
run, index);
} }
} }
@ -340,11 +357,16 @@ proof_suppose_binding (Binding b)
indentPrint (); indentPrint ();
rd = roledef_shift (sys->runs[b->run_from].start, b->ev_from); rd = roledef_shift (sys->runs[b->run_from].start, b->ev_from);
eprintf ("Suppose it originates in run %i, at ", b->run_from); eprintf ("Suppose it originates in run %i, at index %i\n", b->run_from,
b->ev_from);
indentPrint ();
eprintf ("* I.e. event ");
roledefPrint (rd); roledefPrint (rd);
eprintf (" from "); eprintf ("\n");
indentPrint ();
eprintf ("* from ");
role_name_print (b->run_from); role_name_print (b->run_from);
eprintf (" at index %i\n", b->ev_from); eprintf ("\n");
} }
} }
@ -419,7 +441,8 @@ bind_existing_to_goal (const Binding b, const int run, const int index)
if (keylist != NULL && sys->output == PROOF) if (keylist != NULL && sys->output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("* This introduces the obligation to produce the following keys: "); eprintf
("* This introduces the obligation to produce the following keys: ");
termlistPrint (keylist); termlistPrint (keylist);
eprintf ("\n"); eprintf ("\n");
} }
@ -444,12 +467,7 @@ bind_existing_to_goal (const Binding b, const int run, const int index)
} }
else else
{ {
if (sys->output == PROOF) proof_cannot_bind (b, run, index);
{
indentPrint ();
eprintf ("Aborted binding existing run because of cycle.\n");
}
flag = 1;
} }
goal_unbind (b); goal_unbind (b);
return flag; return flag;
@ -481,22 +499,43 @@ bind_existing_run (const Binding b, const Protocol p, const Role r,
const int index) const int index)
{ {
int run, flag; int run, flag;
int found;
if (sys->output == PROOF)
{
indentPrint ();
eprintf ("Can we bind it to an existing regular run?\n");
}
indentDepth++;
flag = 1; flag = 1;
found = 0;
for (run = 0; run < sys->maxruns; run++) for (run = 0; run < sys->maxruns; run++)
{ {
if (sys->runs[run].protocol == p && sys->runs[run].role == r) if (sys->runs[run].protocol == p && sys->runs[run].role == r)
{ {
found++;
if (sys->output == PROOF)
{
if (found == 1)
{
indentPrint ();
eprintf ("Can we bind it to an existing regular run of ");
termPrint (p->nameterm);
eprintf (", ");
termPrint (r->nameterm);
eprintf ("?\n");
}
indentPrint ();
eprintf ("%i. Can we bind it to run %i?\n", found, run);
}
indentDepth++;
flag = flag && bind_existing_to_goal (b, run, index); flag = flag && bind_existing_to_goal (b, run, index);
indentDepth--;
} }
} }
indentDepth--; if (sys->output == PROOF && found == 0)
{
indentPrint ();
eprintf ("There is no existing run for ");
termPrint (p->nameterm);
eprintf (", ");
termPrint (r->nameterm);
eprintf ("\n");
}
return flag; return flag;
} }
@ -511,10 +550,11 @@ bind_new_run (const Binding b, const Protocol p, const Role r,
roleInstance (sys, p, r, NULL, NULL); roleInstance (sys, p, r, NULL, NULL);
run = sys->maxruns - 1; run = sys->maxruns - 1;
proof_suppose_run (run, 0, index+1); proof_suppose_run (run, 0, index + 1);
newgoals = add_read_goals (run, 0, index + 1); newgoals = add_read_goals (run, 0, index + 1);
indentDepth++;
flag = bind_existing_to_goal (b, run, index); flag = bind_existing_to_goal (b, run, index);
indentDepth--;
remove_read_goals (newgoals); remove_read_goals (newgoals);
roleInstanceDestroy (sys); roleInstanceDestroy (sys);
return flag; return flag;
@ -655,9 +695,10 @@ bind_goal_new_m0 (const Binding b)
roleInstance (sys, INTRUDER, I_M, NULL, NULL); roleInstance (sys, INTRUDER, I_M, NULL, NULL);
run = sys->maxruns - 1; run = sys->maxruns - 1;
proof_suppose_run (run, 0,1); proof_suppose_run (run, 0, 1);
sys->runs[run].start->message = termDuplicate (b->term); sys->runs[run].start->message = termDuplicate (b->term);
sys->runs[run].length = 1; sys->runs[run].length = 1;
indentDepth++;
if (goal_bind (b, run, 0)) if (goal_bind (b, run, 0))
{ {
proof_suppose_binding (b); proof_suppose_binding (b);
@ -670,7 +711,12 @@ bind_goal_new_m0 (const Binding b)
} }
flag = flag && iterate (); flag = flag && iterate ();
} }
else
{
proof_cannot_bind (b, run, 0);
}
goal_unbind (b); goal_unbind (b);
indentDepth--;
roleInstanceDestroy (sys); roleInstanceDestroy (sys);
termlistSubstReset (subst); termlistSubstReset (subst);
termlistDelete (subst); termlistDelete (subst);
@ -721,12 +767,11 @@ bind_goal_new_encrypt (const Binding b)
rd->next->message = termDuplicate (t2); rd->next->message = termDuplicate (t2);
rd->next->next->message = termDuplicate (term); rd->next->next->message = termDuplicate (term);
index = 2; index = 2;
proof_suppose_run (run, 0, index+1); proof_suppose_run (run, 0, index + 1);
newgoals = add_read_goals (run, 0, index + 1);
if (sys->output == PROOF) if (sys->output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Encrypting "); eprintf ("* Encrypting ");
termPrint (term); termPrint (term);
eprintf (" using term "); eprintf (" using term ");
termPrint (t1); termPrint (t1);
@ -734,12 +779,19 @@ bind_goal_new_encrypt (const Binding b)
termPrint (t2); termPrint (t2);
eprintf ("\n"); eprintf ("\n");
} }
newgoals = add_read_goals (run, 0, index + 1);
indentDepth++;
if (goal_bind (b, run, index)) if (goal_bind (b, run, index))
{ {
proof_suppose_binding (b); proof_suppose_binding (b);
flag = flag && iterate (); flag = flag && iterate ();
} }
else
{
proof_cannot_bind (b, run, index);
}
goal_unbind (b); goal_unbind (b);
indentDepth--;
remove_read_goals (newgoals); remove_read_goals (newgoals);
roleInstanceDestroy (sys); roleInstanceDestroy (sys);
} }
@ -761,6 +813,7 @@ int
bind_goal_regular_run (const Binding b) bind_goal_regular_run (const Binding b)
{ {
int flag; int flag;
int found;
/* /*
* This is a local function so we have access to goal * This is a local function so we have access to goal
@ -799,17 +852,20 @@ bind_goal_regular_run (const Binding b)
int flag; int flag;
// A good candidate // A good candidate
#ifdef DEBUG found++;
if (DEBUGL (5)) if (sys->output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Term "); eprintf ("* ");
termPrint (b->term); termPrint (b->term);
eprintf (" can possibly be bound by role "); eprintf (" matches the pattern ");
termPrint (rd->message);
eprintf (" from ");
termPrint (p->nameterm);
eprintf (", ");
termPrint (r->nameterm); termPrint (r->nameterm);
eprintf (", index %i\n", index); eprintf (", at %i\n", index);
} }
#endif
// Bind to existing run // Bind to existing run
flag = bind_existing_run (b, p, r, index); flag = bind_existing_run (b, p, r, index);
// bind to new run // bind to new run
@ -818,7 +874,6 @@ bind_goal_regular_run (const Binding b)
} }
else else
{ {
// Cannot unify: no attacks
return 1; return 1;
} }
} }
@ -831,7 +886,16 @@ bind_goal_regular_run (const Binding b)
eprintf ("Try regular role send.\n"); eprintf ("Try regular role send.\n");
} }
#endif #endif
return iterate_role_sends (bind_this_role_send); found = 0;
flag = iterate_role_sends (bind_this_role_send);
if (sys->output == PROOF && found == 0)
{
indentPrint ();
eprintf ("The term ");
termPrint (b->term);
eprintf (" does not match any pattern from the role definitions.\n");
}
return flag;
} }
@ -1035,7 +1099,8 @@ add_claim_specifics (const Claimlist cl, const Roledef rd)
termPrint (rd->message); termPrint (rd->message);
eprintf (" as a goal.\n"); eprintf (" as a goal.\n");
indentPrint (); indentPrint ();
eprintf ("* If all goals can be bound, this constitutes an attack.\n"); eprintf
("* If all goals can be bound, this constitutes an attack.\n");
} }
goal_add (rd->message, 0, cl->ev); // Assumption that all claims are in run 0 goal_add (rd->message, 0, cl->ev); // Assumption that all claims are in run 0
} }
@ -1079,7 +1144,6 @@ iterate ()
int flag; int flag;
flag = 1; flag = 1;
indentDepth++;
if (!prune ()) if (!prune ())
{ {
Binding b; Binding b;
@ -1117,7 +1181,6 @@ iterate ()
flag = bind_goal (b); flag = bind_goal (b);
} }
} }
indentDepth--;
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (5) && !flag) if (DEBUGL (5) && !flag)
@ -1207,7 +1270,7 @@ arachne ()
role_name_print (0); role_name_print (0);
eprintf (" at index %i.\n", cl->ev); eprintf (" at index %i.\n", cl->ev);
} }
proof_suppose_run (0,0, cl->ev+1); proof_suppose_run (0, 0, cl->ev + 1);
add_read_goals (sys->maxruns - 1, 0, cl->ev + 1); add_read_goals (sys->maxruns - 1, 0, cl->ev + 1);