1 /** 2 * --------- 3 * |.##> <##.| Open Smart Card Development Platform (www.openscdp.org) 4 * |# #| 5 * |# #| Copyright (c) 2010 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 BlackListGenerator - Simple generator for black lists based on TR-03129, Version 1.0 25 */ 26 27 // Some constants for blacklist types 28 BlackListGenerator.COMPLETE_LIST = new ByteString("00", HEX); 29 BlackListGenerator.ADDED_LIST = new ByteString("01", HEX); 30 BlackListGenerator.REMOVED_LIST = new ByteString("02", HEX); 31 32 33 // Constructor 34 function BlackListGenerator() { 35 this.content = new ASN1("content", ASN1.SEQUENCE); 36 } 37 38 BlackListGenerator.prototype.reset = function() { 39 } 40 41 42 BlackListGenerator.prototype.setVersion = function(version) { 43 this.version = version; 44 } 45 46 47 BlackListGenerator.prototype.setType = function(type) { 48 this.type = type; 49 } 50 51 52 BlackListGenerator.prototype.setListID = function(listID) { 53 this.listID = listID; 54 } 55 56 57 BlackListGenerator.prototype.setDeltaBase = function(deltaBase) { 58 this.deltaBase = deltaBase; 59 } 60 61 BlackListGenerator.prototype.setDeltaBase = function(deltaBase) { 62 this.deltaBase = deltaBase; 63 } 64 65 BlackListGenerator.prototype.addBlackListDetails = function(sectorID, sectorSpecificIDs) { 66 67 // Create the details 68 var details = new ASN1("BlackListDetails", ASN1.SEQUENCE); 69 details.add(new ASN1("sectorID", ASN1.OCTET_STRING, new ByteString(sectorID, HEX))); 70 71 var ids = new ASN1("sectorSpecificIDs", ASN1.SEQUENCE); 72 73 for (var index in sectorSpecificIDs) { 74 var sectorSpecificID = sectorSpecificIDs[index]; 75 ids.add(new ASN1(ASN1.OCTET_STRING, sectorSpecificID)); 76 } 77 78 // Add the IDs to the details 79 details.add(ids); 80 81 // Add the details to the content 82 this.content.add(details); 83 } 84 85 BlackListGenerator.prototype.generateBlackList = function() { 86 87 // Create a black list 88 var bl = new ASN1(ASN1.SEQUENCE); 89 90 bl.add(new ASN1("version", ASN1.INTEGER, new ByteString(this.version, HEX))); 91 92 bl.add(new ASN1("type", ASN1.INTEGER, new ByteString(this.type, HEX))); 93 94 bl.add(new ASN1("listID", ASN1.OCTET_STRING, new ByteString(this.listID, HEX))); 95 96 if (typeof(this.deltaBase) != "undefined") { 97 bl.add(new ASN1("deltaBase", ASN1.OCTET_STRING, new ByteString(this.deltaBase, HEX))); 98 } 99 100 // Add the content to the list 101 bl.add(this.content); 102 103 return bl.getBytes(); 104 } 105