Pkcs9DocumentName appears to encode as an octet string containing a
_null-terminated_ unicode string.
e.g.
string s = "test.pdf";
DerOctetString octets = new
DerOctetString(Encoding.Unicode.GetBytes(s + "\0"));
Pkcs9DocumentName name = new
Pkcs9DocumentName(octets.GetEncoded());
Console.WriteLine(name.DocumentName);
prints out "test.pdf" correctly for me.
Regards,
Pete Dettman
On 25/04/2013 5:51 PM, Bruno Warmling wrote:
Hi,
I want create one file with extension P7s, who contains inside one
file PDF more some digital signatures, in detached form.
How can I set document name of PDF file?
I am trying using this code(C#):
byte[] textBytes = System.Text.Encoding.Unicode.GetBytes("test.pdf");
DerOctetString berOctetString = new DerOctetString(textBytes);
Org.BouncyCastle.Asn1.Cms.Attribute documentName = new
Org.BouncyCastle.Asn1.Cms.Attribute(dnOid, new BerSet(berOctetString));
This code works, but when i get the encoded data and I tried convert
to SignedCms using this code:
using System.Security.Cryptography;
System.Security.Cryptography.Pkcs.SignedCms signedData = new SignedCms();
signedData.Decode(p7sData);
var rawValue = signedData.SignerInfos()[0].SignedAttributes[0].RawValue;
Pkcs9DocumentName pkcs9DocumentName = new Pkcs9DocumentName(rawValue);
The result of (pkcs9DocumentName.DocumentName):
"test.pdfꮫꮫꮫꮫ"
what is this "ꮫꮫꮫꮫ" in document name? And how to solve this?
I need only "test.pdf", where "test" is a dummy name for my inside PDF.