Skip to content
|
Access key help
Search
Advanced search
A–Z
Contact us
Computer Laboratory
Computer Laboratory
Research
Security Group
CTSRD
Temporally Enhanced Security Logic Assertions (TESLA)
API Documentation
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
libtesla.h
Go to the documentation of this file.
1
/*-
2
* Copyright (c) 2011 Robert N. M. Watson
3
* Copyright (c) 2012-2013 Jonathan Anderson
4
* All rights reserved.
5
*
6
* This software was developed by SRI International and the University of
7
* Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
8
* ("CTSRD"), as part of the DARPA CRASH research programme.
9
*
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions
12
* are met:
13
* 1. Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
15
* 2. Redistributions in binary form must reproduce the above copyright
16
* notice, this list of conditions and the following disclaimer in the
17
* documentation and/or other materials provided with the distribution.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29
* SUCH DAMAGE.
30
*
31
* $Id$
32
*/
33
34
#ifndef _TESLA_STATE
35
#define _TESLA_STATE
36
43
#ifdef _KERNEL
44
#include <sys/types.h>
45
#else
46
#include <stdint.h>
/* int32_t, uint32_t */
47
#endif
48
55
enum
tesla_err_t
{
56
TESLA_SUCCESS
,
/* Success. */
57
TESLA_ERROR_ENOENT
,
/* Entry not found. */
58
TESLA_ERROR_ENOMEM
,
/* Insufficient memory. */
59
TESLA_ERROR_EINVAL
,
/* Invalid parameters. */
60
TESLA_ERROR_UNKNOWN
,
/* An unknown (e.g. platform) error. */
61
};
62
66
const
char
*
tesla_strerror
(int32_t
error
);
67
68
75
struct
tesla_store
;
76
86
enum
tesla_context
{
87
TESLA_CONTEXT_GLOBAL
,
88
TESLA_CONTEXT_THREAD
,
89
};
90
102
int32_t
tesla_store_get
(
enum
tesla_context
context,
103
uint32_t
classes
, uint32_t instances,
104
struct
tesla_store
* *store);
105
106
111
struct
tesla_class
;
112
129
int32_t
tesla_class_get
(
struct
tesla_store
*store,
130
uint32_t
id
,
131
struct
tesla_class
**tclass,
132
const
char
*name,
133
const
char
*description);
134
136
void
tesla_class_put
(
struct
tesla_class
*);
137
138
140
struct
tesla_transition
{
142
uint32_t
from
;
143
145
uint32_t
from_mask
;
146
148
uint32_t
to
;
149
151
uint32_t
to_mask
;
152
154
int
flags
;
155
};
156
157
#define TESLA_TRANS_INIT 0x02
/* May need to initialise the class. */
158
#define TESLA_TRANS_CLEANUP 0x04
/* Clean up the class now. */
159
165
struct
tesla_transitions
{
167
uint32_t
length
;
168
170
struct
tesla_transition
*
transitions
;
171
};
172
173
#define TESLA_KEY_SIZE 4
174
185
struct
tesla_key
{
187
uintptr_t
tk_keys
[
TESLA_KEY_SIZE
];
188
190
uint32_t
tk_mask
;
191
};
192
193
197
void
tesla_update_state
(
enum
tesla_context
context, uint32_t class_id,
198
const
struct
tesla_key
*key,
const
char
*name,
const
char
*description,
199
const
struct
tesla_transitions
*);
200
201
203
struct
tesla_instance
{
204
struct
tesla_key
ti_key
;
205
uint32_t
ti_state
;
206
};
207
208
209
/*
210
* Event notification:
211
*/
213
typedef
void (*
tesla_ev_new_instance
)(
struct
tesla_class
*,
214
struct
tesla_instance
*);
215
217
typedef
void (*
tesla_ev_transition
)(
struct
tesla_class
*,
218
struct
tesla_instance
*,
const
struct
tesla_transition
*);
219
221
typedef
void (*
tesla_ev_clone
)(
struct
tesla_class
*,
222
struct
tesla_instance
*orig,
struct
tesla_instance
*copy,
223
const
struct
tesla_transition
*);
224
226
typedef
void (*
tesla_ev_no_instance
)(
struct
tesla_class
*,
227
const
struct
tesla_key
*,
const
struct
tesla_transitions
*);
228
230
typedef
void (*
tesla_ev_bad_transition
)(
struct
tesla_class
*,
231
struct
tesla_instance
*,
const
struct
tesla_transitions
*);
232
234
typedef
void (*
tesla_ev_error
)(
struct
tesla_class
*, int32_t,
const
char
*);
235
237
typedef
void (*
tesla_ev_accept
)(
struct
tesla_class
*,
238
struct
tesla_instance
*);
239
241
typedef
void (*
tesla_ev_ignored
)(
const
struct
tesla_class
*,
242
const
struct
tesla_key
*,
const
struct
tesla_transitions
*);
243
245
struct
tesla_event_handlers
{
246
tesla_ev_new_instance
teh_init
;
247
tesla_ev_transition
teh_transition
;
248
tesla_ev_clone
teh_clone
;
249
tesla_ev_no_instance
teh_fail_no_instance
;
250
tesla_ev_bad_transition
teh_bad_transition
;
251
tesla_ev_error
teh_err
;
252
tesla_ev_accept
teh_accept
;
253
tesla_ev_ignored
teh_ignored
;
254
};
255
262
struct
tesla_event_metahandler
{
264
const
uint32_t
tem_length
;
265
267
uint32_t
tem_mask
;
268
270
const
struct
tesla_event_handlers
*
const
*
tem_handlers
;
271
};
272
274
int
tesla_set_event_handler
(
struct
tesla_event_handlers
*);
275
277
int
tesla_set_event_handlers
(
struct
tesla_event_metahandler
*);
278
279
#ifdef _KERNEL
280
#define TESLA_KERN_PRINTF_EV 0x1
281
#define TESLA_KERN_PRINTERR_EV 0x2
282
#define TESLA_KERN_DTRACE_EV 0x4
283
#define TESLA_KERN_PANIC_EV 0x8
284
#endif
285
288
#endif
/* _TESLA_STATE */
© 2013 Jonathan Anderson
Information provided by
Jonathan Anderson