コード例 #1
0
ファイル: olsrd_secure.c プロジェクト: TKr/Wive-ng-rt8186
int
secure_plugin_init(void)
{
  int i;


  /* Initialize the timestamp database */
  for(i = 0; i < HASHSIZE; i++)
    {
      timestamps[i].next = &timestamps[i];
      timestamps[i].prev = &timestamps[i];
    }
  olsr_printf(1, "Timestamp database initialized\n");

  if(!strlen(keyfile))
    strscpy(keyfile, KEYFILE, sizeof(keyfile));

  i = read_key_from_file(keyfile);

  if(i < 0)
    {
      olsr_printf(1, "[ENC]Could not read key from file %s!\nExitting!\n\n", keyfile);
      exit(1);
    }
  if(i == 0)
    {
      olsr_printf(1, "[ENC]There was a problem reading key from file %s. Is the key long enough?\nExitting!\n\n", keyfile);
      exit(1);
    }

  /* Register the packet transform function */
  add_ptf(&add_signature);

  olsr_preprocessor_add_function(&secure_preprocessor);
  
  /* Register timeout - poll every 2 seconds */
  olsr_start_timer(2 * MSEC_PER_SEC, 0, OLSR_TIMER_PERIODIC,
                   &timeout_timestamps, NULL, 0);


  return 1;
}
コード例 #2
0
ファイル: main.c プロジェクト: pascalbertrand/aes
static inline void  set_configuration(config *cfg, int argc, char *argv[]) {
    fail_if_bad_usage(argc);
    fail_if_bad_command(cfg, argv[1]);
    read_key_from_file(cfg, argv[2]);
}