Ejemplo n.º 1
0
 public M2ResponseMessage(string respond)
 {
     respHeader.protocolVer  = MsgInitValues.PROTOCOL;
     respHeader.respStatus   = BitConverter.GetBytes((UInt32)enStatusCodes.raErrNone);
     respHeader.respType     = BitConverter.GetBytes((UInt32)enMsgType.raMessage2Resp);
     respHeader.msgLength    = BitConverter.GetBytes((UInt32)enDefaultLength.raDefaultM2Length);
     respHeader.sessionNonce = MsgInitValues.DS_ZERO_BA16;
     respMsg2Body            = new ResponseM2Body();
 }
        //Build an M2 response
        public void buildM2Response(out M2ResponseMessage m2Resp)
        {
            string respond = Constants.Respond;

            byte[] tempM2Bytes = { 0x00 };

            var m2Body     = new ResponseM2Body();
            var m2Response = new M2ResponseMessage(respond);


            //Populate message body components
            m2Response.respMsg2Body.gbX         = Constants.sampleGbXba;
            m2Response.respMsg2Body.gbY         = Constants.sampleGbYba;
            m2Response.respMsg2Body.spId        = SpStartup.iasConnectionMgr.SPID;
            m2Response.respMsg2Body.sigLinkType = Constants.sltype;
            m2Response.respMsg2Body.kdfId       = Constants.kdfId;

            //the m2 slReserved field is automatically initialized in the instance
            m2Response.respMsg2Body.sigSpX = Constants.sigSpXba;
            m2Response.respMsg2Body.sigSpY = Constants.sigSpYba;

            using (RNGCryptoServiceProvider nonceGen = new RNGCryptoServiceProvider())
            {
                if (nonceGen == null)
                {
                    Exception e = new Exception("Internal Error: nonceGen is Null");
                    options.LogThrownException(e);
                    throw e;
                }

                byte[] sessionNonce = Constants.sn2;
                nonceGen.GetBytes(sessionNonce);  //Generate a new nonce
                m2Response.respMsg2Body.cmacsmk   = sessionNonce;
                m2Response.respMsg2Body.sigrlSize = MsgInitValues.DS_EMPTY_BA4;
                m2Response.respMsg2Body.sigRl     = null;

                //Copy each reference to its output parameter
                m2Resp = m2Response;
            }

            return;
        }
Ejemplo n.º 3
0
 public M2ResponseMessage()
 {
     //Constructor to populate an "empty" object
     respHeader.protocolVer   = MsgInitValues.DS_EMPTY_BA2;
     respHeader.respStatus    = BitConverter.GetBytes((UInt32)enStatusCodes.raErrUnknown);
     respHeader.respType      = BitConverter.GetBytes((UInt32)enMsgType.raReserved);
     respHeader.msgLength     = BitConverter.GetBytes((UInt32)enDefaultLength.raDefaultEmptyLength);
     respHeader.sessionNonce  = MsgInitValues.DS_ZERO_BA16;
     respMsg2Body             = new ResponseM2Body();
     respMsg2Body.gbX         = MsgInitValues.DS_EMPTY_BA32;
     respMsg2Body.gbY         = MsgInitValues.DS_EMPTY_BA32;
     respMsg2Body.spId        = MsgInitValues.DS_ZERO_BA16;
     respMsg2Body.sigLinkType = MsgInitValues.DS_EMPTY_BA2;
     respMsg2Body.kdfId       = MsgInitValues.DS_EMPTY_BA2;
     respMsg2Body.sigSpX      = MsgInitValues.DS_EMPTY_BA32;
     respMsg2Body.sigSpY      = MsgInitValues.DS_EMPTY_BA32;
     respMsg2Body.cmacsmk     = MsgInitValues.DS_ZERO_BA16;
     respMsg2Body.sigrlSize   = MsgInitValues.DS_EMPTY_BA4;
     respMsg2Body.sigRl       = null;
 }