Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
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
jarl
tor
Commits
0a6997d7
Commit
0a6997d7
authored
9 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Preserve errno when loading encrypted ed25519 keys.
parent
b566cb9e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/or/routerkeys.c
+6
-0
6 additions, 0 deletions
src/or/routerkeys.c
with
6 additions
and
0 deletions
src/or/routerkeys.c
+
6
−
0
View file @
0a6997d7
...
...
@@ -21,6 +21,7 @@ read_encrypted_secret_key(ed25519_secret_key_t *out,
char
pwbuf
[
256
];
uint8_t
encrypted_key
[
256
];
char
*
tag
=
NULL
;
int
saved_errno
=
0
;
ssize_t
encrypted_len
=
crypto_read_tagged_contents_from_file
(
fname
,
ENC_KEY_HEADER
,
...
...
@@ -28,6 +29,7 @@ read_encrypted_secret_key(ed25519_secret_key_t *out,
encrypted_key
,
sizeof
(
encrypted_key
));
if
(
encrypted_len
<
0
)
{
saved_errno
=
errno
;
log_info
(
LD_OR
,
"%s is missing"
,
fname
);
r
=
0
;
goto
done
;
...
...
@@ -46,6 +48,7 @@ read_encrypted_secret_key(ed25519_secret_key_t *out,
pwbuf
,
pwlen
);
if
(
r
==
UNPWBOX_CORRUPTED
)
{
log_err
(
LD_OR
,
"%s is corrupted."
,
fname
);
saved_errno
=
EINVAL
;
goto
done
;
}
else
if
(
r
==
UNPWBOX_OKAY
)
{
break
;
...
...
@@ -57,6 +60,7 @@ read_encrypted_secret_key(ed25519_secret_key_t *out,
if
(
secret_len
!=
ED25519_SECKEY_LEN
)
{
log_err
(
LD_OR
,
"%s is corrupted."
,
fname
);
saved_errno
=
EINVAL
;
goto
done
;
}
memcpy
(
out
->
seckey
,
secret
,
ED25519_SECKEY_LEN
);
...
...
@@ -70,6 +74,8 @@ read_encrypted_secret_key(ed25519_secret_key_t *out,
memwipe
(
secret
,
0
,
secret_len
);
tor_free
(
secret
);
}
if
(
saved_errno
)
errno
=
saved_errno
;
return
r
;
}
...
...
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