summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/img3.c22
-rw-r--r--src/img3.h4
2 files changed, 25 insertions, 1 deletions
diff --git a/src/img3.c b/src/img3.c
index 902bea4..1969ece 100644
--- a/src/img3.c
+++ b/src/img3.c
@@ -155,6 +155,16 @@ img3_file* img3_parse_file(char* data, int size) {
debug("Parsed CERT element\n");
break;
+ case kUnknElement:
+ image->unkn_element = img3_parse_element(&data[data_offset]);
+ if (image->unkn_element == NULL) {
+ error("ERROR: Unable to parse UNKN element\n");
+ img3_free(image);
+ return NULL;
+ }
+ debug("Parsed UNKN element\n");
+ break;
+
default:
error("ERROR: Unknown IMG3 element type\n");
img3_free(image);
@@ -244,6 +254,11 @@ void img3_free(img3_file* image) {
image->cert_element = NULL;
}
+ if (image->unkn_element != NULL) {
+ img3_free_element(image->unkn_element);
+ image->unkn_element = NULL;
+ }
+
free(image);
image = NULL;
}
@@ -336,6 +351,9 @@ int img3_get_data(img3_file* image, char** pdata, int* psize) {
if (image->cert_element != NULL) {
size += image->cert_element->header->full_size;
}
+ if (image->unkn_element != NULL) {
+ size += image->unkn_element->header->full_size;
+ }
char* data = (char*) malloc(size);
if (data == NULL) {
@@ -393,6 +411,10 @@ int img3_get_data(img3_file* image, char** pdata, int* psize) {
memcpy(&data[offset], image->cert_element->data, image->cert_element->header->full_size);
offset += image->cert_element->header->full_size;
}
+ if (image->unkn_element != NULL) {
+ memcpy(&data[offset], image->unkn_element->data, image->unkn_element->header->full_size);
+ offset += image->unkn_element->header->full_size;
+ }
if (offset != size) {
error("ERROR: Incorrectly sized image data\n");
diff --git a/src/img3.h b/src/img3.h
index 796a8e1..cb042b5 100644
--- a/src/img3.h
+++ b/src/img3.h
@@ -45,7 +45,8 @@ typedef enum {
kVersElement = 0x56455253, // VERS
kBordElement = 0x424F5244, // BORD
kSepoElement = 0x5345504F, // SEPO
- kEcidElement = 0x45434944 // ECID
+ kEcidElement = 0x45434944, // ECID
+ kUnknElement = 0x53414c54 // FIXME
} img3_element_type;
typedef struct {
@@ -81,6 +82,7 @@ typedef struct {
img3_element* ecid_element;
img3_element* shsh_element;
img3_element* cert_element;
+ img3_element* unkn_element;
} img3_file;
void img3_free(img3_file* image);