summaryrefslogtreecommitdiffstats
path: root/qemu/roms/ipxe/src/tests/digest_test.h
blob: 49e06d1cbc237a720ea6ca299471cef4c72924bb (plain)
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
#ifndef _DIGEST_TEST_H
#define _DIGEST_TEST_H

FILE_LICENCE ( GPL2_OR_LATER );

#include <stdint.h>
#include <ipxe/crypto.h>
#include <ipxe/test.h>

/** Maximum number of digest test fragments */
#define NUM_DIGEST_TEST_FRAG 8

/** A digest test fragment list */
struct digest_test_fragments {
	/** Fragment lengths */
	size_t len[NUM_DIGEST_TEST_FRAG];
};

extern int digest_test ( struct digest_algorithm *digest,
			 struct digest_test_fragments *fragments,
			 void *data, size_t len, void *expected );
extern unsigned long digest_cost ( struct digest_algorithm *digest );

/**
 * Report digest test result
 *
 * @v digest		Digest algorithm
 * @v fragments		Digest test fragment list, or NULL
 * @v data		Test data
 * @v len		Length of test data
 * @v expected		Expected digest value
 */
#define digest_ok( digest, fragments, data, len, expected ) do {	\
	ok ( digest_test ( digest, fragments, data, len, expected ) );	\
	} while ( 0 )

#endif /* _DIGEST_TEST_H */