Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
68b0a5ab
Commit
68b0a5ab
authored
Mar 25, 2012
by
KO Myung-Hun
Committed by
Rémi Denis-Courmont
Mar 26, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement vlc_rand_bytes() for OS/2
Signed-off-by:
Rémi Denis-Courmont
<
remi@remlab.net
>
parent
adee869f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
41 deletions
+54
-41
src/misc/rand.c
src/misc/rand.c
+54
-41
No files found.
src/misc/rand.c
View file @
68b0a5ab
...
@@ -26,7 +26,60 @@
...
@@ -26,7 +26,60 @@
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_rand.h>
#include <vlc_rand.h>
#ifndef WIN32
#ifdef __OS2__
void
vlc_rand_bytes
(
void
*
buf
,
size_t
len
)
{
QWORD
qwTime
;
uint8_t
*
p_buf
=
(
uint8_t
*
)
buf
;
while
(
len
>
0
)
{
DosTmrQueryTime
(
&
qwTime
);
*
p_buf
++
=
(
uint8_t
)(
qwTime
.
ulLo
*
rand
());
len
--
;
}
}
#elif defined(WIN32)
#include <wincrypt.h>
void
vlc_rand_bytes
(
void
*
buf
,
size_t
len
)
{
HCRYPTPROV
hProv
;
size_t
count
=
len
;
uint8_t
*
p_buf
=
(
uint8_t
*
)
buf
;
/* fill buffer with pseudo-random data */
while
(
count
>
0
)
{
unsigned
int
val
;
val
=
rand
();
if
(
count
<
sizeof
(
val
))
{
memcpy
(
p_buf
,
&
val
,
count
);
break
;
}
memcpy
(
p_buf
,
&
val
,
sizeof
(
val
));
count
-=
sizeof
(
val
);
p_buf
+=
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.
CRYPT_VERIFYCONTEXT
)
)
// Flag values
{
/* fill buffer with pseudo-random data, intial buffer content
is used as auxillary random seed */
CryptGenRandom
(
hProv
,
len
,
buf
);
CryptReleaseContext
(
hProv
,
0
);
}
}
#else
#include <stdint.h>
#include <stdint.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <stdlib.h>
...
@@ -117,46 +170,6 @@ void vlc_rand_bytes (void *buf, size_t len)
...
@@ -117,46 +170,6 @@ void vlc_rand_bytes (void *buf, size_t len)
}
}
}
}
#else
/* WIN32 */
#include <wincrypt.h>
void
vlc_rand_bytes
(
void
*
buf
,
size_t
len
)
{
HCRYPTPROV
hProv
;
size_t
count
=
len
;
uint8_t
*
p_buf
=
(
uint8_t
*
)
buf
;
/* fill buffer with pseudo-random data */
while
(
count
>
0
)
{
unsigned
int
val
;
val
=
rand
();
if
(
count
<
sizeof
(
val
))
{
memcpy
(
p_buf
,
&
val
,
count
);
break
;
}
memcpy
(
p_buf
,
&
val
,
sizeof
(
val
));
count
-=
sizeof
(
val
);
p_buf
+=
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.
CRYPT_VERIFYCONTEXT
)
)
// Flag values
{
/* fill buffer with pseudo-random data, intial buffer content
is used as auxillary random seed */
CryptGenRandom
(
hProv
,
len
,
buf
);
CryptReleaseContext
(
hProv
,
0
);
}
}
#endif
#endif
static
struct
static
struct
...
...
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