LCOV - code coverage report
Current view: top level - lib - ext.c (source / functions) Hit Total Coverage
Test: GNU Generic Security Service Lines: 5 8 62.5 %
Date: 2010-05-20 Functions: 1 2 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 12 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* ext.c --- Implementation of GSS specific extensions.
       2                 :            :  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010  Simon Josefsson
       3                 :            :  *
       4                 :            :  * This file is part of the Generic Security Service (GSS).
       5                 :            :  *
       6                 :            :  * GSS 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                 :            :  * GSS is distributed in the hope that it will be useful, but WITHOUT
      12                 :            :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
      13                 :            :  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
      14                 :            :  * License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU General Public License
      17                 :            :  * along with GSS; if not, see http://www.gnu.org/licenses or write to
      18                 :            :  * 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                 :            : /**
      26                 :            :  * gss_oid_equal:
      27                 :            :  * @first_oid: (Object ID, read) First Object identifier.
      28                 :            :  * @second_oid: (Object ID, read) First Object identifier.
      29                 :            :  *
      30                 :            :  * Compare two OIDs for equality.  The comparison is "deep", i.e., the
      31                 :            :  * actual byte sequences of the OIDs are compared instead of just the
      32                 :            :  * pointer equality.
      33                 :            :  *
      34                 :            :  * WARNING: This function is a GNU GSS specific extension, and is not
      35                 :            :  * part of the official GSS API.
      36                 :            :  *
      37                 :            :  * Return value: Returns boolean value true when the two OIDs are
      38                 :            :  *   equal, otherwise false.
      39                 :            :  **/
      40                 :            : int
      41                 :         48 : gss_oid_equal (const gss_OID first_oid, const gss_OID second_oid)
      42                 :            : {
      43 [ +  + ][ +  - ]:         48 :   return first_oid && second_oid &&
         [ +  + ][ +  - ]
      44                 :         43 :     first_oid->length == second_oid->length &&
      45                 :         37 :     memcmp (first_oid->elements, second_oid->elements,
      46                 :         74 :             second_oid->length) == 0;
      47                 :            : }
      48                 :            : 
      49                 :            : /**
      50                 :            :  * gss_userok:
      51                 :            :  * @name: (gss_name_t, read) Name to be compared.
      52                 :            :  * @username: Zero terminated string with username.
      53                 :            :  *
      54                 :            :  * Compare the username against the output from gss_export_name()
      55                 :            :  * invoked on @name, after removing the leading OID.  This answers the
      56                 :            :  * question whether the particular mechanism would authenticate them
      57                 :            :  * as the same principal
      58                 :            :  *
      59                 :            :  * WARNING: This function is a GNU GSS specific extension, and is not
      60                 :            :  * part of the official GSS API.
      61                 :            :  *
      62                 :            :  * Return value: Returns 0 if the names match, non-0 otherwise.
      63                 :            :  **/
      64                 :            : int
      65                 :          0 : gss_userok (const gss_name_t name, const char *username)
      66                 :            : {
      67                 :            :   /* FIXME: Call gss_export_name, then remove OID. */
      68 [ #  # ][ #  # ]:          0 :   return name->length == strlen (username) &&
      69                 :          0 :     memcmp (name->value, username, name->length) == 0;
      70                 :            : }

Generated by: LCOV version 1.8