Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Goulet
Tor
Commits
f160212e
Commit
f160212e
authored
Feb 05, 2020
by
Nick Mathewson
👁
Browse files
When parsing tokens, reject early on spurious keys.
parent
9e1085c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/feature/dirparse/parsecommon.c
View file @
f160212e
...
...
@@ -384,10 +384,16 @@ get_next_token(memarea_t *area,
RET_ERR
(
"Couldn't parse object: missing footer or object much too big."
);
if
(
!
strcmp
(
tok
->
object_type
,
"RSA PUBLIC KEY"
))
{
/* If it's a public key */
if
(
o_syn
!=
NEED_KEY
&&
o_syn
!=
NEED_KEY_1024
&&
o_syn
!=
OBJ_OK
)
{
RET_ERR
(
"Unexpected public key."
);
}
tok
->
key
=
crypto_pk_new
();
if
(
crypto_pk_read_public_key_from_string
(
tok
->
key
,
obstart
,
eol
-
obstart
))
RET_ERR
(
"Couldn't parse public key."
);
}
else
if
(
!
strcmp
(
tok
->
object_type
,
"RSA PRIVATE KEY"
))
{
/* private key */
if
(
o_syn
!=
NEED_SKEY_1024
&&
o_syn
!=
OBJ_OK
)
{
RET_ERR
(
"Unexpected private key."
);
}
tok
->
key
=
crypto_pk_new
();
if
(
crypto_pk_read_private_key1024_from_string
(
tok
->
key
,
obstart
,
eol
-
obstart
))
...
...
Write
Preview
Supports
Markdown
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