123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465 |
- // AUTOGENERATED FILE, DO NOT EDIT BY HAND
- #ifndef PB_KEYEXCHANGE_H
- #define PB_KEYEXCHANGE_H
- #include <memory>
- #include <vector>
- #include <PbCommon.h>
- #include <PbWriter.h>
- #include <PbReader.h>
- enum class Product : uint32_t {
- PRODUCT_CLIENT = 0,
- PRODUCT_LIBSPOTIFY = 1,
- PRODUCT_MOBILE = 2,
- PRODUCT_PARTNER = 3,
- PRODUCT_LIBSPOTIFY_EMBEDDED = 5
- };
- enum class Platform : uint32_t {
- PLATFORM_WIN32_X86 = 0,
- PLATFORM_OSX_X86 = 1,
- PLATFORM_LINUX_X86 = 2,
- PLATFORM_IPHONE_ARM = 3,
- PLATFORM_S60_ARM = 4,
- PLATFORM_OSX_PPC = 5,
- PLATFORM_ANDROID_ARM = 6,
- PLATFORM_WINDOWS_CE_ARM = 7,
- PLATFORM_LINUX_X86_64 = 8,
- PLATFORM_OSX_X86_64 = 9,
- PLATFORM_PALM_ARM = 10,
- PLATFORM_LINUX_SH = 11,
- PLATFORM_FREEBSD_X86 = 12,
- PLATFORM_FREEBSD_X86_64 = 13,
- PLATFORM_BLACKBERRY_ARM = 14,
- PLATFORM_SONOS = 15,
- PLATFORM_LINUX_MIPS = 16,
- PLATFORM_LINUX_ARM = 17,
- PLATFORM_LOGITECH_ARM = 18,
- PLATFORM_LINUX_BLACKFIN = 19,
- PLATFORM_WP7_ARM = 20,
- PLATFORM_ONKYO_ARM = 21,
- PLATFORM_QNXNTO_ARM = 22,
- PLATFORM_BCO_ARM = 23
- };
- enum class Cryptosuite : uint32_t {
- CRYPTO_SUITE_SHANNON = 0,
- CRYPTO_SUITE_RC4_SHA1_HMAC = 1
- };
- class LoginCryptoDiffieHellmanChallenge : public BaseProtobufMessage {
- private:
- public:
- LoginCryptoDiffieHellmanChallenge() {};
- std::vector<uint8_t> gs;
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- case 10:
- reader->decodeVector(gs);
- break;
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- writer->addVector(10, gs);
- }
- };
- class LoginCryptoChallengeUnion : public BaseProtobufMessage {
- private:
- public:
- LoginCryptoChallengeUnion() {};
- LoginCryptoDiffieHellmanChallenge diffie_hellman;
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- case 10:
- lastMessagePosition = reader->pos + reader->decodeVarInt<uint32_t>();
- diffie_hellman.parseWithReader(reader);
- reader->maxPosition = lastMessagePosition;
- break;
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- lastMessagePosition = writer->startMessage();
- diffie_hellman.encodeWithWriter(writer);
- writer->finishMessage(10, lastMessagePosition);
- }
- };
- class LoginCryptoDiffieHellmanHello : public BaseProtobufMessage {
- private:
- public:
- LoginCryptoDiffieHellmanHello() {};
- std::vector<uint8_t> gc;
- uint32_t server_keys_known;
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- case 10:
- reader->decodeVector(gc);
- break;
- case 20:
- server_keys_known = reader->decodeVarInt<uint32_t>();
- break;
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- writer->addVector(10, gc);
- writer->addVarInt(20, server_keys_known);
- }
- };
- class LoginCryptoHelloUnion : public BaseProtobufMessage {
- private:
- public:
- LoginCryptoHelloUnion() {};
- LoginCryptoDiffieHellmanHello diffie_hellman;
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- case 10:
- lastMessagePosition = reader->pos + reader->decodeVarInt<uint32_t>();
- diffie_hellman.parseWithReader(reader);
- reader->maxPosition = lastMessagePosition;
- break;
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- lastMessagePosition = writer->startMessage();
- diffie_hellman.encodeWithWriter(writer);
- writer->finishMessage(10, lastMessagePosition);
- }
- };
- class BuildInfo : public BaseProtobufMessage {
- private:
- public:
- BuildInfo() {};
- Product product;
- Platform platform;
- uint64_t version;
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- case 10:
- product = static_cast<Product>(reader->decodeVarInt<uint32_t>());
- break;
- case 30:
- platform = static_cast<Platform>(reader->decodeVarInt<uint32_t>());
- break;
- case 40:
- version = reader->decodeVarInt<uint64_t>();
- break;
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- writer->addVarInt(10, static_cast<uint32_t>(product));
- writer->addVarInt(30, static_cast<uint32_t>(platform));
- writer->addVarInt(40, version);
- }
- };
- class FeatureSet : public BaseProtobufMessage {
- private:
- public:
- FeatureSet() {};
- bool autoupdate2;
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- case 1:
- autoupdate2 = reader->decodeVarInt<bool>();
- break;
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- writer->addVarInt(1, autoupdate2);
- }
- };
- class APChallenge : public BaseProtobufMessage {
- private:
- public:
- APChallenge() {};
- LoginCryptoChallengeUnion login_crypto_challenge;
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- case 10:
- lastMessagePosition = reader->pos + reader->decodeVarInt<uint32_t>();
- login_crypto_challenge.parseWithReader(reader);
- reader->maxPosition = lastMessagePosition;
- break;
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- lastMessagePosition = writer->startMessage();
- login_crypto_challenge.encodeWithWriter(writer);
- writer->finishMessage(10, lastMessagePosition);
- }
- };
- class APResponseMessage : public BaseProtobufMessage {
- private:
- public:
- APResponseMessage() {};
- APChallenge challenge;
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- case 10:
- lastMessagePosition = reader->pos + reader->decodeVarInt<uint32_t>();
- challenge.parseWithReader(reader);
- reader->maxPosition = lastMessagePosition;
- break;
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- lastMessagePosition = writer->startMessage();
- challenge.encodeWithWriter(writer);
- writer->finishMessage(10, lastMessagePosition);
- }
- };
- class LoginCryptoDiffieHellmanResponse : public BaseProtobufMessage {
- private:
- public:
- LoginCryptoDiffieHellmanResponse() {};
- std::vector<uint8_t> hmac;
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- case 10:
- reader->decodeVector(hmac);
- break;
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- writer->addVector(10, hmac);
- }
- };
- class LoginCryptoResponseUnion : public BaseProtobufMessage {
- private:
- public:
- LoginCryptoResponseUnion() {};
- LoginCryptoDiffieHellmanResponse diffie_hellman;
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- case 10:
- lastMessagePosition = reader->pos + reader->decodeVarInt<uint32_t>();
- diffie_hellman.parseWithReader(reader);
- reader->maxPosition = lastMessagePosition;
- break;
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- lastMessagePosition = writer->startMessage();
- diffie_hellman.encodeWithWriter(writer);
- writer->finishMessage(10, lastMessagePosition);
- }
- };
- class CryptoResponseUnion : public BaseProtobufMessage {
- private:
- public:
- CryptoResponseUnion() {};
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- }
- };
- class PoWResponseUnion : public BaseProtobufMessage {
- private:
- public:
- PoWResponseUnion() {};
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- }
- };
- class ClientResponsePlaintext : public BaseProtobufMessage {
- private:
- public:
- ClientResponsePlaintext() {};
- LoginCryptoResponseUnion login_crypto_response;
- PoWResponseUnion pow_response;
- CryptoResponseUnion crypto_response;
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- switch (reader->currentTag)
- {
- case 10:
- lastMessagePosition = reader->pos + reader->decodeVarInt<uint32_t>();
- login_crypto_response.parseWithReader(reader);
- reader->maxPosition = lastMessagePosition;
- break;
- case 20:
- lastMessagePosition = reader->pos + reader->decodeVarInt<uint32_t>();
- pow_response.parseWithReader(reader);
- reader->maxPosition = lastMessagePosition;
- break;
- case 30:
- lastMessagePosition = reader->pos + reader->decodeVarInt<uint32_t>();
- crypto_response.parseWithReader(reader);
- reader->maxPosition = lastMessagePosition;
- break;
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- lastMessagePosition = writer->startMessage();
- login_crypto_response.encodeWithWriter(writer);
- writer->finishMessage(10, lastMessagePosition);
- lastMessagePosition = writer->startMessage();
- pow_response.encodeWithWriter(writer);
- writer->finishMessage(20, lastMessagePosition);
- lastMessagePosition = writer->startMessage();
- crypto_response.encodeWithWriter(writer);
- writer->finishMessage(30, lastMessagePosition);
- }
- };
- class ClientHello : public BaseProtobufMessage {
- private:
- public:
- ClientHello() {};
- BuildInfo build_info;
- LoginCryptoHelloUnion login_crypto_hello;
- std::vector<Cryptosuite> cryptosuites_supported;
- std::vector<uint8_t> client_nonce;
- std::vector<uint8_t> padding;
- FeatureSet feature_set;
-
- bool decodeField(std::shared_ptr<PbReader> reader) {
- if (firstField) {
- cryptosuites_supported.clear();
- }
- switch (reader->currentTag)
- {
- case 10:
- lastMessagePosition = reader->pos + reader->decodeVarInt<uint32_t>();
- build_info.parseWithReader(reader);
- reader->maxPosition = lastMessagePosition;
- break;
- case 50:
- lastMessagePosition = reader->pos + reader->decodeVarInt<uint32_t>();
- login_crypto_hello.parseWithReader(reader);
- reader->maxPosition = lastMessagePosition;
- break;
- case 30:
- cryptosuites_supported.push_back(Cryptosuite());
- cryptosuites_supported[cryptosuites_supported.size()-1] = static_cast<Cryptosuite>(reader->decodeVarInt<uint32_t>());
- break;
- case 60:
- reader->decodeVector(client_nonce);
- break;
- case 70:
- reader->decodeVector(padding);
- break;
- case 80:
- lastMessagePosition = reader->pos + reader->decodeVarInt<uint32_t>();
- feature_set.parseWithReader(reader);
- reader->maxPosition = lastMessagePosition;
- break;
- default:
- return false;
- }
- return true;
- }
- void encodeWithWriter(std::shared_ptr<PbWriter> writer) {
- lastMessagePosition = writer->startMessage();
- build_info.encodeWithWriter(writer);
- writer->finishMessage(10, lastMessagePosition);
- lastMessagePosition = writer->startMessage();
- login_crypto_hello.encodeWithWriter(writer);
- writer->finishMessage(50, lastMessagePosition);
- lastMessagePosition = writer->startMessage();
- for (int i = 0; i < cryptosuites_supported.size(); i++) {
- writer->encodeVarInt(static_cast<uint32_t>(cryptosuites_supported[i]));
- }
- writer->finishMessage(30, lastMessagePosition);
- writer->addVector(60, client_nonce);
- writer->addVector(70, padding);
- lastMessagePosition = writer->startMessage();
- feature_set.encodeWithWriter(writer);
- writer->finishMessage(80, lastMessagePosition);
- }
- };
- #endif
|