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
887178e7
Commit
887178e7
authored
19 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Oops. It looks like there *was* an easy way to make openssl do what we wanted.
svn:r5370
parent
669fdde9
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
+4
-17
4 additions, 17 deletions
src/common/crypto.c
with
4 additions
and
17 deletions
src/common/crypto.c
+
4
−
17
View file @
887178e7
...
...
@@ -1361,6 +1361,8 @@ init_dh_param(void)
dh_param_g
=
g
;
}
#define DH_PRIVATE_KEY_BITS 320
/** Allocate and return a new DH object for a key exchange.
*/
crypto_dh_env_t
*
...
...
@@ -1382,6 +1384,8 @@ crypto_dh_new(void)
if
(
!
(
res
->
dh
->
g
=
BN_dup
(
dh_param_g
)))
goto
err
;
res
->
dh
->
length
=
DH_PRIVATE_KEY_BITS
;
return
res
;
err:
crypto_log_errors
(
LOG_WARN
,
"creating DH object"
);
...
...
@@ -1390,8 +1394,6 @@ crypto_dh_new(void)
return
NULL
;
}
#define DH_PRIVATE_KEY_BITS 320
/** Return the length of the DH key in <b>dh</b>, in bytes.
*/
int
...
...
@@ -1407,22 +1409,7 @@ crypto_dh_get_bytes(crypto_dh_env_t *dh)
int
crypto_dh_generate_public
(
crypto_dh_env_t
*
dh
)
{
int
pk_bits
=
BN_num_bits
(
dh
->
dh
->
p
);
if
(
pk_bits
>
DH_PRIVATE_KEY_BITS
)
pk_bits
=
DH_PRIVATE_KEY_BITS
;
again:
if
(
!
dh
->
dh
->
priv_key
)
{
dh
->
dh
->
priv_key
=
BN_new
();
if
(
!
dh
->
dh
->
priv_key
)
{
err
(
LD_MM
,
"Unable to allocate BN."
);
return
-
1
;
}
}
/* We generate the key ourselves so that we can get a 2-3x speedup by using
* a 320-bit x instead of a 1024-bit x. */
if
(
!
BN_rand
(
dh
->
dh
->
priv_key
,
pk_bits
,
0
,
0
))
{
crypto_log_errors
(
LOG_WARN
,
"Generating DH private key"
);
}
if
(
!
DH_generate_key
(
dh
->
dh
))
{
crypto_log_errors
(
LOG_WARN
,
"generating DH key"
);
return
-
1
;
...
...
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