public KeyExchangeMessage(UInt32 messageVersion, UInt32 sequence, UInt32 flags, ECPublicKey baseKey, byte[] baseKeySignature, ECPublicKey ratchetKey, IdentityKey identityKey) { MaxVersion = CiphertextMessage.CURRENT_VERSION; Version = messageVersion; Sequence = sequence; Flags = flags; BaseKey = baseKey; BaseKeySignature = baseKeySignature; RatchetKey = ratchetKey; IdentityKey = identityKey; byte[] version = { ByteUtil.IntsToByteHighAndLow(Version, MaxVersion) }; var keyExchangeMsg = new WhisperProtos.KeyExchangeMessage { id = (Sequence << 5) | Flags, baseKey = BaseKey.Serialize(), ratchetKey = RatchetKey.Serialize(), identityKey = IdentityKey.Serialize() }; if(Version >= 3) { keyExchangeMsg.baseKeySignature = BaseKeySignature; } byte[] bytes; using(var stream = new MemoryStream()) { Serializer.Serialize(stream, keyExchangeMsg); bytes = stream.ToArray(); } _serialized = ByteUtil.Combine(version, bytes); }
public PreKeyWhisperMessage(UInt32 messageVersion, UInt32 registrationId, Maybe<UInt32> preKeyId, UInt32 signedPreKeyId, ECPublicKey baseKey, IdentityKey identityKey, WhisperMessage message) { MessageVersion = messageVersion; RegistrationId = registrationId; PreKeyId = preKeyId; SignedPreKeyId = signedPreKeyId; BaseKey = baseKey; IdentityKey = identityKey; Message = message; var preKeyMessage = new WhisperProtos.PreKeyWhisperMessage { signedPreKeyId = SignedPreKeyId, baseKey = BaseKey.Serialize(), identityKey = IdentityKey.Serialize(), message = Message.Serialize(), registrationId = registrationId }; preKeyId.Do(pKid => preKeyMessage.preKeyId = pKid); byte[] versionBytes = { ByteUtil.IntsToByteHighAndLow(MessageVersion, CURRENT_VERSION) }; byte[] messageBytes; using(var stream = new MemoryStream()) { Serializer.Serialize(stream, preKeyMessage); messageBytes = stream.ToArray(); } _serialized = ByteUtil.Combine(versionBytes, messageBytes); }
public PreKeyWhisperMessage(uint messageVersion, uint registrationId, May <uint> preKeyId, uint signedPreKeyId, ECPublicKey baseKey, IdentityKey identityKey, WhisperMessage message) { this.version = messageVersion; this.registrationId = registrationId; this.preKeyId = preKeyId; this.signedPreKeyId = signedPreKeyId; this.baseKey = baseKey; this.identityKey = identityKey; this.message = message; WhisperProtos.PreKeyWhisperMessage.Builder builder = WhisperProtos.PreKeyWhisperMessage.CreateBuilder() .SetSignedPreKeyId(signedPreKeyId) .SetBaseKey(ByteString.CopyFrom(baseKey.Serialize())) .SetIdentityKey(ByteString.CopyFrom(identityKey.Serialize())) .SetMessage(ByteString.CopyFrom(message.Serialize())) .SetRegistrationId(registrationId); if (preKeyId.HasValue) // .isPresent() { builder.SetPreKeyId(preKeyId.ForceGetValue()); // get() } byte[] versionBytes = { ByteUtil.IntsToByteHighAndLow((int)this.version, (int)CURRENT_VERSION) }; byte[] messageBytes = builder.Build().ToByteArray(); this.serialized = ByteUtil.Combine(versionBytes, messageBytes); }
public PreKeySignalMessage(uint messageVersion, uint registrationId, May <uint> preKeyId, uint signedPreKeyId, IEcPublicKey baseKey, IdentityKey identityKey, SignalMessage message) { _version = messageVersion; _registrationId = registrationId; _preKeyId = preKeyId; _signedPreKeyId = signedPreKeyId; _baseKey = baseKey; _identityKey = identityKey; _message = message; PreKeySignalMessage preKeySignalMessage = new PreKeySignalMessage { SignedPreKeyId = signedPreKeyId, BaseKey = ByteString.CopyFrom(baseKey.Serialize()), IdentityKey = ByteString.CopyFrom(identityKey.Serialize()), Message = ByteString.CopyFrom(message.Serialize()), RegistrationId = registrationId }; if (preKeyId.HasValue) // .isPresent() { preKeySignalMessage.PreKeyId = preKeyId.ForceGetValue(); // get() } byte[] versionBytes = { ByteUtil.IntsToByteHighAndLow((int)_version, (int)CurrentVersion) }; byte[] messageBytes = preKeySignalMessage.ToByteArray(); _serialized = ByteUtil.Combine(versionBytes, messageBytes); }
public PreKeySignalMessage(uint messageVersion, uint registrationId, May <uint> preKeyId, uint signedPreKeyId, IEcPublicKey baseKey, IdentityKey identityKey, SignalMessage message) { _version = messageVersion; _registrationId = registrationId; _preKeyId = preKeyId; _signedPreKeyId = signedPreKeyId; _baseKey = baseKey; _identityKey = identityKey; _message = message; WhisperProtos.PreKeySignalMessage.Builder builder = WhisperProtos.PreKeySignalMessage.CreateBuilder() .SetSignedPreKeyId(signedPreKeyId) .SetBaseKey(ByteString.CopyFrom(baseKey.Serialize())) .SetIdentityKey(ByteString.CopyFrom(identityKey.Serialize())) .SetMessage(ByteString.CopyFrom(message.Serialize())) .SetRegistrationId(registrationId); if (preKeyId.HasValue) // .isPresent() { builder.SetPreKeyId(preKeyId.ForceGetValue()); // get() } byte[] versionBytes = { ByteUtil.IntsToByteHighAndLow((int)_version, (int)CurrentVersion) }; byte[] messageBytes = builder.Build().ToByteArray(); _serialized = ByteUtil.Combine(versionBytes, messageBytes); }
public void SetLocalIdentityKey(IdentityKey identityKey) { this.sessionStructure = this.sessionStructure.ToBuilder() .SetLocalIdentityPublic(ByteString.CopyFrom(identityKey.Serialize())) .Build(); }
public void SetRemoteIdentityKey(IdentityKey identityKey) { _sessionStructure = _sessionStructure.ToBuilder() .SetRemoteIdentityPublic(ByteString.CopyFrom(identityKey.Serialize())) .Build(); }
public void SetRemoteIdentityKey(IdentityKey identityKey) { Structure.RemoteIdentityPublic = identityKey.Serialize (); }
public void SetLocalIdentityKey(IdentityKey identityKey) { Structure.LocalIdentityPublic = identityKey.Serialize(); }
public void SetLocalIdentityKey(IdentityKey identityKey) { _sessionStructure.LocalIdentityPublic = ByteString.CopyFrom(identityKey.Serialize()); }
public KeyExchangeMessage(uint messageVersion, uint sequence, uint flags, ECPublicKey baseKey, byte[] baseKeySignature, ECPublicKey ratchetKey, IdentityKey identityKey) { this.supportedVersion = CipherTextMessage.CURRENT_VERSION; this.version = messageVersion; this.sequence = sequence; this.flags = flags; this.baseKey = baseKey; this.baseKeySignature = baseKeySignature; this.ratchetKey = ratchetKey; this.identityKey = identityKey; byte[] version = { ByteUtil.IntsToByteHighAndLow((int)this.version, (int)this.supportedVersion) }; WhisperProtos.KeyExchangeMessage.Builder builder = WhisperProtos.KeyExchangeMessage .CreateBuilder() .SetId((sequence << 5) | flags) //(sequence << 5) | flags .SetBaseKey(ByteString.CopyFrom(baseKey.Serialize())) .SetRatchetKey(ByteString.CopyFrom(ratchetKey.Serialize())) .SetIdentityKey(ByteString.CopyFrom(identityKey.Serialize())); if (messageVersion >= 3) { builder.SetBaseKeySignature(ByteString.CopyFrom(baseKeySignature)); } this.serialized = ByteUtil.Combine(version, builder.Build().ToByteArray()); }