/// <summary> /// Compare this object instance with another /// </summary> /// /// <param name="Obj">Object to compare</param> /// /// <returns>True if equal, otherwise false</returns> public override bool Equals(Object Obj) { if (this == Obj) { return(true); } if (Obj == null && this != null) { return(false); } DtmParameters other = (DtmParameters)Obj; if (GetHashCode() != other.GetHashCode()) { return(false); } return(true); }
/// <summary> /// Initialize this class with a random generator /// </summary> /// /// <param name="Parameters">A populated <see cref="DtmParameters"/> class containing the session parameters</param> /// <param name="Host">A populated <see cref="DtmClient"/> class containing the servers identity data</param> /// <param name="Generator">The initialized <see cref="IRandom"/> Prng instance</param> /// <param name="BufferCount">The number of send/receive buffers, default is 1024</param> /// <param name="DisposeEngines">if set to true (default), the primary symmetric ciphers are disposed when this class is disposed</param> public DtmKex(DtmParameters Parameters, DtmClient Host, IRandom Generator, int BufferCount = 1024, bool DisposeEngines = true) { _disposeEngines = DisposeEngines; _dtmParameters = Parameters; _dtmHost = Host; _srvIdentity = new DtmIdentity(Host.PublicId, Parameters.AuthPkeId, Parameters.AuthSession, 0); _exchangeState = DtmExchangeFlags.Connect; _rcvBuffer = new PacketBuffer(BufferCount); _sndBuffer = new PacketBuffer(BufferCount); _rndGenerator = Generator; _bufferCount = BufferCount; }
/// <summary> /// The remote server requires security parameters negotiation to continue. /// <para>Evaluates the requested security parameter requirement from a server, /// using the security context stored in the servers identity structure option flag.</para> /// </summary> /// /// <param name="Context">The servers required security level</param> /// /// <returns>Returns true if the negotiation succeeds</returns> private bool NegotiateSecurity(DtmParamSets.SecurityContexts Context) { // get the clients id structure DtmParamSets.SecurityContexts sxt = DtmParamSets.GetContext(_dtmParameters.OId); // note: only negotiate up as a security measure? if (Context == DtmParamSets.SecurityContexts.X1) _dtmParameters = (DtmParameters)DtmParamSets.DTMX11RNS1R2.DeepCopy(); else if (Context == DtmParamSets.SecurityContexts.X2) _dtmParameters = (DtmParameters)DtmParamSets.DTMX22MNS2R2.DeepCopy(); else if (Context == DtmParamSets.SecurityContexts.X3) _dtmParameters = (DtmParameters)DtmParamSets.DTMX31RNT1R2.DeepCopy(); else if (Context == DtmParamSets.SecurityContexts.X4) _dtmParameters = (DtmParameters)DtmParamSets.DTMX41RNT1R1.DeepCopy(); else return false; // error or failure // copy new security params _srvIdentity = new DtmIdentity(_dtmHost.PublicId, _dtmParameters.AuthPkeId, _dtmParameters.AuthSession, 0); return true; }
/// <summary> /// Serialize an DtmParameters structure /// </summary> /// /// <param name="Paramaters">A DtmParameters structure</param> /// /// <returns>A stream containing the DtmParameters data</returns> public static Stream Serialize(DtmParameters Paramaters) { return Paramaters.ToStream(); }
/// <summary> /// Serialize an DtmParameters structure /// </summary> /// /// <param name="Paramaters">A DtmParameters structure</param> /// /// <returns>A stream containing the DtmParameters data</returns> public static Stream Serialize(DtmParameters Paramaters) { return(Paramaters.ToStream()); }