|
Packit |
549fdc |
/*
|
|
Packit |
549fdc |
* Copyright (C) 2017 Red Hat, Inc.
|
|
Packit |
549fdc |
*
|
|
Packit |
549fdc |
* Author: Nikos Mavrogiannopoulos
|
|
Packit |
549fdc |
*
|
|
Packit |
549fdc |
* This file is part of GnuTLS.
|
|
Packit |
549fdc |
*
|
|
Packit |
549fdc |
* GnuTLS is free software; you can redistribute it and/or modify it
|
|
Packit |
549fdc |
* under the terms of the GNU General Public License as published by
|
|
Packit |
549fdc |
* the Free Software Foundation; either version 3 of the License, or
|
|
Packit |
549fdc |
* (at your option) any later version.
|
|
Packit |
549fdc |
*
|
|
Packit |
549fdc |
* GnuTLS is distributed in the hope that it will be useful, but
|
|
Packit |
549fdc |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
549fdc |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
549fdc |
* General Public License for more details.
|
|
Packit |
549fdc |
*
|
|
Packit |
549fdc |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
549fdc |
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
Packit |
549fdc |
*/
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#ifndef HEX_H
|
|
Packit |
549fdc |
#define HEX_H
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#include <stdio.h>
|
|
Packit |
549fdc |
#include <string.h>
|
|
Packit |
549fdc |
#include <gnutls/gnutls.h>
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
inline static gnutls_datum_t SHEX(const char *hex)
|
|
Packit |
549fdc |
{
|
|
Packit |
549fdc |
gnutls_datum_t input, output;
|
|
Packit |
549fdc |
int ret;
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
input.data = (void*)hex;
|
|
Packit |
549fdc |
input.size = strlen(hex);
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
ret = gnutls_hex_decode2(&input, &output);
|
|
Packit |
549fdc |
assert_int_equal(ret, 0);
|
|
Packit |
549fdc |
return output;
|
|
Packit |
549fdc |
}
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
inline static gnutls_datum_t SDATA(const char *txt)
|
|
Packit |
549fdc |
{
|
|
Packit |
549fdc |
gnutls_datum_t output;
|
|
Packit |
549fdc |
output.data = (void*)gnutls_strdup(txt);
|
|
Packit |
549fdc |
output.size = strlen(txt);
|
|
Packit |
549fdc |
return output;
|
|
Packit |
549fdc |
}
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#endif
|