2004-07-24 16:05:20 +01:00
|
|
|
#ifndef SYSTEM
|
|
|
|
#define SYSTEM
|
2004-04-23 11:58:43 +01:00
|
|
|
|
2004-07-24 20:07:29 +01:00
|
|
|
#include "term.h"
|
|
|
|
#include "termmap.h"
|
|
|
|
#include "termlist.h"
|
2004-04-23 11:58:43 +01:00
|
|
|
#include "knowledge.h"
|
2004-07-24 20:07:29 +01:00
|
|
|
#include "constraint.h"
|
2004-07-21 11:35:39 +01:00
|
|
|
#include "states.h"
|
2004-07-24 20:07:29 +01:00
|
|
|
#include "role.h"
|
2004-08-15 12:55:22 +01:00
|
|
|
#include "list.h"
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
#define runPointerGet(sys,run) sys->runs[run].index
|
|
|
|
#define runPointerSet(sys,run,newp) sys->runs[run].index = newp
|
|
|
|
|
2004-08-09 11:05:58 +01:00
|
|
|
enum outputs
|
2004-08-19 11:46:27 +01:00
|
|
|
{ EMPTY, ATTACK, STATESPACE, SCENARIOS, SUMMARY, PROOF };
|
2004-07-29 14:08:27 +01:00
|
|
|
|
2004-08-10 16:02:37 +01:00
|
|
|
enum engines
|
|
|
|
{ POR_ENGINE, ARACHNE_ENGINE };
|
|
|
|
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Protocol definition.
|
2004-04-23 11:58:43 +01:00
|
|
|
struct protocol
|
|
|
|
{
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Name of the protocol encoded in a term.
|
2004-04-23 11:58:43 +01:00
|
|
|
Term nameterm;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! List of role definitions.
|
2004-04-23 11:58:43 +01:00
|
|
|
Role roles;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! List of role names.
|
2004-04-23 11:58:43 +01:00
|
|
|
Termlist rolenames;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! List of local terms for this protocol.
|
2004-04-23 11:58:43 +01:00
|
|
|
Termlist locals;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Pointer to next protocol.
|
2004-04-23 11:58:43 +01:00
|
|
|
struct protocol *next;
|
|
|
|
};
|
|
|
|
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Shorthand for protocol pointer.
|
2004-04-23 11:58:43 +01:00
|
|
|
typedef struct protocol *Protocol;
|
|
|
|
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Run container.
|
2004-04-23 11:58:43 +01:00
|
|
|
struct run
|
|
|
|
{
|
2004-08-09 11:05:58 +01:00
|
|
|
Protocol protocol; //!< Protocol of this run.
|
|
|
|
Role role; //!< Role of this run.
|
|
|
|
Termlist agents; //!< Agents involved in this run.
|
|
|
|
int step; //!< Current execution point in the run (integer)
|
|
|
|
Roledef index; //!< Current execution point in the run (roledef pointer)
|
|
|
|
Roledef start; //!< Head of the run definition.
|
|
|
|
Knowledge know; //!< Current knowledge of the run.
|
|
|
|
Termlist locals; //!< Locals of the run.
|
2004-08-10 16:02:37 +01:00
|
|
|
Termlist artefacts; //!< Stuff created especially for this run.
|
2004-08-15 20:58:26 +01:00
|
|
|
Termlist substitutions; //!< The substitutions as they came from the roledef unifier
|
2004-08-09 11:05:58 +01:00
|
|
|
int prevSymmRun; //!< Used for symmetry reduction. Either -1, or the previous run with the same role def and at least a single parameter.
|
|
|
|
int firstNonAgentRead; //!< Used for symmetry reductions for equal agents runs; -1 if there is no candidate.
|
|
|
|
int firstReal; //!< 1 if a choose was inserted, otherwise 0
|
2004-04-23 11:58:43 +01:00
|
|
|
};
|
|
|
|
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Shorthand for run pointer.
|
2004-04-23 11:58:43 +01:00
|
|
|
typedef struct run *Run;
|
|
|
|
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Buffer for variables substitution state.
|
2004-04-23 11:58:43 +01:00
|
|
|
struct varbuf
|
|
|
|
{
|
2004-05-15 13:33:01 +01:00
|
|
|
//! List of closed variables.
|
2004-08-09 11:05:58 +01:00
|
|
|
Termlist from;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! List of terms to which the closed variables are bound.
|
2004-08-09 11:05:58 +01:00
|
|
|
Termlist to;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! List of open variables.
|
2004-08-09 11:05:58 +01:00
|
|
|
Termlist empty;
|
2004-04-23 11:58:43 +01:00
|
|
|
};
|
|
|
|
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Shorthand for varbuf pointer.
|
2004-04-23 11:58:43 +01:00
|
|
|
typedef struct varbuf *Varbuf;
|
|
|
|
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Trace buffer.
|
2004-04-23 11:58:43 +01:00
|
|
|
struct tracebuf
|
|
|
|
{
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Length of trace.
|
2004-08-09 11:05:58 +01:00
|
|
|
int length;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Length of trace minus the redundant events.
|
2004-08-09 11:05:58 +01:00
|
|
|
int reallength;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Array of events.
|
2004-08-09 11:05:58 +01:00
|
|
|
Roledef *event;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Array of run identifiers for each event.
|
2004-08-09 11:05:58 +01:00
|
|
|
int *run;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Array of status flags for each event.
|
|
|
|
/**
|
|
|
|
*\sa S_OKE, S_RED, S_TOD, S_UNK
|
|
|
|
*/
|
2004-08-09 11:05:58 +01:00
|
|
|
int *status;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Array for matching sends to reads.
|
2004-08-09 11:05:58 +01:00
|
|
|
int *link;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Index of violated claim in trace.
|
2004-08-09 11:05:58 +01:00
|
|
|
int violatedclaim;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Array of knowledge sets for each event.
|
2004-08-09 11:05:58 +01:00
|
|
|
Knowledge *know;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! List of terms required to be in the final knowledge.
|
2004-08-09 11:05:58 +01:00
|
|
|
Termlist requiredterms;
|
2004-05-15 13:33:01 +01:00
|
|
|
//! List of variables in the system.
|
2004-08-09 11:05:58 +01:00
|
|
|
Varbuf variables;
|
2004-04-23 11:58:43 +01:00
|
|
|
};
|
|
|
|
|
2004-05-15 13:33:01 +01:00
|
|
|
//! The main state structure.
|
2004-04-23 11:58:43 +01:00
|
|
|
struct system
|
|
|
|
{
|
2004-08-10 16:02:37 +01:00
|
|
|
int engine; //!< Engine type (POR_ENGINE,ARACHNE_ENGINE)
|
2004-05-15 13:33:01 +01:00
|
|
|
int step; //!< Step in trace during exploration. Can be managed globally
|
|
|
|
Knowledge know; //!< Knowledge in currect step of system.
|
2004-04-23 11:58:43 +01:00
|
|
|
struct parameters *parameters; // misc
|
|
|
|
/* static run info, maxruns */
|
|
|
|
Run runs;
|
|
|
|
|
|
|
|
/* global */
|
2004-05-15 13:33:01 +01:00
|
|
|
int maxruns; //!< Number of runs in the system.
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
/* properties */
|
2004-05-15 13:33:01 +01:00
|
|
|
Termlist secrets; //!< Integrate secrets list into system.
|
2004-08-09 11:05:58 +01:00
|
|
|
Termlist synchronising_labels; //!< List of labels that might synchronise.
|
2004-05-15 13:33:01 +01:00
|
|
|
int shortestattack; //!< Length of shortest attack trace.
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
/* switches */
|
2004-07-29 11:13:13 +01:00
|
|
|
int output; //!< From enum outputs: what should be produced. Default ATTACK.
|
2004-04-23 11:58:43 +01:00
|
|
|
int report;
|
2004-05-15 13:33:01 +01:00
|
|
|
int prune; //!< Type of pruning.
|
|
|
|
int switch_maxtracelength; //!< Helps to remember the length of the last trace.
|
|
|
|
int maxtracelength; //!< helps to remember the length of the last trace.
|
|
|
|
int switchM; //!< Memory display switch.
|
|
|
|
int switchT; //!< Time display switch.
|
|
|
|
int switchS; //!< Progress display switch. (traversed states)
|
|
|
|
int porparam; //!< A multi-purpose integer parameter, passed to the partial order reduction method selected.
|
2004-08-16 15:49:41 +01:00
|
|
|
int switchRuns; //!< The number of runs as in the switch
|
2004-07-28 12:39:08 +01:00
|
|
|
int switchScenario; //!< -1 to count, 0 for disable, 1-n to select the choose scenario
|
2004-07-29 15:47:46 +01:00
|
|
|
int switchScenarioSize; //!< Scenario size, also called fixed trace prefix length
|
2004-07-14 10:33:55 +01:00
|
|
|
int switchForceChoose; //!< Force chooses for each run, even if involved in first read
|
2004-07-28 12:39:08 +01:00
|
|
|
int switchChooseFirst; //!< Priority to chooses, implicit and explicit
|
2004-07-15 12:04:15 +01:00
|
|
|
int switchReadSymm; //!< Enable read symmetry reduction
|
2004-07-19 10:32:12 +01:00
|
|
|
int switchAgentSymm; //!< Enable agent symmetry reduction
|
2004-07-15 14:32:09 +01:00
|
|
|
int switchSymmOrder; //!< Enable symmetry order reduction
|
2004-07-19 10:44:54 +01:00
|
|
|
int switchNomoreClaims; //!< Enable no more claims cutter
|
|
|
|
int switchReduceEndgame; //!< Enable endgame cutter
|
2004-08-11 09:17:49 +01:00
|
|
|
int switchReduceClaims; //!< Symmetry reduction on claims (only works when switchAgentSymm is true)
|
2004-07-29 13:36:24 +01:00
|
|
|
int switchClaims; //!< Enable clails report
|
2004-08-09 10:42:58 +01:00
|
|
|
Term switchClaimToCheck; //!< Which claim should be checked?
|
2004-07-15 14:32:09 +01:00
|
|
|
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Latex output switch.
|
|
|
|
/**
|
|
|
|
* Obsolete. Use globalLatex instead.
|
|
|
|
*\sa globalLatex
|
|
|
|
*/
|
2004-08-09 11:05:58 +01:00
|
|
|
int latex;
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
/* traversal */
|
2004-05-15 13:33:01 +01:00
|
|
|
int traverse; //!< Traversal method.
|
|
|
|
int explore; //!< Boolean: explore states after actions or not.
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
/* counters */
|
2004-07-30 13:04:38 +01:00
|
|
|
states_t states; //!< States traversed
|
|
|
|
states_t statesScenario; //!< States traversed that are within the scenario, not the prefix
|
2004-07-21 11:35:39 +01:00
|
|
|
states_t interval; //!< Used to update state printing at certain intervals
|
|
|
|
states_t claims; //!< Number of claims encountered.
|
|
|
|
states_t failed; //!< Number of claims failed.
|
2004-07-28 12:39:08 +01:00
|
|
|
int countScenario; //!< Number of scenarios skipped.
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
/* matching */
|
2004-05-15 13:33:01 +01:00
|
|
|
int match; //!< Matching type.
|
|
|
|
int clp; //!< Do we use clp?
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
/* protocol definition */
|
2004-06-16 11:39:13 +01:00
|
|
|
Protocol protocols; //!< List of protocols in the system
|
|
|
|
Termlist locals; //!< List of local terms
|
|
|
|
Termlist variables; //!< List of all variables
|
|
|
|
Termlist untrusted; //!< List of untrusted agent names
|
2004-04-23 11:58:43 +01:00
|
|
|
|
2004-06-14 23:08:47 +01:00
|
|
|
/* protocol preprocessing */
|
2004-06-16 11:39:13 +01:00
|
|
|
int rolecount; //!< Number of roles in the system
|
|
|
|
int roleeventmax; //!< Maximum number of events in a single role
|
2004-07-28 12:39:08 +01:00
|
|
|
int lastChooseRun; //!< Last run with a choose event
|
2004-06-16 11:39:13 +01:00
|
|
|
Claimlist claimlist; //!< List of claims in the system, with occurrence counts
|
2004-06-14 23:08:47 +01:00
|
|
|
|
2004-04-23 11:58:43 +01:00
|
|
|
/* constructed trace pointers, static */
|
2004-06-16 11:39:13 +01:00
|
|
|
Roledef *traceEvent; //!< Trace roledefs: MaxRuns * maxRoledef
|
|
|
|
int *traceRun; //!< Trace run ids: MaxRuns * maxRoledef
|
|
|
|
Knowledge *traceKnow; //!< Trace intruder knowledge: Maxruns * maxRoledef
|
2004-07-21 11:35:39 +01:00
|
|
|
states_t *traceNode; //!< Trace node traversal: Maxruns * maxRoledef
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
/* POR reduction assistance */
|
2004-06-16 11:39:13 +01:00
|
|
|
int PORphase; //!< -1: init (all sends), 0...: recurse reads
|
|
|
|
int PORdone; //!< Simple bit to denote something was done.
|
|
|
|
int knowPhase; //!< Which knowPhase have we already explored?
|
|
|
|
Constraintlist constraints; //!< Only needed for CLP match
|
2004-04-23 11:58:43 +01:00
|
|
|
|
2004-08-15 12:55:22 +01:00
|
|
|
/* Arachne assistance */
|
|
|
|
List bindings; //!< List of bindings
|
|
|
|
|
2004-05-15 13:33:01 +01:00
|
|
|
//! Shortest attack storage.
|
2004-08-09 11:05:58 +01:00
|
|
|
struct tracebuf *attack;
|
2004-07-26 13:43:19 +01:00
|
|
|
|
|
|
|
//! Command line arguments
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
2004-04-23 11:58:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct system *System;
|
|
|
|
|
|
|
|
System systemInit ();
|
|
|
|
void systemReset (const System sys);
|
2004-07-28 12:39:08 +01:00
|
|
|
void systemRuns (const System sys);
|
2004-07-20 13:41:56 +01:00
|
|
|
System systemDuplicate (const System fromsys);
|
|
|
|
void statesPrint (const System sys);
|
|
|
|
void statesPrintShort (const System sys);
|
|
|
|
void systemDestroy (const System sys);
|
|
|
|
void systemDone (const System sys);
|
|
|
|
void ensureValidRun (const System sys, int run);
|
2004-04-23 11:58:43 +01:00
|
|
|
void runPrint (Roledef rd);
|
2004-07-20 13:41:56 +01:00
|
|
|
void runsPrint (const System sys);
|
2004-04-23 11:58:43 +01:00
|
|
|
Term agentOfRunRole (const System sys, const int run, const Term role);
|
|
|
|
Term agentOfRun (const System sys, const int run);
|
|
|
|
void roleInstance (const System sys, const Protocol protocol, const Role role,
|
2004-08-15 20:58:26 +01:00
|
|
|
const Termlist paramlist, Termlist substlist);
|
2004-08-10 16:02:37 +01:00
|
|
|
void roleInstanceDestroy (const System sys);
|
2004-07-20 13:41:56 +01:00
|
|
|
void systemStart (const System sys);
|
2004-04-23 11:58:43 +01:00
|
|
|
void indentActivate ();
|
|
|
|
void indentSet (int i);
|
|
|
|
void indent ();
|
|
|
|
|
|
|
|
Protocol protocolCreate (Term nameterm);
|
|
|
|
void locVarPrint (Termlist tl);
|
|
|
|
void protocolPrint (Protocol p);
|
|
|
|
void protocolsPrint (Protocol p);
|
2004-07-20 13:41:56 +01:00
|
|
|
int untrustedAgent (const System sys, Termlist agents);
|
2004-04-23 11:58:43 +01:00
|
|
|
int getMaxTraceLength (const System sys);
|
|
|
|
void agentsOfRunPrint (const System sys, const int run);
|
|
|
|
void violatedClaimPrint (const System sys, int i);
|
2004-08-09 11:05:58 +01:00
|
|
|
int attackLength (struct tracebuf *tb);
|
|
|
|
void commandlinePrint (FILE * stream, const System sys);
|
2004-04-23 11:58:43 +01:00
|
|
|
|
2004-06-16 11:39:13 +01:00
|
|
|
int compute_rolecount (const System sys);
|
|
|
|
int compute_roleeventmax (const System sys);
|
|
|
|
|
2004-07-28 12:39:08 +01:00
|
|
|
void scenarioPrint (const System sys);
|
2004-08-12 10:14:31 +01:00
|
|
|
int system_iterate_roles (const System sys, int (*func) ());
|
2004-07-28 12:39:08 +01:00
|
|
|
|
2004-04-23 11:58:43 +01:00
|
|
|
#endif
|