defines.h
1 /*
2  This file is part of Pretty Curved Privacy (pcp1).
3 
4  Copyright (C) 2013-2014 T.v.Dein.
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: <tom AT vondein 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_ENFILE_HEADER "----- BEGIN PCP ENCRYPTED FILE -----\r\n"
62 #define PCP_ENFILE_FOOTER "\r\n----- END PCP ENCRYPTED FILE -----\r\n"
63 
64 #define PCP_ZFILE_HEADER "----- BEGIN Z85 ENCODED FILE -----"
65 #define PCP_ZFILE_FOOTER "----- END Z85 ENCODED FILE -----"
66 
67 #define PCP_SIG_HEADER "----- BEGIN ED25519 SIGNED MESSAGE -----"
68 #define PCP_SIG_START "----- BEGIN ED25519 SIGNATURE -----"
69 #define PCP_SIG_END "----- END ED25519 SIGNATURE -----"
70 #define PCP_SIGPREFIX "\nnacl-"
71 
72 #define PCP_ME "Pretty Curved Privacy"
73 
74 #define PCP_KEY_VERSION 6
75 #define PCP_KEY_PRIMITIVE "CURVE25519-ED25519-SALSA20-POLY1305"
76 
77 typedef enum _ZBEGINS {
78  PCP_ENCRYPTED_FILE,
79  Z85_ENCODED_FILE,
80  ED25519_SIGNED_MESSAGE,
81  ED25519_SIGNATURE,
82  ED25519_CURVE29915_PUBLIC_KEY,
83  ED25519_CURVE29915_PRIVATE_KEY,
84 } ZBEGINS;
85 
95 typedef enum _PCP_KEY_TYPES {
101 } PCP_KEY_TYPES;
102 
106 /* save typing, dammit */
107 #define PCP_ENCRYPT_MAC crypto_secretbox_ZEROBYTES + crypto_secretbox_NONCEBYTES
108 
109 /* vault id */
110 #define PCP_VAULT_ID 14
111 #define PCP_VAULT_VERSION 2
112 
113 /* sigs */
114 #define PCP_SIG_VERSION 2
115 
116 /* crypto file format stuff */
117 /* enabled via config.h (configure --enable-cbc) */
118 #ifndef PCP_CBC
119  #define PCP_ASYM_CIPHER 5
120  #define PCP_ASYM_CIPHER_ANON 6
121  #define PCP_SYM_CIPHER 23
122  #define PCP_ASYM_CIPHER_SIG 24
123  #define PCP_BLOCK_SIZE 32 * 1024
124 #else
125 /* CBC mode, use smaller blocks */
126  #define PCP_ASYM_CIPHER 7
127  #define PCP_ASYM_CIPHER_ANON 9
128  #define PCP_ASYM_CIPHER_SIG 8
129  #define PCP_SYM_CIPHER 25
130  #define PCP_BLOCK_SIZE 1 * 1024
131 #endif
132 
133 #define PCP_CRYPTO_ADD (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES)
134 #define PCP_BLOCK_SIZE_IN (PCP_BLOCK_SIZE) + PCP_CRYPTO_ADD + crypto_secretbox_NONCEBYTES
135 #define PCP_ASYM_RECIPIENT_SIZE crypto_secretbox_KEYBYTES + PCP_CRYPTO_ADD + crypto_secretbox_NONCEBYTES
136 
137 /* #define PCP_ASYM_ADD_SENDER_PUB */
138 
139 /* used for self encryption only */
140 #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"
141 
142 #define PCP_RFC_CIPHER 0x21 /* curve25519+ed25519+poly1305+salsa20+blake2 */
143 
144 
145 
146 /* defines for key management (mgmt.c) */
147 #define EXP_PK_CIPHER 0x21
148 #define EXP_PK_CIPHER_NAME "CURVE25519-ED25519-POLY1305-SALSA20"
149 
150 #define EXP_HASH_CIPHER 0x22
151 #define EXP_HASH_NAME "BLAKE2"
152 
153 #define EXP_SIG_CIPHER 0x23
154 #define EXP_SIG_CIPHER_NAME "ED25519"
155 
156 #define EXP_SIG_VERSION 0x01
157 #define EXP_SIG_TYPE 0x1F /* self signed */
158 
159 /* sig sub notiation we support */
160 #define EXP_SIG_SUB_CTIME 2
161 #define EXP_SIG_SUB_SIGEXPIRE 3
162 #define EXP_SIG_SUB_KEYEXPIRE 9
163 #define EXP_SIG_SUB_NOTATION 20
164 #define EXP_SIG_SUB_KEYFLAGS 27
165 
166 /* in armored mode, we're using the usual head+foot */
167 #define EXP_PK_HEADER "----- BEGIN ED25519-CURVE29915 PUBLIC KEY -----"
168 #define EXP_PK_FOOTER "----- END ED25519-CURVE29915 PUBLIC KEY -----"
169 #define EXP_SK_HEADER "----- BEGIN ED25519-CURVE29915 PRIVATE KEY -----"
170 #define EXP_SK_FOOTER "----- END ED25519-CURVE29915 PRIVATE KEY -----"
171 
172 
173 /* pubkey export formats */
174 #define EXP_FORMAT_NATIVE 1
175 #define EXP_FORMAT_PBP 2
176 #define EXP_FORMAT_YAML 3
177 #define EXP_FORMAT_C 4
178 #define EXP_FORMAT_PY 5
179 #define EXP_FORMAT_PERL 6
180 
181 
182 
183 
184 
185 #endif /* _DEFINES_H */
186