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 #ifndef MYSQL_GUNIT_INCORRECT_VAULT_KEY_H 18 #define MYSQL_GUNIT_INCORRECT_VAULT_KEY_H 19 20 #include "vault_key.h" 21 22 namespace keyring { 23 24 struct Incorrect_vault_key : public Vault_key { Incorrect_vault_keyIncorrect_vault_key25 Incorrect_vault_key(const char *a_key_id, const char *a_key_type, 26 const char *a_user_id, const void *a_key, 27 size_t a_key_len) 28 : Vault_key(a_key_id, a_key_type, a_user_id, a_key, a_key_len), 29 add_to_key_id_length(0), 30 add_to_user_id_length(0) 31 { 32 } 33 Incorrect_vault_keyIncorrect_vault_key34 Incorrect_vault_key(const Incorrect_vault_key &incorrect_vault_key) 35 : Vault_key(incorrect_vault_key), 36 add_to_key_id_length(incorrect_vault_key.add_to_key_id_length), 37 add_to_user_id_length(incorrect_vault_key.add_to_user_id_length) 38 { 39 } 40 41 int add_to_key_id_length; 42 int add_to_user_id_length; 43 get_next_keyIncorrect_vault_key44 virtual my_bool get_next_key(IKey **key) 45 { 46 if (was_key_retrieved) 47 { 48 *key= NULL; 49 return TRUE; 50 } 51 *key= new Incorrect_vault_key(*this); 52 was_key_retrieved= true; 53 return FALSE; 54 } 55 create_key_signatureIncorrect_vault_key56 virtual void create_key_signature() const 57 { 58 if (key_id.empty()) 59 return; 60 std::ostringstream key_signature_ss; 61 key_signature_ss << key_id.length() + add_to_key_id_length << '_'; 62 key_signature_ss << key_id; 63 key_signature_ss << user_id.length() + add_to_user_id_length << '_'; 64 key_signature_ss << user_id; 65 key_signature= key_signature_ss.str(); 66 } 67 }; 68 69 } // namespace keyring 70 71 #endif // MYSQL_GUNIT_INCORRECT_VAULT_KEY_H 72