Esempio n. 1
0
int main(void) {
	printf("Testsystem for %s\n", pi_cipher_name); fflush(NULL);

#if PI_SIZE == 16
	size_t key_sizes[] = { 96, 128 };
	size_t npub_sizes[] = { 4 };
#elif PI_SIZE == 32
	size_t key_sizes[] = { 128, 256 };
	size_t npub_sizes[] = { 16 };
#elif PI_SIZE == 64
	size_t key_sizes[] = { 128, 256 };
	size_t npub_sizes[] = { 16 };
#else
#error
#endif

	int i, j;
	char fname[128];
	for (i = 0; i < NUMOF(key_sizes); ++i) {
		for (j = 0; j < NUMOF(npub_sizes); ++j) {
			snprintf(fname, sizeof(fname), "testvectors/%s%03zuv2_%zu.test-vectors", pi_cipher_name, key_sizes[i], npub_sizes[j]);
			freopen(fname, "w", stdout);
			printf("# Testvectors for %s\n", pi_cipher_name);
			printf("#   key size: %zu bits\n", key_sizes[i]);
			printf("#   nonce size: %zu bits\n\n", npub_sizes[j] * 8);
			generate_testvectors(key_sizes[i] / 8, npub_sizes[j]);
			fclose(stdout);
		}
	}

}
Esempio n. 2
0
static void
cyg_hal_plf_serial_init(void)
{
    hal_virtual_comm_table_t* comm;
    int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
    int i;

    // Init channels
#define NUMOF(x) (sizeof(x)/sizeof(x[0]))
    for (i = 0;  i < NUMOF(ser_channels);  i++) {
        init_channel(&ser_channels[i]);
        CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
        comm = CYGACC_CALL_IF_CONSOLE_PROCS();
        CYGACC_COMM_IF_CH_DATA_SET(*comm, &ser_channels[i]);
        CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_plf_serial_write);
        CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_plf_serial_read);
        CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_plf_serial_putc);
        CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_plf_serial_getc);
        CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_plf_serial_control);
        CYGACC_COMM_IF_DBG_ISR_SET(*comm, cyg_hal_plf_serial_isr);
        CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_serial_getc_timeout);
    }
     
    // Restore original console
    CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
}
Esempio n. 3
0
/*
 * Private version of SendCustMsg().
 */
static char *
sendMsg(
	int msgNum,	/* Message catalog number. */
	char *msg)
{
	static struct {
		char *name;
		int priority;
	} SyslogPriorities[] = {
		{ "info", LOG_INFO },
		{ "Emerg", LOG_EMERG },
		{ "alert", LOG_ALERT },
		{ "crit", LOG_CRIT },
		{ "err", LOG_ERR },
		{ "warning", LOG_WARNING },
		{ "notice", LOG_NOTICE },
		{ "debug", LOG_DEBUG },
	};
	boolean_t tonotifyFunc;
	boolean_t toSyslog;
	boolean_t toeventFunc;
	char *eventClass = (char *)NULL;
	char *eventSubclass = (char *)NULL;

	int priority;

	tonotifyFunc = FALSE;
	toSyslog = FALSE;
	toeventFunc = FALSE;
	priority = 0;

	/*
	 * Extract destination and priority.
	 */
	if (*msg == '-') {
		msg++;
		toSyslog = FALSE;
		tonotifyFunc = FALSE;
		toeventFunc = FALSE;
		while (*msg != '\0' && !(isspace(*msg))) {
			if (*msg == 'S') {
				toSyslog = TRUE;
			} else if (*msg == 'N') {
				tonotifyFunc = TRUE;
			} else if (*msg == 'V') {
				toeventFunc = TRUE;
			} else if (*msg == '[') {
				eventClass = ++msg;
				while ((*msg != ':') && (*msg != '\0')) {
					msg++;
				}
				if (*msg != '\0') {
					*msg = '\0';
					eventSubclass = ++msg;
					while ((*msg != ']') &&
					    (*msg != '\0')) {
						msg++;
					}
					if (*msg != '\0') {
						*msg = '\0';
					} else {
						continue;
					}
				} else {
					continue;
				}
			} else {
				int		i;

				for (i = 0; i < NUMOF(SyslogPriorities); i++) {
					if (*SyslogPriorities[i].name == *msg) {
						priority = i;
						break;
					}
				}
			}
			msg++;
		}
		while (isspace(*msg)) {
			msg++;
		}
	}
	if (toeventFunc) {
		(void) PostEvent(eventClass, eventSubclass, msgNum,
		    SyslogPriorities[priority].priority, msg,
		    NOTIFY_AS_FAULT | NOTIFY_AS_TRAP);
	}

	/*
	 * No logging setup.
	 */
	if (logMode == 0) {
		fprintf(stderr, "%s\n", msg);
		return (msg);
	}

	if (toSyslog == FALSE && tonotifyFunc == FALSE &&
	    toeventFunc == FALSE) {
		toSyslog = TRUE;
	}
#if defined(TEST)
	printf("*** %c%c%c %s %d %s %s %s\n", (toSyslog) ? 'S' : '-',
	    (tonotifyFunc) ? 'N' : '-', (toeventFunc) ? 'V' : '-',
	    SyslogPriorities[priority].name,
	    SyslogPriorities[priority].priority,
	    (eventClass) ? eventClass : "-",
	    (eventSubclass) ? eventSubclass : "-", msg);
#else	/* defined(TEST)	*/
	if (toSyslog) {
		sam_syslog(SyslogPriorities[priority].priority, "%s %s\n",
		    SyslogPriorities[priority].name, msg);
	}
#endif	/* defined(TEST)	*/


	if (tonotifyFunc && notifyFunc != NULL) {
		notifyFunc(SyslogPriorities[priority].priority,
		    msgNum, msg);
	}

	return (msg);
}