Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GSoC
GSoC2018
macOS
vlc
Commits
86de045d
Commit
86de045d
authored
Jul 23, 2013
by
Rafaël Carré
Browse files
Don't use CryptGenRandom in Windows Store app
parent
c53d5900
Changes
2
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
86de045d
...
...
@@ -475,7 +475,10 @@ AC_ARG_ENABLE(winstore_app,
[Build targetted for Windows Store apps (default disabled)]))
vlc_winstore_app=0
AS_IF([test "${SYS}" = "mingw32" -a "${enable_winstore_app}" = "yes"], [vlc_winstore_app=1])
AS_IF([test "${SYS}" = "mingw32" -a "${enable_winstore_app}" = "yes"], [
vlc_winstore_app=1
VLC_ADD_LIBS([libvlccore], [-lole32 -lruntimeobject])
])
AC_DEFINE_UNQUOTED(VLC_WINSTORE_APP, ${vlc_winstore_app}, [Define to 1 if you want to build for Windows Store apps])
...
...
src/win32/rand.c
View file @
86de045d
...
...
@@ -26,11 +26,18 @@
#include
<vlc_common.h>
#include
<vlc_rand.h>
#include
<wincrypt.h>
#if VLC_WINSTORE_APP
# define COBJMACROS
# define INITGUID
# include <winstring.h>
# include <roapi.h>
# include <windows.security.cryptography.h>
#else
# include <wincrypt.h>
#endif
void
vlc_rand_bytes
(
void
*
buf
,
size_t
len
)
{
HCRYPTPROV
hProv
;
size_t
count
=
len
;
uint8_t
*
p_buf
=
(
uint8_t
*
)
buf
;
...
...
@@ -50,6 +57,35 @@ void vlc_rand_bytes (void *buf, size_t len)
p_buf
+=
sizeof
(
val
);
}
#if VLC_WINSTORE_APP
static
const
WCHAR
*
className
=
L"Windows.Security.Cryptography.CryptographicBuffer"
;
const
UINT32
clen
=
wcslen
(
className
);
HSTRING
hClassName
=
NULL
;
HSTRING_HEADER
header
;
HRESULT
hr
=
WindowsCreateStringReference
(
className
,
clen
,
&
header
,
&
hClassName
);
if
(
hr
)
{
WindowsDeleteString
(
hClassName
);
return
;
}
ICryptographicBufferStatics
*
cryptoStatics
=
NULL
;
hr
=
RoGetActivationFactory
(
hClassName
,
&
IID_ICryptographicBufferStatics
,
(
void
**
)
&
cryptoStatics
);
WindowsDeleteString
(
hClassName
);
if
(
hr
)
return
;
IBuffer
*
buffer
=
NULL
;
hr
=
ICryptographicBufferStatics_GenerateRandom
(
cryptoStatics
,
len
,
&
buffer
);
if
(
hr
)
return
;
UINT32
olength
;
unsigned
char
*
rnd
=
NULL
;
hr
=
ICryptographicBufferStatics_CopyToByteArray
(
cryptoStatics
,
buffer
,
&
olength
,
(
BYTE
**
)
&
rnd
);
memcpy
(
buf
,
rnd
,
len
);
#else
HCRYPTPROV
hProv
;
/* acquire default encryption context */
if
(
CryptAcquireContext
(
&
hProv
,
// Variable to hold returned handle.
...
...
@@ -63,4 +99,5 @@ void vlc_rand_bytes (void *buf, size_t len)
CryptGenRandom
(
hProv
,
len
,
buf
);
CryptReleaseContext
(
hProv
,
0
);
}
#endif
/* VLC_WINSTORE_APP */
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment