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 */
30 /* Use read_offset() and write_offset() to access offset. */
34 /** Packaged up encrypted message, ready for transport. */
35 typedef struct _MESSAGE
{
42 void load_config(char *config_filename
);
44 FILE *open_offset_file(PAD
*p
, char *mode
);
45 unsigned long read_offset(PAD
*p
);
46 void write_offset(PAD
*p
, unsigned long offset
);
47 void load_pad(char *local_filename
, char *pad_name
);
49 MESSAGE
*unpackage(char *input
);
50 void free_message(MESSAGE
*);
51 char *otp_encrypt(char *input
, unsigned int length
, char *to
, unsigned int *out_length
);
52 unsigned int otp_decrypt(char *input
, char **out
);