One more thing... by analyzing the code below (method
MyCertificateImport() in the example), I imagine that, if the size of
the original byte[] (byteCert) was odd, then we´ll have *three* extra
null bytes passed to the constructor of IntPrt.
If the last two would indicate an "end of string", then what happens to
the third ? If I were to employ the same tecnhique to signing
odd-length binary files, would other implementations still be able to
verify the signatures against the original files ?
Thank you !
(...)
byte[] bstr = new byte[((byteCert.Length + 1) & 0xfffe) + 6];
#if DEBUG
// Output debug info.
Console.WriteLine("BSTR Length = {0}", bstr.Length);
#endif
// We can only do this in unsafe mode.
unsafe
{
fixed(byte * pbstr = bstr)
{
int * pInt = (int *) pbstr;
// Set the BSTR length.
*pInt = byteCert.Length;
// Copy the BSTR content.
Buffer.BlockCopy(byteCert, 0, bstr, 4, byteCert.Length);
// Point pass the length.
fixed(byte * bstrPtr = &bstr[4])
{
certificate.Import(new IntPrt(bstrPtr));
}
(...)
smveloso@gmail.com - 29 Jun 2005 22:17 GMT
Hi,
I think I have solved the problem for Delphi/Win32...
By editing the "type library import" file and changing the declared
type of SignedData.Content to "string" (it was "widestring", which
happens to represent a string as UTF-16 little endian).
I don´t know if the solution is a good one (and I will still work on
it, perhaps I do not have to use a "string" after all, which seems
expensive); however, should anyone find it may be useful, I can post it
here.
Thank you !