File: test_buffer.h

package info (click to toggle)
libreswan 4.14-1.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 69,000 kB
  • sloc: ansic: 114,676; sh: 27,451; xml: 12,342; python: 10,400; makefile: 1,658; javascript: 1,358; perl: 584; sed: 534; yacc: 392; awk: 171
file content (44 lines) | stat: -rw-r--r-- 1,587 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright (C) 2014 Andrew Cagney <[email protected]>
 * Copyright (C) 2015 Andrew Cagney <[email protected]>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <https://www.gnu.org/licenses/gpl2.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

#include <stdbool.h>
#include <features.h>
#include <pk11pub.h>

#include "chunk.h"

chunk_t decode_to_chunk(const char *prefix, const char *string);
PK11SymKey *decode_hex_to_symkey(const char *prefix, const char *string,
				 struct logger *logger);

bool verify_symkey(const char *desc, chunk_t expected, PK11SymKey *actual,
		   struct logger *logger);

bool verify_bytes(const char *desc,
		  const void *expected, size_t expected_size,
		  const void *actual, size_t actual_size);

#define verify_hunk(DESC, EXPECTED, ACTUAL)				\
	({								\
		typeof(EXPECTED) expected_ = EXPECTED; /* evaluate once */ \
		typeof(ACTUAL) actual_ = ACTUAL; /* evaluate once */	\
		verify_bytes(DESC, expected_.ptr, expected_.len,	\
			     actual_.ptr, actual_.len);			\
	})

struct encrypt_desc;

PK11SymKey *decode_to_key(const struct encrypt_desc *encrypt_desc, const char *string,
			  struct logger *logger);