Revision ebafbc92ad9b52ae775ab3bd4f9ddbb32bd51e73 authored by Pierre-Yves Strub on 05 July 2014, 22:13:30 UTC, committed by Pierre-Yves Strub on 05 July 2014, 22:13:30 UTC
1 parent 7c527a4
MAC.ec
(* --------------------------------------------------------------------
* Copyright IMDEA Software Institute / INRIA - 2013, 2014
* -------------------------------------------------------------------- *)
require import FSet.
type key.
type message.
type tag.
module type Scheme = {
proc * init(): unit {}
proc keygen(): key
proc mac(k:key,m:message): tag
proc verify(k:key,m:message,t:tag): bool
}.
module type Oracles = {
proc mac(m:message): tag
proc verify(m:message,t:tag): bool
}.
module Wrap(S:Scheme) = {
var qs:message set
var k:key
proc init(): unit = {
qs = empty;
S.init();
k = S.keygen();
}
proc mac(m:message): tag = {
var r:tag;
qs = add m qs;
r = S.mac(k,m);
return r;
}
proc verify(m:message,t:tag): bool = {
var r:bool;
r = S.verify(k,m,t);
return r;
}
proc fresh(m:message): bool = {
return (!mem m qs);
}
}.
module type Adv_CMA(O:Oracles) = {
proc forge(): (message * tag)
}.
module CMA(S:Scheme,A:Adv_CMA) = {
module O = Wrap(S)
module A = A(O)
proc main(): bool = {
var m:message;
var t:tag;
var forged,fresh:bool;
O.init();
(m,t) = A.forge();
forged = O.verify(m,t);
fresh = O.fresh(m);
return forged /\ fresh;
}
}.
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...