web_common.mli 3.8 KB
Newer Older
Stephane Glondu's avatar
Stephane Glondu committed
1 2 3
(**************************************************************************)
(*                                BELENIOS                                *)
(*                                                                        *)
Stephane Glondu's avatar
Stephane Glondu committed
4
(*  Copyright © 2012-2014 Inria                                           *)
Stephane Glondu's avatar
Stephane Glondu committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
(*                                                                        *)
(*  This program is free software: you can redistribute it and/or modify  *)
(*  it under the terms of the GNU Affero General Public License as        *)
(*  published by the Free Software Foundation, either version 3 of the    *)
(*  License, or (at your option) any later version, with the additional   *)
(*  exemption that compiling, linking, and/or using OpenSSL is allowed.   *)
(*                                                                        *)
(*  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     *)
(*  Affero General Public License for more details.                       *)
(*                                                                        *)
(*  You should have received a copy of the GNU Affero General Public      *)
(*  License along with this program.  If not, see                         *)
(*  <http://www.gnu.org/licenses/>.                                       *)
(**************************************************************************)

22
open Serializable_builtin_t
23
open Serializable_t
Stephane Glondu's avatar
Stephane Glondu committed
24
open Web_serializable_t
25

26 27
val spool_dir : string ref

28
val make_rng : unit -> Platform.rng Lwt.t
29 30 31 32
(** Create a pseudo random number generator initialized by a 128-bit
    secure random seed. *)

module type LWT_RANDOM = Signatures.RANDOM with type 'a t = 'a Lwt.t
33 34

module type LWT_RNG = sig
35
  val rng : Platform.rng Lwt.t
36 37
end

38
module MakeLwtRandom (X : LWT_RNG) : LWT_RANDOM
39 40
(** Lwt-compatible random number generation. *)

41
type error =
42 43 44 45 46 47 48 49
  | Serialization of exn
  | ProofCheck
  | ElectionClosed
  | MissingCredential
  | InvalidCredential
  | RevoteNotAllowed
  | ReusedCredential
  | WrongCredential
Stephane Glondu's avatar
Stephane Glondu committed
50 51
  | UsedCredential
  | CredentialNotFound
52
  | UnauthorizedVoter
53 54 55

exception Error of error

56
val fail : error -> 'a Lwt.t
57

58
val explain_error : error -> string
Stephane Glondu's avatar
Stephane Glondu committed
59

60 61 62 63 64
val open_security_log : string -> unit Lwt.t
(** Set the path to the security logger. *)

val security_log : (unit -> string) -> unit Lwt.t
(** Add an entry to the security log. *)
65 66 67

val fail_http : int -> 'a Lwt.t
val forbidden : unit -> 'a Lwt.t
68 69 70

val rewrite_prefix : string -> string
val set_rewrite_prefix : src:string -> dst:string -> unit
Stephane Glondu's avatar
Stephane Glondu committed
71

72 73 74 75 76
type election_file =
  | ESRaw
  | ESKeys
  | ESCreds
  | ESBallots
Stephane Glondu's avatar
Stephane Glondu committed
77
  | ESVoters
78
  | ESRecords
79
  | ESETally
80
  | ESResult
81 82 83

val election_file_of_string : string -> election_file
val string_of_election_file : election_file -> string
84 85 86 87 88 89

val election_file :
  string ->
  (election_file, [ `WithoutSuffix ],
   [ `One of election_file ] Eliom_parameter.param_name)
  Eliom_parameter.params_type
90 91 92 93 94 95 96 97 98

val uuid_of_string : string -> Uuidm.t

val uuid :
  string ->
  (Uuidm.t, [ `WithoutSuffix ],
   [ `One of Uuidm.t ] Eliom_parameter.param_name)
  Eliom_parameter.params_type

99 100 101 102 103
type setup_voter = {
  sv_id : string;
  mutable sv_password : bool;
}

104 105 106
type setup_election = {
  mutable se_owner : user;
  mutable se_group : string;
107
  mutable se_voters : setup_voter list;
108 109 110 111
  mutable se_questions : template;
  mutable se_public_keys : (string * string ref) list;
  mutable se_metadata : metadata;
  mutable se_public_creds : string;
112
  mutable se_public_creds_received : bool;
113 114 115
}

val generate_token : unit -> string Lwt.t
116 117

val string_of_user : user -> string
Stephane Glondu's avatar
Stephane Glondu committed
118 119

val underscorize : string -> string
120 121

val send_email : string -> string -> string -> string -> unit Lwt.t
122 123

val split_identity : string -> string * string