Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Textual mode #27

Merged
merged 75 commits into from
Sep 25, 2023
Merged

Textual mode #27

merged 75 commits into from
Sep 25, 2023

Conversation

ftheirs
Copy link

@ftheirs ftheirs commented Aug 23, 2023

Merging all the changes from develop branch from this repository and solve conflicts

New features:
Support for Textual mode
Features on develop branch:
Support for Stax
Support for ETH path

Both transaction types (Amino JSON & Textual) can be sign using ETH path. Restricted to INJ so far
Use latest communication package: v3.0.3
Sign command requires now HRP when signing with ETH path.

};
typedef struct CborEncoder CborEncoder;

static const size_t CborIndefiniteLength = SIZE_MAX;

Check notice

Code scanning / CodeQL

Unused static variable

Static variable CborIndefiniteLength is never read.
Comment on lines +515 to +624
return err;
}
err = cbor_value_leave_container(it, &recursed);
if (err)
return err;
return CborNoError;
}

case CborIntegerType: {
uint64_t val;
err = cbor_value_get_raw_integer(it, &val);
cbor_assert(err == CborNoError); /* can't fail */

break;
}

case CborByteStringType:
case CborTextStringType: {
size_t n = 0;
const void *ptr;

err = cbor_value_begin_string_iteration(it);
if (err)
return err;

while (1) {
CborValue next;
err = _cbor_value_get_string_chunk(it, &ptr, &n, &next);
if (!err) {
err = validate_number(it, type, flags);
if (err)
return err;
}

*it = next;
if (err == CborErrorNoMoreStringChunks)
return cbor_value_finish_string_iteration(it);
if (err)
return err;

if (type == CborTextStringType && flags & CborValidateUtf8) {
err = validate_utf8_string(ptr, n);
if (err)
return err;
}
}

return CborNoError;
}

case CborTagType: {
CborTag tag;
err = cbor_value_get_tag(it, &tag);
cbor_assert(err == CborNoError); /* can't fail */

err = cbor_value_advance_fixed(it);
if (err)
return err;
err = validate_tag(it, tag, flags, recursionLeft - 1);
if (err)
return err;

return CborNoError;
}

case CborSimpleType: {
uint8_t simple_type;
err = cbor_value_get_simple_type(it, &simple_type);
cbor_assert(err == CborNoError); /* can't fail */
err = validate_simple_type(simple_type, flags);
if (err)
return err;
break;
}

case CborNullType:
case CborBooleanType:
break;

case CborUndefinedType:
if (flags & CborValidateNoUndefined)
return CborErrorExcludedType;
break;

case CborHalfFloatType:
case CborFloatType:
case CborDoubleType: {
#ifdef CBOR_NO_FLOATING_POINT
return CborErrorUnsupportedType;
#else
err = validate_floating_point(it, type, flags);
if (err)
return err;
break;
#endif /* !CBOR_NO_FLOATING_POINT */
}

case CborInvalidType:
return CborErrorUnknownType;
}

Check notice

Code scanning / CodeQL

Long switch case

Switch has at least one case that is too long: [CborTextStringType (32 lines)](1).
if (flags & CborValidateShortestFloatingPoint && type > CborHalfFloatType) {
if (type == CborDoubleType) {
valf = (float)val;
if ((double)valf == val)

Check notice

Code scanning / CodeQL

Equality test on floating-point values

Equality checks on floating point values can yield unexpected results.
# ifndef CBOR_NO_HALF_FLOAT_TYPE
if (type == CborFloatType) {
valf16 = encode_half(valf);
if (valf == decode_half(valf16))

Check notice

Code scanning / CodeQL

Equality test on floating-point values

Equality checks on floating point values can yield unexpected results.
if (tagData->tag < tag)
continue;
if (tagData->tag > tag)
tagData = NULL;

Check notice

Code scanning / CodeQL

For loop variable changed in body

Loop counters should not be modified in the body of the [loop](1).

/* Error API */

typedef enum CborError {

Check notice

Code scanning / CodeQL

Irregular enum initialization

In an enumerator list, the = construct should not be used to explicitly initialize members other than the first, unless all items are explicitly initialized.
CborSignatureTag = 55799
} CborKnownTags;

/* #define the constants so we can check with #ifdef */

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
@ftheirs ftheirs changed the base branch from main to develop August 24, 2023 11:51
@ftheirs ftheirs changed the base branch from develop to main August 24, 2023 13:52
@xchapron-ledger xchapron-ledger changed the base branch from main to develop September 25, 2023 11:24
@xchapron-ledger
Copy link

@xchapron-ledger xchapron-ledger merged commit 6205ae8 into LedgerHQ:develop Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants