[ pycrypto-Bugs-1343753 ] winrand.c in CryptAcquireContext raises NTE_BAD_KEYSET

"SourceForge.net" <[email protected]> Mon, 31 Oct 2005 04:34:31 -0800
Newsgroups gmane.comp.python.cryptography.cvs
Message-ID <[email protected]>
Bugs item #1343753, was opened at 2005-10-31 04:34
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=120937&aid=1343753&group_id=20937

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: winrand.c in CryptAcquireContext raises NTE_BAD_KEYSET

Initial Comment:
pycrypto acquires context of container that is unique
to each user, but inproperly handles error when
required key set isn't aviable.

Better way (recomended in MSDN):

if (!CryptAcquireContext(&hProv,
                         "Container",
                         NULL,
                         PROV_RSA_FULL,
                         0))
{
    if (GetLastError() == NTE_BAD_KEYSET)
    {
        if (!CryptAcquireContext(&hProv,
                                 "Container",
                                 NULL,
                                 PROV_RSA_FULL,
                                 CRYPT_NEWKEYSET))
        {
            // Error ...
        }
    }
}



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=120937&aid=1343753&group_id=20937


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information