OLD | NEW |
1 /* | 1 /* |
2 * replay-database.h | 2 * replay-database.h |
3 * | 3 * |
4 * interface for a replay database for packet security | 4 * interface for a replay database for packet security |
5 * | 5 * |
6 * David A. McGrew | 6 * David A. McGrew |
7 * Cisco Systems, Inc. | 7 * Cisco Systems, Inc. |
8 */ | 8 */ |
9 | 9 |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 42 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
43 * OF THE POSSIBILITY OF SUCH DAMAGE. | 43 * OF THE POSSIBILITY OF SUCH DAMAGE. |
44 * | 44 * |
45 */ | 45 */ |
46 | 46 |
47 #ifndef REPLAY_DB_H | 47 #ifndef REPLAY_DB_H |
48 #define REPLAY_DB_H | 48 #define REPLAY_DB_H |
49 | 49 |
50 #include "integers.h" /* for uint32_t */ | 50 #include "integers.h" /* for uint32_t */ |
51 #include "datatypes.h" /* for v128_t */ | 51 #include "datatypes.h" /* for v128_t */ |
52 #include "err.h" /* for err_status_t */ | 52 #include "err.h" /* for srtp_err_status_t */ |
| 53 |
| 54 #ifdef __cplusplus |
| 55 extern "C" { |
| 56 #endif |
53 | 57 |
54 /* | 58 /* |
55 * if the ith least significant bit is one, then the packet index | 59 * if the ith least significant bit is one, then the packet index |
56 * window_end-i is in the database | 60 * window_end-i is in the database |
57 */ | 61 */ |
58 | 62 |
59 typedef struct { | 63 typedef struct { |
60 uint32_t window_start; /* packet index of the first bit in bitmask */ | 64 uint32_t window_start; /* packet index of the first bit in bitmask */ |
61 v128_t bitmask; | 65 v128_t bitmask; |
62 } rdb_t; | 66 } srtp_rdb_t; |
63 | 67 |
64 #define rdb_bits_in_bitmask (8*sizeof(v128_t)) | 68 #define rdb_bits_in_bitmask (8 * sizeof(v128_t)) |
65 | 69 |
66 /* | 70 /* |
67 * rdb init | 71 * srtp_rdb_init |
68 * | 72 * |
69 * initalizes rdb | 73 * initalizes rdb |
70 * | 74 * |
71 * returns err_status_ok on success, err_status_t_fail otherwise | 75 * returns srtp_err_status_ok on success, srtp_err_status_t_fail otherwise |
72 */ | 76 */ |
73 | 77 srtp_err_status_t srtp_rdb_init(srtp_rdb_t *rdb); |
74 err_status_t | |
75 rdb_init(rdb_t *rdb); | |
76 | 78 |
77 | 79 |
78 /* | 80 /* |
79 * rdb_check | 81 * srtp_rdb_check |
80 * | 82 * |
81 * checks to see if index appears in rdb | 83 * checks to see if index appears in rdb |
82 * | 84 * |
83 * returns err_status_fail if the index already appears in rdb, | 85 * returns srtp_err_status_fail if the index already appears in rdb, |
84 * returns err_status_ok otherwise | 86 * returns srtp_err_status_ok otherwise |
85 */ | 87 */ |
86 | 88 srtp_err_status_t srtp_rdb_check(const srtp_rdb_t *rdb, uint32_t rdb_index); |
87 err_status_t | |
88 rdb_check(const rdb_t *rdb, uint32_t rdb_index); | |
89 | 89 |
90 /* | 90 /* |
91 * rdb_add_index | 91 * srtp_rdb_add_index |
92 * | 92 * |
93 * adds index to rdb_t (and does *not* check if index appears in db) | 93 * adds index to srtp_rdb_t (and does *not* check if index appears in db) |
94 * | 94 * |
95 * returns err_status_ok on success, err_status_fail otherwise | 95 * returns srtp_err_status_ok on success, srtp_err_status_fail otherwise |
96 * | 96 * |
97 */ | 97 */ |
98 | 98 srtp_err_status_t srtp_rdb_add_index(srtp_rdb_t *rdb, uint32_t rdb_index); |
99 err_status_t | |
100 rdb_add_index(rdb_t *rdb, uint32_t rdb_index); | |
101 | 99 |
102 /* | 100 /* |
103 * the functions rdb_increment() and rdb_get_value() are for use by | 101 * the functions srtp_rdb_increment() and srtp_rdb_get_value() are for use by |
104 * senders, not receivers - DO NOT use these functions on the same | 102 * senders, not receivers - DO NOT use these functions on the same |
105 * rdb_t upon which rdb_add_index is used! | 103 * srtp_rdb_t upon which srtp_rdb_add_index is used! |
106 */ | 104 */ |
107 | 105 |
108 | 106 |
109 /* | 107 /* |
110 * rdb_increment(db) increments the sequence number in db, if it is | 108 * srtp_rdb_increment(db) increments the sequence number in db, if it is |
111 * not too high | 109 * not too high |
112 * | 110 * |
113 * return values: | 111 * return values: |
114 * | 112 * |
115 * err_status_ok no problem | 113 * srtp_err_status_ok no problem |
116 * err_status_key_expired sequence number too high | 114 * srtp_err_status_key_expired sequence number too high |
117 * | 115 * |
118 */ | 116 */ |
119 err_status_t | 117 srtp_err_status_t srtp_rdb_increment(srtp_rdb_t *rdb); |
120 rdb_increment(rdb_t *rdb); | |
121 | 118 |
122 /* | 119 /* |
123 * rdb_get_value(db) returns the current sequence number of db | 120 * srtp_rdb_get_value(db) returns the current sequence number of db |
124 */ | 121 */ |
125 | 122 uint32_t srtp_rdb_get_value(const srtp_rdb_t *rdb); |
126 uint32_t | |
127 rdb_get_value(const rdb_t *rdb); | |
128 | 123 |
129 | 124 |
130 #endif /* REPLAY_DB_H */ | 125 #ifdef __cplusplus |
| 126 } |
| 127 #endif |
| 128 |
| 129 #endif /* REPLAY_DB_H */ |
OLD | NEW |