Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoSign in
Socket

zcbor

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zcbor - pypi Package Compare versions

Comparing version
0.5.0
to
0.5.1
+1
-0
include/zcbor_decode.h

@@ -38,2 +38,3 @@ /*

bool zcbor_size_decode(zcbor_state_t *state, size_t *result);
bool zcbor_int_decode(zcbor_state_t *state, void *result_int, size_t int_size);

@@ -40,0 +41,0 @@ /** The following applies to all _expect() functions that don't have docs.

@@ -41,2 +41,3 @@ /*

*/
bool zcbor_int_encode(zcbor_state_t *state, const void *input_int, size_t int_size);
bool zcbor_int32_encode(zcbor_state_t *state, const int32_t *input);

@@ -43,0 +44,0 @@ bool zcbor_int64_encode(zcbor_state_t *state, const int64_t *input);

+8
-8
Metadata-Version: 2.1
Name: zcbor
Version: 0.5.0
Version: 0.5.1
Summary: zcbor

@@ -32,3 +32,3 @@ Home-page: https://github.com/NordicSemiconductor/zcbor

The CBOR library found at [headers](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/include) and [source](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/src) is used by the generated code, but can also be used directly.
The CBOR library found at [headers](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/include) and [source](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/src) is used by the generated code, but can also be used directly.
If so, you must instantiate a `zcbor_state_t` object, which is most easily done using the `zcbor_new_*_state()` functions or the `ZCBOR_STATE_*()` macros.

@@ -86,3 +86,3 @@

