aboutsummaryrefslogtreecommitdiff
path: root/libstb/secvar/secvar.h
blob: 33cd0a085aefdbb38cf8c9cd53c5cb2b652e9bb6 (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
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
/* Copyright 2013-2019 IBM Corp. */

#ifndef _SECVAR_H_
#define _SECVAR_H_

#include <ccan/list/list.h>
#include <stdint.h>
#include <secvar.h>

#define SECVAR_MAX_KEY_LEN		1024

enum {
	SECVAR_VARIABLE_BANK,
	SECVAR_UPDATE_BANK,
};


#define SECVAR_FLAG_VOLATILE	0x1 /* Instructs storage driver to ignore variable on writes */
#define SECVAR_FLAG_PROTECTED	0x2 /* Instructs storage driver to store in lockable flash */

struct secvar {
	struct list_node link;
	uint64_t key_len;
	uint64_t data_size;
	uint64_t flags;
	char *key;
	char *data;
};

extern struct list_head variable_bank;
extern struct list_head update_bank;
extern int secvar_enabled;
extern int secvar_ready;
extern struct secvar_storage_driver secvar_storage;
extern struct secvar_backend_driver secvar_backend;

// Helper functions
void clear_bank_list(struct list_head *bank);
int copy_bank_list(struct list_head *dst, struct list_head *src);
struct secvar *alloc_secvar(uint64_t key_len, uint64_t data_size);
struct secvar *new_secvar(const char *key, uint64_t key_len,
			       const char *data, uint64_t data_size,
			       uint64_t flags);
int realloc_secvar(struct secvar *node, uint64_t size);
void dealloc_secvar(struct secvar *node);
struct secvar *find_secvar(const char *key, uint64_t key_len, struct list_head *bank);
int is_key_empty(const char *key, uint64_t key_len);
int list_length(struct list_head *bank);

#endif