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
d958b0ea
Commit
d958b0ea
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
c wrapper: add dht_privatekey_delete, handle import failure
parent
6c96a47f
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
c/opendht.cpp
+9
-1
9 additions, 1 deletion
c/opendht.cpp
c/opendht_c.h
+2
-1
2 additions, 1 deletion
c/opendht_c.h
with
11 additions
and
2 deletions
c/opendht.cpp
+
9
−
1
View file @
d958b0ea
...
@@ -118,13 +118,21 @@ dht_privatekey* dht_privatekey_generate(unsigned key_length_bits) {
...
@@ -118,13 +118,21 @@ dht_privatekey* dht_privatekey_generate(unsigned key_length_bits) {
}
}
dht_privatekey
*
dht_privatekey_import
(
const
uint8_t
*
dat
,
size_t
dat_size
,
const
char
*
password
)
{
dht_privatekey
*
dht_privatekey_import
(
const
uint8_t
*
dat
,
size_t
dat_size
,
const
char
*
password
)
{
try
{
return
reinterpret_cast
<
dht_privatekey
*>
(
new
dht
::
crypto
::
PrivateKey
(
dat
,
dat_size
,
password
));
return
reinterpret_cast
<
dht_privatekey
*>
(
new
dht
::
crypto
::
PrivateKey
(
dat
,
dat_size
,
password
));
}
catch
(
const
dht
::
crypto
::
CryptoException
&
e
)
{
return
nullptr
;
}
}
}
dht_publickey
*
dht_privatekey_get_publickey
(
const
dht_privatekey
*
key
)
{
dht_publickey
*
dht_privatekey_get_publickey
(
const
dht_privatekey
*
key
)
{
return
reinterpret_cast
<
dht_publickey
*>
(
new
dht
::
crypto
::
PublicKey
(
reinterpret_cast
<
const
dht
::
crypto
::
PrivateKey
*>
(
key
)
->
getPublicKey
()));
return
reinterpret_cast
<
dht_publickey
*>
(
new
dht
::
crypto
::
PublicKey
(
reinterpret_cast
<
const
dht
::
crypto
::
PrivateKey
*>
(
key
)
->
getPublicKey
()));
}
}
void
dht_privatekey_delete
(
dht_privatekey
*
pk
)
{
delete
reinterpret_cast
<
dht
::
crypto
::
PrivateKey
*>
(
pk
);
}
// dht::DhtRunner
// dht::DhtRunner
dht_runner
*
dht_runner_new
()
{
dht_runner
*
dht_runner_new
()
{
return
reinterpret_cast
<
dht_runner
*>
(
new
dht
::
DhtRunner
);
return
reinterpret_cast
<
dht_runner
*>
(
new
dht
::
DhtRunner
);
...
...
This diff is collapsed.
Click to expand it.
c/opendht_c.h
+
2
−
1
View file @
d958b0ea
...
@@ -63,6 +63,7 @@ typedef struct dht_privatekey dht_privatekey;
...
@@ -63,6 +63,7 @@ typedef struct dht_privatekey dht_privatekey;
OPENDHT_C_PUBLIC
dht_privatekey
*
dht_privatekey_generate
(
unsigned
key_length_bits
);
OPENDHT_C_PUBLIC
dht_privatekey
*
dht_privatekey_generate
(
unsigned
key_length_bits
);
OPENDHT_C_PUBLIC
dht_privatekey
*
dht_privatekey_import
(
const
uint8_t
*
dat
,
size_t
dat_size
,
const
char
*
password
);
OPENDHT_C_PUBLIC
dht_privatekey
*
dht_privatekey_import
(
const
uint8_t
*
dat
,
size_t
dat_size
,
const
char
*
password
);
OPENDHT_C_PUBLIC
dht_publickey
*
dht_privatekey_get_publickey
(
const
dht_privatekey
*
);
OPENDHT_C_PUBLIC
dht_publickey
*
dht_privatekey_get_publickey
(
const
dht_privatekey
*
);
OPENDHT_C_PUBLIC
void
dht_privatekey_delete
(
dht_privatekey
*
pk
);
// dht::crypto::Certificate
// dht::crypto::Certificate
struct
OPENDHT_C_PUBLIC
dht_certificate
;
struct
OPENDHT_C_PUBLIC
dht_certificate
;
...
@@ -74,11 +75,11 @@ typedef bool (*dht_value_cb)(const dht_value* value, bool expired, void* user_da
...
@@ -74,11 +75,11 @@ typedef bool (*dht_value_cb)(const dht_value* value, bool expired, void* user_da
typedef
bool
(
*
dht_done_cb
)(
bool
ok
,
void
*
user_data
);
typedef
bool
(
*
dht_done_cb
)(
bool
ok
,
void
*
user_data
);
typedef
bool
(
*
dht_shutdown_cb
)(
void
*
user_data
);
typedef
bool
(
*
dht_shutdown_cb
)(
void
*
user_data
);
// dht::DhtRunner
struct
OPENDHT_C_PUBLIC
dht_op_token
;
struct
OPENDHT_C_PUBLIC
dht_op_token
;
typedef
struct
dht_op_token
dht_op_token
;
typedef
struct
dht_op_token
dht_op_token
;
OPENDHT_C_PUBLIC
void
dht_op_token_delete
(
dht_op_token
*
token
);
OPENDHT_C_PUBLIC
void
dht_op_token_delete
(
dht_op_token
*
token
);
// dht::DhtRunner
struct
OPENDHT_C_PUBLIC
dht_runner
;
struct
OPENDHT_C_PUBLIC
dht_runner
;
typedef
struct
dht_runner
dht_runner
;
typedef
struct
dht_runner
dht_runner
;
OPENDHT_C_PUBLIC
dht_runner
*
dht_runner_new
();
OPENDHT_C_PUBLIC
dht_runner
*
dht_runner_new
();
...
...
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