@Test public void testDecryptDESKeyThrowsNullPointerException() throws Throwable { byte[] encryptedDESKey = new byte[2]; try { new JCEHandler((Provider) null).decryptDESKey((short) 100, encryptedDESKey, null, true); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.security.Key.getAlgorithm()\" because \"key\" is null", ex.getMessage(), "ex.getMessage()"); } } }
public Key decryptDESKey(short keyLength, byte[] encryptedDESKey, Key encryptingKey, boolean checkParity) throws JCEHandlerException { byte[] clearKeyBytes = doCryptStuff(encryptedDESKey, encryptingKey, Cipher.DECRYPT_MODE); if (checkParity && !Util.isDESParityAdjusted(clearKeyBytes)) { throw new JCEHandlerException("Parity not adjusted"); } return formDESKey(keyLength, clearKeyBytes); }
JCEHandler { public Key decryptDESKey(short keyLength, byte[] encryptedDESKey, Key encryptingKey, boolean checkParity) throws JCEHandlerException { byte[] clearKeyBytes = doCryptStuff(encryptedDESKey, encryptingKey, Cipher.DECRYPT_MODE); if (checkParity && !Util.isDESParityAdjusted(clearKeyBytes)) { throw new JCEHandlerException("Parity not adjusted"); } return formDESKey(keyLength, clearKeyBytes); } }
JCEHandler { public Key decryptDESKey(short keyLength, byte[] encryptedDESKey, Key encryptingKey, boolean checkParity) throws JCEHandlerException { byte[] clearKeyBytes = doCryptStuff(encryptedDESKey, encryptingKey, Cipher.DECRYPT_MODE); if (checkParity && !Util.isDESParityAdjusted(clearKeyBytes)) { throw new JCEHandlerException("Parity not adjusted"); } return formDESKey(keyLength, clearKeyBytes); } JCEHandler(String jceProviderClassName);  JCEHandler(Provider provider); }
JCEHandler { public Key decryptDESKey(short keyLength, byte[] encryptedDESKey, Key encryptingKey, boolean checkParity) throws JCEHandlerException { byte[] clearKeyBytes = doCryptStuff(encryptedDESKey, encryptingKey, Cipher.DECRYPT_MODE); if (checkParity && !Util.isDESParityAdjusted(clearKeyBytes)) { throw new JCEHandlerException("Parity not adjusted"); } return formDESKey(keyLength, clearKeyBytes); } 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 { public Key decryptDESKey(short keyLength, byte[] encryptedDESKey, Key encryptingKey, boolean checkParity) throws JCEHandlerException { byte[] clearKeyBytes = doCryptStuff(encryptedDESKey, encryptingKey, Cipher.DECRYPT_MODE); if (checkParity && !Util.isDESParityAdjusted(clearKeyBytes)) { throw new JCEHandlerException("Parity not adjusted"); } return formDESKey(keyLength, clearKeyBytes); } 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);  }