7 #include <openssl/bn.h>
8 #include <openssl/ssl.h>
9 #include <openssl/bio.h>
10 #include <openssl/err.h>
11 #include <openssl/rsa.h>
12 #include <openssl/evp.h>
13 #include <openssl/pem.h>
14 #include <openssl/sha.h>
15 #include <openssl/rand.h>
16 #include <libex/str.h>
17 #include <libex/file.h>
19 typedef struct ssl_key ssl_key_t
;
20 typedef struct ssl_key_pair ssl_key_pair_t
;
22 const char *ssl_key_msg (ssl_key_t
*key
);
23 const char *ssl_keys_msg (ssl_key_pair_t
*keys
);
28 int ssl_gen_keys (int nbits
, ssl_key_pair_t
*keys
);
29 int ssl_gen_keys_fp (int nbits
, FILE *fp_priv
, FILE *fp_pub
, const char *passwd
, ssl_key_pair_t
*keys
);
30 int ssl_gen_keys_fl (int nbits
, const char *priv
, const char *pub
, const char *passwd
, ssl_key_pair_t
*keys
);
31 int ssl_gen_keys_buf (int nbits
, strptr_t
*priv
, strptr_t
*pub
, const char *passwd
, ssl_key_pair_t
*keys
);
32 int ssl_load_priv_fp (FILE *fp
, const char *passwd
, ssl_key_t
*key
);
33 int ssl_load_priv_fl (const char *fname
, const char *passwd
, ssl_key_t
*key
);
34 int ssl_load_priv_buf (const char *passwd
, ssl_key_t
*key
, strptr_t
*buf
);
35 int ssl_load_pub_fp (FILE *fp
, ssl_key_t
*key
);
36 int ssl_load_pub_fl (const char *fname
, ssl_key_t
*key
);
37 int ssl_load_pub_buf (const char *buf
, size_t buf_len
, ssl_key_t
*key
);
39 int ssl_encrypt_pub (ssl_key_t
*key
, const char *buf
, size_t buf_len
, str_t
**result
);
40 int ssl_decrypt_priv (ssl_key_t
*key
, const char *buf
, size_t buf_len
, str_t
**result
);
42 int ssl_sign (const unsigned char *msg
, size_t mlen
, unsigned char **sig
, size_t *slen
, int dig
, ssl_key_t
*pkey
);
43 int ssl_verify (const unsigned char *msg
, size_t mlen
, const unsigned char *sig
, size_t slen
, int dig
, ssl_key_t
*pkey
);
45 ssl_key_t
*ssl_key_init ();
46 ssl_key_pair_t
*ssl_key_pair_init ();
48 void ssl_free_key (ssl_key_t
*key
);
49 void ssl_free_keys (ssl_key_pair_t
*keys
);