Пример #1
0
        private bool recvNotifyRecvExtKeys(ExtKey key, byte[] msg)
        {
            bool bres = false;

            try
            {
                byte[]  rcvhash = null;
                SMSHash hashid  = (SMSHash)msg[1];
                switch (hashid)
                {
                case SMSHash.MD5:
                    rcvhash = new byte[0x10];
                    break;
                }
                if (rcvhash != null)
                {
                    Array.Copy(msg, 2, rcvhash, 0, rcvhash.Length);
                    bres = SMSCrypt.CheckHash(hashid, key.SyncKey, rcvhash);
                }
                if (bres == true && OnRecvNotifyAcceptecExtKey != null)
                {
                    OnRecvNotifyAcceptecExtKey(this);
                }
            }
            catch
            {
                bres = false;
            }

            return(bres);
        }
Пример #2
0
        public bool PutReciveMessage(byte[] msg, byte[] hash, SMSHash hashid, byte[] ext)
        {
            bool   bRes = false;
            ExtKey key  = getExt(ext);

            if (SMSCrypt.CheckHash(hashid, msg, hash) == true)
            {
                byte [] res;
                string  err;
                err = SMSCrypt.SyncDecode(key.SyncID, msg, key.SyncKey, key.SyncIV, out res);
                if (string.IsNullOrEmpty(err) == true)
                {
                    if (res.Length != 0)
                    {
                        switch (res[0])
                        {
                        case 2:    //Type 2 - уведомление о получении ключей
                            bRes = recvNotifyRecvExtKeys(key, res);

                            break;

                        case 3:    //Type 3 - new messages
                            bRes = recvNewMessage(key, res, hashid, hash);
                            break;

                        case 4:    //Type 4 уведомление о принятых сообщениях .
                            bRes = recvDeliveryNotify(key, res);
                            break;
                        }
                    }
                }
            }
            return(bRes);
        }