internal unsafe SignerInfoCollection(SignedCms signedCms)
        {
            uint num  = 0;
            uint num2 = (uint)Marshal.SizeOf(typeof(uint));

            System.Security.Cryptography.SafeCryptMsgHandle cryptMsgHandle = signedCms.GetCryptMsgHandle();
            if (!System.Security.Cryptography.CAPI.CAPISafe.CryptMsgGetParam(cryptMsgHandle, 5, 0, new IntPtr((void *)&num), new IntPtr((void *)&num2)))
            {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }
            SignerInfo[] infoArray = new SignerInfo[num];
            for (int i = 0; i < num; i++)
            {
                uint num4 = 0;
                if (!System.Security.Cryptography.CAPI.CAPISafe.CryptMsgGetParam(cryptMsgHandle, 6, (uint)i, IntPtr.Zero, new IntPtr((void *)&num4)))
                {
                    throw new CryptographicException(Marshal.GetLastWin32Error());
                }
                System.Security.Cryptography.SafeLocalAllocHandle pvData = System.Security.Cryptography.CAPI.LocalAlloc(0, new IntPtr((long)num4));
                if (!System.Security.Cryptography.CAPI.CAPISafe.CryptMsgGetParam(cryptMsgHandle, 6, (uint)i, pvData, new IntPtr((void *)&num4)))
                {
                    throw new CryptographicException(Marshal.GetLastWin32Error());
                }
                infoArray[i] = new SignerInfo(signedCms, pvData);
            }
            this.m_signerInfos = infoArray;
        }
Exemple #2
0
        internal unsafe SignerInfoCollection(SignedCms signedCms)
        {
            uint dwSigners = 0;
            uint cbCount   = (uint)Marshal.SizeOf(typeof(uint));
            SafeCryptMsgHandle safeCryptMsgHandle = signedCms.GetCryptMsgHandle();

            if (!CAPI.CAPISafe.CryptMsgGetParam(safeCryptMsgHandle,
                                                CAPI.CMSG_SIGNER_COUNT_PARAM,
                                                0,
                                                new IntPtr(&dwSigners),
                                                new IntPtr(&cbCount)))
            {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }

            SignerInfo[] signerInfos = new SignerInfo[dwSigners];
            for (int index = 0; index < dwSigners; index++)
            {
                uint cbCmsgSignerInfo = 0;
                if (!CAPI.CAPISafe.CryptMsgGetParam(safeCryptMsgHandle,
                                                    CAPI.CMSG_SIGNER_INFO_PARAM,
                                                    (uint)index,
                                                    IntPtr.Zero,
                                                    new IntPtr(&cbCmsgSignerInfo)))
                {
                    throw new CryptographicException(Marshal.GetLastWin32Error());
                }

                SafeLocalAllocHandle pbCmsgSignerInfo = CAPI.LocalAlloc(CAPI.LMEM_FIXED, new IntPtr(cbCmsgSignerInfo));

                if (!CAPI.CAPISafe.CryptMsgGetParam(safeCryptMsgHandle,
                                                    CAPI.CMSG_SIGNER_INFO_PARAM,
                                                    (uint)index,
                                                    pbCmsgSignerInfo,
                                                    new IntPtr(&cbCmsgSignerInfo)))
                {
                    throw new CryptographicException(Marshal.GetLastWin32Error());
                }

                signerInfos[index] = new SignerInfo(signedCms, pbCmsgSignerInfo);
            }

            m_signerInfos = signerInfos;
        }
Exemple #3
0
        public void RemoveCounterSignature(int index)
        {
            // We only support one level of counter signing.
            if (m_parentSignerInfo != null)
            {
                throw new CryptographicException(CAPI.E_NOTIMPL);
            }

            RemoveCounterSignature(PkcsUtils.GetSignerIndex(m_signedCms.GetCryptMsgHandle(), this, 0), index);

            return;
        }
        internal unsafe SignerInfoCollection (SignedCms signedCms) {
            uint dwSigners = 0;
            uint cbCount = (uint) Marshal.SizeOf(typeof(uint));
            SafeCryptMsgHandle safeCryptMsgHandle = signedCms.GetCryptMsgHandle();

            if (!CAPI.CAPISafe.CryptMsgGetParam(safeCryptMsgHandle,
                                                CAPI.CMSG_SIGNER_COUNT_PARAM,
                                                0,
                                                new IntPtr(&dwSigners),
                                                new IntPtr(&cbCount)))
                throw new CryptographicException(Marshal.GetLastWin32Error());

            SignerInfo[] signerInfos = new SignerInfo[dwSigners];
            for (int index = 0; index < dwSigners; index++) {
                uint cbCmsgSignerInfo = 0;
                if (!CAPI.CAPISafe.CryptMsgGetParam(safeCryptMsgHandle,
                                                    CAPI.CMSG_SIGNER_INFO_PARAM,
                                                    (uint)index,
                                                    IntPtr.Zero,
                                                    new IntPtr(&cbCmsgSignerInfo)))
                    throw new CryptographicException(Marshal.GetLastWin32Error());

                SafeLocalAllocHandle pbCmsgSignerInfo = CAPI.LocalAlloc(CAPI.LMEM_FIXED, new IntPtr(cbCmsgSignerInfo));

                if (!CAPI.CAPISafe.CryptMsgGetParam(safeCryptMsgHandle,
                                                    CAPI.CMSG_SIGNER_INFO_PARAM,
                                                    (uint)index,
                                                    pbCmsgSignerInfo,
                                                    new IntPtr(&cbCmsgSignerInfo)))
                    throw new CryptographicException(Marshal.GetLastWin32Error());

                signerInfos[index] = new SignerInfo(signedCms, pbCmsgSignerInfo);
            }

            m_signerInfos = signerInfos;
        }