internal unsafe RecipientInfoCollection(System.Security.Cryptography.SafeCryptMsgHandle safeCryptMsgHandle) { bool flag = PkcsUtils.CmsSupported(); uint num = 0; uint num2 = (uint)Marshal.SizeOf(typeof(uint)); if (flag) { if (!System.Security.Cryptography.CAPI.CAPISafe.CryptMsgGetParam(safeCryptMsgHandle, 0x21, 0, new IntPtr((void *)&num), new IntPtr((void *)&num2))) { throw new CryptographicException(Marshal.GetLastWin32Error()); } } else if (!System.Security.Cryptography.CAPI.CAPISafe.CryptMsgGetParam(safeCryptMsgHandle, 0x11, 0, new IntPtr((void *)&num), new IntPtr((void *)&num2))) { throw new CryptographicException(Marshal.GetLastWin32Error()); } this.m_recipientInfos = new ArrayList(); for (uint i = 0; i < num; i++) { uint num4; System.Security.Cryptography.SafeLocalAllocHandle handle; System.Security.Cryptography.CAPI.CMSG_KEY_AGREE_PUBLIC_KEY_RECIPIENT_INFO cmsg_key_agree_public_key_recipient_info; uint num7; System.Security.Cryptography.SafeLocalAllocHandle handle2; if (!flag) { goto Label_020B; } PkcsUtils.GetParam(safeCryptMsgHandle, 0x24, i, out handle, out num4); System.Security.Cryptography.CAPI.CMSG_CMS_RECIPIENT_INFO cmsg_cms_recipient_info = (System.Security.Cryptography.CAPI.CMSG_CMS_RECIPIENT_INFO)Marshal.PtrToStructure(handle.DangerousGetHandle(), typeof(System.Security.Cryptography.CAPI.CMSG_CMS_RECIPIENT_INFO)); switch (cmsg_cms_recipient_info.dwRecipientChoice) { case 1: { System.Security.Cryptography.CAPI.CMSG_KEY_TRANS_RECIPIENT_INFO keyTrans = (System.Security.Cryptography.CAPI.CMSG_KEY_TRANS_RECIPIENT_INFO)Marshal.PtrToStructure(cmsg_cms_recipient_info.pRecipientInfo, typeof(System.Security.Cryptography.CAPI.CMSG_KEY_TRANS_RECIPIENT_INFO)); this.m_recipientInfos.Add(new KeyTransRecipientInfo(handle, keyTrans, i)); continue; } case 2: { System.Security.Cryptography.CAPI.CMSG_KEY_AGREE_RECIPIENT_INFO cmsg_key_agree_recipient_info = (System.Security.Cryptography.CAPI.CMSG_KEY_AGREE_RECIPIENT_INFO)Marshal.PtrToStructure(cmsg_cms_recipient_info.pRecipientInfo, typeof(System.Security.Cryptography.CAPI.CMSG_KEY_AGREE_RECIPIENT_INFO)); switch (cmsg_key_agree_recipient_info.dwOriginatorChoice) { case 2: goto Label_0192; } throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Cms_Invalid_Originator_Identifier_Choice"), cmsg_key_agree_recipient_info.dwOriginatorChoice.ToString(CultureInfo.CurrentCulture)); } default: throw new CryptographicException(-2147483647); } System.Security.Cryptography.CAPI.CMSG_KEY_AGREE_CERT_ID_RECIPIENT_INFO certIdRecipient = (System.Security.Cryptography.CAPI.CMSG_KEY_AGREE_CERT_ID_RECIPIENT_INFO)Marshal.PtrToStructure(cmsg_cms_recipient_info.pRecipientInfo, typeof(System.Security.Cryptography.CAPI.CMSG_KEY_AGREE_CERT_ID_RECIPIENT_INFO)); for (uint j = 0; j < certIdRecipient.cRecipientEncryptedKeys; j++) { this.m_recipientInfos.Add(new KeyAgreeRecipientInfo(handle, certIdRecipient, i, j)); } continue; Label_0192: cmsg_key_agree_public_key_recipient_info = (System.Security.Cryptography.CAPI.CMSG_KEY_AGREE_PUBLIC_KEY_RECIPIENT_INFO)Marshal.PtrToStructure(cmsg_cms_recipient_info.pRecipientInfo, typeof(System.Security.Cryptography.CAPI.CMSG_KEY_AGREE_PUBLIC_KEY_RECIPIENT_INFO)); for (uint k = 0; k < cmsg_key_agree_public_key_recipient_info.cRecipientEncryptedKeys; k++) { this.m_recipientInfos.Add(new KeyAgreeRecipientInfo(handle, cmsg_key_agree_public_key_recipient_info, i, k)); } continue; Label_020B: PkcsUtils.GetParam(safeCryptMsgHandle, 0x13, i, out handle2, out num7); System.Security.Cryptography.CAPI.CERT_INFO certInfo = (System.Security.Cryptography.CAPI.CERT_INFO)Marshal.PtrToStructure(handle2.DangerousGetHandle(), typeof(System.Security.Cryptography.CAPI.CERT_INFO)); this.m_recipientInfos.Add(new KeyTransRecipientInfo(handle2, certInfo, i)); } this.m_safeCryptMsgHandle = safeCryptMsgHandle; }
internal KeyTransRecipientInfo(System.Security.Cryptography.SafeLocalAllocHandle pRecipientInfo, System.Security.Cryptography.CAPI.CMSG_KEY_TRANS_RECIPIENT_INFO keyTrans, uint index) : base(RecipientInfoType.KeyTransport, RecipientSubType.CmsKeyTransport, pRecipientInfo, keyTrans, index) { this.Reset((int)keyTrans.dwVersion); }