Emil Assarsson wrote:

I have a problem with some allocation errors in SEC_PKCS12AddCertAndKey().
> I have the same error if I use SEC_PKCS12CreatePasswordPrivSafe().
I get a return value != SECSuccess and the PR_GetError() is returning a
> -8173 (SEC_ERROR_NO_MEMORY).

and

I've traced it down to "secport.c" line 550 in function PORT_UCS2_ASCIIConversion

if(!ucs2AsciiConvertFunc) {
    return PR_FALSE;
}

What is this? and why? I just wanted to create a pkcs12 but got sneard by som ascii convertion code. And in the end I got a Memory error... :-(

NSS's pkcs12 library requires any application that uses it to define certain callback functions, and register them with the library.

In this case, the application needs to call
PORT_SetUCS2_ASCIIConversionFunction() with the address of the
application's conversion function, before calling the functions that
need the conversion.

mozilla sets these callback functions.  NSS also has a pkcs12 utilitiy
program that does this.  I wonder if perhaps that program will do what
you need, and save you the effort of writing your own (?).  In any case
the source to that utility program is instructive in how to set up the
callbacks, and provides sample callback functions.

Here is some helpful information for figuring out answers to questions
like the ones you asked.

1. If you go to http://lxr.mozilla.org/mozilla/ and type the identifier
ucs2AsciiConvertFunc into the box labelled "Identifier Search" and click
the "Find" button, it will take you to a page that shows you all about
that identifier.  That page will have links to the declaration,
definition, and all uses in mozilla, and the source to which it links
will also have links to the information for all the identifiers in them.

2. The NSS utility programs exist for (at least) 3 purposes:
a) to use the NSS libraries to perform common tasks,
b) to test the NSS library functions (e.g. for QA), and
c) to act as examples of how to use many of the functions.

I recommend that you examine the source to the pkcs12 utility, which
may be seen at http://lxr.mozilla.org/mozilla/source/security/nss/cmd/pk12util/pk12util.c
for more info on how to use the PKCS12 library functions.


What is needed to make SEC_PKCS12CreatePasswordPrivSafe() work?

I suggest you look at the code that leads to this line of source: http://lxr.mozilla.org/mozilla/source/security/nss/cmd/pk12util/pk12util.c#633

Regards
Emil Assarsson



Regards,

Nelson B
12345678901234567890123456789012345678901234567890123456789012345678901234567890
00000000011111111112222222222333333333344444444445555555555666666666677777777778

_______________________________________________
mozilla-crypto mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-crypto

Reply via email to