1 /** Practical One-time Pad Library
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*/
33 /* Use read_offset() and write_offset() to access offset. */
37 /** Packaged up encrypted message, ready for transport. */
38 typedef struct _MESSAGE
{
45 void load_config(char *config_filename
);
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
);
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
);