summaryrefslogtreecommitdiff
path: root/common/mock/fpsensor_state_mock.c
blob: cbeb29ae3cd64012f00fe6151fed3389ccd16c47 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Copyright 2020 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include <stddef.h>
#include <string.h>

#include "common.h"
#include "driver/fingerprint/fpsensor.h"
#include "ec_commands.h"
#include "test_util.h"

#ifndef TEST_BUILD
#error "Mocks should only be in the test build."
#endif

const uint8_t default_fake_tpm_seed[] = {
	0xd9, 0x71, 0xaf, 0xc4, 0xcd, 0x36, 0xe3, 0x60, 0xf8, 0x5a, 0xa0,
	0xa6, 0x2c, 0xb3, 0xf5, 0xe2, 0xeb, 0xb9, 0xd8, 0x2f, 0xb5, 0x78,
	0x5c, 0x79, 0x82, 0xce, 0x06, 0x3f, 0xcc, 0x23, 0xb9, 0xe7,
};
BUILD_ASSERT(sizeof(default_fake_tpm_seed) == FP_CONTEXT_TPM_BYTES);

const uint8_t default_fake_fp_positive_match_salt
	[FP_MAX_FINGER_COUNT][FP_POSITIVE_MATCH_SALT_BYTES] = {
		{ 0x04, 0x1f, 0x5a, 0xac, 0x5f, 0x79, 0x10, 0xaf, 0x04, 0x1d,
		  0x46, 0x3a, 0x5f, 0x08, 0xee, 0xcb },
		{ 0x04, 0x1f, 0x5a, 0xac, 0x5f, 0x79, 0x10, 0xaf, 0x04, 0x1d,
		  0x46, 0x3a, 0x5f, 0x08, 0xee, 0xcb },
		{ 0x04, 0x1f, 0x5a, 0xac, 0x5f, 0x79, 0x10, 0xaf, 0x04, 0x1d,
		  0x46, 0x3a, 0x5f, 0x08, 0xee, 0xcb },
		{ 0x04, 0x1f, 0x5a, 0xac, 0x5f, 0x79, 0x10, 0xaf, 0x04, 0x1d,
		  0x46, 0x3a, 0x5f, 0x08, 0xee, 0xcb },
		{ 0x04, 0x1f, 0x5a, 0xac, 0x5f, 0x79, 0x10, 0xaf, 0x04, 0x1d,
		  0x46, 0x3a, 0x5f, 0x08, 0xee, 0xcb }
	};
BUILD_ASSERT(sizeof(default_fake_fp_positive_match_salt) ==
	     FP_MAX_FINGER_COUNT * FP_POSITIVE_MATCH_SALT_BYTES);

const uint8_t trivial_fp_positive_match_salt
	[FP_MAX_FINGER_COUNT][FP_POSITIVE_MATCH_SALT_BYTES] = {
		{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		  0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
		{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		  0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
		{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		  0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
		{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		  0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
		{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		  0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
	};
BUILD_ASSERT(sizeof(trivial_fp_positive_match_salt) ==
	     FP_MAX_FINGER_COUNT * FP_POSITIVE_MATCH_SALT_BYTES);

int fpsensor_state_mock_set_tpm_seed(
	const uint8_t tpm_seed[FP_CONTEXT_TPM_BYTES])
{
	struct ec_params_fp_seed params;

	params.struct_version = FP_TEMPLATE_FORMAT_VERSION;
	memcpy(params.seed, tpm_seed, FP_CONTEXT_TPM_BYTES);

	return test_send_host_command(EC_CMD_FP_SEED, 0, &params,
				      sizeof(params), NULL, 0);
}