internal static BufLen Send(DHHandshakeContext context) { context.TimestampA = (uint)Math.Ceiling((DateTime.UtcNow - I2PDate.RefDate).TotalSeconds); var cleartext = new List <byte>(); var ri = RouterContext.Inst.MyRouterIdentity.ToByteArray(); cleartext.AddRange(BufUtils.Flip16B((ushort)ri.Length)); cleartext.AddRange(ri); cleartext.AddRange(BufUtils.Flip32B(context.TimestampA)); #if LOG_ALL_TRANSPORT DebugUtils.Log("SessionConfirmA send TimestampA: " + (I2PDate.RefDate.AddSeconds(context.TimestampA).ToString())); DebugUtils.Log("SessionConfirmA send TimestampB: " + (I2PDate.RefDate.AddSeconds(context.TimestampB).ToString())); #endif var sign = I2PSignature.DoSign(RouterContext.Inst.PrivateSigningKey, context.X.Key, context.Y.Key, context.RemoteRI.IdentHash.Hash, BufUtils.Flip32BL(context.TimestampA), BufUtils.Flip32BL(context.TimestampB)); var padsize = BufUtils.Get16BytePadding(sign.Length + cleartext.Count); cleartext.AddRange(BufUtils.Random(padsize)); cleartext.AddRange(sign); var buf = new BufLen(cleartext.ToArray()); context.Encryptor.ProcessBytes(buf); return(buf); }
internal static BufLen Send(DHHandshakeContext context) { context.TimestampA = (uint)Math.Ceiling((DateTime.UtcNow - I2PDate.RefDate).TotalSeconds); var cleartext = new BufRefStream(); var ri = RouterContext.Inst.MyRouterIdentity.ToByteArray(); cleartext.Write(BufUtils.Flip16B((ushort)ri.Length)); cleartext.Write(ri); cleartext.Write(BufUtils.Flip32B(context.TimestampA)); Logging.LogDebugData($"SessionConfirmA send TimestampA: {I2PDate.RefDate.AddSeconds( context.TimestampA )}"); Logging.LogDebugData($"SessionConfirmA send TimestampB: {I2PDate.RefDate.AddSeconds( context.TimestampB )}"); var sign = I2PSignature.DoSign(RouterContext.Inst.PrivateSigningKey, context.X.Key, context.Y.Key, context.RemoteRI.IdentHash.Hash, BufUtils.Flip32BL(context.TimestampA), BufUtils.Flip32BL(context.TimestampB)); var padsize = BufUtils.Get16BytePadding((int)(sign.Length + cleartext.Length)); cleartext.Write(BufUtils.RandomBytes(padsize)); cleartext.Write(sign); var buf = new BufLen(cleartext.ToArray()); context.Encryptor.ProcessBytes(buf); return(buf); }
public void Write(BufRefStream dest) { var buf = new BufRefStream(); foreach (var one in Mappings) { one.Key.Write(buf); buf.Write((byte)'='); one.Value.Write(buf); buf.Write((byte)';'); } dest.Write(BufUtils.Flip16B((ushort)buf.Length)); dest.Write(buf); }
public override void Write(BufRefStream dest) { dest.Write(BufUtils.Flip16B(SessionId)); Config.Write(dest); }