1 #ifndef SEQUOIA_OPENPGP_CRYPTO_H
2 #define SEQUOIA_OPENPGP_CRYPTO_H
3 
4 #include <sequoia/openpgp/types.h>
5 
6 /*/
7 /// Creates a new session key.
8 /*/
9 pgp_session_key_t pgp_session_key_new (size_t size);
10 
11 /*/
12 /// Creates a new session key from a buffer.
13 /*/
14 pgp_session_key_t pgp_session_key_from_bytes (uint8_t *buf, size_t size);
15 
16 /*/
17 /// Frees a session key.
18 /*/
19 void pgp_session_key_free (pgp_session_key_t);
20 
21 /*/
22 /// Returns a human readable description of this object suitable for
23 /// debugging.
24 /*/
25 char *pgp_session_key_debug (const pgp_session_key_t fp);
26 
27 /*/
28 /// Clones the session key.
29 /*/
30 pgp_session_key_t pgp_session_key_clone (pgp_session_key_t session_key);
31 
32 /*/
33 /// Compares session keys.
34 /*/
35 bool pgp_session_key_equal (const pgp_session_key_t a,
36 			   const pgp_session_key_t b);
37 
38 /*/
39 /// Creates a new password from a buffer.
40 /*/
41 pgp_password_t pgp_password_from_bytes (uint8_t *buf, size_t size);
42 
43 /*/
44 /// Frees a password.
45 /*/
46 void pgp_password_free (pgp_password_t);
47 
48 /*/
49 /// Returns a human readable description of this object suitable for
50 /// debugging.
51 /*/
52 char *pgp_password_debug (const pgp_password_t fp);
53 
54 /*/
55 /// Clones the password.
56 /*/
57 pgp_password_t pgp_password_clone (pgp_password_t password);
58 
59 /*/
60 /// Compares passwords.
61 /*/
62 bool pgp_password_equal (const pgp_password_t a, const pgp_password_t b);
63 
64 typedef struct pgp_key_unencrypted *pgp_key_unencrypted_t;
65 
66 /*/
67 /// Creates a signature.
68 ///
69 /// This is a low-level mechanism to produce an arbitrary OpenPGP
70 /// signature.  Using this trait allows Sequoia to perform all
71 /// operations involving signing to use a variety of secret key
72 /// storage mechanisms (e.g. smart cards).
73 /*/
74 typedef struct pgp_signer *pgp_signer_t;
75 
76 /*/
77 /// Frees a signer.
78 /*/
79 void pgp_signer_free (pgp_signer_t s);
80 
81 /*/
82 /// A cryptographic key pair.
83 ///
84 /// A `KeyPair` is a combination of public and secret key.  If both
85 /// are available in memory, a `KeyPair` is a convenient
86 /*/
87 typedef struct pgp_key_pair *pgp_key_pair_t;
88 
89 /*/
90 /// Creates a new key pair.
91 /*/
92 void pgp_key_pair_new (pgp_key_t pub, pgp_key_unencrypted_t secret);
93 
94 /*/
95 /// Frees a key pair.
96 /*/
97 void pgp_key_pair_free (pgp_key_pair_t kp);
98 
99 /*/
100 /// Creates a signer from a key pair.
101 ///
102 /// Note that the returned object merely references the key pair, and
103 /// must not outlive the key pair.
104 /*/
105 pgp_signer_t pgp_key_pair_as_signer (pgp_key_pair_t kp);
106 
107 #endif /* SEQUOIA_OPENPGP_CRYPTO_H */
108