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
53ef9d24
Commit
53ef9d24
authored
Jun 15, 2011
by
Rafaël Carré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: factorize using macro
also fix a memleak in an error path
parent
515c1d35
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
75 deletions
+26
-75
src/misc/update_crypto.c
src/misc/update_crypto.c
+26
-75
No files found.
src/misc/update_crypto.c
View file @
53ef9d24
...
@@ -73,6 +73,16 @@ static inline int scalar_number( uint8_t *p, int header_len )
...
@@ -73,6 +73,16 @@ static inline int scalar_number( uint8_t *p, int header_len )
/* number of data bytes in a MPI */
/* number of data bytes in a MPI */
#define mpi_len( mpi ) ( ( scalar_number( mpi, 2 ) + 7 ) / 8 )
#define mpi_len( mpi ) ( ( scalar_number( mpi, 2 ) + 7 ) / 8 )
#define READ_MPI(n, bits) do { \
if( i_read + 2 > i_packet_len ) \
goto error; \
int len = mpi_len( p_buf ); \
if( len > (bits)/8 || i_read + 2 + len > i_packet_len ) \
goto error; \
len += 2; \
memcpy( n, p_buf, len ); \
p_buf += len; i_read += len; \
} while(0)
/*
/*
* fill a public_key_packet_t structure from public key packet data
* fill a public_key_packet_t structure from public key packet data
...
@@ -98,59 +108,18 @@ static int parse_public_key_packet( public_key_packet_t *p_key, uint8_t *p_buf,
...
@@ -98,59 +108,18 @@ static int parse_public_key_packet( public_key_packet_t *p_key, uint8_t *p_buf,
if
(
p_key
->
algo
!=
PUBLIC_KEY_ALGO_DSA
)
if
(
p_key
->
algo
!=
PUBLIC_KEY_ALGO_DSA
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
/* read p */
READ_MPI
(
p_key
->
p
,
1024
);
if
(
i_read
+
2
>
i_packet_len
)
READ_MPI
(
p_key
->
q
,
160
);
return
VLC_EGENERIC
;
READ_MPI
(
p_key
->
g
,
1024
);
READ_MPI
(
p_key
->
y
,
1024
);
int
i_p_len
=
mpi_len
(
p_buf
);
if
(
i_p_len
>
128
||
i_read
+
2
+
i_p_len
>
i_packet_len
)
return
VLC_EGENERIC
;
memcpy
(
p_key
->
p
,
p_buf
,
2
+
i_p_len
);
p_buf
+=
2
+
i_p_len
;
i_read
+=
2
+
i_p_len
;
/* read q */
if
(
i_read
+
2
>
i_packet_len
)
return
VLC_EGENERIC
;
int
i_q_len
=
mpi_len
(
p_buf
);
if
(
i_q_len
>
20
||
i_read
+
2
+
i_q_len
>
i_packet_len
)
return
VLC_EGENERIC
;
memcpy
(
p_key
->
q
,
p_buf
,
2
+
i_q_len
);
p_buf
+=
2
+
i_q_len
;
i_read
+=
2
+
i_q_len
;
/* read g */
if
(
i_read
+
2
>
i_packet_len
)
return
VLC_EGENERIC
;
int
i_g_len
=
mpi_len
(
p_buf
);
if
(
i_g_len
>
128
||
i_read
+
2
+
i_g_len
>
i_packet_len
)
return
VLC_EGENERIC
;
memcpy
(
p_key
->
g
,
p_buf
,
2
+
i_g_len
);
p_buf
+=
2
+
i_g_len
;
i_read
+=
2
+
i_g_len
;
/* read y */
if
(
i_read
+
2
>
i_packet_len
)
return
VLC_EGENERIC
;
int
i_y_len
=
mpi_len
(
p_buf
);
if
(
i_y_len
>
128
||
i_read
+
2
+
i_y_len
>
i_packet_len
)
return
VLC_EGENERIC
;
memcpy
(
p_key
->
y
,
p_buf
,
2
+
i_y_len
);
i_read
+=
2
+
i_y_len
;
if
(
i_read
!=
i_packet_len
)
/* some extra data eh ? */
if
(
i_read
!=
i_packet_len
)
/* some extra data eh ? */
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
error:
return
VLC_EGENERIC
;
}
}
...
@@ -288,9 +257,9 @@ static size_t parse_signature_v4_packet( signature_packet_t *p_sig,
...
@@ -288,9 +257,9 @@ static size_t parse_signature_v4_packet( signature_packet_t *p_sig,
static
int
parse_signature_packet
(
signature_packet_t
*
p_sig
,
static
int
parse_signature_packet
(
signature_packet_t
*
p_sig
,
uint8_t
*
p_buf
,
size_t
i_
sig
_len
)
uint8_t
*
p_buf
,
size_t
i_
packet
_len
)
{
{
if
(
!
i_
sig
_len
)
/* 1st sanity check, we need at least the version */
if
(
!
i_
packet
_len
)
/* 1st sanity check, we need at least the version */
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
p_sig
->
version
=
*
p_buf
++
;
p_sig
->
version
=
*
p_buf
++
;
...
@@ -299,12 +268,12 @@ static int parse_signature_packet( signature_packet_t *p_sig,
...
@@ -299,12 +268,12 @@ static int parse_signature_packet( signature_packet_t *p_sig,
switch
(
p_sig
->
version
)
switch
(
p_sig
->
version
)
{
{
case
3
:
case
3
:
i_read
=
parse_signature_v3_packet
(
p_sig
,
p_buf
,
i_
sig
_len
);
i_read
=
parse_signature_v3_packet
(
p_sig
,
p_buf
,
i_
packet
_len
);
break
;
break
;
case
4
:
case
4
:
p_sig
->
specific
.
v4
.
hashed_data
=
NULL
;
p_sig
->
specific
.
v4
.
hashed_data
=
NULL
;
p_sig
->
specific
.
v4
.
unhashed_data
=
NULL
;
p_sig
->
specific
.
v4
.
unhashed_data
=
NULL
;
i_read
=
parse_signature_v4_packet
(
p_sig
,
p_buf
,
i_
sig
_len
);
i_read
=
parse_signature_v4_packet
(
p_sig
,
p_buf
,
i_
packet
_len
);
break
;
break
;
default:
default:
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
...
@@ -335,30 +304,11 @@ static int parse_signature_packet( signature_packet_t *p_sig,
...
@@ -335,30 +304,11 @@ static int parse_signature_packet( signature_packet_t *p_sig,
p_buf
--
;
/* rewind to the version byte */
p_buf
--
;
/* rewind to the version byte */
p_buf
+=
i_read
;
p_buf
+=
i_read
;
if
(
i_read
+
2
>
i_sig_len
)
READ_MPI
(
p_sig
->
r
,
160
);
goto
error
;
READ_MPI
(
p_sig
->
s
,
160
);
size_t
i_r_len
=
mpi_len
(
p_buf
);
i_read
+=
2
;
if
(
i_read
+
i_r_len
>
i_sig_len
||
i_r_len
>
20
)
goto
error
;
memcpy
(
p_sig
->
r
,
p_buf
,
2
+
i_r_len
);
p_buf
+=
2
+
i_r_len
;
i_read
+=
i_r_len
;
if
(
i_read
+
2
>
i_sig_len
)
goto
error
;
size_t
i_s_len
=
mpi_len
(
p_buf
);
i_read
+=
2
;
if
(
i_read
+
i_s_len
>
i_sig_len
||
i_s_len
>
20
)
goto
error
;
memcpy
(
p_sig
->
s
,
p_buf
,
2
+
i_s_len
);
p_buf
+=
2
+
i_s_len
;
i_read
+=
i_s_len
;
assert
(
i_read
==
i_
sig
_len
);
assert
(
i_read
==
i_
packet
_len
);
if
(
i_read
<
i_
sig
_len
)
/* some extra data, hm ? */
if
(
i_read
<
i_
packet
_len
)
/* some extra data, hm ? */
goto
error
;
goto
error
;
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
...
@@ -834,6 +784,7 @@ uint8_t *hash_sha1_from_public_key( public_key_t *p_pkey )
...
@@ -834,6 +784,7 @@ uint8_t *hash_sha1_from_public_key( public_key_t *p_pkey )
p_hash
[
0
]
!=
p_pkey
->
sig
.
hash_verification
[
0
]
||
p_hash
[
0
]
!=
p_pkey
->
sig
.
hash_verification
[
0
]
||
p_hash
[
1
]
!=
p_pkey
->
sig
.
hash_verification
[
1
]
)
p_hash
[
1
]
!=
p_pkey
->
sig
.
hash_verification
[
1
]
)
{
{
free
(
p_hash
);
return
NULL
;
return
NULL
;
}
}
...
...
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