** +-----------------+
** | device tree | p pages
** +-----------------+
+** | signature | 256 bytes
+** +-----------------+
**
** n = (kernel_size + page_size - 1) / page_size
** m = (ramdisk_size + page_size - 1) / page_size
" [ --pagesize <pagesize> ]\n"
" [ --ramdisk_offset <address> ]\n"
" [ --dt <filename> ]\n"
+ " [ --signature <filename> ]\n"
" -o|--output <filename>\n"
);
return 1;
char *board = "";
char *dt_fn = 0;
void *dt_data = 0;
+ char *sig_fn = 0;
+ void *sig_data = 0;
unsigned pagesize = 2048;
int fd;
SHA_CTX ctx;
}
} else if(!strcmp(arg, "--dt")) {
dt_fn = val;
+ } else if(!strcmp(arg, "--signature")) {
+ sig_fn = val;
} else {
return usage();
}
}
}
+ if(sig_fn) {
+ sig_data = load_file(sig_fn, 0);
+ if (sig_data == 0) {
+ fprintf(stderr,"error: could not load signature '%s'\n", sig_fn);
+ return 1;
+ }
+ }
+
/* put a hash of the contents in the header so boot images can be
* differentiated based on their first 2k.
*/
if(write(fd, dt_data, hdr.dt_size) != hdr.dt_size) goto fail;
if(write_padding(fd, pagesize, hdr.dt_size)) goto fail;
}
+
+ if(sig_data) {
+ if(write(fd, sig_data, 256) != 256) goto fail;
+ }
+
return 0;
fail:
total_read += header.dt_size;
fwrite(dt, header.dt_size, 1, r);
fclose(d);
-
+
+ total_read += read_padding(f, header.dt_size, pagesize);
+
+ sprintf(tmp, "%s/%s", directory, basename(filename));
+ strcat(tmp, "-signature");
+ FILE *fsig = fopen(tmp, "wb");
+ byte* bsig = (byte*)malloc(256);
+ //printf("Reading signature...\n");
+ fread(bsig, 256, 1, f);
+ total_read += 256;
+ fwrite(bsig, 256, 1, r);
+ fclose(fsig);
+
fclose(f);
//printf("Total Read: %d\n", total_read);