blob: 4236568f6ed8294875083cb888d6bdf1d471a2a5 (
plain)
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
|
//! Cryptographic primitives.
//!
//! Wraps [`sequoia-openpgp::crypto`].
//!
//! [`sequoia-openpgp::crypto`]: ../../../sequoia_openpgp/crypto/index.html
use ::core::Context;
extern crate sequoia_openpgp;
use self::sequoia_openpgp::{
crypto,
packet::Key,
};
/// Frees a signer.
#[no_mangle]
pub extern "system" fn sq_signer_free
(s: Option<&mut &'static mut crypto::Signer>)
{
ffi_free!(s)
}
/// Creates a new key pair.
#[no_mangle]
pub extern "system" fn sq_key_pair_new
(ctx: *mut Context, public: *mut Key, secret: *mut crypto::mpis::SecretKey)
-> *mut crypto::KeyPair
{
let ctx = ffi_param_ref_mut!(ctx);
let public = ffi_param_move!(public);
let secret = ffi_param_move!(secret);
fry_box!(ctx, crypto::KeyPair::new(*public, *secret))
}
/// Frees a key pair.
#[no_mangle]
pub extern "system" fn sq_key_pair_free
(kp: Option<&mut crypto::KeyPair>)
{
ffi_free!(kp)
}
/// Creates a signer from a key pair.
///
/// Note that the returned object merely references the key pair, and
/// must not outlive the key pair.
#[no_mangle]
pub extern "system" fn sq_key_pair_as_signer
(kp: *mut crypto::KeyPair)
-> *mut &'static mut crypto::Signer
{
let kp = ffi_param_ref_mut!(kp);
let signer: &mut crypto::Signer = kp;
box_raw!(signer)
//box_raw!(kp)
}
|