Skip to content

Commit

Permalink
Merge pull request #173 from VirgilSecurity/release/v0.1.1-alpha
Browse files Browse the repository at this point in the history
Release/v0.1.1 alpha
  • Loading branch information
kutashenko authored Dec 3, 2019
2 parents 778ea50 + d9ca0d0 commit d6ed7aa
Show file tree
Hide file tree
Showing 44 changed files with 587 additions and 255 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ endif()
#
# Target platform
#
option(VIRGIL_IOT_MCU_BUILD "Enable build for MCU" ON)
option(VIRGIL_IOT_MCU_BUILD "Disable build for MCU by default" OFF)

#
# Additional HAL include paths
Expand Down
81 changes: 46 additions & 35 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ vs_cloud_init(vs_curl_http_impl(), vs_aws_message_bin_impl(), secmodule_impl);
\endcode
*
* You need to implement custom storage. As an example you can see default implementation in
* <a href="https://github.com/VirgilSecurity/demo-iotkit-nix/blob/release/v0.1.0-alpha/common/src/helpers/app-storage.c#L73">vs_app_storage_init_impl()</a> function in app-storage.c file.
* <a
href="https://github.com/VirgilSecurity/demo-iotkit-nix/blob/release/v0.1.0-alpha/common/src/helpers/app-storage.c#L73">vs_app_storage_init_impl()</a>
function in app-storage.c file.
*/

#ifndef VS_AWS_DEFAULT_MESSAGE_BIN_IMPL_H
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ vs_cloud_init(vs_curl_http_impl(), vs_aws_message_bin_impl(), secmodule_impl);
\endcode
*
* You need to implement custom storage implementation. As an example you can see default implementation in
* <a href="https://github.com/VirgilSecurity/demo-iotkit-nix/blob/release/v0.1.0-alpha/common/src/helpers/app-storage.c#L73"> vs_app_storage_init_impl()</a> function in app-storage.c file.
* <a
href="https://github.com/VirgilSecurity/demo-iotkit-nix/blob/release/v0.1.0-alpha/common/src/helpers/app-storage.c#L73">
vs_app_storage_init_impl()</a> function in app-storage.c file.
*/

#ifndef VS_CURL_HTTP_DEFAULT_IMPL_H
Expand Down
11 changes: 11 additions & 0 deletions helpers/json/include/virgil/iot/json/json_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
#ifndef _JSON_GENERATOR_H_
#define _JSON_GENERATOR_H_

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

