1 /*
2  * Copyright (c) 2014 Jerry Lundström <lundstrom.jerry@gmail.com>
3  * Copyright (c) 2014 .SE (The Internet Infrastructure Foundation).
4  * Copyright (c) 2014 OpenDNSSEC AB (svb)
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 #ifndef __key_data_ext_h
31 #define __key_data_ext_h
32 
33 #include "key_state.h"
34 #include "hsm_key.h"
35 
36 /**
37  * Cache all key states objects for a key data object.
38  * \param[in] key_data a key_data_t pointer.
39  * \return DB_ERROR_* on failure, otherwise DB_OK.
40  */
41 extern int key_data_cache_key_states(key_data_t* key_data);
42 
43 /**
44  * Get the cached DS key state object of a key data object.
45  * key_data_cache_key_states() must have been called before this.
46  * \param[in] key_data a key_data_t pointer.
47  * \return a key_state_t pointer.
48  */
49 extern const key_state_t* key_data_cached_ds(key_data_t* key_data);
50 
51 /**
52  * Get the cached RRSIG key state object of a key data object.
53  * key_data_cache_key_states() must have been called before this.
54  * \param[in] key_data a key_data_t pointer.
55  * \return a key_state_t pointer.
56  */
57 extern const key_state_t* key_data_cached_rrsig(key_data_t* key_data);
58 
59 /**
60  * Get the cached DNSKEY key state object of a key data object.
61  * key_data_cache_key_states() must have been called before this.
62  * \param[in] key_data a key_data_t pointer.
63  * \return a key_state_t pointer.
64  */
65 extern const key_state_t* key_data_cached_dnskey(key_data_t* key_data);
66 
67 /**
68  * Get the cached RRSIG DNSKEY key state object of a key data object.
69  * key_data_cache_key_states() must have been called before this.
70  * \param[in] key_data a key_data_t pointer.
71  * \return a key_state_t pointer.
72  */
73 extern const key_state_t* key_data_cached_rrsigdnskey(key_data_t* key_data);
74 
75 /**
76  * Get the cached DS key state object of a key data object.
77  * key_data_cache_key_states() must have been called before this.
78  * \param[in] key_data a key_data_t pointer.
79  * \return a key_state_t pointer.
80  */
81 extern key_state_t* key_data_get_cached_ds(key_data_t* key_data);
82 
83 /**
84  * Get the cached RRSIG key state object of a key data object.
85  * key_data_cache_key_states() must have been called before this.
86  * \param[in] key_data a key_data_t pointer.
87  * \return a key_state_t pointer.
88  */
89 extern key_state_t* key_data_get_cached_rrsig(key_data_t* key_data);
90 
91 /**
92  * Get the cached DNSKEY key state object of a key data object.
93  * key_data_cache_key_states() must have been called before this.
94  * \param[in] key_data a key_data_t pointer.
95  * \return a key_state_t pointer.
96  */
97 extern key_state_t* key_data_get_cached_dnskey(key_data_t* key_data);
98 
99 /**
100  * Get the cached RRSIG DNSKEY key state object of a key data object.
101  * key_data_cache_key_states() must have been called before this.
102  * \param[in] key_data a key_data_t pointer.
103  * \return a key_state_t pointer.
104  */
105 extern key_state_t* key_data_get_cached_rrsigdnskey(key_data_t* key_data);
106 
107 /**
108  * Get the cached hsm key object of a key data object.
109  * key_data_cache_hsm_key() must have been called before this.
110  * \param[in] key_data a key_data_t pointer.
111  * \return a key_state_t pointer.
112  */
113 extern const hsm_key_t* key_data_cached_hsm_key(const key_data_t* key_data);
114 
115 #endif
116