Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orbea
Tor
Commits
c3ad2a1d
Commit
c3ad2a1d
authored
4 years ago
by
Alexander Hansen Færøy
Browse files
Options
Downloads
Plain Diff
Merge branch 'tor-github/pr/1785' into maint-0.3.5
parents
bebdd288
5721ec22
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changes/bug33032
+6
-0
6 additions, 0 deletions
changes/bug33032
src/lib/encoding/pem.c
+7
-1
7 additions, 1 deletion
src/lib/encoding/pem.c
src/test/test_pem.c
+30
-0
30 additions, 0 deletions
src/test/test_pem.c
with
43 additions
and
1 deletion
changes/bug33032
0 → 100644
+
6
−
0
View file @
c3ad2a1d
o Minor bugfixes (key portability):
- When reading PEM-encoded key data, tolerate CRLF line-endings even if
we are not running on Windows. Previously, non-Windows hosts
would reject these line-endings in certain positions, making
certain key files hard to move from one host to another.
Fixes bug 33032; bugfix on 0.3.5.1-alpha.
This diff is collapsed.
Click to expand it.
src/lib/encoding/pem.c
+
7
−
1
View file @
c3ad2a1d
...
...
@@ -85,13 +85,19 @@ pem_decode(uint8_t *dest, size_t destlen, const char *src, size_t srclen,
src
=
eat_whitespace_eos
(
src
,
eos
);
char
*
tag
=
NULL
;
tor_asprintf
(
&
tag
,
"-----BEGIN %s-----
\n
"
,
objtype
);
tor_asprintf
(
&
tag
,
"-----BEGIN %s-----"
,
objtype
);
if
((
size_t
)(
eos
-
src
)
<
strlen
(
tag
)
||
fast_memneq
(
src
,
tag
,
strlen
(
tag
)))
{
tor_free
(
tag
);
return
-
1
;
}
src
+=
strlen
(
tag
);
tor_free
(
tag
);
/* At this point we insist on spaces (including CR), then an LF. */
src
=
eat_whitespace_eos_no_nl
(
src
,
eos
);
if
(
src
==
eos
||
*
src
!=
'\n'
)
{
/* Extra junk at end of line: this isn't valid. */
return
-
1
;
}
// NOTE lack of trailing \n. We do not enforce its presence.
tor_asprintf
(
&
tag
,
"
\n
-----END %s-----"
,
objtype
);
...
...
This diff is collapsed.
Click to expand it.
src/test/test_pem.c
+
30
−
0
View file @
c3ad2a1d
...
...
@@ -115,8 +115,38 @@ test_crypto_pem_decode(void *arg)
;
}
static
void
test_crypto_pem_decode_crlf
(
void
*
arg
)
{
(
void
)
arg
;
char
crlf_version
[
4096
];
uint8_t
buf
[
4096
];
/* Convert 'expected' to a version with CRLF instead of LF. */
const
char
*
inp
=
expected
;
char
*
outp
=
crlf_version
;
while
(
*
inp
)
{
if
(
*
inp
==
'\n'
)
{
*
outp
++
=
'\r'
;
}
*
outp
++
=
*
inp
++
;
}
*
outp
=
0
;
/* Decoding should succeed (or else we have bug 33032 again) */
int
n
=
pem_decode
(
buf
,
sizeof
(
buf
),
crlf_version
,
strlen
(
crlf_version
),
"WOMBAT QUOTE"
);
tt_int_op
(
n
,
OP_EQ
,
strlen
(
example_pre
));
tt_mem_op
(
buf
,
OP_EQ
,
example_pre
,
n
);
done:
;
}
struct
testcase_t
pem_tests
[]
=
{
{
"encode"
,
test_crypto_pem_encode
,
0
,
NULL
,
NULL
},
{
"decode"
,
test_crypto_pem_decode
,
0
,
NULL
,
NULL
},
{
"decode_crlf"
,
test_crypto_pem_decode_crlf
,
0
,
NULL
,
NULL
},
END_OF_TESTCASES
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment