Changeset View
Changeset View
Standalone View
Standalone View
src/client/actions/encryption.cpp
| Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | namespace Kazv | ||||
| ClientResult updateClient(ClientModel m, GenerateAndUploadOneTimeKeysAction a) | ClientResult updateClient(ClientModel m, GenerateAndUploadOneTimeKeysAction a) | ||||
| { | { | ||||
| if (! m.crypto) { | if (! m.crypto) { | ||||
| kzo.client.warn() << "Client::crypto is invalid, ignoring it." << std::endl; | kzo.client.warn() << "Client::crypto is invalid, ignoring it." << std::endl; | ||||
| return { std::move(m), simpleFail }; | return { std::move(m), simpleFail }; | ||||
| } | } | ||||
| kzo.client.dbg() << "Generating one-time keys..." << std::endl; | kzo.client.dbg() << "Generating " << a.numToGen << " one-time keys..." << std::endl; | ||||
| auto maxNumKeys = m.constCrypto().maxNumberOfOneTimeKeys(); | auto maxNumKeys = m.constCrypto().maxNumberOfOneTimeKeys(); | ||||
| auto numLocalKeys = m.constCrypto().numUnpublishedOneTimeKeys(); | auto numLocalKeys = m.constCrypto().numUnpublishedOneTimeKeys(); | ||||
| auto numStoredKeys = m.constCrypto().uploadedOneTimeKeysCount(signedCurve25519) + numLocalKeys; | auto numStoredKeys = m.constCrypto().uploadedOneTimeKeysCount(signedCurve25519) + numLocalKeys; | ||||
| auto numKeysToGenerate = a.numToGen; | auto numKeysToGenerate = a.numToGen; | ||||
| auto genKeysLimit = maxNumKeys - numStoredKeys; | auto genKeysLimit = maxNumKeys - numStoredKeys; | ||||
| if (numKeysToGenerate > genKeysLimit) { | if (numKeysToGenerate > genKeysLimit) { | ||||
| ▲ Show 20 Lines • Show All 590 Lines • Show Last 20 Lines | |||||