[libav-devel] [PATCH] use bcrypt instead of the old wincrypt API

Martin Storsjö martin at martin.st
Fri Mar 30 21:07:55 CEST 2018


On Fri, 30 Mar 2018, James Almer wrote:

> On 3/30/2018 3:13 PM, Martin Storsjö wrote:
>> On Fri, 30 Mar 2018, James Almer wrote:
>> 
>>> On 3/30/2018 10:57 AM, Martin Storsjö wrote:
>>>> On Fri, 30 Mar 2018, Diego Biurrun wrote:
>>>>
>>>>> On Fri, Mar 30, 2018 at 10:43:27AM -0300, James Almer wrote:
>>>>>> On 3/30/2018 10:38 AM, Diego Biurrun wrote:
>>>>>> > On Fri, Mar 30, 2018 at 12:38:05PM +0200, Steve Lhomme wrote:
>>>>>> >> Le 30/03/2018 à 10:46, Diego Biurrun a écrit :
>>>>>> >>> On Fri, Mar 30, 2018 at 09:36:05AM +0200, Steve Lhomme wrote:
>>>>>> >>>> --- a/configure
>>>>>> >>>> +++ b/configure
>>>>>> >>>> @@ -4581,6 +4582,7 @@ check_lib ole32    "windows.h"           
>>>>>> CoTaskMemFree        -lole32
>>>>>> >>>>   check_lib shell32  "windows.h shellapi.h" CommandLineToArgvW  
>>>>>> -lshell32
>>>>>> >>>>   check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom      
>>>>>> -ladvapi32
>>>>>> >>>>   check_lib psapi    "windows.h psapi.h"    GetProcessMemoryInfo
>>>>>> -lpsapi
>>>>>> >>>> +check_cpp_condition Vista+ windows.h "_WIN32_WINNT >= 0x0600"
>>>>>> && check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom  -lbcrypt
>>>>>>
>>>>>> If you don't need to set any variable then just use
>>>>>> test_cpp_condition()
>>>>>
>>>>> Yes, good point.
>>>>>
>>>>>> >>> Do you really need to check the Vista condition? What about using
>>>>>> bcrypt
>>>>>> >>> unconditionally if available?
>>>>>> >>
>>>>>> >> Yes, you need to use it only on builds that won't run on XP.
>>>>>> Otherwise it
>>>>>> >> will fail to load the bcrypt.dll and the whole libavutil DLL (or
>>>>>> whatever
>>>>>> >> its form) will fail to load. It would be possible to do it
>>>>>> dynamically but
>>>>>> >> IMO it's overkill. It's not really a critical component.
>>>>>> > > Is bcrypt available on XP? If no then the CPP condition check
>>>>>> would seem
>>>>>> > unnecessary. You could just check for bcrypt and bcrypt being
>>>>>> available
>>>>>> > would imply Vista. I think I'm missing something.
>>>>>>
>>>>>> check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom  -lbcrypt
>>>>>>
>>>>>> Seems to succeed even if targeting XP, at least on mingw-w64.
>>>>>
>>>>> Isn't that wrong then?
>>>>
>>>> I guess it just means that mingw-w64 doesn't have _WIN32_WINNT ifdefs
>>>> guarding the availability of this function in the headers. (The official
>>>> windows SDK might, although that SDK also have dropped XP support long
>>>> ago iirc.)
>>>
>>> bcrypt.h on mingw-w64 is completely wrapped in checks like
>>>
>>> #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) || _WIN32_WINNT
>>>> = 0x0A00
>>>
>>> The former is the reason it succeeds in XP, seeing the latter is
>>> checking for Windows 10 or newer.
>> 
>> Hmm, ok. I guess the correct form would be something like
>> "(WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) && _WIN32_WINNT >=
>> 0x0600) || _WIN32_WINNT >= 0x0A00" then.
>> 
>> // Martin
>
> The WINAPI_PARTITION_DESKTOP check is already done in configure to
> enable or disable the uwp variable.

Not sure I see how that relates... that part of the header guard makes it 
visible on and makes the check succeed when targeting XP, even though it 
really isn't available there according to Steve.

> In any case, does this mean that on uwp neither BCryptGenRandom or
> CryptGenRandom are available/allowed?

The way I read that, for UWP on Win10, the bcrypt.h stuff should be fine, 
no? (Based on the mingw-w64 header guards, it might not be for win8/8.1 
RT/store/UWP/whatever apps, although MSDN doesn't seem to say anything 
about it.)

// Martin


More information about the libav-devel mailing list