Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Benjamin J. Thompson
Tor
Commits
7fbf1e22
Commit
7fbf1e22
authored
13 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'asn-mytor/bug4746'
parents
8d74fba6
d05bc021
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/crypto.c
+21
-4
21 additions, 4 deletions
src/common/crypto.c
with
21 additions
and
4 deletions
src/common/crypto.c
+
21
−
4
View file @
7fbf1e22
...
...
@@ -1837,7 +1837,10 @@ crypto_store_dynamic_dh_modulus(const char *fname)
DH
*
dh
=
NULL
;
unsigned
char
*
dh_string_repr
=
NULL
,
*
cp
=
NULL
;
char
*
base64_encoded_dh
=
NULL
;
char
*
file_string
=
NULL
;
int
retval
=
-
1
;
const
static
char
*
file_header
=
"# This file contains stored Diffie-Hellman"
" parameters for future use.
\n
# You *do not* need to edit this file.
\n\n
"
;
tor_assert
(
fname
);
...
...
@@ -1876,7 +1879,11 @@ crypto_store_dynamic_dh_modulus(const char *fname)
goto
done
;
}
if
(
write_bytes_to_new_file
(
fname
,
base64_encoded_dh
,
new_len
,
0
)
<
0
)
{
/* concatenate file header and the dh parameters blob */
tor_asprintf
(
&
file_string
,
"%s%s"
,
file_header
,
base64_encoded_dh
);
/* write to file */
if
(
write_bytes_to_new_file
(
fname
,
file_string
,
strlen
(
file_string
),
0
)
<
0
)
{
log_info
(
LD_CRYPTO
,
"'%s' was already occupied."
,
fname
);
goto
done
;
}
...
...
@@ -1888,6 +1895,7 @@ crypto_store_dynamic_dh_modulus(const char *fname)
DH_free
(
dh
);
tor_free
(
dh_string_repr
);
tor_free
(
base64_encoded_dh
);
tor_free
(
file_string
);
return
retval
;
}
...
...
@@ -1899,6 +1907,7 @@ crypto_get_stored_dynamic_dh_modulus(const char *fname)
{
int
retval
;
char
*
contents
=
NULL
;
const
char
*
contents_tmp
=
NULL
;
int
dh_codes
;
char
*
fname_new
=
NULL
;
DH
*
stored_dh
=
NULL
;
...
...
@@ -1915,15 +1924,23 @@ crypto_get_stored_dynamic_dh_modulus(const char *fname)
goto
done
;
/*usually means that ENOENT. don't try to move file to broken.*/
}
/* skip the file header */
contents_tmp
=
eat_whitespace
(
contents
);
if
(
!*
contents_tmp
)
{
log_warn
(
LD_CRYPTO
,
"Stored dynamic DH modulus file "
"seems corrupted (eat_whitespace)."
);
goto
err
;
}
/* 'fname' contains the DH parameters stored in base64-ed DER
* format. We are only interested in the DH modulus.
* NOTE: We allocate more storage here than we need. Since we're already
* doing that, we can also add 1 byte extra to appease Coverity's
* scanner. */
cp
=
base64_decoded_dh
=
tor_malloc_zero
(
strlen
(
contents
)
+
1
);
length
=
base64_decode
((
char
*
)
base64_decoded_dh
,
strlen
(
contents
),
contents
,
strlen
(
contents
));
cp
=
base64_decoded_dh
=
tor_malloc_zero
(
strlen
(
contents
_tmp
)
+
1
);
length
=
base64_decode
((
char
*
)
base64_decoded_dh
,
strlen
(
contents
_tmp
),
contents
_tmp
,
strlen
(
contents
_tmp
));
if
(
length
<
0
)
{
log_warn
(
LD_CRYPTO
,
"Stored dynamic DH modulus seems corrupted (base64)."
);
goto
err
;
...
...
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