Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
86de045d
Commit
86de045d
authored
Jul 23, 2013
by
Rafaël Carré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use CryptGenRandom in Windows Store app
parent
c53d5900
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
3 deletions
+43
-3
configure.ac
configure.ac
+4
-1
src/win32/rand.c
src/win32/rand.c
+39
-2
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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