Example #1
0
  private void handleSecrecy(
      Entity session,
      Entity child,
      List<ITerm> knowers,
      FunctionSymbol setSymbol,
      String protName,
      ExpressionContext ctx,
      ITerm term) {
    LocationInfo loc = term.getLocation();
    Entity rootEnt = session.findRootEntity();
    FunctionTerm secrecyTerm =
        rootEnt.secrecyTerm(
            session,
            session.getIDSymbol().term(loc, child),
            child,
            knowers,
            term /* = payload*/,
            setSymbol,
            protName,
            loc);
    // System.out.println("secrecy term: " + secrecyTerm.getRepresentation());

    ctx.addSessionGoalTerm(secrecyTerm);
    for (ITerm t : session.childChain(loc, child)) {
      ctx.addSessionGoalTerm(t);
    }
  }
Example #2
0
 // for new-style (i.e., session) secrecy and channel goals
 public void buildGoalContext(ExpressionContext ctx, ITerm term) {
   Entity current = term.getScope().findFirstEntity();
   LocationInfo loc = term.getLocation();
   if (current == null
       || goal == null
       || !(goal.getOwner()
           instanceof Entity)) { // maybe due to disabled goal, which is warned for.
     if (goal != null) // should not get here!
     current
           .getErrorGatherer()
           .addError(
               loc,
               ErrorMessages.INTERNAL_ERROR_ANNOTATION_LOST,
               this.name,
               term.getRepresentation());
     return;
   }
   Entity session = (Entity) goal.getOwner();
   IScope root = session.findRoot();
   if (goal instanceof SessionSecrecyGoal) {
     SessionSecrecyGoal secrGoal = (SessionSecrecyGoal) goal;
     handleSecrecy(
         session,
         current,
         knowers,
         secrGoal.getSetSymbol(),
         secrGoal.getSecrecyProtocolName(),
         ctx,
         term);
   } else {
     SessionChannelGoal chGoal = (SessionChannelGoal) goal;
     boolean undirectedAuth = chGoal.hasUndirectedAuthentication();
     ITerm actor = current.getActorSymbol().term();
     boolean senderIsActor = actor.equals(sender);
     boolean receiverIsActor = actor.equals(receiver);
     {
       if (sender != null && (receiver != null || undirectedAuth)) {
         if (chGoal.hasSecrecy()) {
           List<ITerm> knowers = new ArrayList<ITerm>();
           knowers.add(sender);
           knowers.add(receiver);
           handleSecrecy(
               session,
               current,
               knowers,
               chGoal.getSetSymbol(),
               chGoal.getSecrecyProtocolName(),
               ctx,
               term);
           // retract secrecy on receive (i.e. add intruder to set of knowers):
           if (receiverIsActor) {
             ITerm retractSecr =
                 root.findFunction(Prelude.ADD)
                     .term(
                         chGoal.getSetSymbol().term(session.getIDSymbol().term()),
                         root.findConstant(Prelude.INTRUDER).term());
             ctx.addSessionGoalTerm(retractSecr);
           }
         }
         if (chGoal.hasAuthentication() || chGoal.hasFreshness()) {
           List<ITerm> toAdd = new ArrayList<ITerm>();
           ConstantSymbol cAuthProt = null;
           if (chGoal.hasAuthentication()) {
             cAuthProt =
                 session.findRootEntity().findConstant(chGoal.getAuthenticationProtocolName());
           }
           ConstantSymbol cFreshProt = null;
           if (chGoal.hasFreshness()) {
             cFreshProt = session.findRootEntity().findConstant(chGoal.getFreshnessProtocolName());
           }
           if (senderIsActor) { // sender side
             if (chGoal.hasAuthentication()) {
               toAdd.add(
                   root.findFunction(Prelude.WITNESS)
                       .term(
                           actor,
                           chGoal.hasUndirectedAuthentication()
                               ? root.findConstant(Prelude.INTRUDER).term()
                               : receiver,
                           cAuthProt.term(),
                           term));
             }
             /*							if (chGoal.hasFreshness()) {
             	toAdd.add(root.findFunction(Prelude.WITNESS).term(mappedSender.term(), <ceiver.term(), cFreshProt.term(), this));
             }*/
           } else { // receiver side
             if (chGoal.hasAuthentication()) {
               toAdd.add(
                   root.findFunction(Prelude.REQUEST)
                       .term(actor, sender, cAuthProt.term(), term, current.getIDSymbol().term()));
             }
             if (chGoal.hasFreshness()) {
               toAdd.add(
                   root.findFunction(Prelude.REQUEST)
                       .term(
                           actor, sender, cFreshProt.term(), term, current.getIDSymbol().term()));
             }
           }
           for (ITerm t : toAdd) {
             ctx.addSessionGoalTerm(t);
           }
         }
       }
     }
   }
 }