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 * Interface dependencies:
33 struct sipe_tls_random
{
35 guint length
; /* in bytes */
39 * Allocate a buffer with N random bits
41 * @param random pointer to random bytes buffer
42 * @param bits number of random bits (will be rounded up be dividable by 16)
44 void sipe_tls_fill_random(struct sipe_tls_random
*random
,
48 * Free a random bytes buffer
50 * @param random pointer to random bytes buffer
52 void sipe_tls_free_random(struct sipe_tls_random
*random
);
56 * Public part of TLS state tracking
58 * If @c session_key != @c NULL then handshake is complete
60 enum sipe_tls_digest_algorithm
{
61 SIPE_TLS_DIGEST_ALGORITHM_NONE
,
62 SIPE_TLS_DIGEST_ALGORITHM_MD5
,
63 SIPE_TLS_DIGEST_ALGORITHM_SHA1
65 struct sipe_tls_state
{
66 const guchar
*in_buffer
;
70 enum sipe_tls_digest_algorithm algorithm
;
71 const guchar
*client_key
;
72 const guchar
*server_key
;
77 * TLS data expansion function P_SHA1(secret, seed)
79 * @param secret pointer to binary secret
80 * @param secret_length length of secret
81 * @param seed pointer to binary seed
82 * @param seed_length length of seed
83 * @param output_length how much data to generate
85 * @return generated data. Must be g_free()'d
87 guchar
*sipe_tls_p_sha1(const guchar
*secret
,
94 * Initialize TLS state
96 * @param certificate opaque pointer to the user certificate
98 * @return TLS state structure
100 struct sipe_tls_state
*sipe_tls_start(gpointer certificate
);
103 * Proceed to next TLS state
105 * @param state pointer to TLS state structure
106 * @param incoming pointer to incoming message (NULL for initial transition)
107 * @param in_length length of incoming message
109 * @return TLS state structure
111 gboolean
sipe_tls_next(struct sipe_tls_state
*state
);
114 * Extract expiration time from TLS certificate
116 * @param state pointer to TLS state structure
118 * @return expiration time in seconds
120 guint
sipe_tls_expires(struct sipe_tls_state
*state
);
125 * @param state pointer to TLS state structure
127 void sipe_tls_free(struct sipe_tls_state
*state
);