-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpgp-ffi.h
More file actions
107 lines (90 loc) · 2.87 KB
/
pgp-ffi.h
File metadata and controls
107 lines (90 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* Generated by cbindgen */
#ifndef pgp_ffi_h
#define pgp_ffi_h
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct Certificate Certificate;
typedef struct Key Key;
typedef struct UserID UserID;
/**
* # Safety
* `cert` must be non-null and from a `pgp_certificate_*` constructor.
*/
void pgp_certificate_free(struct Certificate *cert);
/**
* # Safety
* `key` must be non-null and from a `pgp_key_*` constructor.
*/
void pgp_key_free(struct Key *key);
/**
* # Safety
* `user_id` must be non-null and from a `pgp_user_id_*` constructor.
*/
void pgp_user_id_free(struct UserID *user_id);
/**
* Parse an ASCII-armored PGP cert into `*cert`.
*
* # Safety
* `armored` and `cert` must be non-null.
*/
int32_t pgp_certificate_from_armored(const char *armored, struct Certificate **cert);
/**
* Generate a new certificate with the given user ID.
*
* # Safety
* `user_id` and `new_cert` must be non-null.
*/
int32_t pgp_key_generate(const char *user_id, struct Certificate **new_cert);
/**
* Export the certificate as an ASCII-armored secret key block.
* Caller must free `*armored` with `free()`.
*
* # Safety
* `cert` and `armored` must be non-null.
*/
int32_t pgp_certificate_export_armored(const struct Certificate *cert, char **armored);
/**
* Revoke the cert and write the updated cert to `*revoked_cert`.
*
* # Safety
* `cert` and `revoked_cert` must be non-null.
*/
int32_t pgp_certificate_revoke(const struct Certificate *cert, struct Certificate **revoked_cert);
/**
* Add a transport-encryption subkey, writing the updated cert to `*new_cert`.
*
* # Safety
* `cert` and `new_cert` must be non-null.
*/
int32_t pgp_certificate_add_transport_encryption_subkey(const struct Certificate *cert,
struct Certificate **new_cert);
/**
* Revoke the subkey at `subkey_index`, writing the updated cert to `*new_cert`.
*
* # Safety
* `cert` and `new_cert` must be non-null.
*/
int32_t pgp_certificate_revoke_subkey(const struct Certificate *cert,
uint32_t subkey_index,
struct Certificate **new_cert);
/**
* Add `user_id` to the cert, writing the updated cert to `*new_cert`.
*
* # Safety
* `cert`, `user_id`, and `new_cert` must be non-null.
*/
int32_t pgp_certificate_add_userid(const struct Certificate *cert,
const char *user_id,
struct Certificate **new_cert);
/**
* Revoke the exact-match user ID, writing the updated cert to `*new_cert`.
*
* # Safety
* `cert`, `user_id`, and `new_cert` must be non-null.
*/
int32_t pgp_certificate_revoke_userid(const struct Certificate *cert,
const char *user_id,
struct Certificate **new_cert);
#endif /* pgp_ffi_h */