Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
8a0b8bd8
Commit
8a0b8bd8
authored
Sep 02, 2007
by
Damien Fouilleul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
misc/rand.c: actually, windows comes with a particularily comprehensive crypto library
parent
71308486
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
16 deletions
+29
-16
src/misc/rand.c
src/misc/rand.c
+29
-16
No files found.
src/misc/rand.c
View file @
8a0b8bd8
...
...
@@ -116,28 +116,41 @@ void vlc_rand_bytes (void *buf, size_t len)
}
#else
/* WIN32 */
#define _CRT_RAND_S
#include <
stdlib
.h>
#include <
wincrypt
.h>
void
vlc_rand_bytes
(
void
*
buf
,
size_t
len
)
{
while
(
len
>
0
)
HCRYPTPROV
hProv
;
size_t
count
=
len
;
/* fill buffer with pseudo-random data */
while
(
count
>
0
)
{
unsigned
int
val
;
#if 0
rand_s (&val);
#else
abort
();
#endif
if
(
len
<
sizeof
(
val
))
{
memcpy
(
buf
,
&
val
,
len
);
break
;
}
val
=
rand
();
if
(
count
<
sizeof
(
val
))
{
memcpy
(
buf
,
&
val
,
count
);
break
;
}
memcpy
(
buf
,
&
val
,
sizeof
(
val
));
count
-=
sizeof
(
val
);
}
memcpy
(
buf
,
&
val
,
sizeof
(
val
));
len
-=
sizeof
(
val
);
/* acquire default encryption context */
if
(
CryptAcquireContext
(
&
hProv
,
// Variable to hold returned handle.
NULL
,
// Use default key container.
MS_DEF_PROV
,
// Use default CSP.
PROV_RSA_FULL
,
// Type of provider to acquire.
0
)
)
{
/* fill buffer with pseudo-random data, intial buffer content
is used as auxillary random seed */
CryptGenRandom
(
hProv
,
len
,
buf
);
CryptReleaseContext
(
hProv
,
0
);
}
}
#endif
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