@Test public void testGetBytesLengthThrowsJCEHandlerException() throws Throwable { try { jCEHandler.getBytesLength((short) 100); fail("Expected JCEHandlerException to be thrown"); } catch (JCEHandlerException ex) { assertEquals("Unsupported key length: 100 bits", ex.getMessage(), "ex.getMessage()"); assertNull(ex.getNested(), "ex.getNested()"); } }
int getBytesLength(short keyLength) throws JCEHandlerException { int bytesLength = 0; switch (keyLength) { case SMAdapter.LENGTH_DES: bytesLength = 8; break; case SMAdapter.LENGTH_DES3_2KEY: bytesLength = 16; break; case SMAdapter.LENGTH_DES3_3KEY: bytesLength = 24; break; default: throw new JCEHandlerException("Unsupported key length: " + keyLength + " bits"); } return bytesLength; }
JCEHandler { int getBytesLength(short keyLength) throws JCEHandlerException { int bytesLength = 0; switch (keyLength) { case SMAdapter.LENGTH_DES: bytesLength = 8; break; case SMAdapter.LENGTH_DES3_2KEY: bytesLength = 16; break; case SMAdapter.LENGTH_DES3_3KEY: bytesLength = 24; break; default: throw new JCEHandlerException("Unsupported key length: " + keyLength + " bits"); } return bytesLength; } }
JCEHandler { int getBytesLength(short keyLength) throws JCEHandlerException { int bytesLength = 0; switch (keyLength) { case SMAdapter.LENGTH_DES: bytesLength = 8; break; case SMAdapter.LENGTH_DES3_2KEY: bytesLength = 16; break; case SMAdapter.LENGTH_DES3_3KEY: bytesLength = 24; break; default: throw new JCEHandlerException("Unsupported key length: " + keyLength + " bits"); } return bytesLength; } JCEHandler(String jceProviderClassName);  JCEHandler(Provider provider); }
JCEHandler { int getBytesLength(short keyLength) throws JCEHandlerException { int bytesLength = 0; switch (keyLength) { case SMAdapter.LENGTH_DES: bytesLength = 8; break; case SMAdapter.LENGTH_DES3_2KEY: bytesLength = 16; break; case SMAdapter.LENGTH_DES3_3KEY: bytesLength = 24; break; default: throw new JCEHandlerException("Unsupported key length: " + keyLength + " bits"); } return bytesLength; } 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 { int getBytesLength(short keyLength) throws JCEHandlerException { int bytesLength = 0; switch (keyLength) { case SMAdapter.LENGTH_DES: bytesLength = 8; break; case SMAdapter.LENGTH_DES3_2KEY: bytesLength = 16; break; case SMAdapter.LENGTH_DES3_3KEY: bytesLength = 24; break; default: throw new JCEHandlerException("Unsupported key length: " + keyLength + " bits"); } return bytesLength; } 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);  }