### Question:
SCPDiversification { public static GPKeySet diversify(GPKeySet keys, GPKeyDiversification diversification, byte[] diversificationData) { if (keys.getDiversification() != GPKeyDiversification.NONE) { throw new IllegalArgumentException("Cannot diversify a diversified keyset"); } if(diversification == GPKeyDiversification.NONE) { throw new IllegalArgumentException("No need to diversify for diversification NONE"); } String diversifiedName = keys.getName() + "-" + diversification.name() + ":" + HexUtil.bytesToHex(diversificationData); GPKeySet diversifiedKeys = new GPKeySet(diversifiedName, keys.getKeyVersion(), diversification); for(GPKeyUsage type: DIVERSIFICATION_KEYS) { GPKey key = keys.getKeyByUsage(type); if(key != null) { GPKey diversifiedKey; switch (diversification) { case EMV: diversifiedKey = SCPDiversification.diversifyKeyEMV(type, key, diversificationData); break; case VISA2: diversifiedKey = SCPDiversification.diversifyKeyVisa2(type, key, diversificationData); break; default: throw new RuntimeException("Unsupported diversification " + diversification); } diversifiedKeys.putKey(diversifiedKey); } } return diversifiedKeys; }  static GPKeySet diversify(GPKeySet keys, GPKeyDiversification diversification, byte[] diversificationData);  }### Answer:
@Test public void testDiversifyEMV_00000000000000000000() { GPKeySet diversified = SCPDiversification.diversify( GPKeySet.GLOBALPLATFORM, GPKeyDiversification.EMV, HexUtil.hexToBytes("00000000000000000000")); Assert.assertEquals(0, diversified.getKeyVersion()); GPKey encKey = diversified.getKeyByUsage(GPKeyUsage.ENC); Assert.assertArrayEquals(HexUtil.hexToBytes("5d9a62e01df1fa7a93f231000f4ac272"), encKey.getSecret()); GPKey macKey = diversified.getKeyByUsage(GPKeyUsage.MAC); Assert.assertArrayEquals(HexUtil.hexToBytes("13179f2220fc6bce5e740387eb78db5c"), macKey.getSecret()); GPKey kekKey = diversified.getKeyByUsage(GPKeyUsage.KEK); Assert.assertArrayEquals(HexUtil.hexToBytes("8bbe5457944d18df460af68730f570a2"), kekKey.getSecret()); }
@Test public void testDiversifyEMV_0102030405060708090A() { GPKeySet diversified = SCPDiversification.diversify( GPKeySet.GLOBALPLATFORM, GPKeyDiversification.EMV, HexUtil.hexToBytes("0102030405060708090A")); Assert.assertEquals(0, diversified.getKeyVersion()); GPKey encKey = diversified.getKeyByUsage(GPKeyUsage.ENC); Assert.assertArrayEquals(HexUtil.hexToBytes("6438a05ac377df302423bc5e2038fb5b"), encKey.getSecret()); GPKey macKey = diversified.getKeyByUsage(GPKeyUsage.MAC); Assert.assertArrayEquals(HexUtil.hexToBytes("5a9402ddabc5b9497bbece0884929b83"), macKey.getSecret()); GPKey kekKey = diversified.getKeyByUsage(GPKeyUsage.KEK); Assert.assertArrayEquals(HexUtil.hexToBytes("acb4c129b3912fb782a4eaee043bae95"), kekKey.getSecret()); }