//! Retrieve rightmost thing of label Term rightMostTerm (Term t) { if (t != NULL) { t = deVar (t); if (realTermTuple (t)) { return rightMostTerm (TermOp2 (t)); } } return t; }
/** * Try to unify (a subterm of) tbig with tsmall. * * Callback is called with a list of substitutions, and a list of terms that * need to be decrypted in order for this to work. * * E.g. subtermUnify ( {{m}k1}k2, m ) yields a list : {{m}k1}k2, {m}k1 (where * the {m}k1 is the last added node to the list) * * The callback should return true for the iteration to proceed, or false to abort. * The final result is this flag. * * This is the actual procedure used by the Arachne algorithm in archne.c */ int subtermUnify (Term tbig, Term tsmall, Termlist tl, Termlist keylist, int (*callback) (), void *state) { int proceed; struct su_kcb_state kcb_state; kcb_state.oldstate = state; kcb_state.callback = callback; kcb_state.keylist = keylist; proceed = true; // Devar tbig = deVar (tbig); tsmall = deVar (tsmall); // Three options: // 1. simple unification proceed = proceed && unify (tbig, tsmall, tl, keycallback, &kcb_state); // [2/3]: complex if (switches.intruder) { // 2. interm unification // Only if there is an intruder if (realTermTuple (tbig)) { proceed = proceed && subtermUnify (TermOp1 (tbig), tsmall, tl, keylist, callback, state); proceed = proceed && subtermUnify (TermOp2 (tbig), tsmall, tl, keylist, callback, state); } // 3. unification with encryption needed if (realTermEncrypt (tbig)) { // extend the keylist keylist = termlistAdd (keylist, tbig); proceed = proceed && subtermUnify (TermOp (tbig), tsmall, tl, keylist, callback, state); // remove last item again keylist = termlistDelTerm (keylist); } } // Athena problem case: open variable about to be unified. /** * In this case we really need to consider the problematic Athena case for untyped variables. */ if (isTermVariable (tbig)) { // Check the type: can it contain tuples, encryptions? if (isOpenVariable (tbig)) { // This one needs to be pursued by further constraint adding /** * Currently, this is not implemented yet. TODO. * This is actually the main Athena problem that we haven't solved yet. */ // Mark that we don't have a full proof, and possibly remark in proof output. markNoFullProof (tbig, tsmall); } } return proceed; }