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

"SourceForge.net" <[email protected]> Fri, 27 Jun 2008 05:44:58 +0000
Newsgroups gmane.comp.python.cryptography.cvs
Message-ID <[email protected]>
Bugs item #1343753, was opened at 2005-10-31 23:34
Message generated for change (Comment added) made by mhammond
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
Private: No
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 ...
        }
    }
}



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

Comment By: Mark Hammond (mhammond)
Date: 2008-06-27 15:44

Message:
Logged In: YES 
user_id=14198
Originator: NO

I've uploaded a patch at
http://sourceforge.net/tracker/index.php?func=detail&aid=2003762&group_id=20937&atid=320937

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

Comment By: A.M. Kuchling (akuchling)
Date: 2005-11-30 06:51

Message:
Logged In: YES 
user_id=11375

Please provide a patch; I can't figure out what fix you're
actually suggesting.


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

Comment By: Nobody/Anonymous (nobody)
Date: 2005-11-03 23:09

Message:
Logged In: NO 

I had the exact same problem, and the exact same fix solved
it...

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

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

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php