LCOV - code coverage report
Current view: top level - source4/torture/auth - smbencrypt.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 14 15 93.3 %
Date: 2024-04-21 15:09:00 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    tests for smbencrypt code
       5             : 
       6             :    Copyright (C) Andrew Tridgell 2011
       7             :    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2011
       8             : 
       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 3 of the License, or
      12             :    (at your option) any later version.
      13             : 
      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.
      18             : 
      19             :    You should have received a copy of the GNU General Public License
      20             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      21             : */
      22             : 
      23             : #include "includes.h"
      24             : #include "libcli/auth/libcli_auth.h"
      25             : #include "torture/torture.h"
      26             : #include "torture/auth/proto.h"
      27             : 
      28           1 : static bool torture_deshash(struct torture_context *tctx)
      29             : {
      30           1 :         struct {
      31             :                 const char *input;
      32             :                 uint8_t output[16];
      33             :                 bool should_pass;
      34           1 :         } testcases[] = {
      35             :                 { "",
      36             :                   { 0xAA, 0xD3, 0xB4, 0x35, 0xB5, 0x14, 0x04, 0xEE,
      37             :                     0xAA, 0xD3, 0xB4, 0x35, 0xB5, 0x14, 0x04, 0xEE }, true},
      38             :                 { "abcdefgh",
      39             :                   { 0xE0, 0xC5, 0x10, 0x19, 0x9C, 0xC6, 0x6A, 0xBD,
      40             :                     0x5A, 0xCD, 0xCD, 0x7C, 0x24, 0x7F, 0xA8, 0x3A }, true},
      41             :                 { "0123456789abc",
      42             :                   { 0x56, 0x45, 0xF1, 0x3F, 0x50, 0x08, 0x82, 0xB2,
      43             :                     0x50, 0x79, 0x8A, 0xE6, 0x33, 0x38, 0xAF, 0xE9 }, true},
      44             :                 { "0123456789abcd",
      45             :                   { 0x56, 0x45, 0xF1, 0x3F, 0x50, 0x08, 0x82, 0xB2,
      46             :                     0x1A, 0xC3, 0x88, 0x4B, 0x83, 0x32, 0x45, 0x40 }, true},
      47             :                 { "0123456789abcde",
      48             :                   { 0x56, 0x45, 0xF1, 0x3F, 0x50, 0x08, 0x82, 0xB2,
      49             :                     0x1A, 0xC3, 0x88, 0x4B, 0x83, 0x32, 0x45, 0x40 }, false},
      50             :         };
      51           1 :         int i;
      52           6 :         for (i=0; i<ARRAY_SIZE(testcases); i++) {
      53           5 :                 uint8_t res[16];
      54           5 :                 bool ret;
      55           5 :                 ret = E_deshash(testcases[i].input, res);
      56           5 :                 torture_assert(tctx, ret == testcases[i].should_pass,
      57             :                                "E_deshash bad result");
      58           5 :                 torture_assert_mem_equal(tctx, res, testcases[i].output, 16, "E_deshash bad return data");
      59             :         }
      60           0 :         return true;
      61             : }
      62             : 
      63        2354 : struct torture_suite *torture_smbencrypt(TALLOC_CTX *mem_ctx)
      64             : {
      65        2354 :         struct torture_suite *suite = torture_suite_create(mem_ctx, "smbencrypt");
      66             : 
      67        2354 :         torture_suite_add_simple_test(suite, "deshash check", torture_deshash);
      68             : 
      69        2354 :         return suite;
      70             : }

Generated by: LCOV version 1.14