Fix off-by-one error in null termination of decrypted messages.
[easyotp.git] / libotp.h
blobae16a169eecc883fe3b9c18670d1bdcef7104d1e
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 #define OFFSET_FILE_EXTENSION ".off"
12 #define OFFSET_SIZE 11 /* strlen("4294967296") + 1 */
14 #define PAD_NAME_LENGTH 4
16 #define MAX_CONFIG_LINE 1024 /* should be enough, >MAX_PATH */
18 /* One-time pad. */
19 typedef struct _PAD {
20 char *local_filename;
21 char *name;
22 FILE *fp;
23 struct _PAD *next;
24 /* Use read_offset() and write_offset() to access offset. */
25 } PAD;
28 /** Packaged up encrypted message, ready for transport. */
29 typedef struct _MESSAGE {
30 unsigned long offset;
31 PAD *pad;
32 unsigned long length;
33 char *cipher_text;
34 } MESSAGE;
36 void show_pads();
37 FILE *open_offset_file(PAD *p, char *mode);
38 unsigned long read_offset(PAD *p);
39 void write_offset(PAD *p, unsigned long offset);
40 void load_pad(char *local_filename, char *pad_name);
41 void free_pads();
42 MESSAGE *unpackage(char *input);
43 void free_message(MESSAGE *);
44 unsigned int otp_decrypt(char *input, char **out);
45 char *otp_decrypt_msg(MESSAGE *msg);