// AUTOGENERATED FILE, DO NOT EDIT BY HAND #ifndef PB_KEYEXCHANGE_H #define PB_KEYEXCHANGE_H #include #include #include #include #include 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 gs; bool decodeField(std::shared_ptr reader) { switch (reader->currentTag) { case 10: reader->decodeVector(gs); break; default: return false; } return true; } void encodeWithWriter(std::shared_ptr writer) { writer->addVector(10, gs); } }; class LoginCryptoChallengeUnion : public BaseProtobufMessage { private: public: LoginCryptoChallengeUnion() {}; LoginCryptoDiffieHellmanChallenge diffie_hellman; bool decodeField(std::shared_ptr reader) { switch (reader->currentTag) { case 10: lastMessagePosition = reader->pos + reader->decodeVarInt(); diffie_hellman.parseWithReader(reader); reader->maxPosition = lastMessagePosition; break; default: return false; } return true; } void encodeWithWriter(std::shared_ptr writer) { lastMessagePosition = writer->startMessage(); diffie_hellman.encodeWithWriter(writer); writer->finishMessage(10, lastMessagePosition); } }; class LoginCryptoDiffieHellmanHello : public BaseProtobufMessage { private: public: LoginCryptoDiffieHellmanHello() {}; std::vector gc; uint32_t server_keys_known; bool decodeField(std::shared_ptr reader) { switch (reader->currentTag) { case 10: reader->decodeVector(gc); break; case 20: server_keys_known = reader->decodeVarInt(); break; default: return false; } return true; } void encodeWithWriter(std::shared_ptr 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 reader) { switch (reader->currentTag) { case 10: lastMessagePosition = reader->pos + reader->decodeVarInt(); diffie_hellman.parseWithReader(reader); reader->maxPosition = lastMessagePosition; break; default: return false; } return true; } void encodeWithWriter(std::shared_ptr 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 reader) { switch (reader->currentTag) { case 10: product = static_cast(reader->decodeVarInt()); break; case 30: platform = static_cast(reader->decodeVarInt()); break; case 40: version = reader->decodeVarInt(); break; default: return false; } return true; } void encodeWithWriter(std::shared_ptr writer) { writer->addVarInt(10, static_cast(product)); writer->addVarInt(30, static_cast(platform)); writer->addVarInt(40, version); } }; class FeatureSet : public BaseProtobufMessage { private: public: FeatureSet() {}; bool autoupdate2; bool decodeField(std::shared_ptr reader) { switch (reader->currentTag) { case 1: autoupdate2 = reader->decodeVarInt(); break; default: return false; } return true; } void encodeWithWriter(std::shared_ptr writer) { writer->addVarInt(1, autoupdate2); } }; class APChallenge : public BaseProtobufMessage { private: public: APChallenge() {}; LoginCryptoChallengeUnion login_crypto_challenge; bool decodeField(std::shared_ptr reader) { switch (reader->currentTag) { case 10: lastMessagePosition = reader->pos + reader->decodeVarInt(); login_crypto_challenge.parseWithReader(reader); reader->maxPosition = lastMessagePosition; break; default: return false; } return true; } void encodeWithWriter(std::shared_ptr 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 reader) { switch (reader->currentTag) { case 10: lastMessagePosition = reader->pos + reader->decodeVarInt(); challenge.parseWithReader(reader); reader->maxPosition = lastMessagePosition; break; default: return false; } return true; } void encodeWithWriter(std::shared_ptr writer) { lastMessagePosition = writer->startMessage(); challenge.encodeWithWriter(writer); writer->finishMessage(10, lastMessagePosition); } }; class LoginCryptoDiffieHellmanResponse : public BaseProtobufMessage { private: public: LoginCryptoDiffieHellmanResponse() {}; std::vector hmac; bool decodeField(std::shared_ptr reader) { switch (reader->currentTag) { case 10: reader->decodeVector(hmac); break; default: return false; } return true; } void encodeWithWriter(std::shared_ptr writer) { writer->addVector(10, hmac); } }; class LoginCryptoResponseUnion : public BaseProtobufMessage { private: public: LoginCryptoResponseUnion() {}; LoginCryptoDiffieHellmanResponse diffie_hellman; bool decodeField(std::shared_ptr reader) { switch (reader->currentTag) { case 10: lastMessagePosition = reader->pos + reader->decodeVarInt(); diffie_hellman.parseWithReader(reader); reader->maxPosition = lastMessagePosition; break; default: return false; } return true; } void encodeWithWriter(std::shared_ptr writer) { lastMessagePosition = writer->startMessage(); diffie_hellman.encodeWithWriter(writer); writer->finishMessage(10, lastMessagePosition); } }; class CryptoResponseUnion : public BaseProtobufMessage { private: public: CryptoResponseUnion() {}; bool decodeField(std::shared_ptr reader) { switch (reader->currentTag) { default: return false; } return true; } void encodeWithWriter(std::shared_ptr writer) { } }; class PoWResponseUnion : public BaseProtobufMessage { private: public: PoWResponseUnion() {}; bool decodeField(std::shared_ptr reader) { switch (reader->currentTag) { default: return false; } return true; } void encodeWithWriter(std::shared_ptr writer) { } }; class ClientResponsePlaintext : public BaseProtobufMessage { private: public: ClientResponsePlaintext() {}; LoginCryptoResponseUnion login_crypto_response; PoWResponseUnion pow_response; CryptoResponseUnion crypto_response; bool decodeField(std::shared_ptr reader) { switch (reader->currentTag) { case 10: lastMessagePosition = reader->pos + reader->decodeVarInt(); login_crypto_response.parseWithReader(reader); reader->maxPosition = lastMessagePosition; break; case 20: lastMessagePosition = reader->pos + reader->decodeVarInt(); pow_response.parseWithReader(reader); reader->maxPosition = lastMessagePosition; break; case 30: lastMessagePosition = reader->pos + reader->decodeVarInt(); crypto_response.parseWithReader(reader); reader->maxPosition = lastMessagePosition; break; default: return false; } return true; } void encodeWithWriter(std::shared_ptr 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 cryptosuites_supported; std::vector client_nonce; std::vector padding; FeatureSet feature_set; bool decodeField(std::shared_ptr reader) { if (firstField) { cryptosuites_supported.clear(); } switch (reader->currentTag) { case 10: lastMessagePosition = reader->pos + reader->decodeVarInt(); build_info.parseWithReader(reader); reader->maxPosition = lastMessagePosition; break; case 50: lastMessagePosition = reader->pos + reader->decodeVarInt(); login_crypto_hello.parseWithReader(reader); reader->maxPosition = lastMessagePosition; break; case 30: cryptosuites_supported.push_back(Cryptosuite()); cryptosuites_supported[cryptosuites_supported.size()-1] = static_cast(reader->decodeVarInt()); break; case 60: reader->decodeVector(client_nonce); break; case 70: reader->decodeVector(padding); break; case 80: lastMessagePosition = reader->pos + reader->decodeVarInt(); feature_set.parseWithReader(reader); reader->maxPosition = lastMessagePosition; break; default: return false; } return true; } void encodeWithWriter(std::shared_ptr 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(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