Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
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
savoirfairelinux
opendht
Commits
867bcf15
Commit
867bcf15
authored
8 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
crypto: add EC key generation
parent
fb882ee4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/opendht/crypto.h
+1
-0
1 addition, 0 deletions
include/opendht/crypto.h
src/crypto.cpp
+14
-0
14 additions, 0 deletions
src/crypto.cpp
with
15 additions
and
0 deletions
include/opendht/crypto.h
+
1
−
0
View file @
867bcf15
...
@@ -148,6 +148,7 @@ struct OPENDHT_PUBLIC PrivateKey
...
@@ -148,6 +148,7 @@ struct OPENDHT_PUBLIC PrivateKey
* Recommended values: 4096, 8192
* Recommended values: 4096, 8192
*/
*/
static
PrivateKey
generate
(
unsigned
key_length
=
4096
);
static
PrivateKey
generate
(
unsigned
key_length
=
4096
);
static
PrivateKey
generateEC
();
gnutls_privkey_t
key
{};
gnutls_privkey_t
key
{};
gnutls_x509_privkey_t
x509_key
{};
gnutls_x509_privkey_t
x509_key
{};
...
...
This diff is collapsed.
Click to expand it.
src/crypto.cpp
+
14
−
0
View file @
867bcf15
...
@@ -739,6 +739,20 @@ PrivateKey::generate(unsigned key_length)
...
@@ -739,6 +739,20 @@ PrivateKey::generate(unsigned key_length)
return
PrivateKey
{
key
};
return
PrivateKey
{
key
};
}
}
PrivateKey
PrivateKey
::
generateEC
()
{
gnutls_x509_privkey_t
key
;
if
(
gnutls_x509_privkey_init
(
&
key
)
!=
GNUTLS_E_SUCCESS
)
throw
CryptoException
(
"Can't initialize private key."
);
int
err
=
gnutls_x509_privkey_generate
(
key
,
GNUTLS_PK_EC
,
gnutls_sec_param_to_pk_bits
(
GNUTLS_PK_EC
,
GNUTLS_SEC_PARAM_ULTRA
),
0
);
if
(
err
!=
GNUTLS_E_SUCCESS
)
{
gnutls_x509_privkey_deinit
(
key
);
throw
CryptoException
(
std
::
string
(
"Can't generate EC key pair: "
)
+
gnutls_strerror
(
err
));
}
return
PrivateKey
{
key
};
}
Identity
Identity
generateIdentity
(
const
std
::
string
&
name
,
crypto
::
Identity
ca
,
unsigned
key_length
,
bool
is_ca
)
generateIdentity
(
const
std
::
string
&
name
,
crypto
::
Identity
ca
,
unsigned
key_length
,
bool
is_ca
)
{
{
...
...
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