2404N/A * The contents of this file are subject to the terms of the 2404N/A * Common Development and Distribution License, Version 1.0 only 2404N/A * (the "License"). You may not use this file except in compliance 2404N/A * See the License for the specific language governing permissions 2404N/A * and limitations under the License. 2404N/A * When distributing Covered Code, include this CDDL HEADER in each 6982N/A * If applicable, add the following below this CDDL HEADER, with the 6982N/A * fields enclosed by brackets "[]" replaced with your own identifying 2404N/A * Portions Copyright [yyyy] [name of copyright owner] 3232N/A * Copyright 2008 Sun Microsystems, Inc. 6206N/A * Portions copyright 2013 ForgeRock AS 2404N/A This class tests the CryptoManager. 2684N/A // Removes at least secret keys added in this test case. 2616N/A // The certificate should now be accessible in the truststore backend via LDAP. 3853N/A "ldaps://" +
"127.0.0.1" +
":" 2616N/A "cn=Directory Manager",
"password",
2673N/A // TODO: should the below dn be in ConfigConstants? 2616N/A /* attribute ds-cfg-public-key-certificate is a MUST in the schema */ 2616N/A // Compare the certificate values. 2616N/A // Compare the MD5 hash of the LDAP attribute with the one 2616N/A // retrieved from the CryptoManager. 6206N/A // Call twice to ensure idempotent. 2616N/A // TODO: other-than-default MAC 2525N/A @return The set of Cipher parameters with which to test. 2714N/A// TODO: paramList.add(new CipherParameters("Blowfish", "CFB", "NoPadding", 448, 64)); 2736N/A// TODO: paramList.add(new CipherParameters("AES", "CBC", "PKCS5Padding", 256, 64)); 2525N/A Tests a simple encryption-decryption cycle using the supplied cipher 2525N/A @param cp Cipher parameters to use for this test iteration. 2404N/A @throws Exception If an exceptional condition arises. 2525N/A Tests a simple cipher stream encryption-decryption cycle using the supplied 2525N/A @param cp Cipher parameters to use for this test iteration. 2404N/A @throws Exception If an exceptional condition arises. 2436N/A // TODO: check tempfile for plaintext. 2531N/A Tests to ensure the same key identifier (and hence, key) is used for 2531N/A successive encryptions specifying the same algorithm and key length. 2668N/A The default encryption cipher requires an initialization vector. Confirm 2668N/A successive uses of a key produces distinct ciphertext. 2531N/A @throws Exception In case an error occurs in the encryption routine. 2668N/A // test for distinct ciphertext 2668N/A Test that secret keys are persisted: Encrypt some data using a 2668N/A variety of transformations, restart the instance, and decrypt the 2668N/A @throws Exception In case an error occurs in the encryption routine. 2673N/A Mark a key compromised; ensure 1) subsequent encryption requests use a 2673N/A new key; 2) ciphertext produced using the compromised key can still be 2673N/A decrypted; 3) once the compromised key entry is removed, confirm ciphertext 2673N/A produced using the compromised key can no longer be decrypted. 2669N/A @throws Exception In case something exceptional happens. 2669N/A // Initial encryption ensures a cipher key entry is in ADS. 2669N/A // Retrieve all uncompromised cipher key entries corresponding to the 2669N/A // specified transformation and key length. Mark each entry compromised. 2669N/A /* size limit */ 0,
/* time limit */ 0,
3912N/A //Wait so the above asynchronous modification can be applied. The crypto 3912N/A //manager's cipherKeyEntryCache needs to be updated before the encrypt() 2669N/A // Use the transformation and key length again. A new cipher key 2673N/A // 1. Test for distinct keys. 2673N/A // 2. Confirm ciphertext produced using the compromised key can still be 2673N/A // 3. Delete the compromised entry(ies) and ensure ciphertext produced 2673N/A // using a compromised key can no longer be decrypted. 2673N/A // TODO: if reasons are added to CryptoManagerException, check for 2740N/A TODO: Test shared secret key wrapping (various wrapping ciphers, if configurable). 2673N/A TODO: Test the secret key synchronization protocol. 2673N/A 1. Create the first instance; add reversible password storage scheme 2673N/A to password policy; add entry using explicit password policy; confirm 2673N/A secret key entry has been produced. 2673N/A 2. Create and initialize the second instance into the existing ADS domain. 2673N/A The secret key entries should be propagated to the second instance via 2673N/A replication. Then the new instance should detect that the secret key 2673N/A entries are missing ds-cfg-symmetric-key attribute values for that 2673N/A instance, inducing the key synchronization protocol. 2673N/A 3. Confirm the second instance can decrypt the password of the entry 2673N/A added in step 1; e.g., bind as that user. 2673N/A 4. Stop the second instance. At the first instance, enable a different 2673N/A reversible password storage scheme (different cipher transformation, 2673N/A and hence secret key entry); add another entry using that password 2673N/A storage scheme; start the second instance; ensure the password can 2673N/A be decrypted at the second instance.