mirror of
https://github.com/bettse/seader.git
synced 2026-08-28 10:34:05 +00:00
asn1: move metadata tables out of RAM
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include <lib/nfc/protocols/mf_classic/mf_classic_poller.h>
|
||||
#include <nfc/helpers/iso13239_crc.h>
|
||||
|
||||
#define TAG "PluginHF"
|
||||
#define TAG "PluginHF"
|
||||
#define HF_DIAG_D(...) SEADER_VERBOSE_D(TAG, __VA_ARGS__)
|
||||
#define HF_DIAG_I(...) SEADER_VERBOSE_I(TAG, __VA_ARGS__)
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ typedef struct asn_INTEGER_enum_map_s {
|
||||
} asn_INTEGER_enum_map_t;
|
||||
|
||||
/* This type describes an enumeration for INTEGER and ENUMERATED types */
|
||||
typedef struct asn_INTEGER_specifics_s {
|
||||
typedef const struct asn_INTEGER_specifics_s {
|
||||
const asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */
|
||||
const unsigned int *enum2value; /* "tag" => N; sorted by tag */
|
||||
int map_count; /* Elements in either map */
|
||||
|
||||
@@ -73,7 +73,7 @@ OCTET_STRING_t *OCTET_STRING_new_fromBuf(const asn_TYPE_descriptor_t *td,
|
||||
* Internally useful stuff. *
|
||||
****************************/
|
||||
|
||||
typedef struct asn_OCTET_STRING_specifics_s {
|
||||
typedef const struct asn_OCTET_STRING_specifics_s {
|
||||
/*
|
||||
* Target structure description.
|
||||
*/
|
||||
|
||||
@@ -190,7 +190,7 @@ CHOICE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
|
||||
do {
|
||||
const asn_TYPE_tag2member_t *t2m;
|
||||
asn_TYPE_tag2member_t key;
|
||||
struct asn_TYPE_tag2member_s key;
|
||||
|
||||
key.el_tag = tlv_tag;
|
||||
t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct asn_CHOICE_specifics_s {
|
||||
typedef const struct asn_CHOICE_specifics_s {
|
||||
/*
|
||||
* Target structure description.
|
||||
*/
|
||||
|
||||
@@ -304,7 +304,7 @@ SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
* sorted array of tags.
|
||||
*/
|
||||
const asn_TYPE_tag2member_t *t2m;
|
||||
asn_TYPE_tag2member_t key = {0, 0, 0, 0};
|
||||
struct asn_TYPE_tag2member_s key = {0, 0, 0, 0};
|
||||
key.el_tag = tlv_tag;
|
||||
key.el_no = edx;
|
||||
t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct asn_SEQUENCE_specifics_s {
|
||||
typedef const struct asn_SEQUENCE_specifics_s {
|
||||
/*
|
||||
* Target structure description.
|
||||
*/
|
||||
|
||||
@@ -141,7 +141,7 @@ typedef asn_type_selector_result_t(asn_type_selector_f)(
|
||||
* Generalized functions for dealing with the speciic type.
|
||||
* May be directly invoked by applications.
|
||||
*/
|
||||
typedef struct asn_TYPE_operation_s {
|
||||
typedef const struct asn_TYPE_operation_s {
|
||||
asn_struct_free_f *free_struct; /* Free the structure */
|
||||
asn_struct_print_f *print_struct; /* Human readable output */
|
||||
asn_struct_compare_f *compare_struct; /* Compare two structures */
|
||||
@@ -169,7 +169,7 @@ typedef struct asn_encoding_constraints_s {
|
||||
/*
|
||||
* The definitive description of the destination language's structure.
|
||||
*/
|
||||
typedef struct asn_TYPE_descriptor_s {
|
||||
typedef const struct asn_TYPE_descriptor_s {
|
||||
const char *name; /* A name of the ASN.1 type. "" in some cases. */
|
||||
const char *xml_tag; /* Name used in XML tag */
|
||||
|
||||
@@ -177,7 +177,7 @@ typedef struct asn_TYPE_descriptor_s {
|
||||
* Generalized functions for dealing with the specific type.
|
||||
* May be directly invoked by applications.
|
||||
*/
|
||||
asn_TYPE_operation_t *op;
|
||||
const asn_TYPE_operation_t *op;
|
||||
|
||||
/***********************************************************************
|
||||
* Internally useful members. Not to be used by applications directly. *
|
||||
@@ -197,7 +197,7 @@ typedef struct asn_TYPE_descriptor_s {
|
||||
/*
|
||||
* An ASN.1 production type members (members of SEQUENCE, SET, CHOICE).
|
||||
*/
|
||||
struct asn_TYPE_member_s *elements;
|
||||
const struct asn_TYPE_member_s *elements;
|
||||
unsigned elements_count;
|
||||
|
||||
/*
|
||||
@@ -217,13 +217,13 @@ typedef struct asn_TYPE_descriptor_s {
|
||||
ATF_OPEN_TYPE = 0x02, /* Open Type */
|
||||
ATF_ANY_TYPE = 0x04 /* ANY type (deprecated!) */
|
||||
};
|
||||
typedef struct asn_TYPE_member_s {
|
||||
typedef const struct asn_TYPE_member_s {
|
||||
enum asn_TYPE_flags_e flags; /* Element's presentation flags */
|
||||
unsigned optional; /* Following optional members, including current */
|
||||
unsigned memb_offset; /* Offset of the element */
|
||||
ber_tlv_tag_t tag; /* Outmost (most immediate) tag */
|
||||
int tag_mode; /* IMPLICIT/no/EXPLICIT tag at current level */
|
||||
asn_TYPE_descriptor_t *type; /* Member type descriptor */
|
||||
const asn_TYPE_descriptor_t *type; /* Member type descriptor */
|
||||
asn_type_selector_f *type_selector; /* IoS runtime type selector */
|
||||
asn_encoding_constraints_t encoding_constraints;
|
||||
int (*default_value_cmp)(const void *sptr); /* Compare DEFAULT <value> */
|
||||
@@ -234,7 +234,7 @@ typedef struct asn_TYPE_member_s {
|
||||
/*
|
||||
* BER tag to element number mapping.
|
||||
*/
|
||||
typedef struct asn_TYPE_tag2member_s {
|
||||
typedef const struct asn_TYPE_tag2member_s {
|
||||
ber_tlv_tag_t el_tag; /* Outmost tag of the member */
|
||||
unsigned el_no; /* Index of the associated member, base 0 */
|
||||
int toff_first; /* First occurence of the el_tag, relative */
|
||||
|
||||
@@ -265,8 +265,8 @@ uper_open_type_get(const asn_codec_ctx_t *ctx, const asn_TYPE_descriptor_t *td,
|
||||
|
||||
int
|
||||
uper_open_type_skip(const asn_codec_ctx_t *ctx, asn_per_data_t *pd) {
|
||||
asn_TYPE_descriptor_t s_td;
|
||||
asn_TYPE_operation_t s_op;
|
||||
struct asn_TYPE_descriptor_s s_td = {0};
|
||||
struct asn_TYPE_operation_s s_op = {0};
|
||||
asn_dec_rval_t rv;
|
||||
|
||||
s_td.name = "<unknown extension>";
|
||||
|
||||
@@ -15,7 +15,7 @@ extern "C" {
|
||||
/*
|
||||
* Pre-computed PER constraints.
|
||||
*/
|
||||
typedef struct asn_per_constraint_s {
|
||||
typedef const struct asn_per_constraint_s {
|
||||
enum asn_per_constraint_flags {
|
||||
APC_UNCONSTRAINED = 0x0, /* No PER visible constraints */
|
||||
APC_SEMI_CONSTRAINED = 0x1, /* Constrained at "lb" */
|
||||
@@ -27,7 +27,7 @@ typedef struct asn_per_constraint_s {
|
||||
long lower_bound; /* "lb" value */
|
||||
long upper_bound; /* "ub" value */
|
||||
} asn_per_constraint_t;
|
||||
typedef struct asn_per_constraints_s {
|
||||
typedef const struct asn_per_constraints_s {
|
||||
asn_per_constraint_t value;
|
||||
asn_per_constraint_t size;
|
||||
int (*value2code)(unsigned int value);
|
||||
|
||||
@@ -25,7 +25,7 @@ typedef struct asn_INTEGER_enum_map_s {
|
||||
} asn_INTEGER_enum_map_t;
|
||||
|
||||
/* This type describes an enumeration for INTEGER and ENUMERATED types */
|
||||
typedef struct asn_INTEGER_specifics_s {
|
||||
typedef const struct asn_INTEGER_specifics_s {
|
||||
const asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */
|
||||
const unsigned int *enum2value; /* "tag" => N; sorted by tag */
|
||||
int map_count; /* Elements in either map */
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct asn_NativeReal_specifics_s {
|
||||
typedef const struct asn_NativeReal_specifics_s {
|
||||
unsigned float_size; /* sizeof(float) or sizeof(double) */
|
||||
} asn_NativeReal_specifics_t;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ OCTET_STRING_t *OCTET_STRING_new_fromBuf(const asn_TYPE_descriptor_t *td,
|
||||
* Internally useful stuff. *
|
||||
****************************/
|
||||
|
||||
typedef struct asn_OCTET_STRING_specifics_s {
|
||||
typedef const struct asn_OCTET_STRING_specifics_s {
|
||||
/*
|
||||
* Target structure description.
|
||||
*/
|
||||
|
||||
@@ -190,7 +190,7 @@ CHOICE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
|
||||
do {
|
||||
const asn_TYPE_tag2member_t *t2m;
|
||||
asn_TYPE_tag2member_t key;
|
||||
struct asn_TYPE_tag2member_s key;
|
||||
|
||||
key.el_tag = tlv_tag;
|
||||
t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct asn_CHOICE_specifics_s {
|
||||
typedef const struct asn_CHOICE_specifics_s {
|
||||
/*
|
||||
* Target structure description.
|
||||
*/
|
||||
|
||||
@@ -304,7 +304,7 @@ SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
* sorted array of tags.
|
||||
*/
|
||||
const asn_TYPE_tag2member_t *t2m;
|
||||
asn_TYPE_tag2member_t key = {0, 0, 0, 0};
|
||||
struct asn_TYPE_tag2member_s key = {0, 0, 0, 0};
|
||||
key.el_tag = tlv_tag;
|
||||
key.el_no = edx;
|
||||
t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct asn_SEQUENCE_specifics_s {
|
||||
typedef const struct asn_SEQUENCE_specifics_s {
|
||||
/*
|
||||
* Target structure description.
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct asn_SET_specifics_s {
|
||||
typedef const struct asn_SET_specifics_s {
|
||||
/*
|
||||
* Target structure description.
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct asn_SET_OF_specifics_s {
|
||||
typedef const struct asn_SET_OF_specifics_s {
|
||||
/*
|
||||
* Target structure description.
|
||||
*/
|
||||
|
||||
@@ -141,7 +141,7 @@ typedef asn_type_selector_result_t(asn_type_selector_f)(
|
||||
* Generalized functions for dealing with the speciic type.
|
||||
* May be directly invoked by applications.
|
||||
*/
|
||||
typedef struct asn_TYPE_operation_s {
|
||||
typedef const struct asn_TYPE_operation_s {
|
||||
asn_struct_free_f *free_struct; /* Free the structure */
|
||||
asn_struct_print_f *print_struct; /* Human readable output */
|
||||
asn_struct_compare_f *compare_struct; /* Compare two structures */
|
||||
@@ -169,7 +169,7 @@ typedef struct asn_encoding_constraints_s {
|
||||
/*
|
||||
* The definitive description of the destination language's structure.
|
||||
*/
|
||||
typedef struct asn_TYPE_descriptor_s {
|
||||
typedef const struct asn_TYPE_descriptor_s {
|
||||
const char *name; /* A name of the ASN.1 type. "" in some cases. */
|
||||
const char *xml_tag; /* Name used in XML tag */
|
||||
|
||||
@@ -177,7 +177,7 @@ typedef struct asn_TYPE_descriptor_s {
|
||||
* Generalized functions for dealing with the specific type.
|
||||
* May be directly invoked by applications.
|
||||
*/
|
||||
asn_TYPE_operation_t *op;
|
||||
const asn_TYPE_operation_t *op;
|
||||
|
||||
/***********************************************************************
|
||||
* Internally useful members. Not to be used by applications directly. *
|
||||
@@ -197,7 +197,7 @@ typedef struct asn_TYPE_descriptor_s {
|
||||
/*
|
||||
* An ASN.1 production type members (members of SEQUENCE, SET, CHOICE).
|
||||
*/
|
||||
struct asn_TYPE_member_s *elements;
|
||||
const struct asn_TYPE_member_s *elements;
|
||||
unsigned elements_count;
|
||||
|
||||
/*
|
||||
@@ -217,13 +217,13 @@ typedef struct asn_TYPE_descriptor_s {
|
||||
ATF_OPEN_TYPE = 0x02, /* Open Type */
|
||||
ATF_ANY_TYPE = 0x04 /* ANY type (deprecated!) */
|
||||
};
|
||||
typedef struct asn_TYPE_member_s {
|
||||
typedef const struct asn_TYPE_member_s {
|
||||
enum asn_TYPE_flags_e flags; /* Element's presentation flags */
|
||||
unsigned optional; /* Following optional members, including current */
|
||||
unsigned memb_offset; /* Offset of the element */
|
||||
ber_tlv_tag_t tag; /* Outmost (most immediate) tag */
|
||||
int tag_mode; /* IMPLICIT/no/EXPLICIT tag at current level */
|
||||
asn_TYPE_descriptor_t *type; /* Member type descriptor */
|
||||
const asn_TYPE_descriptor_t *type; /* Member type descriptor */
|
||||
asn_type_selector_f *type_selector; /* IoS runtime type selector */
|
||||
asn_encoding_constraints_t encoding_constraints;
|
||||
int (*default_value_cmp)(const void *sptr); /* Compare DEFAULT <value> */
|
||||
@@ -234,7 +234,7 @@ typedef struct asn_TYPE_member_s {
|
||||
/*
|
||||
* BER tag to element number mapping.
|
||||
*/
|
||||
typedef struct asn_TYPE_tag2member_s {
|
||||
typedef const struct asn_TYPE_tag2member_s {
|
||||
ber_tlv_tag_t el_tag; /* Outmost tag of the member */
|
||||
unsigned el_no; /* Index of the associated member, base 0 */
|
||||
int toff_first; /* First occurence of the el_tag, relative */
|
||||
|
||||
@@ -265,8 +265,8 @@ uper_open_type_get(const asn_codec_ctx_t *ctx, const asn_TYPE_descriptor_t *td,
|
||||
|
||||
int
|
||||
uper_open_type_skip(const asn_codec_ctx_t *ctx, asn_per_data_t *pd) {
|
||||
asn_TYPE_descriptor_t s_td;
|
||||
asn_TYPE_operation_t s_op;
|
||||
struct asn_TYPE_descriptor_s s_td = {0};
|
||||
struct asn_TYPE_operation_s s_op = {0};
|
||||
asn_dec_rval_t rv;
|
||||
|
||||
s_td.name = "<unknown extension>";
|
||||
|
||||
@@ -15,7 +15,7 @@ extern "C" {
|
||||
/*
|
||||
* Pre-computed PER constraints.
|
||||
*/
|
||||
typedef struct asn_per_constraint_s {
|
||||
typedef const struct asn_per_constraint_s {
|
||||
enum asn_per_constraint_flags {
|
||||
APC_UNCONSTRAINED = 0x0, /* No PER visible constraints */
|
||||
APC_SEMI_CONSTRAINED = 0x1, /* Constrained at "lb" */
|
||||
@@ -27,7 +27,7 @@ typedef struct asn_per_constraint_s {
|
||||
long lower_bound; /* "lb" value */
|
||||
long upper_bound; /* "ub" value */
|
||||
} asn_per_constraint_t;
|
||||
typedef struct asn_per_constraints_s {
|
||||
typedef const struct asn_per_constraints_s {
|
||||
asn_per_constraint_t value;
|
||||
asn_per_constraint_t size;
|
||||
int (*value2code)(unsigned int value);
|
||||
|
||||
@@ -908,7 +908,8 @@ bool seader_parse_version(Seader* seader, uint8_t* buf, size_t size) {
|
||||
#endif
|
||||
if(version.version.size == 2) {
|
||||
memcpy(seader->sam_version, version.version.buf, version.version.size);
|
||||
SEADER_VERBOSE_I(TAG, "SAM Version: %d.%d", seader->sam_version[0], seader->sam_version[1]);
|
||||
SEADER_VERBOSE_I(
|
||||
TAG, "SAM Version: %d.%d", seader->sam_version[0], seader->sam_version[1]);
|
||||
}
|
||||
|
||||
rtn = true;
|
||||
@@ -1588,7 +1589,8 @@ void seader_mfc_transmit(
|
||||
|
||||
void seader_parse_nfc_command_transmit(Seader* seader, NFCSend_t* nfcSend) {
|
||||
#ifdef ASN1_DEBUG
|
||||
SEADER_VERBOSE_HEX(FuriLogLevelDebug, TAG, "Transmit data", nfcSend->data.buf, nfcSend->data.size);
|
||||
SEADER_VERBOSE_HEX(
|
||||
FuriLogLevelDebug, TAG, "Transmit data", nfcSend->data.buf, nfcSend->data.size);
|
||||
#endif
|
||||
|
||||
PluginHfAction action = {
|
||||
@@ -1829,7 +1831,8 @@ NfcCommand seader_worker_card_detect(
|
||||
SeaderCredential* credential = seader->credential;
|
||||
|
||||
CardDetails_t cardDetails = {0};
|
||||
SEADER_VERBOSE_D(TAG, "Build card_detect sak=%02x uid_len=%u ats_len=%u", sak, uid_len, ats_len);
|
||||
SEADER_VERBOSE_D(
|
||||
TAG, "Build card_detect sak=%02x uid_len=%u ats_len=%u", sak, uid_len, ats_len);
|
||||
|
||||
/* The UID is reused as the current diversifier seed for formats that need one. This is
|
||||
not universal across all media, but it is the intentional behavior for the cards Seader
|
||||
|
||||
@@ -26,9 +26,7 @@ static void seader_scene_start_begin_detection(Seader* seader) {
|
||||
seader);
|
||||
}
|
||||
|
||||
static void seader_scene_start_finish_board_auto_recover(
|
||||
Seader* seader,
|
||||
bool preserve_read_type) {
|
||||
static void seader_scene_start_finish_board_auto_recover(Seader* seader, bool preserve_read_type) {
|
||||
if(!seader) {
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-1
@@ -557,7 +557,8 @@ void seader_worker_reading(Seader* seader) {
|
||||
seader->hf_read_failure_reason = SeaderHfReadFailureReasonNone;
|
||||
seader->hf_read_last_progress_tick = 0U;
|
||||
}
|
||||
SEADER_VERBOSE_D(TAG, "HF loop selected type=%d stage=%d", type_to_read, seader_worker->stage);
|
||||
SEADER_VERBOSE_D(
|
||||
TAG, "HF loop selected type=%d stage=%d", type_to_read, seader_worker->stage);
|
||||
|
||||
if(type_to_read == SeaderCredentialTypeNone) {
|
||||
SeaderCredentialType detected_types[SEADER_MAX_DETECTED_CARD_TYPES] = {0};
|
||||
|
||||
+10
-10
@@ -29,20 +29,20 @@ void seader_verbose_hex(
|
||||
seader_verbose_hex(level, tag, prefix, data, len)
|
||||
#else
|
||||
#define SEADER_VERBOSE_D(tag, format, ...) \
|
||||
do { \
|
||||
(void)(tag); \
|
||||
do { \
|
||||
(void)(tag); \
|
||||
} while(0)
|
||||
#define SEADER_VERBOSE_I(tag, format, ...) \
|
||||
do { \
|
||||
(void)(tag); \
|
||||
do { \
|
||||
(void)(tag); \
|
||||
} while(0)
|
||||
#define SEADER_VERBOSE_HEX(level, tag, prefix, data, len) \
|
||||
do { \
|
||||
(void)(level); \
|
||||
(void)(tag); \
|
||||
(void)(prefix); \
|
||||
(void)(data); \
|
||||
(void)(len); \
|
||||
do { \
|
||||
(void)(level); \
|
||||
(void)(tag); \
|
||||
(void)(prefix); \
|
||||
(void)(data); \
|
||||
(void)(len); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user