Delta Chat Core C-API
mrpgp.h
1 /*******************************************************************************
2  *
3  * Delta Chat Core
4  * Copyright (C) 2017 Björn Petersen
5  * Contact: r10s@b44t.com, http://b44t.com
6  *
7  * This program is free software: you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later
10  * version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program. If not, see http://www.gnu.org/licenses/ .
19  *
20  ******************************************************************************/
21 
22 
23 #ifndef __MRPGP_H__
24 #define __MRPGP_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 /*** library-private **********************************************************/
31 
32 typedef struct mrkey_t mrkey_t;
33 typedef struct mrkeyring_t mrkeyring_t;
34 
35 
36 /* validation errors */
37 #define MR_VALIDATE_NO_SIGNATURE 0x01
38 #define MR_VALIDATE_UNKNOWN_SIGNATURE 0x02
39 #define MR_VALIDATE_BAD_SIGNATURE 0x04
40 #define MR_VALIDATE_NOT_MUTUAL 0x08
41 
42 /* misc. */
43 void mrpgp_init (mrmailbox_t*);
44 void mrpgp_exit (mrmailbox_t*);
45 void mrpgp_rand_seed (mrmailbox_t*, const void* buf, size_t bytes);
46 
47 
48 /* public key encryption */
49 int mrpgp_create_keypair (mrmailbox_t*, const char* addr, mrkey_t* public_key, mrkey_t* private_key);
50 int mrpgp_is_valid_key (mrmailbox_t*, const mrkey_t*);
51 int mrpgp_calc_fingerprint (mrmailbox_t*, const mrkey_t*, uint8_t** fingerprint, size_t* fingerprint_bytes);
52 int mrpgp_split_key (mrmailbox_t*, const mrkey_t* private_in, mrkey_t* public_out);
53 
54 int mrpgp_pk_encrypt (mrmailbox_t*, const void* plain, size_t plain_bytes, const mrkeyring_t*, const mrkey_t* sign_key, int use_armor, void** ret_ctext, size_t* ret_ctext_bytes);
55 int mrpgp_pk_decrypt (mrmailbox_t*, const void* ctext, size_t ctext_bytes, const mrkeyring_t*, const mrkey_t* validate_key, int use_armor, void** plain, size_t* plain_bytes, int* ret_validation_errors);
56 
57 
58 #ifdef __cplusplus
59 } /* /extern "C" */
60 #endif
61 #endif /* __MRPGP_H__ */
An object representing a single mailbox.
Definition: mrmailbox.h:194