| 90 | } |
| 91 | |
| 92 | std::optional<snap::utils::crypto::AesEncryptor::Key> AndroidKeychain::getSecretKey() { |
| 93 | std::lock_guard<Valdi::Mutex> guard(_mutex); |
| 94 | if (!_fetchedSecretKey) { |
| 95 | _fetchedSecretKey = true; |
| 96 | |
| 97 | VALDI_TRACE("Valdi.getAndroidKeychainSecretKey") |
| 98 | |
| 99 | auto secretKeyJava = _getSecretKeyMethod.call(_keychainJava.toObject()); |
| 100 | if (!secretKeyJava.isNull()) { |
| 101 | auto bytes = |
| 102 | ValdiAndroid::toByteArray(JavaEnv(), reinterpret_cast<jbyteArray>(secretKeyJava.getUnsafeObject())); |
| 103 | snap::utils::crypto::AesEncryptor::Key key; |
| 104 | SC_ASSERT(sizeof(key) == bytes.size()); |
| 105 | |
| 106 | std::memcpy(key.data(), bytes.data(), bytes.size()); |
| 107 | _secretKey = {key}; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | return _secretKey; |
| 112 | } |
| 113 | |
| 114 | } // namespace ValdiAndroid |
nothing calls this directly
no test coverage detected