public byte[] GetEncodedRecipient(int index) { //Certificate certificate = recipient.GetX509(); PdfPublicKeyRecipient recipient = (PdfPublicKeyRecipient)recipients[index]; byte[] cms = recipient.Cms; if (cms != null) { return(cms); } X509Certificate certificate = recipient.Certificate; int permission = recipient.Permission;//PdfWriter.AllowCopy | PdfWriter.AllowPrinting | PdfWriter.AllowScreenReaders | PdfWriter.AllowAssembly; int revision = 3; permission |= (int)(revision == 3 ? (uint)0xfffff0c0 : (uint)0xffffffc0); permission &= unchecked ((int)0xfffffffc); permission += 1; byte[] pkcs7input = new byte[24]; byte one = (byte)(permission); byte two = (byte)(permission >> 8); byte three = (byte)(permission >> 16); byte four = (byte)(permission >> 24); Array.Copy(seed, 0, pkcs7input, 0, 20); // put this seed in the pkcs7 input pkcs7input[20] = four; pkcs7input[21] = three; pkcs7input[22] = two; pkcs7input[23] = one; Asn1Object obj = CreateDERForRecipient(pkcs7input, certificate); MemoryStream baos = new MemoryStream(); DerOutputStream k = new DerOutputStream(baos); k.WriteObject(obj); cms = baos.ToArray(); recipient.Cms = cms; return(cms); }
public void AddRecipient(PdfPublicKeyRecipient recipient) { recipients.Add(recipient); }