[Assignment-7] add embedded_device_syntax; add .h

This commit is contained in:
Sascha Tommasone 2024-07-06 17:50:09 +02:00
parent f007db4867
commit 343620a870
Signed by: saschato
GPG key ID: 751068A86FCAA217
2 changed files with 13 additions and 2 deletions

View file

@ -21,6 +21,13 @@ typedef struct {
uint8_t *public_key_path;
} 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) {
if(public_key_file == NULL) {
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);
}
int main(int argc, char **argv) {
int handle_embedded_device(int argc, char **argv) {
embedded_device_args args = {
.firmware_path = NULL,
.public_key_path = NULL
@ -71,7 +78,7 @@ int main(int argc, char **argv) {
}
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];
} else if((strcmp(argv[i], "-firm") == 0) && (argc - i >= 2)) {
args.firmware_path = argv[i+1];

View file

@ -3,4 +3,8 @@
#include <stdint.h>
char *embedded_device_syntax(void);
int handle_embedded_device(int argc, char **argv);
#endif