1 /**
  2  *  ---------
  3  * |.##> <##.|  Open Smart Card Development Platform (www.openscdp.org)
  4  * |#       #|  
  5  * |#       #|  Copyright (c) 1999-2009 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 Test document revocation crypto
 25  */
 26 
 27 var crypto = new Crypto();
 28 
 29 // Revocation key at CVCA
 30 // Generated at setup
 31 var prkRev = new Key("kp_prk_RevocationKey.xml");
 32 
 33 // Revocation key of document
 34 // Generated per document and send to CVCA
 35 var pukId = new Key("kp_puk_IDKey.xml");
 36 
 37 
 38 // Revocation ID calculated from pukRevId = 04 || prkRev * pukId
 39 // Calculated when document is revoked. Id is send to DV
 40 var inp = pukId.getComponent(Key.ECC_QX).concat(pukId.getComponent(Key.ECC_QY));
 41 var pukRevId = ByteString.valueOf(0x04).concat(crypto.decrypt(prkRev, Crypto.ECDHP, inp));
 42 print("Revocation ID                   : " + pukRevId);
 43 
 44 
 45 // Transformation at DV for each sector with Hash(X-coordinate(prkSector * pukRevId));
 46 var prkSector = new Key("kp_prk_SectorKey1.xml");
 47 var secrevid1 = crypto.digest(Crypto.SHA_256, crypto.decrypt(prkSector, Crypto.ECDH, pukRevId.bytes(1)));
 48 print("Sector Revocation ID at DV      : " + secrevid1);
 49 
 50 
 51 // Calculation of the sector revocation id in the document
 52 var prkId = new Key("kp_prk_IDKey.xml");
 53 var pukSector = new Key("kp_puk_SectorKey1.xml");
 54 var inp = pukSector.getComponent(Key.ECC_QX).concat(pukSector.getComponent(Key.ECC_QY));
 55 var secrevid2 = crypto.digest(Crypto.SHA_256, crypto.decrypt(prkId, Crypto.ECDH, inp));
 56 print("Sector Revocation ID at document: " + secrevid2);
 57 
 58