libpcp  0.2.1
crypto.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 _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 
118 size_t pcp_sodium_box(unsigned char **cipher,
119  unsigned char *cleartext,
120  size_t clearsize,
121  unsigned char *nonce,
122  unsigned char *secret,
123  unsigned char *pub);
124 
125 int pcp_sodium_verify_box(unsigned char **cleartext, unsigned char* message,
126  size_t messagesize, unsigned char *nonce,
127  unsigned char *secret, unsigned char *pub);
128 
149 unsigned char *pcp_box_encrypt(pcp_key_t *secret, pcp_pubkey_t *pub,
150  unsigned char *message, size_t messagesize,
151  size_t *csize);
152 
173 unsigned char *pcp_box_decrypt(pcp_key_t *secret, pcp_pubkey_t *pub,
174  unsigned char *cipher, size_t ciphersize,
175  size_t *dsize);
176 
177 
197 size_t pcp_encrypt_stream(Pcpstream *in, Pcpstream* out, pcp_key_t *s, pcp_pubkey_t *p, int signcrypt);
198 
220 size_t pcp_encrypt_stream_sym(Pcpstream *in, Pcpstream* out, unsigned char *symkey, int havehead, pcp_rec_t *recsign);
221 
222 
244 size_t pcp_decrypt_stream(Pcpstream *in, Pcpstream* out, pcp_key_t *s, unsigned char *symkey, int verify);
245 
246 
266 size_t pcp_decrypt_stream_sym(Pcpstream *in, Pcpstream* out, unsigned char *symkey, pcp_rec_t *recverify);
267 
268 pcp_rec_t *pcp_rec_new(unsigned char *cipher, size_t clen, pcp_key_t *secret, pcp_pubkey_t *pub);
269 void pcp_rec_free(pcp_rec_t *r);
270 
271 #endif /* _HAVE_PCP_CRYPTO_H */
272