Example #1
0
int main(int argc, const char **argv) {

	EstEID_Certs *certs = EstEID_loadCerts(NULL);
	if (certs != NULL) {
		EstEID_printCerts(certs);
		while(1) {
			printf("tokensChanged: %i\n", EstEID_tokensChanged());
			getchar();
		}
		//EstEID_waitForSlotEvent();
		if (argc == 2) sign(argv[1], certs);
		EstEID_freeCerts(certs);
	}
	else {
		printf("error: %s (error code: %i)\n", EstEID_error, EstEID_errorCode);
	}
}
Example #2
0
EstEID_Certs *EstEID_loadCerts() {
	LOG_LOCATION;
	if (!EstEID_initializeCryptoki()) {
		EstEID_log("cryptoki initialization result forces to return NULL");
		return NULL;
	}
	if (certs && !EstEID_tokensChanged()){
		EstEID_log("tokens not changed, returning existing certs");
		return certs;
	}
	if (certs) EstEID_freeCerts();
	LOG_LOCATION;

	certs = (EstEID_Certs *)malloc(sizeof(EstEID_Certs));
	if (!EstEID_loadSlotIDs(certs)) return NULL;
	for (unsigned int i = 0; i < certs->count; i++) {
		if (!EstEID_loadCertInfo(certs, i)) return NULL;
		EstEID_log("slotID=%lu", certs->slotIDs[i]);
		EstEID_logMap(certs->certs[i]);
	}
	EstEID_log("returning %u fresh cert(s)", certs->count);
	return certs;
}