1 load("EAC2CVRequestGenerator.js");
  2 
  3 function test(crypto, priKey, pubKey, taOID) {
  4 	var reqGenerator = new EAC2CVRequestGenerator(crypto);
  5 
  6 	// Set CPI
  7 	reqGenerator.setProfileIdentifier(0x00);
  8 
  9 	// Set "inner" CAR
 10 	var CAR = "decvca00000";
 11 	reqGenerator.setCAR(CAR);
 12     
 13 	// Set public key for request
 14 	reqGenerator.setPublicKey(pubKey);
 15 
 16 	// Set oid of algorithm
 17 	reqGenerator.setTAAlgorithmIdentifier(taOID);
 18 
 19 	// Set some dummy extensions
 20 	var ext1 = new ASN1("ext1", new ByteString("06022A11", HEX));
 21 	var ext2 = new ASN1("ext2", new ByteString("06022A12", HEX));
 22 	reqGenerator.setExtensions([ext1, ext2]);
 23 
 24 	// Set CHR for the request
 25 	var CHR = "dedvca00001";
 26 	reqGenerator.setCHR(CHR);
 27 
 28 	// Generate the request
 29 	var req = reqGenerator.generateAuthenticatedCVRequest(priKey, priKey, new PublicKeyReference("dedvca00000"), taOID);
 30 	print(req);
 31 
 32 	var cvreq = new CVC(req);
 33 	print(cvreq);
 34 
 35 	assert(cvreq.verifyWith(crypto, pubKey, taOID));
 36 	assert(cvreq.verifyATWith(crypto, pubKey, taOID));
 37 }
 38 
 39 
 40 var crypto = new Crypto();
 41 
 42 var priKey = new Key();
 43 var pubKey = new Key();
 44 priKey.setType(Key.PRIVATE);
 45 pubKey.setType(Key.PUBLIC);
 46 priKey.setComponent(Key.ECC_CURVE_OID, new ByteString("brainpoolP256t1", OID));
 47 pubKey.setComponent(Key.ECC_CURVE_OID, new ByteString("brainpoolP256t1", OID));
 48 crypto.generateKeyPair(Crypto.EC, pubKey, priKey);
 49 
 50 test(crypto, priKey, pubKey, new ByteString("id-TA-ECDSA-SHA-256", OID));
 51 
 52 
 53 var priKey = new Key();
 54 var pubKey = new Key();
 55 priKey.setType(Key.PRIVATE);
 56 pubKey.setType(Key.PUBLIC);
 57 pubKey.setSize(1024);
 58 crypto.generateKeyPair(Crypto.RSA, pubKey, priKey);
 59 
 60 test(crypto, priKey, pubKey, new ByteString("id-TA-RSA-v1-5-SHA-256", OID));
 61