libpcp  0.2.4
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 
119 size_t pcp_sodium_box(byte **cipher,
120  byte *cleartext,
121  size_t clearsize,
122  byte *nonce,
123  byte *secret,
124  byte *pub);
125 
126 int pcp_sodium_verify_box(byte **cleartext, byte* message,
127  size_t messagesize, byte *nonce,
128  byte *secret, byte *pub);
129 
152 byte *pcp_box_encrypt(PCPCTX *ptx, pcp_key_t *secret, pcp_pubkey_t *pub,
153  byte *message, size_t messagesize,
154  size_t *csize);
155 
178 byte *pcp_box_decrypt(PCPCTX *ptx, pcp_key_t *secret, pcp_pubkey_t *pub,
179  byte *cipher, size_t ciphersize,
180  size_t *dsize);
181 
182 
206 size_t pcp_encrypt_stream(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, pcp_key_t *s, pcp_pubkey_t *p, int signcrypt, int anon);
207 
231 size_t pcp_encrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte *symkey, int havehead, pcp_rec_t *recsign);
232 
233 
259 size_t pcp_decrypt_stream(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, pcp_key_t *s, byte *symkey, int verify, int anon);
260 
261 
283 size_t pcp_decrypt_stream_sym(PCPCTX *ptx, Pcpstream *in, Pcpstream* out, byte *symkey, pcp_rec_t *recverify);
284 
285 pcp_rec_t *pcp_rec_new(byte *cipher, size_t clen, pcp_key_t *secret, pcp_pubkey_t *pub);
286 void pcp_rec_free(pcp_rec_t *r);
287 
288 #endif /* _HAVE_PCP_CRYPTO_H */
289