public ExtKey getInitalData() { if (m_rngCsp == null) { m_rngCsp = new RNGCryptoServiceProvider(); } ExtKey exkey = new SMS.ExtKey(m_rngCsp, SMSSyncAlgo.DES, SMSHash.MD5); Monitor.Enter(this); if (m_TmpExts == null) { m_TmpExts = new List <ExtKey>(); } m_TmpExts.Add(exkey); Monitor.Exit(this); return(exkey); }
private bool recvNewMessage(ExtKey key, byte[] msg, SMSHash hashid, byte[] hash) { ushort nummsg = BitConverter.ToUInt16(msg, 1); ushort retry = BitConverter.ToUInt16(msg, 3); string text = Encoding.UTF8.GetString(msg, 5, msg.Length - 5); MORZEMessage mmsg = new MORZEMessage(text, hashid, hash, nummsg); if (OnRecvMessage != null) { OnRecvMessage(this, mmsg); } BufferBuilder bb = new BufferBuilder(); bb.AddByte(4); // Type 4 - notify recived message bb.AddByte((byte)hashid); bb.AddBytes(hash); byte [] netmsg; bool bres = false; string err = SMSCrypt.SyncEncode(key.SyncID, bb.GetAllBytes(), key.SyncKey, key.SyncIV, out netmsg); if (string.IsNullOrEmpty(err) == true) { if (m_responseMsg == null) { m_responseMsg = new List <byte[]>(); } m_responseMsg.Add(netmsg); bres = true; } return(bres); }