コード例 #1
0
ファイル: jwt_wrap.c プロジェクト: memre/jose-c
int
main (int argc, char **argv)
{
  struct arguments arguments;
  int rc = -1;
  char *jwt;

  /* Default values. */
  arguments.silent = 0;
  arguments.verbose = 0;
  arguments.hardware = 0;
  arguments.input_file = stdin;
  arguments.display = "sexp";
  arguments.alg = NONE;
  key_f = NULL;

  /* Parse our arguments; every option seen by parse_opt will
     be reflected in arguments. */
  argp_parse (&argp, argc, argv, 0, 0, &arguments);

  lca_init();

  if (!arguments.hardware)
      jwt = f2jwt (arguments.input_file, arguments.alg, soft_sign);

  if (NULL == jwt)
      return -3;
  else
      printf ("%s\n", jwt);

  exit (rc);
}
コード例 #2
0
static struct lca_config *
lca_preinit()
{
	extern struct lca_config lca_configuration;

	lca_init(&lca_configuration, 0);
	return &lca_configuration;
}
コード例 #3
0
void
lcaattach(device_t parent, device_t self, void *aux)
{
	struct lca_softc *sc = device_private(self);
	struct lca_config *lcp;
	struct pcibus_attach_args pba;

	/* note that we've attached the chipset; can't have 2 LCAs. */
	/* Um, not sure about this.  XXX JH */
	lcafound = 1;
	sc->sc_dev = self;

	/*
	 * set up the chipset's info; done once at console init time
	 * (maybe), but we must do it twice to take care of things
	 * that need to use memory allocation.
	 */
	lcp = sc->sc_lcp = &lca_configuration;
	lca_init(lcp, 1);

	/* XXX print chipset information */
	aprint_normal("\n");

	lca_dma_init(lcp);

	switch (cputype) {
#ifdef DEC_AXPPCI_33
	case ST_DEC_AXPPCI_33:
		pci_axppci_33_pickintr(lcp);
		break;
#endif
#ifdef DEC_ALPHABOOK1
	case ST_ALPHABOOK1:
		pci_alphabook1_pickintr(lcp);
		break;
#endif
#ifdef DEC_EB66
	case ST_EB66:
		pci_eb66_pickintr(lcp);
		break;
#endif

	default:
		panic("lcaattach: shouldn't be here, really...");
	}

	pba.pba_iot = &lcp->lc_iot;
	pba.pba_memt = &lcp->lc_memt;
	pba.pba_dmat =
	    alphabus_dma_get_tag(&lcp->lc_dmat_direct, ALPHA_BUS_PCI);
	pba.pba_dmat64 = NULL;
	pba.pba_pc = &lcp->lc_pc;
	pba.pba_bus = 0;
	pba.pba_bridgetag = NULL;
	pba.pba_flags = PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY |
	    PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
	config_found_ia(self, "pcibus", &pba, pcibusprint);
}
コード例 #4
0
ファイル: handshake.c プロジェクト: memre/jose-c
int main(void)
{


    json_t *jwk;
    struct MemoryStruct res;
    struct timeval tval_before, tval_after, tval_result;

    lca_init();

    int fd = start();

    if (lca_load_signing_key ("test_keys/atmel.key", &signing_key))
        return -1;

    jwk = gcry_pubkey2jwk (&signing_key);

    assert (NULL != jwk);

    json_dumpf (jwk, stdout, 0);


    char *m1 = build_key_post (jwk);

    printf ("Post key: %s\n", m1);

    char *b = combine (postkey, m1);
    char *c = combine (getkey, m1);

    /* char *b = malloc (strlen(m1) + strlen(postkey) + 1); */
    /* memset (b, 0, strlen(m1) + strlen(postkey) + 1); */

    /* printf ("here"); */

    /* strcpy (b, postkey); */
    /* strcat (postkey, m1); */



  curl_global_init(CURL_GLOBAL_ALL);


  res = get (b);

  free (res.memory);

  res = get (c);

  json_t *dm_key = get_dm_key (res.memory);

  free (res.memory);

  char *hello = build_hello (sub);

  gettimeofday(&tval_before, NULL);

  char *d = combine (posthello, hello);

  res = get (d);

  json_t *hello_rsp = verify_hello (res.memory, dm_key);
  free (res.memory);

  char *done = build_hello_rsp (sub, hello_rsp);
  char *e = combine (postdone, done);

  res = get (e);

  json_t *done_rsp = verify_done (res.memory, dm_key);
  free (res.memory);

  gettimeofday(&tval_after, NULL);

  free (e);
  free (d);
  free (b);
  free (c);
  /* we're done with libcurl, so clean it up */
  curl_global_cleanup();

  timersub(&tval_after, &tval_before, &tval_result);

  printf("Time elapsed: %ld.%06ld\n", (long int)tval_result.tv_sec, (long int)tval_result.tv_usec);

  return 0;

}
コード例 #5
0
ファイル: dec_eb66.c プロジェクト: lacombar/netbsd-alc
static void
dec_eb66_cons_init()
{
	struct ctb *ctb;
	struct lca_config *lcp;
	extern struct lca_config lca_configuration;

	lcp = &lca_configuration;
	lca_init(lcp, 0);

	ctb = (struct ctb *)(((char *)hwrpb) + hwrpb->rpb_ctb_off);

	switch (ctb->ctb_term_type) {
	case CTB_PRINTERPORT: 
		/* serial console ... */
		/* XXX */
		{
			/*
			 * Delay to allow PROM putchars to complete.
			 * FIFO depth * character time,
			 * character time = (1000000 / (defaultrate / 10))
			 */
			DELAY(160000000 / comcnrate);

			if(comcnattach(&lcp->lc_iot, 0x3f8, comcnrate,
			    COM_FREQ, COM_TYPE_NORMAL,
			    (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
				panic("can't init serial console");

			break;
		}

	case CTB_GRAPHICS:
#if NPCKBD > 0
		/* display console ... */
		/* XXX */
		(void) pckbc_cnattach(&lcp->lc_iot, IO_KBD, KBCMDP,
		    PCKBC_KBD_SLOT);

		if (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) ==
		    CTB_TURBOSLOT_TYPE_ISA)
			isa_display_console(&lcp->lc_iot, &lcp->lc_memt);
		else
			pci_display_console(&lcp->lc_iot, &lcp->lc_memt,
			    &lcp->lc_pc, CTB_TURBOSLOT_BUS(ctb->ctb_turboslot),
			    CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0);
#else
		panic("not configured to use display && keyboard console");
#endif
		break;

	default:
		printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
		printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);

		panic("consinit: unknown console type %ld",
		    ctb->ctb_term_type);
	}
#ifdef KGDB
	/* Attach the KGDB device. */
	alpha_kgdb_init(kgdb_devlist, &lcp->lc_iot);
#endif /* KGDB */
}