PreIssuance.js

Summary

Pre Issuance Functions


Class Summary
PreIssuance  

/**
 *  ---------
 * |.##> <##.|  SmartCard-HSM Support Scripts
 * |#       #|
 * |#       #|  Copyright (c) 2011-2024 CardContact Systems GmbH
 * |'##> <##'|  32429 Minden, Germany (www.cardcontact.de)
 *  ---------
 *
 * Consult your license package for usage terms and conditions.
 *
 * @fileoverview Pre Issuance Functions
 */


load("keys.js");


function PreIssuance(job) {
	this.job = job;
	this.customerkeys = CustomerKeys;

	this.aid = new ByteString("A000000151000000", HEX);

	this.af = new ApplicationFactory(new Crypto());
	this.af.addApplicationProfile("profiles/ap_jcop_cardmanager_kst.xml");
}

exports.PreIssuance = PreIssuance;

PreIssuance.type = "initializer";



PreIssuance.prototype.configure = function() {
}



PreIssuance.prototype.handleCard = function(card) {
	card.reset(Card.RESET_COLD);

	var data = {
	};

	var dm = {
		get: function(name, fixed, length, encoding) {
			if (typeof(data[name]) == "undefined") {
				return null;
			}

			return data[name];
		}
	}

	var appl = this.af.getApplicationInstance(dm, this.aid, card, this.job.Profile);

	for (var i = 0; i < this.job.Steps.length; i++) {
		appl.key = this.keys;
		appl.run(this.job.Steps[i]);
	}

	return "OK";
}



PreIssuance.prototype.addKey = function(name, value) {
	var key = new Key();
	key.setComponent(Key.DES, value);
	this.keys[name] = key;
}



PreIssuance.prototype.configure = function() {
	this.keys = [];
	var a = new ASN1(this.customerkeys[this.job.Keys].KST);
	this.addKey("K_ENC", a.get(0).value);
	this.addKey("K_MAC", a.get(1).value);
	this.addKey("K_DEK", a.get(2).value);

	if (typeof(this.customerkeys[this.job.Keys].NewKST)) {
		var a = new ASN1(this.customerkeys[this.job.Keys].NewKST);
		this.addKey("K_SENC", a.get(0).value);
		this.addKey("K_SMAC", a.get(1).value);
		this.addKey("K_SDEK", a.get(2).value);
	}
}


Documentation generated by JSDoc on Thu Apr 3 11:32:15 2025