tdb: version 1.4.12
[samba4-gss.git] / lib / fuzzing / fuzz_sess_crypt_blob.c
blobbed697ef87c9b9655e4c45312d78625ecf2291bc
1 /*
2 Fuzzing sess_*crypt_blob
3 Copyright (C) Catalyst IT 2020
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "includes.h"
19 #include "fuzzing/fuzzing.h"
20 #include "libcli/auth/libcli_auth.h"
21 #include "session.h"
23 int LLVMFuzzerInitialize(int *argc, char ***argv)
25 return 0;
29 int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
31 TALLOC_CTX *mem_ctx = NULL;
32 DATA_BLOB blob, session_key, out;
33 size_t slen;
34 if (len < 1) {
35 return 0;
38 slen = input[0];
39 if (len < slen + 1) {
40 return 0;
43 session_key.data = input + 1;
44 session_key.length = slen;
45 blob.data = input + 1 + slen;
46 blob.length = len - slen - 1;
48 mem_ctx = talloc_new(NULL);
50 out = sess_encrypt_blob(mem_ctx, &blob, &session_key);
51 sess_decrypt_blob(mem_ctx, &blob, &session_key, &out);
53 TALLOC_FREE(mem_ctx);
54 return 0;