If OCSP revocation data are invalid or too old set appropriate verification flags.
[gnutls.git] / lib / gnutls_datum.c
blobacbde1f0aa7977f1585d2e6aa4ee061915927687
1 /*
2 * Copyright (C) 2001-2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
8 * The GnuTLS is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
23 /* contains functions that make it easier to
24 * write vectors of <size|data>. The destination size
25 * should be preallocated (datum.size+(bits/8))
28 #include <gnutls_int.h>
29 #include <gnutls_num.h>
30 #include <gnutls_datum.h>
31 #include <gnutls_errors.h>
33 int
34 _gnutls_set_datum (gnutls_datum_t * dat, const void *data,
35 size_t data_size)
37 if (data_size == 0 || data == NULL)
39 dat->data = NULL;
40 dat->size = 0;
41 return 0;
44 dat->data = gnutls_malloc (data_size);
45 if (dat->data == NULL)
46 return GNUTLS_E_MEMORY_ERROR;
48 dat->size = data_size;
49 memcpy (dat->data, data, data_size);
51 return 0;
54 int
55 _gnutls_datum_append (gnutls_datum_t * dst, const void *data,
56 size_t data_size)
59 dst->data = gnutls_realloc (dst->data, data_size + dst->size);
60 if (dst->data == NULL)
61 return GNUTLS_E_MEMORY_ERROR;
63 memcpy (&dst->data[dst->size], data, data_size);
64 dst->size += data_size;
66 return 0;
69 void
70 _gnutls_free_datum (gnutls_datum_t * dat)
72 if (dat->data != NULL)
73 gnutls_free (dat->data);
75 dat->data = NULL;
76 dat->size = 0;