LCOV - code coverage report
Current view: top level - lib/crypto - gnutls_weak_crypto.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 8 8 100.0 %
Date: 2021-09-23 10:06:22 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2019      Andreas Schneider <asn@samba.org>
       3             :  *
       4             :  * This program is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 3 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * This program is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #include "includes.h"
      19             : #include "lib/crypto/gnutls_helpers.h"
      20             : 
      21             : #include <gnutls/crypto.h>
      22             : #include <gnutls/gnutls.h>
      23             : 
      24       39323 : bool samba_gnutls_weak_crypto_allowed(void)
      25             : {
      26       39323 :         gnutls_cipher_hd_t cipher_hnd = NULL;
      27       39323 :         gnutls_datum_t key = {
      28             :                 .data = discard_const_p(unsigned char, "SystemLibraryDTC"),
      29             :                 .size = 16,
      30             :         };
      31             :         int rc;
      32             : 
      33             :         /*
      34             :          * If RC4 is not allowed to be initialzed then weak crypto is not
      35             :          * allowed.
      36             :          */
      37       39323 :         rc = gnutls_cipher_init(&cipher_hnd,
      38             :                                 GNUTLS_CIPHER_ARCFOUR_128,
      39             :                                 &key,
      40             :                                 NULL);
      41       39323 :         if (rc == GNUTLS_E_UNWANTED_ALGORITHM) {
      42           3 :                 return false;
      43             :         }
      44             : 
      45       39320 :         gnutls_cipher_deinit(cipher_hnd);
      46             : 
      47       39320 :         return true;
      48             : }

Generated by: LCOV version 1.13