LCOV - code coverage report
Current view: top level - shishi/lib - pki.c (source / functions) Hit Total Coverage
Test: GNU Shishi Lines: 0 36 0.0 %
Date: 2010-05-20 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* pki.c --- Public Key Infrastructure support functions for Shishi.
       2                 :            :  * Copyright (C) 2002, 2003, 2004, 2007, 2010  Simon Josefsson
       3                 :            :  *
       4                 :            :  * This file is part of Shishi.
       5                 :            :  *
       6                 :            :  * Shishi is free software; you can redistribute it and/or modify it
       7                 :            :  * under the terms of the GNU General Public License as published by
       8                 :            :  * the Free Software Foundation; either version 3 of the License, or
       9                 :            :  * (at your option) any later version.
      10                 :            :  *
      11                 :            :  * Shishi is distributed in the hope that it will be useful, but
      12                 :            :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :            :  * GNU General Public License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU General Public License
      17                 :            :  * along with Shishi; if not, see http://www.gnu.org/licenses or write
      18                 :            :  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
      19                 :            :  * Floor, Boston, MA 02110-1301, USA
      20                 :            :  *
      21                 :            :  */
      22                 :            : 
      23                 :            : #include "internal.h"
      24                 :            : 
      25                 :            : #define X509CA_FILE "client.ca"
      26                 :            : #define X509KEY_FILE "client.key"
      27                 :            : #define X509CERT_FILE "client.certs"
      28                 :            : 
      29                 :            : /**
      30                 :            :  * shishi_x509ca_default_file_guess:
      31                 :            :  * @handle: Shishi library handle create by shishi_init().
      32                 :            :  *
      33                 :            :  * Guesses the default X.509 CA certificate filename; it is
      34                 :            :  * $HOME/.shishi/client.ca.
      35                 :            :  *
      36                 :            :  * Return value: Returns default X.509 client certificate filename as
      37                 :            :  *   a string that has to be deallocated with free() by the caller.
      38                 :            :  **/
      39                 :            : char *
      40                 :          0 : shishi_x509ca_default_file_guess (Shishi * handle)
      41                 :            : {
      42                 :          0 :   return shishi_cfg_userdirectory_file (handle, X509CA_FILE);
      43                 :            : }
      44                 :            : 
      45                 :            : /**
      46                 :            :  * shishi_x509ca_default_file_set:
      47                 :            :  * @handle: Shishi library handle create by shishi_init().
      48                 :            :  * @x509cafile: string with new default x509 client certificate file name,
      49                 :            :  *   or NULL to reset to default.
      50                 :            :  *
      51                 :            :  * Set the default X.509 CA certificate filename used in the library.
      52                 :            :  * The certificate is used during TLS connections with the KDC to
      53                 :            :  * authenticate the KDC.  The string is copied into the library, so
      54                 :            :  * you can dispose of the variable immediately after calling this
      55                 :            :  * function.
      56                 :            :  **/
      57                 :            : void
      58                 :          0 : shishi_x509ca_default_file_set (Shishi * handle, const char *x509cafile)
      59                 :            : {
      60                 :          0 :   free (handle->x509cafile);
      61         [ #  # ]:          0 :   if (x509cafile)
      62                 :          0 :     handle->x509cafile = xstrdup (x509cafile);
      63                 :            :   else
      64                 :          0 :     handle->x509cafile = shishi_x509ca_default_file_guess (handle);
      65                 :          0 : }
      66                 :            : 
      67                 :            : /**
      68                 :            :  * shishi_x509ca_default_file:
      69                 :            :  * @handle: Shishi library handle create by shishi_init().
      70                 :            :  *
      71                 :            :  * Get filename for default X.509 CA certificate.
      72                 :            :  *
      73                 :            :  * Return value: Returns the default X.509 CA certificate filename
      74                 :            :  *   used in the library.  The certificate is used during TLS
      75                 :            :  *   connections with the KDC to authenticate the KDC.  The string is
      76                 :            :  *   not a copy, so don't modify or deallocate it.
      77                 :            :  **/
      78                 :            : const char *
      79                 :          0 : shishi_x509ca_default_file (Shishi * handle)
      80                 :            : {
      81         [ #  # ]:          0 :   if (!handle->x509cafile)
      82                 :          0 :     shishi_x509ca_default_file_set (handle, NULL);
      83                 :            : 
      84                 :          0 :   return handle->x509cafile;
      85                 :            : }
      86                 :            : 
      87                 :            : /**
      88                 :            :  * shishi_x509cert_default_file_guess:
      89                 :            :  * @handle: Shishi library handle create by shishi_init().
      90                 :            :  *
      91                 :            :  * Guesses the default X.509 client certificate filename; it is
      92                 :            :  * $HOME/.shishi/client.certs.
      93                 :            :  *
      94                 :            :  * Return value: Returns default X.509 client certificate filename as
      95                 :            :  *   a string that has to be deallocated with free() by the caller.
      96                 :            :  **/
      97                 :            : char *
      98                 :          0 : shishi_x509cert_default_file_guess (Shishi * handle)
      99                 :            : {
     100                 :          0 :   return shishi_cfg_userdirectory_file (handle, X509CERT_FILE);
     101                 :            : }
     102                 :            : 
     103                 :            : /**
     104                 :            :  * shishi_x509cert_default_file_set:
     105                 :            :  * @handle: Shishi library handle create by shishi_init().
     106                 :            :  * @x509certfile: string with new default x509 client certificate file name,
     107                 :            :  *   or NULL to reset to default.
     108                 :            :  *
     109                 :            :  * Set the default X.509 client certificate filename used in the
     110                 :            :  * library.  The certificate is used during TLS connections with the
     111                 :            :  * KDC to authenticate the client.  The string is copied into the
     112                 :            :  * library, so you can dispose of the variable immediately after
     113                 :            :  * calling this function.
     114                 :            :  **/
     115                 :            : void
     116                 :          0 : shishi_x509cert_default_file_set (Shishi * handle, const char *x509certfile)
     117                 :            : {
     118                 :          0 :   free (handle->x509certfile);
     119         [ #  # ]:          0 :   if (x509certfile)
     120                 :          0 :     handle->x509certfile = xstrdup (x509certfile);
     121                 :            :   else
     122                 :          0 :     handle->x509certfile = shishi_x509cert_default_file_guess (handle);
     123                 :          0 : }
     124                 :            : 
     125                 :            : /**
     126                 :            :  * shishi_x509cert_default_file:
     127                 :            :  * @handle: Shishi library handle create by shishi_init().
     128                 :            :  *
     129                 :            :  * Get filename for default X.509 certificate.
     130                 :            :  *
     131                 :            :  * Return value: Returns the default X.509 client certificate filename
     132                 :            :  *   used in the library.  The certificate is used during TLS
     133                 :            :  *   connections with the KDC to authenticate the client.  The string is
     134                 :            :  *   not a copy, so don't modify or deallocate it.
     135                 :            :  **/
     136                 :            : const char *
     137                 :          0 : shishi_x509cert_default_file (Shishi * handle)
     138                 :            : {
     139         [ #  # ]:          0 :   if (!handle->x509certfile)
     140                 :          0 :     shishi_x509cert_default_file_set (handle, NULL);
     141                 :            : 
     142                 :          0 :   return handle->x509certfile;
     143                 :            : }
     144                 :            : 
     145                 :            : /**
     146                 :            :  * shishi_x509key_default_file_guess:
     147                 :            :  * @handle: Shishi library handle create by shishi_init().
     148                 :            :  *
     149                 :            :  * Guesses the default X.509 client key filename; it is
     150                 :            :  * $HOME/.shishi/client.key.
     151                 :            :  *
     152                 :            :  * Return value: Returns default X.509 client key filename as
     153                 :            :  *   a string that has to be deallocated with free() by the caller.
     154                 :            :  **/
     155                 :            : char *
     156                 :          0 : shishi_x509key_default_file_guess (Shishi * handle)
     157                 :            : {
     158                 :          0 :   return shishi_cfg_userdirectory_file (handle, X509KEY_FILE);
     159                 :            : }
     160                 :            : 
     161                 :            : /**
     162                 :            :  * shishi_x509key_default_file_set:
     163                 :            :  * @handle: Shishi library handle create by shishi_init().
     164                 :            :  * @x509keyfile: string with new default x509 client key file name, or
     165                 :            :  *   NULL to reset to default.
     166                 :            :  *
     167                 :            :  * Set the default X.509 client key filename used in the library.  The
     168                 :            :  * key is used during TLS connections with the KDC to authenticate the
     169                 :            :  * client.  The string is copied into the library, so you can dispose
     170                 :            :  * of the variable immediately after calling this function.
     171                 :            :  **/
     172                 :            : void
     173                 :          0 : shishi_x509key_default_file_set (Shishi * handle, const char *x509keyfile)
     174                 :            : {
     175                 :          0 :   free (handle->x509keyfile);
     176         [ #  # ]:          0 :   if (x509keyfile)
     177                 :          0 :     handle->x509keyfile = xstrdup (x509keyfile);
     178                 :            :   else
     179                 :          0 :     handle->x509keyfile = shishi_x509key_default_file_guess (handle);
     180                 :          0 : }
     181                 :            : 
     182                 :            : /**
     183                 :            :  * shishi_x509key_default_file:
     184                 :            :  * @handle: Shishi library handle create by shishi_init().
     185                 :            :  *
     186                 :            :  * Get filename for default X.509 key.
     187                 :            :  *
     188                 :            :  * Return value: Returns the default X.509 client key filename
     189                 :            :  *   used in the library.  The key is used during TLS
     190                 :            :  *   connections with the KDC to authenticate the client.  The string is
     191                 :            :  *   not a copy, so don't modify or deallocate it.
     192                 :            :  **/
     193                 :            : const char *
     194                 :          0 : shishi_x509key_default_file (Shishi * handle)
     195                 :            : {
     196         [ #  # ]:          0 :   if (!handle->x509keyfile)
     197                 :          0 :     shishi_x509key_default_file_set (handle, NULL);
     198                 :            : 
     199                 :          0 :   return handle->x509keyfile;
     200                 :            : }

Generated by: LCOV version 1.8