| 116 | } |
| 117 | |
| 118 | bool EncryptedDiskCache::restoreCryptoKey(const StringBox& path) { |
| 119 | auto encryptoKeyBinary = _keychain->get(path); |
| 120 | if (encryptoKeyBinary.empty()) { |
| 121 | return false; |
| 122 | } |
| 123 | |
| 124 | snap::utils::crypto::AesEncryptor::Key cryptoKeyData; |
| 125 | if (encryptoKeyBinary.size() != cryptoKeyData.size()) { |
| 126 | return false; |
| 127 | } |
| 128 | |
| 129 | std::memcpy(cryptoKeyData.data(), encryptoKeyBinary.data(), encryptoKeyBinary.size()); |
| 130 | _cryptoKey = {cryptoKeyData}; |
| 131 | return true; |
| 132 | } |
| 133 | |
| 134 | void EncryptedDiskCache::generateCryptoKey(const StringBox& path) { |
| 135 | auto key = DataEncryptor::generateKey(); |