BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

ssl_sock.h
Go to the documentation of this file.
1 /* $Id: ssl_sock.h 4973 2015-01-15 06:55:02Z nanang $ */
2 /*
3  * Copyright (C) 2009-2011 Teluu Inc. (http://www.teluu.com)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 #ifndef __PJ_SSL_SOCK_H__
20 #define __PJ_SSL_SOCK_H__
21 
27 #include <pj/ioqueue.h>
28 #include <pj/sock.h>
29 #include <pj/sock_qos.h>
30 
31 
33 
54 
55 
61 
62 
64 {
69 
74 
79 
84 
90 
95 
102 
107 
112 
117 
125 
130 
132 
133 
134 typedef enum pj_ssl_cert_name_type
135 {
136  PJ_SSL_CERT_NAME_UNKNOWN = 0,
137  PJ_SSL_CERT_NAME_RFC822,
138  PJ_SSL_CERT_NAME_DNS,
139  PJ_SSL_CERT_NAME_URI,
140  PJ_SSL_CERT_NAME_IP
141 } pj_ssl_cert_name_type;
142 
146 typedef struct pj_ssl_cert_info {
147 
148  unsigned version;
154  struct {
159  } subject;
161  struct {
162  pj_str_t cn;
163  pj_str_t info;
165  } issuer;
167  struct {
172  } validity;
174  struct {
175  unsigned cnt;
176  struct {
177  pj_ssl_cert_name_type type;
180  } *entry;
181  } subj_alt_name;
185 
186 
199  const pj_str_t *CA_file,
200  const pj_str_t *cert_file,
201  const pj_str_t *privkey_file,
202  const pj_str_t *privkey_pass,
203  pj_ssl_cert_t **p_cert);
204 
222  pj_pool_t *pool,
223  const pj_str_t *CA_file,
224  const pj_str_t *CA_path,
225  const pj_str_t *cert_file,
226  const pj_str_t *privkey_file,
227  const pj_str_t *privkey_pass,
228  pj_ssl_cert_t **p_cert);
229 
230 
243  const char *indent,
244  char *buf,
245  pj_size_t buf_size);
246 
247 
261  pj_uint32_t verify_status,
262  const char *error_strings[],
263  unsigned *count);
264 
265 
269 typedef enum pj_ssl_cipher {
270 
271  /* Unsupported cipher */
272  PJ_TLS_UNKNOWN_CIPHER = -1,
273 
274  /* NULL */
275  PJ_TLS_NULL_WITH_NULL_NULL = 0x00000000,
276 
277  /* TLS/SSLv3 */
278  PJ_TLS_RSA_WITH_NULL_MD5 = 0x00000001,
279  PJ_TLS_RSA_WITH_NULL_SHA = 0x00000002,
280  PJ_TLS_RSA_WITH_NULL_SHA256 = 0x0000003B,
281  PJ_TLS_RSA_WITH_RC4_128_MD5 = 0x00000004,
282  PJ_TLS_RSA_WITH_RC4_128_SHA = 0x00000005,
283  PJ_TLS_RSA_WITH_3DES_EDE_CBC_SHA = 0x0000000A,
284  PJ_TLS_RSA_WITH_AES_128_CBC_SHA = 0x0000002F,
285  PJ_TLS_RSA_WITH_AES_256_CBC_SHA = 0x00000035,
286  PJ_TLS_RSA_WITH_AES_128_CBC_SHA256 = 0x0000003C,
287  PJ_TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x0000003D,
288  PJ_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA = 0x0000000D,
289  PJ_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA = 0x00000010,
290  PJ_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 0x00000013,
291  PJ_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 0x00000016,
292  PJ_TLS_DH_DSS_WITH_AES_128_CBC_SHA = 0x00000030,
293  PJ_TLS_DH_RSA_WITH_AES_128_CBC_SHA = 0x00000031,
294  PJ_TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 0x00000032,
295  PJ_TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 0x00000033,
296  PJ_TLS_DH_DSS_WITH_AES_256_CBC_SHA = 0x00000036,
297  PJ_TLS_DH_RSA_WITH_AES_256_CBC_SHA = 0x00000037,
298  PJ_TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 0x00000038,
299  PJ_TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 0x00000039,
300  PJ_TLS_DH_DSS_WITH_AES_128_CBC_SHA256 = 0x0000003E,
301  PJ_TLS_DH_RSA_WITH_AES_128_CBC_SHA256 = 0x0000003F,
302  PJ_TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 = 0x00000040,
303  PJ_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = 0x00000067,
304  PJ_TLS_DH_DSS_WITH_AES_256_CBC_SHA256 = 0x00000068,
305  PJ_TLS_DH_RSA_WITH_AES_256_CBC_SHA256 = 0x00000069,
306  PJ_TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 = 0x0000006A,
307  PJ_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = 0x0000006B,
308  PJ_TLS_DH_anon_WITH_RC4_128_MD5 = 0x00000018,
309  PJ_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA = 0x0000001B,
310  PJ_TLS_DH_anon_WITH_AES_128_CBC_SHA = 0x00000034,
311  PJ_TLS_DH_anon_WITH_AES_256_CBC_SHA = 0x0000003A,
312  PJ_TLS_DH_anon_WITH_AES_128_CBC_SHA256 = 0x0000006C,
313  PJ_TLS_DH_anon_WITH_AES_256_CBC_SHA256 = 0x0000006D,
314 
315  /* TLS (deprecated) */
316  PJ_TLS_RSA_EXPORT_WITH_RC4_40_MD5 = 0x00000003,
317  PJ_TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 0x00000006,
318  PJ_TLS_RSA_WITH_IDEA_CBC_SHA = 0x00000007,
319  PJ_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x00000008,
320  PJ_TLS_RSA_WITH_DES_CBC_SHA = 0x00000009,
321  PJ_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x0000000B,
322  PJ_TLS_DH_DSS_WITH_DES_CBC_SHA = 0x0000000C,
323  PJ_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x0000000E,
324  PJ_TLS_DH_RSA_WITH_DES_CBC_SHA = 0x0000000F,
325  PJ_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x00000011,
326  PJ_TLS_DHE_DSS_WITH_DES_CBC_SHA = 0x00000012,
327  PJ_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x00000014,
328  PJ_TLS_DHE_RSA_WITH_DES_CBC_SHA = 0x00000015,
329  PJ_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 = 0x00000017,
330  PJ_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 0x00000019,
331  PJ_TLS_DH_anon_WITH_DES_CBC_SHA = 0x0000001A,
332 
333  /* SSLv3 */
334  PJ_SSL_FORTEZZA_KEA_WITH_NULL_SHA = 0x0000001C,
335  PJ_SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA = 0x0000001D,
336  PJ_SSL_FORTEZZA_KEA_WITH_RC4_128_SHA = 0x0000001E,
337 
338  /* SSLv2 */
339  PJ_SSL_CK_RC4_128_WITH_MD5 = 0x00010080,
340  PJ_SSL_CK_RC4_128_EXPORT40_WITH_MD5 = 0x00020080,
341  PJ_SSL_CK_RC2_128_CBC_WITH_MD5 = 0x00030080,
342  PJ_SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5 = 0x00040080,
343  PJ_SSL_CK_IDEA_128_CBC_WITH_MD5 = 0x00050080,
344  PJ_SSL_CK_DES_64_CBC_WITH_MD5 = 0x00060040,
345  PJ_SSL_CK_DES_192_EDE3_CBC_WITH_MD5 = 0x000700C0
346 
347 } pj_ssl_cipher;
348 
349 
359  unsigned *cipher_num);
360 
361 
370 
371 
380 PJ_DECL(const char*) pj_ssl_cipher_name(pj_ssl_cipher cipher);
381 
382 
393 PJ_DECL(pj_ssl_cipher) pj_ssl_cipher_id(const char *cipher_name);
394 
395 
399 typedef struct pj_ssl_sock_cb
400 {
427  pj_bool_t (*on_data_read)(pj_ssl_sock_t *ssock,
428  void *data,
429  pj_size_t size,
430  pj_status_t status,
431  pj_size_t *remainder);
452  pj_bool_t (*on_data_recvfrom)(pj_ssl_sock_t *ssock,
453  void *data,
454  pj_size_t size,
455  const pj_sockaddr_t *src_addr,
456  int addr_len,
457  pj_status_t status);
458 
472  pj_bool_t (*on_data_sent)(pj_ssl_sock_t *ssock,
474  pj_ssize_t sent);
475 
490  pj_bool_t (*on_accept_complete)(pj_ssl_sock_t *ssock,
491  pj_ssl_sock_t *newsock,
492  const pj_sockaddr_t *src_addr,
493  int src_addr_len);
494 
507  pj_bool_t (*on_connect_complete)(pj_ssl_sock_t *ssock,
508  pj_status_t status);
509 
511 
512 
517 typedef enum pj_ssl_sock_proto
518 {
523 
528 
533 
538 
543 
548 
553  PJ_SSL_SOCK_PROTO_SSL23 = (1 << 16) - 1,
554 
559 
561 
562 
566 typedef struct pj_ssl_sock_info
567 {
573 
579 
585 
590 
595 
600 
605 
610 
614  unsigned long last_native_err;
615 
620 
622 
623 
627 typedef struct pj_ssl_sock_param
628 {
639 
645  int sock_af;
646 
653 
659 
666 
671 
675  void *user_data;
676 
684 
697  unsigned async_cnt;
698 
713 
728 
738 
748 
754  unsigned ciphers_num;
755 
761 
769 
776 
784 
795 
803 
812 
821 
829 
837 
846 
848 
849 
856 PJ_DECL(void) pj_ssl_sock_param_default(pj_ssl_sock_param *param);
857 
858 
869  const pj_ssl_sock_param *param,
870  pj_ssl_sock_t **p_ssock);
871 
872 
889  pj_ssl_sock_t *ssock,
890  pj_pool_t *pool,
891  const pj_ssl_cert_t *cert);
892 
893 
903 
904 
918  void *user_data);
919 
928 PJ_DECL(void*) pj_ssl_sock_get_user_data(pj_ssl_sock_t *ssock);
929 
930 
940  pj_ssl_sock_info *info);
941 
942 
966  pj_pool_t *pool,
967  unsigned buff_size,
968  pj_uint32_t flags);
969 
985  pj_pool_t *pool,
986  unsigned buff_size,
987  void *readbuf[],
988  pj_uint32_t flags);
989 
1004  pj_pool_t *pool,
1005  unsigned buff_size,
1006  pj_uint32_t flags);
1007 
1023  pj_pool_t *pool,
1024  unsigned buff_size,
1025  void *readbuf[],
1026  pj_uint32_t flags);
1027 
1050  const void *data,
1051  pj_ssize_t *size,
1052  unsigned flags);
1053 
1076  pj_ioqueue_op_key_t *send_key,
1077  const void *data,
1078  pj_ssize_t *size,
1079  unsigned flags,
1080  const pj_sockaddr_t *addr,
1081  int addr_len);
1082 
1083 
1105  pj_pool_t *pool,
1106  const pj_sockaddr_t *local_addr,
1107  int addr_len);
1108 
1109 
1129  pj_pool_t *pool,
1130  const pj_sockaddr_t *localaddr,
1131  const pj_sockaddr_t *remaddr,
1132  int addr_len);
1133 
1134 
1150 
1151 
1157 
1158 #endif /* __PJ_SSL_SOCK_H__ */

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.