renamed lua scripts. minor adaptations
This commit is contained in:
1 parent
d5e6464660
commit
778ede25e7
9 files changed
+68
-140
No files matched your search
@@ -107,6 +107,37 @@ int asn1_print(uint8_t *asn1buf, size_t asn1buflen, const char *indent) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int asn1_get_tag_length(const uint8_t *data, size_t *n, size_t *offset, size_t total_length) {
|
||||
|
||||
if (*offset >= total_length) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (data[*offset] & 0x80) {
|
||||
|
||||
// Long form: number of length bytes is indicated by the lower 7 bits
|
||||
size_t len_bytes = data[*offset] & 0x7F;
|
||||
|
||||
*offset += 1;
|
||||
|
||||
if (*offset + len_bytes > total_length) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*n = 0;
|
||||
for (size_t i = 0; i < len_bytes; i++) {
|
||||
*n = (*n << 8) | data[*offset];
|
||||
*offset += 1;
|
||||
}
|
||||
} else {
|
||||
// Short form: length is directly represented
|
||||
*n = data[*offset];
|
||||
*offset += 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char *hex;
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
int asn1_print(uint8_t *asn1buf, size_t asn1buflen, const char *indent);
|
||||
int ecdsa_asn1_get_signature(uint8_t *signature, size_t signaturelen, uint8_t *rval, uint8_t *sval);
|
||||
|
||||
int asn1_get_tag_length(const uint8_t *data, size_t *n, size_t *offset, size_t total_length);
|
||||
int asn1_selftest(void);
|
||||
|
||||
#endif /* asn1utils.h */
|
||||
Reference in new issue
Block a user