Ejemplo n.º 1
0
// This function represents the server application.
// We pass in the key predicate just to get hold of the creator principal id.
struct item *compute_response(int server, struct item *request)
  /*@ requires [?f]world(rpc_pub, rpc_key_clsfy) &*&
               principal(server, ?count) &*&
               item(?key, symmetric_key_item(?creator, ?id), rpc_pub) &*&
               item(request, ?req, rpc_pub) &*&
               (
                 col || bad(creator) || bad(shared_with(creator, id)) ||
                 request(creator, shared_with(creator, id), req)
               );
  @*/
  /*@ ensures  [f]world(rpc_pub, rpc_key_clsfy) &*& 
               principal(server, count + 1) &*&
               item(key, symmetric_key_item(creator, id), rpc_pub) &*& 
               item(request, req, rpc_pub) &*& 
               item(result, ?resp, rpc_pub) &*& [_]rpc_pub(resp) &*& 
               response(creator, shared_with(creator, id), req, resp) == true;
  @*/
{
  //@ item n = nonce_item(server, count + 1, 0);
  //@ close rpc_pub(n);  
  //@ leak rpc_pub(n);
  int random = random_int();
  struct item *response = create_data_item((void*) &random, (int) sizeof(int));
  //@ assert item(response, ?resp, rpc_pub);
  //@ assume (response(creator, shared_with(creator, id), req, resp) == true);
  //@ close rpc_pub(resp);
  //@ leak rpc_pub(resp);
  return response;
}
Ejemplo n.º 2
0
void *sender_t(void* data) //@ : pthread_run_joinable
  //@ requires pthread_run_pre(sender_t)(data, ?x);
  //@ ensures pthread_run_post(sender_t)(data, x) &*& result == 0;
{
  //@ open pthread_run_pre(sender_t)(data, _);
  struct ss_auth_args *args = (void*) data;
  struct item *key = args->key;
  //@ assert principal(?principal, ?count);
  //@ item n = nonce_item(principal, count + 1, 0);
  //@ close ss_auth_pub(n);
  //@ leak ss_auth_pub(n);
  int i = random_int();
  struct item *mess_authage = create_data_item((void*) &i, (int) sizeof(int));
  //@ chars_to_integer(&i);
  //@ assert item(key, private_key_item(?sender, _), ss_auth_pub);
  //@ item datai = data_item(chars_of_int(i));
  //@ assume (app_send_event(sender, datai));
  //@ assert [_]world(ss_auth_pub, ss_auth_key_clsfy);
  //@ close ss_auth_pub(datai);
  //@ leak ss_auth_pub(datai);
  app_send(key, mess_authage);
  //@ close pthread_run_post(sender_t)(data, _);
  item_free(mess_authage);
  return 0;
}
Ejemplo n.º 3
0
void send_data(struct network_status *net_stat)
  /*@ requires [?f0]world(?pub, ?key_clsfy) &*&
               proof_obligations(pub) &*&
               network_status(net_stat) &*&
               principal(?principal, ?count1) &*&
               true == bad(principal); @*/
  /*@ ensures  [f0]world(pub, key_clsfy) &*&
               proof_obligations(pub) &*&
               network_status(net_stat) &*&
               principal(principal, ?count2); @*/
{
  int data_size = random_int_();
  if (data_size > MIN_RANDOM_SIZE)
  {
    char* data = malloc((int) data_size);
    if (data == 0) abort_crypto_lib("malloc failed");
    random_buffer_(data, data_size);
    struct item *item = create_data_item(data, data_size);
    //@ assert item(item, ?i, pub) &*& i == data_item(?d);
    free(data);
    //@ open proof_obligations(pub);
    //@ assert is_public_data(?proof, pub);
    //@ proof(i);
    //@ close proof_obligations(pub);
    network_send(net_stat, item);
    item_free(item);
  }
}
Ejemplo n.º 4
0
void *sender_t(void* data) //@ : pthread_run_joinable
  //@ requires pthread_run_pre(sender_t)(data, ?x);
  //@ ensures pthread_run_post(sender_t)(data, x) &*& result == 0;
{
  //@ open pthread_run_pre(sender_t)(data, _);
  struct ss_args *args = (void*) data;
  struct item *key = args->key;
  int i = random_int();
  struct item *message = create_data_item((void*) &i, (int) sizeof(int));
  //@ chars_to_integer(&i);
  //@ assert item(key, symmetric_key_item(?sender, _), ss_pub);
  //@ item datai = data_item(chars_of_int(i));
  //@ assume (app_send_event(sender, datai));
  //@ assert [_]world(ss_pub);
  //@ get_info_for_item(datai);
  //@ close ss_pub(datai);
  //@ leak ss_pub(datai);
  app_send(key, message);
  //@ close pthread_run_post(sender_t)(data, _);
  item_free(message);
  return 0;
}