s3:winbindd: s/struct event_context/struct tevent_context
[Samba/gebeck_regimport.git] / source4 / torture / auth / smbencrypt.c
blob79c90eb0561abea96719351e1006683da7e4a0d3
1 /*
2 Unix SMB/CIFS implementation.
4 tests for smbencrypt code
6 Copyright (C) Andrew Tridgell 2011
7 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2011
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.
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.
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/>.
23 #include "includes.h"
24 #include "libcli/auth/libcli_auth.h"
25 #include "torture/torture.h"
26 #include "torture/auth/proto.h"
28 static bool torture_deshash(struct torture_context *tctx)
30 struct {
31 const char *input;
32 uint8_t output[16];
33 bool should_pass;
34 } 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},
51 int i;
52 for (i=0; i<ARRAY_SIZE(testcases); i++) {
53 uint8_t res[16];
54 bool ret;
55 ret = E_deshash(testcases[i].input, res);
56 torture_assert(tctx, ret == testcases[i].should_pass,
57 "E_deshash bad result");
58 torture_assert_mem_equal(tctx, res, testcases[i].output, 16, "E_deshash bad return data");
60 return true;
63 struct torture_suite *torture_smbencrypt(TALLOC_CTX *mem_ctx)
65 struct torture_suite *suite = torture_suite_create(mem_ctx, "smbencrypt");
67 torture_suite_add_simple_test(suite, "deshash check", torture_deshash);
69 return suite;