1 /** 2 * --------- 3 * |.##> <##.| Open Smart Card Development Platform (www.openscdp.org) 4 * |# #| 5 * |# #| Copyright (c) 1999-2018 CardContact Software & System Consulting 6 * |'##> <##'| Andreas Schwier, 32429 Minden, Germany (www.cardcontact.de) 7 * --------- 8 * 9 * This file is part of OpenSCDP. 10 * 11 * OpenSCDP is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License version 2 as 13 * published by the Free Software Foundation. 14 * 15 * OpenSCDP is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with OpenSCDP; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 * 24 * @fileoverview SignatureKey - Object storing information related to PrK.QES 25 */ 26 27 var FileSystemIdObject = require('scsh/cardsim/FileSystemIdObject').FileSystemIdObject; 28 var APDU = require('scsh/cardsim/APDU').APDU; 29 30 31 32 /** 33 * Create a signature key object 34 * 35 * @class Class implementing signature keys 36 * 37 * @param {String} name the human readable name of the object 38 * @param {Number} id the key id 39 */ 40 function SignatureKey(name, id) { 41 FileSystemIdObject.call(this, name, id); 42 this.isTerminated = true; // State after TERMINATE 43 this.allowTerminate = true; 44 } 45 46 SignatureKey.prototype = new FileSystemIdObject(); 47 SignatureKey.prototype.constructor = SignatureKey; 48 49 exports.SignatureKey = SignatureKey; 50 51 52 SignatureKey.TYPE_KEY = "signaturekey"; 53 54 55 56 /** 57 * Override from base class 58 */ 59 SignatureKey.prototype.getType = function() { 60 return SignatureKey.TYPE_KEY = "signaturekey"; 61 } 62 63 64 65 /** 66 * Terminate authentication object 67 */ 68 SignatureKey.prototype.terminate = function() { 69 if (!this.allowTerminate) { 70 throw new GPError("SignatureKey", GPError.INVALID_DATA, APDU.SW_CONDOFUSENOTSAT, "Terminate not allowed for signature key"); 71 } 72 this.isTerminated = true; 73 } 74 75 76 77 /** 78 * Convert object to a human readable string 79 */ 80 SignatureKey.prototype.toString = function() { 81 return this.name + (this.isTerminated ? " terminated" : " active"); 82 } 83 84 85