webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
rdb.h
Go to the documentation of this file.
1 /*
2  * replay-database.h
3  *
4  * interface for a replay database for packet security
5  *
6  * David A. McGrew
7  * Cisco Systems, Inc.
8  */
9 
10 
11 /*
12  *
13  * Copyright (c) 2001-2006, Cisco Systems, Inc.
14  * All rights reserved.
15  *
16  * Redistribution and use in source and binary forms, with or without
17  * modification, are permitted provided that the following conditions
18  * are met:
19  *
20  * Redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer.
22  *
23  * Redistributions in binary form must reproduce the above
24  * copyright notice, this list of conditions and the following
25  * disclaimer in the documentation and/or other materials provided
26  * with the distribution.
27  *
28  * Neither the name of the Cisco Systems, Inc. nor the names of its
29  * contributors may be used to endorse or promote products derived
30  * from this software without specific prior written permission.
31  *
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
35  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
36  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
37  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
39  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
42  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
43  * OF THE POSSIBILITY OF SUCH DAMAGE.
44  *
45  */
46 
47 #ifndef REPLAY_DB_H
48 #define REPLAY_DB_H
49 
50 #include "integers.h" /* for uint32_t */
51 #include "datatypes.h" /* for v128_t */
52 #include "err.h" /* for srtp_err_status_t */
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 /*
59  * if the ith least significant bit is one, then the packet index
60  * window_end-i is in the database
61  */
62 
63 typedef struct {
64  uint32_t window_start; /* packet index of the first bit in bitmask */
66 } srtp_rdb_t;
67 
68 #define rdb_bits_in_bitmask (8 * sizeof(v128_t))
69 
70 /*
71  * srtp_rdb_init
72  *
73  * initalizes rdb
74  *
75  * returns srtp_err_status_ok on success, srtp_err_status_t_fail otherwise
76  */
78 
79 
80 /*
81  * srtp_rdb_check
82  *
83  * checks to see if index appears in rdb
84  *
85  * returns srtp_err_status_fail if the index already appears in rdb,
86  * returns srtp_err_status_ok otherwise
87  */
89 
90 /*
91  * srtp_rdb_add_index
92  *
93  * adds index to srtp_rdb_t (and does *not* check if index appears in db)
94  *
95  * returns srtp_err_status_ok on success, srtp_err_status_fail otherwise
96  *
97  */
99 
100 /*
101  * the functions srtp_rdb_increment() and srtp_rdb_get_value() are for use by
102  * senders, not receivers - DO NOT use these functions on the same
103  * srtp_rdb_t upon which srtp_rdb_add_index is used!
104  */
105 
106 
107 /*
108  * srtp_rdb_increment(db) increments the sequence number in db, if it is
109  * not too high
110  *
111  * return values:
112  *
113  * srtp_err_status_ok no problem
114  * srtp_err_status_key_expired sequence number too high
115  *
116  */
118 
119 /*
120  * srtp_rdb_get_value(db) returns the current sequence number of db
121  */
123 
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif /* REPLAY_DB_H */
unsigned int uint32_t
Definition: ptypes.h:105
srtp_err_status_t srtp_rdb_init(srtp_rdb_t *rdb)
Definition: rdb.c:64
v128_t bitmask
Definition: rdb.h:65
uint32_t window_start
Definition: rdb.h:64
Definition: datatypes.h:90
Definition: rdb.h:63
srtp_err_status_t srtp_rdb_check(const srtp_rdb_t *rdb, uint32_t rdb_index)
Definition: rdb.c:74
uint32_t srtp_rdb_get_value(const srtp_rdb_t *rdb)
Definition: rdb.c:139
srtp_err_status_t srtp_rdb_add_index(srtp_rdb_t *rdb, uint32_t rdb_index)
Definition: rdb.c:104
srtp_err_status_t
Definition: srtp.h:245
srtp_err_status_t srtp_rdb_increment(srtp_rdb_t *rdb)
Definition: rdb.c:130