On Mon, Jul 26, 2010 at 6:07 AM, Hanno Böck <ha...@hboeck.de> wrote:
>
> The code looks like this:
>
>
> SEC_ASN1_MKSUB(SECOID_AlgorithmIDTemplate)
>
> const SEC_ASN1Template MY_RSAPSSParamsTemplate[] =
> {
>    { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(SECKEYRSAPSSParams) },
>    { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | SEC_ASN1_EXPLICIT |
>          SEC_ASN1_XTRN | SEC_ASN1_POINTER | SEC_ASN1_CONTEXT_SPECIFIC | 0,
>          offsetof(SECKEYRSAPSSParams, hashAlg),
>          SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate) },
>    { 0 }
> };
>
> SECStatus
> PSSU_EncodeDER(SECItem *dest, CK_RSA_PKCS_PSS_PARAMS *in)
> {
>    SECKEYRSAPSSParams *pss_params;
>    PRArenaPool *arena;
>    SECItem *ret;
>    unsigned int i;
>
>    arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
>    pss_params = PORT_ZAlloc(sizeof(pss_params));
>    pss_params->hashAlg = PORT_ZAlloc(sizeof(SECAlgorithmID));
>
>    SECOID_SetAlgorithmID(arena, pss_params->hashAlg, SEC_OID_SHA256, NULL);
>
>    ret = SEC_ASN1EncodeItem(arena, NULL, pss_params,
> MY_RSAPSSParamsTemplate);
>
>    PORT_FreeArena(arena, PR_FALSE);
>    return SECSuccess;
> }

I checked your code again and still didn't see anything wrong.
So you need to find out in a debugger why, when the assertion
at secasn1u.c:93 fails, theTemplate->sub is NULL.  In
particular, which element in the MY_RSAPSSParamsTemplate
array is theTemplate pointing to, and why is theTemplate->sub
not SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate).

Wan-Teh
-- 
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to