1 /* Copyright (c) 2018, 2021 Percona LLC and/or its affiliates. All rights reserved.
2
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License
5 as published by the Free Software Foundation; version 2 of
6 the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
17 #include "vault_key.h"
18 #include <sstream>
19
20 namespace keyring {
21
get_next_key(IKey ** key)22 my_bool Vault_key::get_next_key(IKey **key)
23 {
24 if (was_key_retrieved)
25 {
26 *key= NULL;
27 return TRUE;
28 }
29 *key= new Vault_key(*this);
30 was_key_retrieved= true;
31 return FALSE;
32 }
33
has_next_key()34 my_bool Vault_key::has_next_key() { return !was_key_retrieved; }
35
xor_data()36 void Vault_key::xor_data() { /* We do not xor data in keyring_vault */}
37
xor_data(uchar *,size_t)38 void Vault_key::xor_data(uchar *, size_t)
39 {
40 /* We do not xor data in keyring_vault */
41 }
42
get_key_data() const43 uchar *Vault_key::get_key_data() const { return key.get(); }
44
get_key_data_size() const45 size_t Vault_key::get_key_data_size() const { return key_len; }
46
get_key_type() const47 const std::string *Vault_key::get_key_type() const { return &this->key_type; }
48
create_key_signature() const49 void Vault_key::create_key_signature() const
50 {
51 if (key_id.empty())
52 return;
53 std::ostringstream key_signature_ss;
54 key_signature_ss << key_id.length() << '_';
55 key_signature_ss << key_id;
56 key_signature_ss << user_id.length() << '_';
57 key_signature_ss << user_id;
58 key_signature= key_signature_ss.str();
59 }
60
61 } // namespace keyring
62