Example #1
0
        /// <summary>
        /// 医嘱P1签名
        /// </summary>
        /// <param name="strContent"></param>
        /// <param name="strCerId"></param>
        /// <param name="strmsg"></param>
        /// <returns></returns>
        public bool SignOrderItemP1(string strContent, string strCerId, string strpwd, out string strmsg)
        {
            strmsg = "";
            if (!InitCa(out strmsg))
            {
                return(false);
            }
            InitCaConnection(out strmsg);
            if (!"".Equals(strmsg))
            {
                return(false);
            }
            //核对用户工号
            _userId = GetCertInfoByOId(certBase64, "2.4.16.11.7.3");
            if (!_userId.Equals(strCerId.ToString()))
            {
                strmsg = "系统用户ID与CA的keyID不一致!";
                return(false);
            }
            int usbLogin = medicalTK.SOF_Login(cerlst[0], strpwd);

            if (usbLogin != 0)
            {
                strmsg = "密码错误:" + medicalTK.GetLastError();
                return(false);
            }


            #region 签名值
            string encryptData = medicalTK.SOF_SignData(cerlst[0], strContent);
            if ("".Equals(encryptData))
            {
                strmsg = "P1签名错误码:" + medicalTK.GetLastError();
                return(false);
            }
            #endregion

            #region 验证签名
            int iRet = vstkClientPro.SOF_VerifySignedData(certBase64, strContent, encryptData);
            if (iRet != 0)
            {
                strmsg = "P1验签失败,错误码:" + vstkClientPro.SOF_GetLastError().ToString();
                return(false);
            }
            #endregion

            return(true);
        }
Example #2
0
 /// <summary>
 /// P1签名
 /// </summary>
 /// <param name="certId">证书标识</param>
 /// <param name="flatData">原文</param>
 /// <returns>P1签名值</returns>
 public string P1Sign(string certId, string flatData)
 {
     return(medicalTK.SOF_SignData(certId, flatData));
 }