libpcp  0.2.1
defines.h
1 /*
2  This file is part of Pretty Curved Privacy (pcp1).
3 
4  Copyright (C) 2013 T.Linden.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19  You can contact me by mail: <tlinden AT cpan DOT org>.
20 */
21 
22 
23 #ifndef _DEFINES_H
24 #define _DEFINES_H
25 
26 
54 #include "config.h"
55 
56 typedef unsigned char byte; /* Single unsigned byte = 8 bits */
57 typedef unsigned short dbyte; /* Double byte = 16 bits */
58 typedef unsigned int qbyte; /* Quad byte = 32 bits */
59 
60 /* key stuff, deprecated. */
61 #define PCP_KEY_HEADER "----- BEGIN PCP SECRET KEY -----"
62 #define PCP_KEY_FOOTER "------ END PCP SECRET KEY ------"
63 
64 #define PCP_PUBKEY_HEADER "----- BEGIN PCP PUBLIC KEY -----"
65 #define PCP_PUBKEY_FOOTER "------ END PCP PUBLICKEY ------"
66 
67 #define PCP_ENFILE_HEADER "----- BEGIN PCP ENCRYPTED FILE -----"
68 #define PCP_ENFILE_FOOTER "------ END PCP ENCRYPTED FILE ------"
69 
70 #define PCP_ZFILE_HEADER "----- BEGIN Z85 ENCODED FILE -----"
71 #define PCP_ZFILE_FOOTER "------ END Z85 ENCODED FILE ------"
72 
73 #define PCP_SIG_HEADER "----- BEGIN ED25519 SIGNED MESSAGE -----"
74 #define PCP_SIG_START "----- BEGIN ED25519 SIGNATURE -----"
75 #define PCP_SIG_END "------ END ED25519 SIGNATURE ------"
76 #define PCP_SIGPREFIX "\nnacl-"
77 
78 #define PCP_ME "Pretty Curved Privacy"
79 
80 #define PCP_KEY_VERSION 6
81 #define PCP_KEY_PRIMITIVE "CURVE25519-ED25519-SALSA20-POLY1305"
82 
92 typedef enum _PCP_KEY_TYPES {
98 } PCP_KEY_TYPES;
99 
103 /* save typing, dammit */
104 #define PCP_ENCRYPT_MAC crypto_secretbox_ZEROBYTES + crypto_secretbox_NONCEBYTES
105 
106 /* vault id */
107 #define PCP_VAULT_ID 14
108 #define PCP_VAULT_VERSION 2
109 
110 /* sigs */
111 #define PCP_SIG_VERSION 2
112 
113 /* crypto file format stuff */
114 /* enabled via config.h (configure --enable-cbc) */
115 #ifndef PCP_CBC
116  #define PCP_ASYM_CIPHER 5
117  #define PCP_SYM_CIPHER 23
118  #define PCP_BLOCK_SIZE 32 * 1024
119 #else
120 /* CBC mode, use smaller blocks */
121  #define PCP_ASYM_CIPHER 7
122  #define PCP_SYM_CIPHER 25
123  #define PCP_BLOCK_SIZE 1 * 1024
124 #endif
125 
126 #define PCP_CRYPTO_ADD (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES)
127 #define PCP_BLOCK_SIZE_IN (PCP_BLOCK_SIZE) + PCP_CRYPTO_ADD + crypto_secretbox_NONCEBYTES
128 #define PCP_ASYM_RECIPIENT_SIZE crypto_secretbox_KEYBYTES + PCP_CRYPTO_ADD + crypto_secretbox_NONCEBYTES
129 
130 /* #define PCP_ASYM_ADD_SENDER_PUB */
131 
132 /* used for self encryption only */
133 #define PBP_COMPAT_SALT "qa~t](84z<1t<1oz:ik.@IRNyhG=8q(on9}4#!/_h#a7wqK{Nt$T?W>,mt8NqYq&6U<GB1$,<$j>,rSYI2GRDd:Bcm"
134 
135 #define PCP_RFC_CIPHER 0x21 /* curve25519+ed25519+poly1305+salsa20+blake2 */
136 
145 /* error handling */
146 
152 extern char *PCP_ERR;
153 
158 extern byte PCP_ERRSET;
159 
164 extern int PCP_EXIT;
165 
176 void fatal(const char * fmt, ...);
177 
183 void fatals_ifany();
184 
190 void fatals_reset();
191 
194 void fatals_done();
195 
196 #endif /* _DEFINES_H */
197