#define MAX_JSON_STR_LEN 64 /* Maximum object or member name length */
#define MAX_JSON_VAL_LEN 128 /* Maximum value name length */
typedef enum {
Expand Down Expand Up @@ -398,4 +403,10 @@ json_set_array_value(struct json_str *jptr, char *str, int value, float val, jso
#define json_set_array_bool(jptr, val) \
((val == true) ? (json_set_array_value(jptr, NULL, 1, 0.0, JSON_VAL_BOOL)) \
: (json_set_array_value(jptr, NULL, 0, 0.0, JSON_VAL_BOOL)))

#ifdef __cplusplus
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif /* _JSON_GENERATOR_H_ */
10 changes: 10 additions & 0 deletions helpers/json/include/virgil/iot/json/json_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@
#include <stdint.h>
#include "jsmn.h"

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

#define MOD_ERROR_START(x) (x << 12 | 0)

#ifdef JSMN_SHORT_TOKENS
Expand Down Expand Up @@ -724,4 +729,9 @@ json_array_get_array_object(jobj_t *jobj, uint16_t index, int *num_elements);
int
json_array_release_array_object(jobj_t *jobj);

#ifdef __cplusplus
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif /* __JSON_PARSER_H__ */
10 changes: 10 additions & 0 deletions helpers/status_code/include/virgil/iot/status_code/status_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@

#include <virgil/iot/macros/macros.h>

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

/** Status code
*
* Zero value #VS_CODE_OK is used for non-error values. Negative values mean error
Expand Down Expand Up @@ -159,4 +164,9 @@ typedef enum {
*/
#define STATUS_CHECK_RET_BOOL(OPERATION, MESSAGE, ...) BOOL_CHECK_RET(VS_CODE_OK == (OPERATION), (MESSAGE), ##__VA_ARGS__)

#ifdef __cplusplus
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif // VS_IOT_SDK_STATUS_CODE
10 changes: 10 additions & 0 deletions helpers/storage_hal/include/virgil/iot/storage_hal/storage_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
#include <virgil/iot/status_code/status_code.h>
#include <sys/types.h>

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

#define VS_STORAGE_ELEMENT_ID_MAX (32)

typedef uint8_t vs_storage_element_id_t[VS_STORAGE_ELEMENT_ID_MAX];
Expand Down Expand Up @@ -220,4 +225,9 @@ typedef struct {

} vs_storage_op_ctx_t;

#ifdef __cplusplus
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif //VS_STORAGE_HAL_H
10 changes: 10 additions & 0 deletions helpers/update/include/virgil/iot/update/update.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
#include <virgil/iot/status_code/status_code.h>
#include <virgil/iot/provision/provision.h>

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

/** File types */
enum vs_update_file_type_id_t {
VS_UPDATE_FIRMWARE, /**< Firmware files for different manufactures and device types */
Expand Down Expand Up @@ -291,4 +296,9 @@ typedef struct __attribute__((__packed__)) vs_update_interface_t {

} vs_update_interface_t;

#ifdef __cplusplus
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif // VS_UPDATE_H
4 changes: 3 additions & 1 deletion modules/cloud/include/virgil/iot/cloud/base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
#include <stdbool.h>

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

Expand Down Expand Up @@ -182,7 +183,8 @@ bool
base64encode(const unsigned char *in, int inlen, char *out, int *outlen);

#ifdef __cplusplus
}
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif /* _BASE64_H_ */
14 changes: 12 additions & 2 deletions modules/cloud/include/virgil/iot/cloud/cloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
* \section cloud_usage Cloud Usage
*
* Function #vs_cloud_message_bin_process tries to obtain credentials for connecting to message bin broker from thing
* service using #vs_cloud_http_request_func_t and connect to the broker using #vs_cloud_mb_connect_subscribe_func_t. Then
* it waits for new messages, periodically calling #vs_cloud_mb_process_func_t. User can register own handlers for
* service using #vs_cloud_http_request_func_t and connect to the broker using #vs_cloud_mb_connect_subscribe_func_t.
* Then it waits for new messages, periodically calling #vs_cloud_mb_process_func_t. User can register own handlers for
* events of new firmware or trust list by calling #vs_cloud_message_bin_register_default_handler or custom handler for
* raw data processing from some topics by calling #vs_cloud_message_bin_register_custom_handler. Cloud module uses
* provision and firmware modules, which must be initialized before.
Expand Down Expand Up @@ -154,6 +154,11 @@ tl_topic_process(const uint8_t *url, uint16_t length) {
#include <global-hal.h>
#include <virgil/iot/status_code/status_code.h>

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

/** Length of the update URL string */
#define VS_UPD_URL_STR_SIZE 200

Expand Down Expand Up @@ -378,4 +383,9 @@ vs_cloud_init(const vs_cloud_impl_t *cloud_impl,
const vs_cloud_message_bin_impl_t *message_bin_impl,
vs_secmodule_impl_t *secmodule);

#ifdef __cplusplus
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif // VS_CLOUD_H
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include <virgil/iot/secmodule/secmodule.h>

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

Expand Down Expand Up @@ -180,9 +181,9 @@ vs_converters_raw_sign_to_mbedtls(vs_secmodule_keypair_type_e keypair_type,
uint16_t buf_sz,
uint16_t *signature_sz);


#ifdef __cplusplus
}
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif // VS_CRYPTO_CONVERTERS_H
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
#ifndef VS_SECMODULE_SOFT_DEVICE_H
#define VS_SECMODULE_SOFT_DEVICE_H

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

/** Maximum data size of standard slot */
#define KEY_SLOT_STD_DATA_SIZE (380)

Expand Down Expand Up @@ -129,4 +134,9 @@ typedef enum {
/** Firmware key 2 slot */
#define FW2_KEY_SLOT VS_KEY_SLOT_STD_MTP_7

#ifdef __cplusplus
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif // VS_SECMODULE_SOFT_DEVICE_H
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
#ifndef VS_SECMODULE_HELPERS_H_
#define VS_SECMODULE_HELPERS_H_

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

#include <virgil/iot/secmodule/secmodule.h>

#define VS_PUBKEY_SECP192_LEN (49)
Expand Down Expand Up @@ -155,4 +160,10 @@ vs_secmodule_tiny_secp256_signature_to_virgil(const uint8_t raw_signature[VS_SIG
uint8_t *virgil_sign,
uint16_t buf_sz,
uint16_t *virgil_sign_sz);

#ifdef __cplusplus
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif // VS_SECMODULE_HELPERS_H_
10 changes: 10 additions & 0 deletions modules/crypto/secmodule/include/virgil/iot/secmodule/secmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ vs_soft_secmodule_deinit();
#include <virgil/iot/status_code/status_code.h>
#include <virgil/iot/secmodule/devices/secmodule-soft.h>

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

/** Keypair types */
typedef enum {
VS_KEYPAIR_INVALID = -1, /**< Invalid keypair */
Expand Down Expand Up @@ -542,4 +547,9 @@ vs_secmodule_ecies_encrypt(const vs_secmodule_impl_t *secmodule_impl,
size_t buf_sz,
size_t *cryptogram_sz);

#ifdef __cplusplus
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif // VS_SECMODULE_INTERFACE_API_H
10 changes: 10 additions & 0 deletions modules/firmware/include/virgil/iot/firmware/firmware.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ Firmware module");
#include <virgil/iot/update/update.h>
#include <virgil/iot/secmodule/secmodule.h>

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

/** Firmware descriptor */
typedef struct __attribute__((__packed__)) {
vs_file_info_t info; /**< File information */
Expand Down Expand Up @@ -512,4 +517,9 @@ vs_firmware_hton_descriptor(vs_firmware_descriptor_t *desc);
void
vs_firmware_hton_header(vs_firmware_header_t *header);

#ifdef __cplusplus
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif // VS_FIRMWARE_H
10 changes: 10 additions & 0 deletions modules/firmware/include/virgil/iot/firmware/firmware_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@

#include <virgil/iot/status_code/status_code.h>

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

/** Prepare space
*
* Signature for function that is called by #vs_firmware_install_firmware Firmware library function to prepare space for
Expand Down Expand Up @@ -89,4 +94,9 @@ vs_firmware_install_append_data_hal(const void *data, uint16_t data_sz);
vs_status_e
vs_firmware_get_own_firmware_footer_hal(void *footer, size_t footer_sz);

#ifdef __cplusplus
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif // VS_FIRMWARE_INTERFACE_H
10 changes: 10 additions & 0 deletions modules/logger/include/virgil/iot/logger/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ logger_hal_implementation
#include <stdarg.h>
#include <string.h>

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

/** Logging level
*/
typedef enum {
Expand Down Expand Up @@ -293,4 +298,9 @@ vs_logger_message_hex(vs_log_level_t level,

#endif // VS_IOT_LOGGER_USE_LIBRARY

#ifdef __cplusplus
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif // AP_SECURITY_SDK_LOGGER_H
11 changes: 9 additions & 2 deletions modules/protocols/snap/include/virgil/iot/protocols/snap.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@
* #vs_snap_service_t structure and register service by #vs_snap_register_service call.
*/

#ifndef AP_SECURITY_SDK_SNAP_H
#define AP_SECURITY_SDK_SNAP_H

#include <stdint.h>

#include <virgil/iot/protocols/snap/snap-structs.h>
#include <virgil/iot/status_code/status_code.h>

#ifdef __cplusplus
namespace VirgilIoTKit {
extern "C" {
#endif

Expand Down Expand Up @@ -194,5 +198,8 @@ vs_snap_stat_t
vs_snap_get_statistics(void);

#ifdef __cplusplus
}
#endif
} // extern "C"
} // namespace VirgilIoTKit
#endif

#endif // AP_SECURITY_SDK_SNAP_H
Loading

0 comments on commit d6ed7aa

Please sign in to comment.