digest: add support for OpenSSL 1.1.0
[siplcs.git] / src / core / sipe-cert-crypto.h
blob76045a7dfdcd5a767cc8a95bad43a4c55b1b26b0
1 /**
2 * @file sipe-cert-crypto.h
4 * pidgin-sipe
6 * Copyright (C) 2011-12 SIPE Project <http://sipe.sourceforge.net/>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * Internal interface between sipe-certificate/sipe-tls
26 * and the certificate crypto implementation
30 * Interface dependencies:
32 * <glib.h>
35 /* Forward declarations */
36 struct sipe_cert_crypto;
38 /**
39 * Free certificate crypto backend data
41 * @return opaque pointer to backend private data
43 struct sipe_cert_crypto *sipe_cert_crypto_init(void);
45 /**
46 * Free certificate crypto backend data
48 * @param scc opaque pointer to backend private data
50 void sipe_cert_crypto_free(struct sipe_cert_crypto *scc);
52 /**
53 * Create a certificate request as Base64 encoded string
55 * @param scc opaque pointer to backend private data
56 * @param subject subject for certificate request
58 * @return Base64 encoded string. Must be @g_free'd()
60 gchar *sipe_cert_crypto_request(struct sipe_cert_crypto *scc,
61 const gchar *subject);
63 /**
64 * Destroy certificate (this is a @GDestroyNotify)
66 * @param certificate opaque pointer to backend certificate structure
67 * May be @c NULL
69 void sipe_cert_crypto_destroy(gpointer certificate);
71 /**
72 * Decode a client certificate from Base64 string
74 * @param base64 Base64 encoded DER data
76 * @return opaque pointer to certificate. Must be @sipe_cert_crypto_destroy()'d.
78 gpointer sipe_cert_crypto_decode(struct sipe_cert_crypto *scc,
79 const gchar *base64);
81 /**
82 * Import a server certificate from DER data
84 * @param raw DER data
85 * @param length length of DER data
87 * @return opaque pointer to certificate. Must be @sipe_cert_crypto_destroy()'d.
89 gpointer sipe_cert_crypto_import(const guchar *raw, gsize length);
91 /**
92 * Check if certificate is valid until @c offset seconds from now
94 * @param certificate opaque pointer to backend certificate structure
95 * @param offset seconds from now
97 * @return @c TRUE if certificate is still valid at that time
99 gboolean sipe_cert_crypto_valid(gpointer certificate,
100 guint offset);
103 * Return how many seconds until the certificate expires
105 * @param certificate opaque pointer to backend certificate structure
107 * @return offset in seconds
109 guint sipe_cert_crypto_expires(gpointer certificate);
112 * Return length of certificate in DER form
114 * @param certificate opaque pointer to backend certificate structure
116 * @return length in bytes
118 gsize sipe_cert_crypto_raw_length(gpointer certificate);
121 * Return certificate in DER form
123 * @param certificate opaque pointer to backend certificate structure
125 * @return pointer to DER data
127 const guchar *sipe_cert_crypto_raw(gpointer certificate);
130 * Get public key for certificate
132 * @param certificate opaque pointer to backend certificate structure
134 * @return opaque pointer to backend public key structure
136 gpointer sipe_cert_crypto_public_key(gpointer certificate);
139 * Get public key modulus length for server certificate
141 * @param certificate opaque pointer to backend certificate structure
143 * @return server public key strength
145 gsize sipe_cert_crypto_modulus_length(gpointer certificate);
148 * Get private key for client certificate
150 * @param certificate opaque pointer to backend certificate structure
152 * @return opaque pointer to backend private key structure
154 gpointer sipe_cert_crypto_private_key(gpointer certificate);
157 * Create test certificate for internal key pair (ONLY USE FOR TEST CODE!!!)
159 * @param scc opaque pointer to backend private data
161 * @return opaque pointer to backend certificate structure
163 gpointer sipe_cert_crypto_test_certificate(struct sipe_cert_crypto *scc);