Patrick wrote:
>
> This is to follow up on a previous posting where:
[snip]
> Nelson Bolyard responded saying that instead of doing:
[snip]
> I should do:
>
> SEC_ASN1_MKSUB(SECOID_AlgorithmIDTemplate)
> static SEC_ASN1Template template[] = {
> { SEC_ASN1_SEQUENCE, 0, NULL, sizeof (SDRResult) },
> { SEC_ASN1_OCTET_STRING, offsetof(SDRResult, keyid) },
> { SEC_ASN1_INLINE | SEC_ASN1_XTRN, offsetof(SDRResult, alg),
> SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
> //{ SEC_ASN1_INLINE, offsetof(SDRResult, alg),
> SECOID_AlgorithmIDTemplate },
> { SEC_ASN1_OCTET_STRING, offsetof(SDRResult, data) },
> { 0 }
> };
IIRC, I said there were two choices including (a) replicating the constant
template in your own code (with a different name), or (b) the indirect
data reference approach described above. Method a is easier, but I did
write at length about method b (because it's so much more complicated).
It may not have been obvious that I was trying to recommend method a,
and was using the lengthy details of method b to show why I wasn't
recommending that. Method a was supposed to be a obvious choice.
Perhaps you should give that a try.
> Well I still had problems after the change...
What problems were you having?
> Anyway, my new question now is:
> why doesn't the pk11wrap/pk11sdr.c code itself not use the second method?
Because it's in the same DLL as the template it's referencing.
> It looks like it refers to the SECOID_AlgorithmIDTemplate directly...
Correct. It works because the array in pk11wrap/pk11sdr.c and the
SECOID_AlgorithmIDTemplate are both part of the same DLL, nss3.dll.
If they were not part of the same DLL (or same .exe) it would not work.
Was your recent inquiry about building with static libs related to this
issue?
The "direct method" will not work on Win32 unless the code referring to
the template is in the same DLL (or same .exe) as the template itself.
In your case, you're trying to access a template in nss3.dll. You can't
do that on Win32 with the direct method since your code isn't part of
that dll. Static libs won't help that problem.
--
Nelson Bolyard
Disclaimer: I speak for myself, not for Netscape