@Test public void testFormDESKey() throws Throwable { byte[] clearKeyBytes = new byte[4]; SecretKeySpec result = (SecretKeySpec) jCEHandler.formDESKey((short) 64, clearKeyBytes); assertEquals("DES", result.getAlgorithm(), "result.getAlgorithm()"); }
protected Key formDESKey(short keyLength, byte[] clearKeyBytes) throws JCEHandlerException { Key key = null; switch (keyLength) { case SMAdapter.LENGTH_DES: { key = new SecretKeySpec(clearKeyBytes, ALG_DES); } break; case SMAdapter.LENGTH_DES3_2KEY: { clearKeyBytes = ISOUtil.concat(clearKeyBytes, 0, getBytesLength(SMAdapter.LENGTH_DES3_2KEY), clearKeyBytes, 0, getBytesLength(SMAdapter.LENGTH_DES)); } case SMAdapter.LENGTH_DES3_3KEY: { key = new SecretKeySpec(clearKeyBytes, ALG_TRIPLE_DES); } } if (key == null) throw new JCEHandlerException("Unsupported DES key length: " + keyLength + " bits"); return key; }
JCEHandler { protected Key formDESKey(short keyLength, byte[] clearKeyBytes) throws JCEHandlerException { Key key = null; switch (keyLength) { case SMAdapter.LENGTH_DES: { key = new SecretKeySpec(clearKeyBytes, ALG_DES); } break; case SMAdapter.LENGTH_DES3_2KEY: { clearKeyBytes = ISOUtil.concat(clearKeyBytes, 0, getBytesLength(SMAdapter.LENGTH_DES3_2KEY), clearKeyBytes, 0, getBytesLength(SMAdapter.LENGTH_DES)); } case SMAdapter.LENGTH_DES3_3KEY: { key = new SecretKeySpec(clearKeyBytes, ALG_TRIPLE_DES); } } if (key == null) throw new JCEHandlerException("Unsupported DES key length: " + keyLength + " bits"); return key; } }
JCEHandler { protected Key formDESKey(short keyLength, byte[] clearKeyBytes) throws JCEHandlerException { Key key = null; switch (keyLength) { case SMAdapter.LENGTH_DES: { key = new SecretKeySpec(clearKeyBytes, ALG_DES); } break; case SMAdapter.LENGTH_DES3_2KEY: { clearKeyBytes = ISOUtil.concat(clearKeyBytes, 0, getBytesLength(SMAdapter.LENGTH_DES3_2KEY), clearKeyBytes, 0, getBytesLength(SMAdapter.LENGTH_DES)); } case SMAdapter.LENGTH_DES3_3KEY: { key = new SecretKeySpec(clearKeyBytes, ALG_TRIPLE_DES); } } if (key == null) throw new JCEHandlerException("Unsupported DES key length: " + keyLength + " bits"); return key; } JCEHandler(String jceProviderClassName);  JCEHandler(Provider provider); }
JCEHandler { protected Key formDESKey(short keyLength, byte[] clearKeyBytes) throws JCEHandlerException { Key key = null; switch (keyLength) { case SMAdapter.LENGTH_DES: { key = new SecretKeySpec(clearKeyBytes, ALG_DES); } break; case SMAdapter.LENGTH_DES3_2KEY: { clearKeyBytes = ISOUtil.concat(clearKeyBytes, 0, getBytesLength(SMAdapter.LENGTH_DES3_2KEY), clearKeyBytes, 0, getBytesLength(SMAdapter.LENGTH_DES)); } case SMAdapter.LENGTH_DES3_3KEY: { key = new SecretKeySpec(clearKeyBytes, ALG_TRIPLE_DES); } } if (key == null) throw new JCEHandlerException("Unsupported DES key length: " + keyLength + " bits"); return key; } JCEHandler(String jceProviderClassName);  JCEHandler(Provider provider); Key generateDESKey(short keyLength); byte[] encryptDESKey(short keyLength, Key clearDESKey, Key encryptingKey); Key decryptDESKey(short keyLength, byte[] encryptedDESKey, Key encryptingKey, boolean checkParity); byte[] encryptData(byte[] data, Key key); byte[] decryptData(byte[] encryptedData, Key key); byte[] encryptDataCBC(byte[] data, Key key, byte[] iv); byte[] decryptDataCBC(byte[] encryptedData, Key key, byte[] iv); byte[] generateMAC(byte[] data, Key kd, String macAlgorithm); }
JCEHandler { protected Key formDESKey(short keyLength, byte[] clearKeyBytes) throws JCEHandlerException { Key key = null; switch (keyLength) { case SMAdapter.LENGTH_DES: { key = new SecretKeySpec(clearKeyBytes, ALG_DES); } break; case SMAdapter.LENGTH_DES3_2KEY: { clearKeyBytes = ISOUtil.concat(clearKeyBytes, 0, getBytesLength(SMAdapter.LENGTH_DES3_2KEY), clearKeyBytes, 0, getBytesLength(SMAdapter.LENGTH_DES)); } case SMAdapter.LENGTH_DES3_3KEY: { key = new SecretKeySpec(clearKeyBytes, ALG_TRIPLE_DES); } } if (key == null) throw new JCEHandlerException("Unsupported DES key length: " + keyLength + " bits"); return key; } JCEHandler(String jceProviderClassName);  JCEHandler(Provider provider); Key generateDESKey(short keyLength); byte[] encryptDESKey(short keyLength, Key clearDESKey, Key encryptingKey); Key decryptDESKey(short keyLength, byte[] encryptedDESKey, Key encryptingKey, boolean checkParity); byte[] encryptData(byte[] data, Key key); byte[] decryptData(byte[] encryptedData, Key key); byte[] encryptDataCBC(byte[] data, Key key, byte[] iv); byte[] decryptDataCBC(byte[] encryptedData, Key key, byte[] iv); byte[] generateMAC(byte[] data, Key kd, String macAlgorithm);  }