2007-06-11 13:01:04 +01:00
|
|
|
/*
|
|
|
|
* Scyther : An automatic verifier for security protocols.
|
2012-04-24 12:56:51 +01:00
|
|
|
* Copyright (C) 2007-2012 Cas Cremers
|
2007-06-11 13:01:04 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2004-07-24 16:05:20 +01:00
|
|
|
#ifndef ROLES
|
|
|
|
#define ROLES
|
|
|
|
|
2004-07-24 20:07:29 +01:00
|
|
|
#include "term.h"
|
|
|
|
#include "termmap.h"
|
|
|
|
#include "termlist.h"
|
2004-07-24 16:05:20 +01:00
|
|
|
#include "knowledge.h"
|
|
|
|
#include "states.h"
|
|
|
|
|
2004-08-09 11:05:58 +01:00
|
|
|
enum eventtype
|
2012-04-25 08:53:07 +01:00
|
|
|
{ RECV, SEND, CLAIM, ANYEVENT };
|
2004-07-24 16:05:20 +01:00
|
|
|
|
|
|
|
//! The container for the claim info list
|
2006-02-22 08:24:29 +00:00
|
|
|
/**
|
|
|
|
* Defaults are set in compiler.c (claimCreate)
|
|
|
|
*/
|
2004-07-24 16:05:20 +01:00
|
|
|
struct claimlist
|
|
|
|
{
|
2004-07-24 21:30:00 +01:00
|
|
|
//! The type of claim
|
|
|
|
Term type;
|
2004-07-24 16:05:20 +01:00
|
|
|
//! The term element for this node.
|
|
|
|
Term label;
|
2005-12-28 11:50:17 +00:00
|
|
|
//! Any parameters
|
|
|
|
Term parameter;
|
2004-10-14 14:19:36 +01:00
|
|
|
//! The pointer to the protocol (not defined typically, because
|
|
|
|
//! at compile time of the claim the protocol structure is not known yet.)
|
2004-08-14 16:59:14 +01:00
|
|
|
void *protocol;
|
2004-07-24 16:05:20 +01:00
|
|
|
//! The name of the role in which it occurs.
|
|
|
|
Term rolename;
|
2004-08-14 16:59:14 +01:00
|
|
|
//! The pointer to the role structure
|
|
|
|
void *role;
|
2004-08-14 20:19:23 +01:00
|
|
|
//! The pointer to the roledef
|
|
|
|
void *roledef;
|
2004-07-24 16:05:20 +01:00
|
|
|
//! Number of occurrences in system exploration.
|
|
|
|
states_t count;
|
|
|
|
//! Number of occurrences that failed.
|
|
|
|
states_t failed;
|
2006-02-22 08:24:29 +00:00
|
|
|
//! Number of iterations traversed for this claim.
|
|
|
|
states_t states;
|
2004-08-19 14:09:35 +01:00
|
|
|
//! Whether the result is complete or not (failings always are!)
|
|
|
|
int complete;
|
2005-01-14 13:01:31 +00:00
|
|
|
//! If we ran into the time bound (incomplete, and bad for results)
|
|
|
|
int timebound;
|
2005-12-27 13:44:12 +00:00
|
|
|
//! Some claims are always true (shown by the initial scan)
|
|
|
|
int alwaystrue;
|
|
|
|
//! Warnings should tell you more
|
|
|
|
int warnings;
|
2004-08-19 14:09:35 +01:00
|
|
|
|
2004-08-09 11:05:58 +01:00
|
|
|
int r; //!< role number for mapping
|
|
|
|
int ev; //!< event index in role
|
2004-07-24 16:05:20 +01:00
|
|
|
//! Preceding label list
|
|
|
|
Termlist prec;
|
2004-08-27 13:36:23 +01:00
|
|
|
//! Roles that are involved (nameterms)
|
|
|
|
Termlist roles;
|
2004-07-24 16:05:20 +01:00
|
|
|
//! Next node pointer or NULL for the last element of the function.
|
|
|
|
struct claimlist *next;
|
2007-01-29 17:20:45 +00:00
|
|
|
|
|
|
|
int lineno;
|
2004-07-24 16:05:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
//! Shorthand for claimlist pointers.
|
|
|
|
typedef struct claimlist *Claimlist;
|
|
|
|
|
|
|
|
//! Structure for a role event node or list.
|
|
|
|
/**
|
|
|
|
*\sa role
|
|
|
|
*/
|
|
|
|
struct roledef
|
|
|
|
{
|
|
|
|
//! flag for internal actions.
|
|
|
|
/**
|
2012-04-25 08:53:07 +01:00
|
|
|
* Typically, this is true to signify internal recvs (e.g. variable choices)
|
|
|
|
* as opposed to a normal recv.
|
2004-07-24 16:05:20 +01:00
|
|
|
*/
|
|
|
|
int internal;
|
|
|
|
//! Type of event.
|
|
|
|
/**
|
2012-04-25 08:53:07 +01:00
|
|
|
*\sa RECV, SEND, CLAIM
|
2004-07-24 16:05:20 +01:00
|
|
|
*/
|
|
|
|
int type;
|
|
|
|
//! Event label.
|
|
|
|
Term label;
|
|
|
|
//! Event sender.
|
|
|
|
Term from;
|
|
|
|
//! Event target.
|
|
|
|
Term to;
|
|
|
|
//! Event message.
|
|
|
|
Term message;
|
|
|
|
//! Pointer to next roledef node.
|
|
|
|
struct roledef *next;
|
|
|
|
|
|
|
|
/*
|
2012-04-25 08:53:07 +01:00
|
|
|
* Substructure for recvs
|
2004-07-24 16:05:20 +01:00
|
|
|
*/
|
|
|
|
//! Illegal injections for this event.
|
2004-07-24 21:30:00 +01:00
|
|
|
/**
|
|
|
|
* For send this means that the send is allowed if it is NULL, otherwise it is blocked.
|
|
|
|
*/
|
2004-07-24 16:05:20 +01:00
|
|
|
Knowledge forbidden;
|
|
|
|
//! knowledge transitions counter.
|
|
|
|
int knowPhase;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Substructure for claims
|
|
|
|
*/
|
|
|
|
//! Pointer to claim type info
|
|
|
|
Claimlist claiminfo;
|
|
|
|
|
2004-08-10 16:17:00 +01:00
|
|
|
/*
|
|
|
|
* Bindings for Arachne engine
|
|
|
|
*/
|
2006-01-02 21:06:08 +00:00
|
|
|
int bound; //!< determines whether it is already bound
|
2004-08-10 16:17:00 +01:00
|
|
|
|
2004-07-24 16:05:20 +01:00
|
|
|
/* evt runid for synchronisation, but that is implied in the
|
|
|
|
base array */
|
2007-01-29 17:20:45 +00:00
|
|
|
int lineno;
|
2004-07-24 16:05:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
//! Shorthand for roledef pointer.
|
|
|
|
typedef struct roledef *Roledef;
|
|
|
|
|
|
|
|
//! Role definition.
|
|
|
|
/**
|
|
|
|
*\sa roledef
|
|
|
|
*/
|
|
|
|
struct role
|
|
|
|
{
|
|
|
|
//! Name of the role encoded in a term.
|
|
|
|
Term nameterm;
|
|
|
|
//! List of role events.
|
|
|
|
Roledef roledef;
|
|
|
|
//! Local constants for this role.
|
|
|
|
Termlist locals;
|
2004-08-12 10:14:31 +01:00
|
|
|
//! Local variables for this role.
|
|
|
|
Termlist variables;
|
2005-12-28 11:50:17 +00:00
|
|
|
//! Declared constants for this role
|
|
|
|
Termlist declaredconsts;
|
2005-12-27 13:44:12 +00:00
|
|
|
//! Declared variables for this role
|
|
|
|
Termlist declaredvars;
|
2006-07-27 11:44:12 +01:00
|
|
|
//! Initial role knowledge
|
|
|
|
Termlist knows;
|
2005-09-09 11:05:29 +01:00
|
|
|
//! Flag for initiator roles
|
|
|
|
int initiator;
|
2006-01-02 16:05:53 +00:00
|
|
|
//! Flag for singular roles
|
|
|
|
int singular;
|
2004-07-24 16:05:20 +01:00
|
|
|
//! Pointer to next role definition.
|
|
|
|
struct role *next;
|
2007-01-29 17:20:45 +00:00
|
|
|
//! Line number
|
|
|
|
int lineno;
|
2004-07-24 16:05:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
//! Shorthand for role pointer.
|
|
|
|
typedef struct role *Role;
|
|
|
|
|
|
|
|
void roledefPrint (Roledef rd);
|
2004-10-28 13:56:13 +01:00
|
|
|
void roledefPrintShort (Roledef rd);
|
2004-07-24 16:05:20 +01:00
|
|
|
Roledef roledefDuplicate1 (const Roledef rd);
|
|
|
|
Roledef roledefDuplicate (Roledef rd);
|
|
|
|
void roledefDelete (Roledef rd);
|
|
|
|
void roledefDestroy (Roledef rd);
|
2004-08-09 11:05:58 +01:00
|
|
|
Roledef roledefInit (int type, Term label, Term from, Term to, Term msg,
|
|
|
|
Claimlist cl);
|
|
|
|
Roledef roledefAdd (Roledef rd, int type, Term label, Term from, Term to,
|
|
|
|
Term msg, Claimlist cl);
|
2004-07-24 16:05:20 +01:00
|
|
|
Role roleCreate (Term nameterm);
|
|
|
|
void rolePrint (Role r);
|
|
|
|
void rolesPrint (Role r);
|
2004-08-12 10:14:31 +01:00
|
|
|
int roledef_iterate_events (Roledef rd, int (*func) ());
|
2004-08-12 12:22:49 +01:00
|
|
|
int roledef_length (const Roledef rd);
|
|
|
|
Roledef roledef_shift (Roledef rd, int i);
|
2006-03-08 15:12:58 +00:00
|
|
|
int roledefSubTerm (Roledef rd, Term tsub);
|
2006-07-31 12:08:51 +01:00
|
|
|
Knowledge WellFormedEvent (Term role, Knowledge know, Roledef rd);
|
2004-07-24 16:05:20 +01:00
|
|
|
|
|
|
|
#endif
|