diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2017-07-30 03:01:08 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2017-08-03 07:55:06 +0200 |
commit | 5874432ee1b714ecad5c05c1dfdd2b02ee3e7cb3 (patch) | |
tree | fae45797a29caf185fb140d1f75f5b9b44acd636 /devel | |
parent | 781e864706819652129130f5f2ee5d2aef680540 (diff) | |
download | gnutls-5874432ee1b714ecad5c05c1dfdd2b02ee3e7cb3.tar.gz |
fuzz: introduced psk.h common header
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Diffstat (limited to 'devel')
-rw-r--r-- | devel/fuzz/gnutls_psk_client_fuzzer.cc | 10 | ||||
-rw-r--r-- | devel/fuzz/gnutls_psk_server_fuzzer.cc | 5 | ||||
-rw-r--r-- | devel/fuzz/psk.h | 32 |
3 files changed, 40 insertions, 7 deletions
diff --git a/devel/fuzz/gnutls_psk_client_fuzzer.cc b/devel/fuzz/gnutls_psk_client_fuzzer.cc index 9d8e2ef10a..35b85f64c5 100644 --- a/devel/fuzz/gnutls_psk_client_fuzzer.cc +++ b/devel/fuzz/gnutls_psk_client_fuzzer.cc @@ -31,6 +31,8 @@ #include <gnutls/gnutls.h> +#include "psk.h" + struct mem_st { const uint8_t *data; size_t size; @@ -79,10 +81,10 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size) gnutls_session_t session; gnutls_psk_client_credentials_t pcred; struct mem_st memdata; - gnutls_datum_t pskkey; + gnutls_datum_t psk_key; - pskkey.data = (unsigned char*)"\x8a\x77\x59\xb3\xf2\x69\x83\xc4\x53\xe4\x48\x06\x0b\xde\x89\x81"; - pskkey.size = 16; + psk_key.data = (unsigned char*)psk_key16; + psk_key.size = 16; res = gnutls_init(&session, GNUTLS_CLIENT); assert(res >= 0); @@ -90,7 +92,7 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size) res = gnutls_psk_allocate_client_credentials(&pcred); assert(res >= 0); - res = gnutls_psk_set_client_credentials(pcred, "test", &pskkey, GNUTLS_PSK_KEY_RAW); + res = gnutls_psk_set_client_credentials(pcred, "test", &psk_key, GNUTLS_PSK_KEY_RAW); assert(res >= 0); res = gnutls_credentials_set(session, GNUTLS_CRD_PSK, pcred); diff --git a/devel/fuzz/gnutls_psk_server_fuzzer.cc b/devel/fuzz/gnutls_psk_server_fuzzer.cc index a9708261af..60b8a94710 100644 --- a/devel/fuzz/gnutls_psk_server_fuzzer.cc +++ b/devel/fuzz/gnutls_psk_server_fuzzer.cc @@ -30,6 +30,7 @@ #include <gnutls/gnutls.h> #include "certs.h" +#include "psk.h" struct mem_st { const uint8_t *data; @@ -77,9 +78,7 @@ psk_cb(gnutls_session_t session, const char *username, key->data = (unsigned char*)gnutls_malloc(16); assert(key->data != NULL); - memcpy(key->data, - "\x8a\x77\x59\xb3\xf2\x69\x83\xc4\x53\xe4\x48\x06\x0b\xde\x89\x81", - 16); + memcpy(key->data, psk_key16, 16); key->size = 16; return 0; diff --git a/devel/fuzz/psk.h b/devel/fuzz/psk.h new file mode 100644 index 0000000000..fe4a8af743 --- /dev/null +++ b/devel/fuzz/psk.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2017 Nikos Mavrogiannopoulos + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef PSK_H +# define PSK_H + +static const uint8_t psk_key16[] = { + 0x8a, 0x77, 0x59, 0xb3, 0xf2, 0x69, 0x83, 0xc4, + 0x53, 0xe4, 0x48, 0x06, 0x0b, 0xde, 0x89, 0x81 +}; + +#endif |