Rename SecureInbox to SecureMail, since it is used for not only ingoing but also...
[easyotp.git] / libotp.h
blobf979dd898fed483587a3a67392dbfcb2f6d778f1
1 /** Practical One-time Pad Library
3 * Created:20080514
4 * By Jeff Connelly
5 */
7 #define MARKER_TO "to:"
8 #define MARKER_BEGIN "--EMOTP_BEGIN--"
9 #define MARKER_END "--EMOTP_END--"
11 /** Pad messages to a multiple of this many bytes, to hide the true
12 * message length. Higher obscures more information but burns more pad.
13 * For the best security, this should be the length of the longest message
14 * you'll ever send, then all messages will be the same length and an attacker
15 * can tell nothing by the length of the message!.
17 #define PADDING_MULTIPLE 16
19 #define OFFSET_FILE_EXTENSION ".off"
20 #define OFFSET_SIZE 11 /* strlen("4294967296") + 1 */
21 #define PAD_NAME_LENGTH 4
22 #define MAX_CONFIG_LINE 1024 /* should be enough, >MAX_PATH */
24 /* Define to get warnings if a message is replayed. */
25 /*#define WARN_REPLAY*/
27 /* One-time pad. */
28 typedef struct _PAD {
29 char *local_filename;
30 char *name;
31 FILE *fp;
32 struct _PAD *next;
33 /* Use read_offset() and write_offset() to access offset. */
34 } PAD;
37 /** Packaged up encrypted message, ready for transport. */
38 typedef struct _MESSAGE {
39 unsigned long offset;
40 PAD *pad;
41 unsigned long length;
42 char *cipher_text;
43 } MESSAGE;
45 void load_config(char *config_filename);
46 void show_pads();
47 FILE *open_offset_file(PAD *p, char *mode);
48 unsigned long read_offset(PAD *p);
49 void write_offset(PAD *p, unsigned long offset);
50 void load_pad(char *local_filename, char *pad_name);
51 void free_pads();
52 MESSAGE *unpackage(char *input);
53 void free_message(MESSAGE *);
54 char *otp_encrypt(char *input, unsigned int length, char *to, unsigned int *out_length);
55 unsigned int otp_decrypt(char *input, char **out);