By invoking `zcbor` (when installed via Pip or setup.py), or the Python script [zcbor.py](https://github.com/NordicSemiconductor/zcbor/blob/0.5.0/zcbor/zcbor.py) directly, you can generate C code that validates/encodes/decodes CBOR data conforming to a CDDL schema.
By invoking `zcbor` (when installed via Pip or setup.py), or the Python script [zcbor.py](https://github.com/NordicSemiconductor/zcbor/blob/0.5.1/zcbor/zcbor.py) directly, you can generate C code that validates/encodes/decodes CBOR data conforming to a CDDL schema.
zcbor can also validate and convert CBOR data to and from JSON/YAML, either from the command line, or imported as a module.

@@ -166,3 +166,3 @@ Finally, the package contains a light-weight CBOR encoding/decoding library in C.

There are tests for the code generation in [tests/](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/tests/).
There are tests for the code generation in [tests/](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/tests/).
The tests require [Zephyr](https://github.com/zephyrproject-rtos/zephyr) (if your shell is set up to build Zephyr samples, the tests should also build).

@@ -229,3 +229,3 @@

See [test3_simple](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/tests/decode/test3_simple/) for CDDL example code.
See [test3_simple](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/tests/decode/test3_simple/) for CDDL example code.

@@ -280,3 +280,3 @@ Introduction to CBOR

This example is is taken from [test3_simple](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/tests/decode/test3_simple/).
This example is is taken from [test3_simple](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/tests/decode/test3_simple/).

@@ -387,3 +387,3 @@ If your CDDL file contains the following code:

There are also test.sh scripts to quickly run all tests.
[`tests/test.sh`](https://github.com/NordicSemiconductor/zcbor/blob/0.5.0/tests/test.sh) runs all tests, including python tests in [`tests/scripts`](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/tests/scripts).
[`tests/test.sh`](https://github.com/NordicSemiconductor/zcbor/blob/0.5.1/tests/test.sh) runs all tests, including python tests in [`tests/scripts`](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/tests/scripts).

@@ -393,3 +393,3 @@ These tests are dependent upon the `pycodestyle` package from `pip`.

To set up the environment to run the ztest tests, follow [Zephyr's Getting Started Guide](https://docs.zephyrproject.org/latest/getting_started/index.html), or see the workflow in the [`.github`](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/.github) directory.
To set up the environment to run the ztest tests, follow [Zephyr's Getting Started Guide](https://docs.zephyrproject.org/latest/getting_started/index.html), or see the workflow in the [`.github`](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/.github) directory.

@@ -396,0 +396,0 @@ Command line documentation

cbor2>=5.4.2.post1
pyyaml>=6.0.0
pyyaml>=5.4.1
regex>=2022.3.15

@@ -158,24 +158,8 @@ /*

bool zcbor_int32_decode(zcbor_state_t *state, int32_t *result)
bool zcbor_int_decode(zcbor_state_t *state, void *result_int, size_t int_size)
{
int64_t result64;
if (zcbor_int64_decode(state, &result64)) {
if (result64 > INT32_MAX) {
ERR_RESTORE(ZCBOR_ERR_INT_SIZE);
}
*result = (int32_t)result64;
return true;
} else {
ZCBOR_FAIL();
}
}
bool zcbor_int64_decode(zcbor_state_t *state, int64_t *result)
{
INITIAL_CHECKS();
uint8_t major_type = MAJOR_TYPE(*state->payload);
uint64_t uint_result;
int64_t int_result;
uint8_t *result_uint8 = (uint8_t *)result_int;
int8_t *result_int8 = (int8_t *)result_int;

@@ -188,11 +172,11 @@ if (major_type != ZCBOR_MAJOR_TYPE_PINT

if (!value_extract(state, &uint_result, sizeof(uint_result))) {
if (!value_extract(state, result_int, int_size)) {
ZCBOR_FAIL();
}
zcbor_print("uintval: %" PRIu64 "\r\n", uint_result);
int_result = (int64_t)uint_result;
if (int_result < 0) {
#ifdef CONFIG_BIG_ENDIAN
if (result_int8[0] < 0) {
#else
if (result_int8[int_size - 1] < 0) {
#endif
/* Value is too large to fit in a signed integer. */

@@ -203,9 +187,8 @@ ERR_RESTORE(ZCBOR_ERR_INT_SIZE);

if (major_type == ZCBOR_MAJOR_TYPE_NINT) {
/* Convert from CBOR's representation. */
*result = -1 - int_result;
} else {
*result = int_result;
/* Convert from CBOR's representation by flipping all bits. */
for (int i = 0; i < int_size; i++) {
result_uint8[i] = (uint8_t)~result_uint8[i];
}
}
zcbor_print("val: %" PRIi64 "\r\n", *result);
return true;

@@ -215,2 +198,14 @@ }

bool zcbor_int32_decode(zcbor_state_t *state, int32_t *result)
{
return zcbor_int_decode(state, result, sizeof(*result));
}
bool zcbor_int64_decode(zcbor_state_t *state, int64_t *result)
{
return zcbor_int_decode(state, result, sizeof(*result));
}
bool zcbor_uint32_decode(zcbor_state_t *state, uint32_t *result)

@@ -217,0 +212,0 @@ {

@@ -144,22 +144,31 @@ /*

bool zcbor_int32_put(zcbor_state_t *state, int32_t input)
bool zcbor_int_encode(zcbor_state_t *state, const void *input_int, size_t int_size)
{
return zcbor_int64_put(state, input);
}
zcbor_major_type_t major_type;
uint8_t input_buf[8];
const uint8_t *input_uint8 = input_int;
const int8_t *input_int8 = input_int;
const uint8_t *input = input_int;
if (int_size > sizeof(int64_t)) {
ZCBOR_ERR(ZCBOR_ERR_INT_SIZE);
}
bool zcbor_int64_put(zcbor_state_t *state, int64_t input)
{
zcbor_major_type_t major_type;
#ifdef CONFIG_BIG_ENDIAN
if (input_int8[0] < 0) {
#else
if (input_int8[int_size - 1] < 0) {
#endif
major_type = ZCBOR_MAJOR_TYPE_NINT;
if (input < 0) {
major_type = ZCBOR_MAJOR_TYPE_NINT;
/* Convert from CBOR's representation. */
input = -1 - input;
/* Convert to CBOR's representation by flipping all bits. */
for (int i = 0; i < int_size; i++) {
input_buf[i] = (uint8_t)~input_uint8[i];
}
input = input_buf;
} else {
major_type = ZCBOR_MAJOR_TYPE_PINT;
input = input;
}
if (!value_encode(state, major_type, &input, 8)) {
if (!value_encode(state, major_type, input, int_size)) {
ZCBOR_FAIL();

@@ -174,6 +183,12 @@ }

{
return zcbor_int32_put(state, *input);
return zcbor_int_encode(state, input, sizeof(*input));
}
bool zcbor_int64_encode(zcbor_state_t *state, const int64_t *input)
{
return zcbor_int_encode(state, input, sizeof(*input));
}
static bool uint32_encode(zcbor_state_t *state, const uint32_t *input,

@@ -198,8 +213,2 @@ zcbor_major_type_t major_type)

bool zcbor_int64_encode(zcbor_state_t *state, const int64_t *input)
{
return zcbor_int64_put(state, *input);
}
static bool uint64_encode(zcbor_state_t *state, const uint64_t *input,

@@ -224,2 +233,14 @@ zcbor_major_type_t major_type)

bool zcbor_int32_put(zcbor_state_t *state, int32_t input)
{
return zcbor_int_encode(state, &input, sizeof(input));
}
bool zcbor_int64_put(zcbor_state_t *state, int64_t input)
{
return zcbor_int_encode(state, &input, sizeof(input));
}
bool zcbor_uint32_put(zcbor_state_t *state, uint32_t input)

@@ -226,0 +247,0 @@ {

Metadata-Version: 2.1
Name: zcbor
Version: 0.5.0
Version: 0.5.1
Summary: zcbor

@@ -32,3 +32,3 @@ Home-page: https://github.com/NordicSemiconductor/zcbor

The CBOR library found at [headers](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/include) and [source](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/src) is used by the generated code, but can also be used directly.
The CBOR library found at [headers](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/include) and [source](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/src) is used by the generated code, but can also be used directly.
If so, you must instantiate a `zcbor_state_t` object, which is most easily done using the `zcbor_new_*_state()` functions or the `ZCBOR_STATE_*()` macros.

@@ -86,3 +86,3 @@

By invoking `zcbor` (when installed via Pip or setup.py), or the Python script [zcbor.py](https://github.com/NordicSemiconductor/zcbor/blob/0.5.0/zcbor/zcbor.py) directly, you can generate C code that validates/encodes/decodes CBOR data conforming to a CDDL schema.
By invoking `zcbor` (when installed via Pip or setup.py), or the Python script [zcbor.py](https://github.com/NordicSemiconductor/zcbor/blob/0.5.1/zcbor/zcbor.py) directly, you can generate C code that validates/encodes/decodes CBOR data conforming to a CDDL schema.
zcbor can also validate and convert CBOR data to and from JSON/YAML, either from the command line, or imported as a module.

@@ -166,3 +166,3 @@ Finally, the package contains a light-weight CBOR encoding/decoding library in C.

There are tests for the code generation in [tests/](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/tests/).
There are tests for the code generation in [tests/](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/tests/).
The tests require [Zephyr](https://github.com/zephyrproject-rtos/zephyr) (if your shell is set up to build Zephyr samples, the tests should also build).

@@ -229,3 +229,3 @@

See [test3_simple](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/tests/decode/test3_simple/) for CDDL example code.
See [test3_simple](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/tests/decode/test3_simple/) for CDDL example code.

@@ -280,3 +280,3 @@ Introduction to CBOR

This example is is taken from [test3_simple](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/tests/decode/test3_simple/).
This example is is taken from [test3_simple](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/tests/decode/test3_simple/).

@@ -387,3 +387,3 @@ If your CDDL file contains the following code:

There are also test.sh scripts to quickly run all tests.
[`tests/test.sh`](https://github.com/NordicSemiconductor/zcbor/blob/0.5.0/tests/test.sh) runs all tests, including python tests in [`tests/scripts`](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/tests/scripts).
[`tests/test.sh`](https://github.com/NordicSemiconductor/zcbor/blob/0.5.1/tests/test.sh) runs all tests, including python tests in [`tests/scripts`](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/tests/scripts).

@@ -393,3 +393,3 @@ These tests are dependent upon the `pycodestyle` package from `pip`.

To set up the environment to run the ztest tests, follow [Zephyr's Getting Started Guide](https://docs.zephyrproject.org/latest/getting_started/index.html), or see the workflow in the [`.github`](https://github.com/NordicSemiconductor/zcbor/tree/0.5.0/.github) directory.
To set up the environment to run the ztest tests, follow [Zephyr's Getting Started Guide](https://docs.zephyrproject.org/latest/getting_started/index.html), or see the workflow in the [`.github`](https://github.com/NordicSemiconductor/zcbor/tree/0.5.1/.github) directory.

@@ -396,0 +396,0 @@ Command line documentation

cbor2>=5.4.2.post1
pyyaml>=6.0.0
pyyaml>=5.4.1
regex>=2022.3.15

@@ -1,1 +0,1 @@

0.5.0
0.5.1

Sorry, the diff of this file is too big to display