digest: add support for OpenSSL 1.1.0
[siplcs.git] / src / core / sipe-tls-analyzer.c
blob000890d32d4da9b42d5ba56d89a1919e0506e549
1 /**
2 * @file sipe-tls-analyzer.c
4 * pidgin-sipe
6 * Copyright (C) 2015 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
24 * Takes Base64-encoded gssapi-data= values from TLS-DSK authentication attempt
25 * on the command line and prints out the TLS message contents in human readable
26 * format.
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
33 #include <stdlib.h>
34 #include <stdarg.h>
36 #include <glib.h>
37 #include <glib/gprintf.h>
39 #include "sipe-common.h"
40 #include "sipe-utils.h"
41 #define _SIPE_COMPILING_ANALYZER
42 #include "sipe-tls.c"
44 /* stub functions */
45 void sipe_backend_debug_literal(SIPE_UNUSED_PARAMETER sipe_debug_level level,
46 const gchar *msg)
48 printf("%s", msg);
51 void sipe_backend_debug(SIPE_UNUSED_PARAMETER sipe_debug_level level,
52 const gchar *format,
53 ...)
55 va_list ap;
56 va_start(ap, format);
57 vprintf(format, ap);
58 va_end(ap);
61 int main(int argc, char *argv[])
63 struct tls_internal_state *state;
65 if (argc < 2) {
66 fprintf(stderr, "Usage: %s <gssapi-data> ...\n", argv[0]);
67 return(1);
70 state = g_new0(struct tls_internal_state, 1);
71 state->debug = g_string_new("");
73 while (--argc > 0) {
74 const gchar *base64 = *++argv;
75 guchar *buffer;
77 printf("Base64: %s\n", base64);
78 buffer = g_base64_decode(base64, &state->common.in_length);
79 if (buffer && state->common.in_length) {
80 printf("Decoded %" G_GSIZE_FORMAT " bytes\n",
81 state->common.in_length);
82 state->common.in_buffer = buffer;
83 tls_record_parse(state, TRUE, 0);
84 free_parse_data(state);
85 printf("-------------------------------------------------------------------------------\n");
86 g_free(buffer);
87 } else {
88 printf("Corrupted Base64 - skipping\n");
92 g_string_free(state->debug, TRUE);
93 g_free(state);
95 return(0);
99 Local Variables:
100 mode: c
101 c-file-style: "bsd"
102 indent-tabs-mode: t
103 tab-width: 8
104 End: