Wei Shao wrote:
Hi,


if I need to populate a OCTET_STRING for DER encoding, how shall I
prepare the SECItem structure?

I need to call this method,

SECStatus
DER_Encode(PRArenaPool *arena, SECItem *dest, DERTemplate *dtemplate,
void *src)


where src is a pointer to SECItem structure. How shall I prepare the
data?  Do I need to set

item->data[0] == SEC_ASN1_OCTET_STRING Does it get length from item->len ?
The oid data needs to be binary encoded (not a string like 1.2.345.6, but the OID encoding of that string). Set this value as item->data.
The length is in item->len.

This is typically done as follows:

SECITEM oidItem;

oidItem->data = oid_data;
oidItem->len = oid_data_len;
.
.
.

Der_Encode (......., &oidItem).



If you are returning an allocated SECITEM, there are utitilies in NSS (look at secitem.h). That will help you manage your secitems.

bob.

Thanks,
Wei

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

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

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

Reply via email to