[Assignment-7] add embedded_device_syntax; add .h
This commit is contained in:
parent
f007db4867
commit
343620a870
2 changed files with 13 additions and 2 deletions
|
@ -21,6 +21,13 @@ typedef struct {
|
||||||
uint8_t *public_key_path;
|
uint8_t *public_key_path;
|
||||||
} embedded_device_args;
|
} embedded_device_args;
|
||||||
|
|
||||||
|
char *embedded_device_syntax(void) {
|
||||||
|
return
|
||||||
|
"embedded device (sim) mock up implementation of a embedded device\n"
|
||||||
|
" -ppub <path> file path of the PEM encoded public key of the proxy\n"
|
||||||
|
" -firm <path> path of to firmware binary\n";
|
||||||
|
}
|
||||||
|
|
||||||
static EVP_PKEY *read_public_key(uint8_t *public_key_file_path, EVP_PKEY **key) {
|
static EVP_PKEY *read_public_key(uint8_t *public_key_file_path, EVP_PKEY **key) {
|
||||||
if(public_key_file == NULL) {
|
if(public_key_file == NULL) {
|
||||||
fprintf(stderr, "public_key_file_path is a null pointer!\n");
|
fprintf(stderr, "public_key_file_path is a null pointer!\n");
|
||||||
|
@ -60,7 +67,7 @@ static void hash_firmware(uint8_t *firmware_path, EVP_MD_CTX **ctx) {
|
||||||
exit: fclose(fd);
|
exit: fclose(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int handle_embedded_device(int argc, char **argv) {
|
||||||
embedded_device_args args = {
|
embedded_device_args args = {
|
||||||
.firmware_path = NULL,
|
.firmware_path = NULL,
|
||||||
.public_key_path = NULL
|
.public_key_path = NULL
|
||||||
|
@ -71,7 +78,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 1; i < argc; i += 2) {
|
for(int i = 1; i < argc; i += 2) {
|
||||||
if((strcmp(argv[i], "-pub") == 0) && (argc - i >= 2)) {
|
if((strcmp(argv[i], "-ppub") == 0) && (argc - i >= 2)) {
|
||||||
args.public_key_path = argv[i+1];
|
args.public_key_path = argv[i+1];
|
||||||
} else if((strcmp(argv[i], "-firm") == 0) && (argc - i >= 2)) {
|
} else if((strcmp(argv[i], "-firm") == 0) && (argc - i >= 2)) {
|
||||||
args.firmware_path = argv[i+1];
|
args.firmware_path = argv[i+1];
|
||||||
|
|
|
@ -3,4 +3,8 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
char *embedded_device_syntax(void);
|
||||||
|
|
||||||
|
int handle_embedded_device(int argc, char **argv);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue