RDK Documentation (Open Sourced RDK Components)
main.c
1 #include "rdm_rsa_signature_verify.h"
2 
3 void usage(void)
4 {
5  printf("Usage:\n");
6  printf(" f <filename>\n");
7  printf(" s <signature file> [PEM format]\n");
8  printf(" k <public key file>\n");
9  exit (1);
10 }
11 
12 int main(int argc, char *argv[])
13 {
14  int status = 0, opt = 0;
15  int outputMsgLen=REPLY_MSG_LEN;
16  char outputMsg[REPLY_MSG_LEN] = "no response received";
17  char *dataFile=NULL, *sigFile=NULL, *keyFile=NULL;
18 
19  debug_print("Program name: %s\n", argv[0]);
20 
21  /* Initialize the openSSL crypto library and configurations */
22  init_ssl_lib();
23  while ((opt = getopt(argc, argv, "f:s:k:")) != -1) {
24  switch(opt) {
25  case 'f':
26  dataFile = optarg;
27  printf("Input option value=%s\n", dataFile);
28  break;
29  case 's':
30  sigFile = optarg;
31  printf("Output option value=%s\n", sigFile);
32  break;
33  case 'k':
34  keyFile = optarg;
35  printf("Output option value=%s\n", keyFile);
36  break;
37  case '?':
38  if (optopt == 'f') {
39  printf("Missing mandatory Input File\n");
40  } else if (optopt == 's') {
41  printf("Missing mandatory Signature File\n");
42  } else if (optopt == 'k') {
43  printf("Missing mandatory Key File\n");
44  } else {
45  printf("Invalid option received\n");
46  }
47  usage();
48  break;
49  }
50  }
51  if ( dataFile == NULL || sigFile == NULL || keyFile == NULL ) {
52  usage();
53  exit(1);
54  }
55 
56  status = rdm_openssl_rsa_file_signature_verify( dataFile, -1, sigFile,
57  keyFile, outputMsg, &outputMsgLen );
58  debug_print("rdm_openssl_rsa_file_signature_verify returns: %s\n",outputMsg);
59  if ( status == retcode_success ) {
60  printf("RSA Signature Validation Success\n");
61  } else {
62  printf("RSA Signature Verification Failed\n");
63  }
64  return status;
65 }
REPLY_MSG_LEN
#define REPLY_MSG_LEN
Definition: rdm_rsa_signature_verify.h:83
retcode_success
#define retcode_success
Definition: rdm_rsa_signature_verify.h:64
init_ssl_lib
void init_ssl_lib(void)
This function initializes the openSSL crypto library and configurations.
Definition: rdm_rsa_signature_verify.c:356
debug_print
#define debug_print(fmt, args...)
Definition: rdm_rsa_signature_verify.h:76
rdm_openssl_rsa_file_signature_verify
int rdm_openssl_rsa_file_signature_verify(const char *data_file, size_t file_len, const char *sig_file, const char *vkey_file, char *reply_msg, int *reply_msg_len)
This function is used for a signature validation of the package.
Definition: rdm_rsa_signature_verify.c:836