This repository has been archived by the owner on Mar 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into helpersjava-bindings
- Loading branch information
Showing
34 changed files
with
503 additions
and
506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
cc_library( | ||
name = "api", | ||
srcs = ["api.c"], | ||
hdrs = ["api.h"], | ||
deps = [ | ||
"//common:errors", | ||
"//common/model:bundle", | ||
"//mam/v2/mam", | ||
"//mam/v2/mam:mam_psk_t_set", | ||
"//mam/v2/mam:mam_types", | ||
"//mam/v2/ntru:mam_ntru_pk_t_set", | ||
"//mam/v2/ntru:mam_ntru_sk_t_set", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) 2018 IOTA Stiftung | ||
* https://github.com/iotaledger/entangled | ||
* | ||
* MAM is based on an original implementation & specification by apmi.bsu.by | ||
* [ITSec Lab] | ||
* | ||
* Refer to the LICENSE file for licensing information | ||
*/ | ||
|
||
#include "mam/v2/api/api.h" | ||
#include "mam/v2/mam/mam_psk_t_set.h" | ||
#include "mam/v2/ntru/mam_ntru_pk_t_set.h" | ||
#include "mam/v2/ntru/mam_ntru_sk_t_set.h" | ||
#include "mam/v2/prng/prng.h" | ||
|
||
retcode_t mam_api_init(mam_api_t *const api, trits_t const prng_secret_key) { | ||
retcode_t ret = RC_OK; | ||
|
||
api->version = MAM_API_VERSION; | ||
if ((ret = mam_prng_init(&api->prng, prng_secret_key)) != RC_OK) { | ||
return ret; | ||
} | ||
api->ntru_sks = NULL; | ||
api->ntru_pks = NULL; | ||
api->psks = NULL; | ||
|
||
return ret; | ||
} | ||
|
||
retcode_t mam_api_destroy(mam_api_t *const api) { | ||
retcode_t ret = RC_OK; | ||
|
||
if ((ret = mam_prng_destroy(&api->prng)) != RC_OK) { | ||
return ret; | ||
} | ||
mam_ntru_sk_t_set_free(&api->ntru_sks); | ||
mam_ntru_pk_t_set_free(&api->ntru_pks); | ||
mam_psk_t_set_free(&api->psks); | ||
|
||
return RC_OK; | ||
} | ||
|
||
retcode_t mam_api_add_ntru_sk(mam_api_t *const api, | ||
mam_ntru_sk_t const *const ntru_sk) { | ||
return mam_ntru_sk_t_set_add(&api->ntru_sks, ntru_sk); | ||
} | ||
|
||
retcode_t mam_api_add_ntru_pk(mam_api_t *const api, | ||
mam_ntru_pk_t const *const ntru_pk) { | ||
return mam_ntru_pk_t_set_add(&api->ntru_pks, ntru_pk); | ||
} | ||
|
||
retcode_t mam_api_add_psk(mam_api_t *const api, mam_psk_t const *const psk) { | ||
return mam_psk_t_set_add(&api->psks, psk); | ||
} | ||
|
||
retcode_t mam_api_bundle_write_msg( | ||
mam_api_t *const api, mam_msg_pubkey_t pubkey, mam_msg_keyload_t keyload, | ||
mam_msg_checksum_t checksum, mam_channel_t const *const cha, | ||
mam_endpoint_t const *const epa, mam_channel_t const *const ch1a, | ||
mam_endpoint_t const *const ep1a, flex_trit_t const *const payload, | ||
bundle_transactions_t *const bundle) { | ||
return RC_MAM2_NOT_IMPLEMENTED; | ||
} | ||
|
||
retcode_t mam_api_bundle_write_packet( | ||
mam_api_t *const api, mam_msg_pubkey_t pubkey, mam_msg_keyload_t keyload, | ||
mam_msg_checksum_t checksum, mam_channel_t const *const cha, | ||
mam_endpoint_t const *const epa, mam_channel_t const *const ch1a, | ||
mam_endpoint_t const *const ep1a, flex_trit_t const *const payload, | ||
bundle_transactions_t *const bundle) { | ||
return RC_MAM2_NOT_IMPLEMENTED; | ||
} | ||
|
||
retcode_t mam_api_bundle_read(mam_api_t *const api, | ||
mam_channel_t const *const cha, | ||
bundle_transactions_t const *const bundle, | ||
flex_trit_t *const payload) { | ||
return RC_MAM2_NOT_IMPLEMENTED; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2018 IOTA Stiftung | ||
* https://github.com/iotaledger/entangled | ||
* | ||
* MAM is based on an original implementation & specification by apmi.bsu.by | ||
* [ITSec Lab] | ||
* | ||
* Refer to the LICENSE file for licensing information | ||
*/ | ||
|
||
#ifndef __MAM_V2_API_API_H__ | ||
#define __MAM_V2_API_API_H__ | ||
|
||
#include "common/errors.h" | ||
#include "common/model/bundle.h" | ||
#include "common/trinary/flex_trit.h" | ||
#include "mam/v2/mam/mam.h" | ||
#include "mam/v2/mam/mam_types.h" | ||
#include "mam/v2/ntru/ntru_types.h" | ||
#include "mam/v2/prng/prng_types.h" | ||
|
||
#define MAM_API_VERSION 0 | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct mam_api_s { | ||
tryte_t version; | ||
mam_prng_t prng; | ||
mam_ntru_sk_t_set_t ntru_sks; | ||
mam_ntru_pk_t_set_t ntru_pks; | ||
mam_psk_t_set_t psks; | ||
} mam_api_t; | ||
|
||
retcode_t mam_api_init(mam_api_t *const api, trits_t const prng_secret_key); | ||
|
||
retcode_t mam_api_destroy(mam_api_t *const api); | ||
|
||
retcode_t mam_api_add_ntru_sk(mam_api_t *const api, | ||
mam_ntru_sk_t const *const ntru_sk); | ||
|
||
retcode_t mam_api_add_ntru_pk(mam_api_t *const api, | ||
mam_ntru_pk_t const *const ntru_pk); | ||
|
||
retcode_t mam_api_add_psk(mam_api_t *const api, mam_psk_t const *const psk); | ||
|
||
retcode_t mam_api_bundle_write_msg( | ||
mam_api_t *const api, mam_msg_pubkey_t pubkey, mam_msg_keyload_t keyload, | ||
mam_msg_checksum_t checksum, mam_channel_t const *const cha, | ||
mam_endpoint_t const *const epa, mam_channel_t const *const ch1a, | ||
mam_endpoint_t const *const ep1a, flex_trit_t const *const payload, | ||
bundle_transactions_t *const bundle); | ||
|
||
retcode_t mam_api_bundle_write_packet( | ||
mam_api_t *const api, mam_msg_pubkey_t pubkey, mam_msg_keyload_t keyload, | ||
mam_msg_checksum_t checksum, mam_channel_t const *const cha, | ||
mam_endpoint_t const *const epa, mam_channel_t const *const ch1a, | ||
mam_endpoint_t const *const ep1a, flex_trit_t const *const payload, | ||
bundle_transactions_t *const bundle); | ||
|
||
retcode_t mam_api_bundle_read(mam_api_t *const api, | ||
mam_channel_t const *const cha, | ||
bundle_transactions_t const *const bundle, | ||
flex_trit_t *const payload); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // __MAM_V2_API_API_H__ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.