loudmouth/lm-ssl-base.c
author Frank Zschockelt <lm@freakysoft.de>
Thu, 04 Feb 2016 19:18:03 +0100
changeset 690 7ccf2113ec5f
parent 664 f57b1b61e1fe
child 704 d682ae8d7d3a
permissions -rw-r--r--
Update the postal address of the FSF
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
516
4dd3aa6b83e5 Change the tab width to 4 steps in the emacs headers
Mikael Hallendal <micke@imendio.com>
parents: 515
diff changeset
     1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     2
/*
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     3
 * Copyright (C) 2003-2006 Imendio AB
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     4
 *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     6
 * modify it under the terms of the GNU Lesser General Public License as
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     7
 * published by the Free Software Foundation; either version 2 of the
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     8
 * License, or (at your option) any later version.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
     9
 *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    13
 * Lesser General Public License for more details.
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    14
 *
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    15
 * You should have received a copy of the GNU Lesser General Public
690
7ccf2113ec5f Update the postal address of the FSF
Frank Zschockelt <lm@freakysoft.de>
parents: 664
diff changeset
    16
 * License along with this program; if not, see <https://www.gnu.org/licenses>
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    17
 */
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    18
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    19
#include "lm-ssl-base.h"
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    20
#include "lm-ssl-internals.h"
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    21
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    22
void
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
    23
_lm_ssl_base_init (LmSSLBase      *base,
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    24
                   const gchar    *expected_fingerprint,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    25
                   LmSSLFunction   ssl_function,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    26
                   gpointer        user_data,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    27
                   GDestroyNotify  notify)
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    28
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    29
    base->ref_count      = 1;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    30
    base->func           = ssl_function;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    31
    base->func_data      = user_data;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    32
    base->data_notify    = notify;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    33
    base->fingerprint[0] = '\0';
650
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
    34
    base->cipher_list    = NULL;
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 518
diff changeset
    35
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    36
    if (expected_fingerprint) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    37
        base->expected_fingerprint = g_memdup (expected_fingerprint, 16);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    38
    } else {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    39
        base->expected_fingerprint = NULL;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    40
    }
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    41
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    42
    if (!base->func) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    43
        /* If user didn't provide an SSL func the default will be used
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    44
         * this function will always tell the connection to continue.
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    45
         */
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    46
        base->func = _lm_ssl_func_always_continue;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    47
    }
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    48
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    49
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    50
void
650
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
    51
_lm_ssl_base_set_cipher_list (LmSSLBase   *base,
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
    52
                              const gchar *cipher_list)
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
    53
{
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
    54
    if (base->cipher_list)
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
    55
        g_free (base->cipher_list);
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
    56
    base->cipher_list = g_strdup (cipher_list);
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
    57
}
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
    58
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
    59
void
651
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
    60
_lm_ssl_base_set_ca_path (LmSSLBase   *base,
664
f57b1b61e1fe Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents: 651
diff changeset
    61
                          const gchar *ca_path)
651
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
    62
{
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
    63
    if (base->ca_path)
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
    64
        g_free (base->ca_path);
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
    65
    base->ca_path = g_strdup (ca_path);
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
    66
}
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
    67
void
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    68
_lm_ssl_base_free_fields (LmSSLBase *base)
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    69
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    70
    g_free (base->expected_fingerprint);
650
a51209f570b6 Implemented lm_ssl_set_cipher_list
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
    71
    g_free (base->cipher_list);
651
2990ee03cfa3 Implemented lm_ssl_set_ca
Frank Zschockelt <lm@freakysoft.de>
parents: 650
diff changeset
    72
    g_free (base->ca_path);
137
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    73
}
18785575aa7a 2006-04-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
diff changeset
    74