crypto.h
1 /*
2  This file is part of Pretty Curved Privacy (pcp1).
3 
4  Copyright (C) 2013-2015 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 _HAVE_PCP_CRYPTO_H
24 #define _HAVE_PCP_CRYPTO_H
25 
26 #include <sodium.h>
27 #include <string.h>
28 #include <stdio.h>
29 #include <sodium.h>
30 #include <stdlib.h>
31 
32 #include "defines.h"
33 #include "mem.h"
34 #include "key.h"
35 #include "keyhash.h"
36 #include "ed.h"
37 #include "pcpstream.h"
38 #include "context.h"
39 
142 byte *pcp_box_encrypt(PCPCTX *ptx, pcp_key_t *secret, pcp_pubkey_t *pub,
143  byte *message, size_t messagesize,
144  size_t *csize);
145 
168 byte *pcp_box_decrypt(PCPCTX *ptx, pcp_key_t *secret, pcp_pubkey_t *pub,
169  byte *cipher, size_t ciphersize,
170  size_t *dsize);
171 
172 
196 size_t pcp_encrypt_stream(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, pcp_key_t *s, pcp_pubkey_t *p, int signcrypt, int anon);
197 
221 size_t pcp_encrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte *symkey, int havehead, pcp_rec_t *recsign);
222 
223 
249 size_t pcp_decrypt_stream(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, pcp_key_t *s, byte *symkey, int verify, int anon);
250 
251 
273 size_t pcp_decrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte *symkey, pcp_rec_t *recverify);
274 
275 
276 
277 
295 size_t pcp_sodium_mac(byte **cipher,
296  byte *cleartext,
297  size_t clearsize,
298  byte *nonce,
299  byte *key);
300 
301 
320 int pcp_sodium_verify_mac(byte **cleartext,
321  byte* message,
322  size_t messagesize,
323  byte *nonce,
324  byte *key);
325 
326 
327 
328 
329 
330 
331 
332 
333 pcp_rec_t *pcp_rec_new(byte *cipher, size_t clen, pcp_key_t *secret, pcp_pubkey_t *pub);
334 void pcp_rec_free(pcp_rec_t *r);
335 
336 #endif /* _HAVE_PCP_CRYPTO_H */
337