2015-06-11 19:03:22 +02:00
|
|
|
#ifndef AXOLOTL_ACCOUNT_HH_
|
|
|
|
#define AXOLOTL_ACCOUNT_HH_
|
|
|
|
|
|
|
|
#include "axolotl/list.hh"
|
2015-06-12 15:09:41 +02:00
|
|
|
#include "axolotl/crypto.hh"
|
|
|
|
#include "axolotl/error.hh"
|
2015-06-11 19:03:22 +02:00
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
namespace axolotl {
|
|
|
|
|
|
|
|
|
|
|
|
struct LocalKey {
|
|
|
|
std::uint32_t id;
|
|
|
|
Curve25519KeyPair key;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct SignedKey : LocalKey {
|
|
|
|
std::uint8_t signature[64];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static std::size_t const MAX_ONE_TIME_KEYS = 100;
|
|
|
|
|
|
|
|
struct Account {
|
|
|
|
LocalKey identity_key;
|
|
|
|
LocalKey last_resort_one_time_key;
|
|
|
|
List<LocalKey, MAX_ONE_TIME_KEYS> one_time_keys;
|
2015-06-12 15:09:41 +02:00
|
|
|
ErrorCode last_error;
|
2015-06-11 19:03:22 +02:00
|
|
|
|
|
|
|
/** Number of random bytes needed to create a new account */
|
|
|
|
std::size_t new_account_random_length();
|
|
|
|
|
|
|
|
/** Create a new account. Returns NOT_ENOUGH_RANDOM if the number of random
|
|
|
|
* bytes is too small. */
|
2015-06-12 15:09:41 +02:00
|
|
|
std::size_t new_account(
|
2015-06-11 19:03:22 +02:00
|
|
|
uint8_t const * random, std::size_t random_length
|
|
|
|
);
|
|
|
|
|
2015-06-12 15:09:41 +02:00
|
|
|
LocalKey const * lookup_key(
|
|
|
|
std::uint32_t id
|
|
|
|
);
|
2015-06-12 17:15:37 +02:00
|
|
|
};
|
2015-06-12 15:09:41 +02:00
|
|
|
|
2015-06-11 19:03:22 +02:00
|
|
|
|
2015-06-12 17:15:37 +02:00
|
|
|
std::size_t pickle_length(
|
|
|
|
Account const & value
|
|
|
|
);
|
2015-06-11 19:03:22 +02:00
|
|
|
|
2015-06-12 17:15:37 +02:00
|
|
|
|
|
|
|
std::uint8_t * pickle(
|
|
|
|
std::uint8_t * pos,
|
|
|
|
Account const & value
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
std::uint8_t const * unpickle(
|
|
|
|
std::uint8_t const * pos, std::uint8_t const * end,
|
|
|
|
Account & value
|
|
|
|
);
|
2015-06-11 19:03:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace axolotl
|
|
|
|
|
|
|
|
#endif /* AXOLOTL_ACCOUNT_HH_ */
|