Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
36c19167
Commit
36c19167
authored
May 12, 2014
by
Rafaël Carré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: support up to 3k DSA keys
parent
5ce0c2c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
35 deletions
+49
-35
src/misc/update.h
src/misc/update.h
+9
-12
src/misc/update_crypto.c
src/misc/update_crypto.c
+40
-23
No files found.
src/misc/update.h
View file @
36c19167
...
...
@@ -48,16 +48,16 @@ enum /* Signature subpacket types */
};
struct
public_key_packet_t
{
/* a public key packet (DSA) is 418 bytes */
{
uint8_t
version
;
/* we use only version 4 */
uint8_t
timestamp
[
4
];
/* creation time of the key */
uint8_t
algo
;
/* we only use DSA */
/* the multi precision integers, with their 2 bytes length header */
uint8_t
p
[
2
+
12
8
];
uint8_t
q
[
2
+
2
0
];
uint8_t
g
[
2
+
12
8
];
uint8_t
y
[
2
+
12
8
];
uint8_t
p
[
2
+
3072
/
8
];
uint8_t
q
[
2
+
2
56
/
8
];
uint8_t
g
[
2
+
3072
/
8
];
uint8_t
y
[
2
+
3072
/
8
];
};
/* used for public key and file signatures */
...
...
@@ -91,14 +91,11 @@ struct signature_packet_t
/* The part below is made of consecutive MPIs, their number and size being
* public-key-algorithm dependent.
*
* Since we use DSA signatures only, there is 2 integers, r & s, made of:
* 2 bytes for the integer length (scalar number)
* 160 bits (20 bytes) for the integer itself
*
* Note: the integers may be less than 160 significant bits
* Since we use DSA signatures only, there is 2 integers, r & s.
* They range from 160 for 1k keys to 256 bits for 3k keys.
*/
uint8_t
r
[
2
+
2
0
];
uint8_t
s
[
2
+
2
0
];
uint8_t
r
[
2
+
2
56
/
8
];
uint8_t
s
[
2
+
2
56
/
8
];
};
typedef
struct
public_key_packet_t
public_key_packet_t
;
...
...
src/misc/update_crypto.c
View file @
36c19167
...
...
@@ -71,18 +71,36 @@ static inline int scalar_number( const uint8_t *p, int header_len )
/* number of data bytes in a MPI */
#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)
static
int
mpi_len
(
const
uint8_t
*
mpi
)
{
return
(
scalar_number
(
mpi
,
2
)
+
7
)
/
8
;
}
static
size_t
read_mpi
(
uint8_t
*
dst
,
const
uint8_t
*
buf
,
size_t
buflen
,
size_t
bits
)
{
if
(
buflen
<
2
)
return
0
;
size_t
n
=
mpi_len
(
buf
);
if
(
n
*
8
>
bits
)
return
0
;
n
+=
2
;
if
(
buflen
<
n
)
return
0
;
memcpy
(
dst
,
buf
,
n
);
return
n
;
}
#define READ_MPI(d, bits) do { \
size_t n = read_mpi(d, p_buf, i_packet_len - i_read, bits); \
if (!n) goto error; \
p_buf += n; \
i_read += n; \
} while(0)
/*
* fill a public_key_packet_t structure from public key packet data
...
...
@@ -91,8 +109,7 @@ static inline int scalar_number( const uint8_t *p, int header_len )
static
int
parse_public_key_packet
(
public_key_packet_t
*
p_key
,
const
uint8_t
*
p_buf
,
size_t
i_packet_len
)
{
if
(
i_packet_len
>
418
||
i_packet_len
<
6
)
if
(
i_packet_len
<
6
)
return
VLC_EGENERIC
;
size_t
i_read
=
0
;
...
...
@@ -108,15 +125,15 @@ static int parse_public_key_packet( public_key_packet_t *p_key,
if
(
p_key
->
algo
!=
GCRY_PK_DSA
)
return
VLC_EGENERIC
;
READ_MPI
(
p_key
->
p
,
1024
);
READ_MPI
(
p_key
->
q
,
160
);
READ_MPI
(
p_key
->
g
,
1024
);
READ_MPI
(
p_key
->
y
,
1024
);
READ_MPI
(
p_key
->
p
,
3072
);
READ_MPI
(
p_key
->
q
,
256
);
READ_MPI
(
p_key
->
g
,
3072
);
READ_MPI
(
p_key
->
y
,
3072
);
if
(
i_read
!=
i_packet_len
)
/* some extra data eh ? */
return
VLC_
EGENERIC
;
if
(
i_read
==
i_packet_len
)
return
VLC_
SUCCESS
;
return
VLC_SUCCESS
;
/* some extra data eh ? */
error:
return
VLC_EGENERIC
;
...
...
@@ -301,8 +318,8 @@ static int parse_signature_packet( signature_packet_t *p_sig,
p_buf
--
;
/* rewind to the version byte */
p_buf
+=
i_read
;
READ_MPI
(
p_sig
->
r
,
160
);
READ_MPI
(
p_sig
->
s
,
160
);
READ_MPI
(
p_sig
->
r
,
256
);
READ_MPI
(
p_sig
->
s
,
256
);
assert
(
i_read
==
i_packet_len
);
if
(
i_read
<
i_packet_len
)
/* some extra data, hm ? */
...
...
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