| | |
| | | */ |
| | | package org.opends.server.crypto; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.Attributes.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileOutputStream; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.Attributes.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | This class tests the CryptoManager. |
| | | */ |
| | |
| | | @Test(dataProvider="cipherParametersData") |
| | | public void testEncryptDecryptSuccess(CipherParameters cp) |
| | | throws Exception { |
| | | final CryptoManager cm = DirectoryServer.getCryptoManager(); |
| | | final CryptoManager cm = getServerContext().getCryptoManager(); |
| | | final String secretMessage = "1234"; |
| | | |
| | | final byte[] cipherText = (null == cp.getTransformation()) |
| | |
| | | public void testKeyEntryReuse() |
| | | throws Exception { |
| | | |
| | | final CryptoManager cm = DirectoryServer.getCryptoManager(); |
| | | final CryptoManager cm = TestCaseUtils.getServerContext().getCryptoManager(); |
| | | final String secretMessage = "zyxwvutsrqponmlkjihgfedcba"; |
| | | |
| | | final byte[] cipherText = cm.encrypt(secretMessage.getBytes()); |
| | |
| | | @Test |
| | | public void testKeyPersistence() |
| | | throws Exception { |
| | | final CryptoManager cm = DirectoryServer.getCryptoManager(); |
| | | final CryptoManager cm = getServerContext().getCryptoManager(); |
| | | final String secretMessage = "zyxwvutsrqponmlkjihgfedcba"; |
| | | |
| | | final byte[] cipherText = cm.encrypt("Blowfish/CFB/NoPadding", 128, |
| | |
| | | */ |
| | | @Test |
| | | public void testCompromisedKey() throws Exception { |
| | | final CryptoManager cm = DirectoryServer.getCryptoManager(); |
| | | final CryptoManager cm = getServerContext().getCryptoManager(); |
| | | final String secretMessage = "zyxwvutsrqponmlkjihgfedcba"; |
| | | final String cipherTransformationName = "AES/CBC/PKCS5Padding"; |
| | | final int cipherKeyLength = 128; |