private List<CipherSpec> getCipherSpecs(boolean encryptionEnabled, boolean advancedModeEnabled) throws Exception { List<CipherSpec> cipherSpecs = new ArrayList<CipherSpec>(); if (encryptionEnabled) { if (advancedModeEnabled) { cipherSpecs = askCipherSpecs(); } else { // Default cipherSpecs = CipherSpecs.getDefaultCipherSpecs(); } } return cipherSpecs; }
public static String encrypt(String decryptedPlainString) throws CipherException { InputStream plaintextInputStream = IOUtils.toInputStream(decryptedPlainString); byte[] encryptedBytes = CipherUtil.encrypt(plaintextInputStream, CipherSpecs.getDefaultCipherSpecs(), UserConfig.getConfigEncryptionKey()); return StringUtil.toHex(encryptedBytes); } }
public String createEncryptedLink(SaltedSecretKey masterKey) throws Exception { byte[] plaintextStorageXml = getPlaintextStorageXml(); List<CipherSpec> cipherSpecs = CipherSpecs.getDefaultCipherSpecs(); // TODO [low] Shouldn't this be the same as the application?! byte[] masterKeySalt = masterKey.getSalt(); byte[] encryptedPluginBytes = CipherUtil.encrypt(new ByteArrayInputStream(plaintextStorageXml), cipherSpecs, masterKey); String masterKeySaltEncodedStr = Base58.encode(masterKeySalt); String encryptedEncodedPlugin = Base58.encode(encryptedPluginBytes); String applicationLink = String.format(LINK_FORMAT_ENCRYPTED, masterKeySaltEncodedStr, encryptedEncodedPlugin); if (shortUrl) { return shortenLink(applicationLink); } else { return applicationLink; } }
public static InitOperationOptions createTestInitOperationOptions(String machineName) throws Exception { File tempLocalDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("client-" + machineName, machineName)); File tempRepoDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("repo", machineName)); tempLocalDir.mkdirs(); tempRepoDir.mkdirs(); RepoTO repoTO = createRepoTO(); // Create config TO ConfigTO configTO = new ConfigTO(); configTO.setMachineName(machineName + Math.abs(new Random().nextInt())); // Get Masterkey SaltedSecretKey masterKey = getMasterKey(); configTO.setMasterKey(masterKey); // Generic connection settings wont work anymore, because they are plugin dependent now. LocalTransferSettings transferSettings = Plugins.get("local", TransferPlugin.class).createEmptySettings(); transferSettings.setPath(tempRepoDir); configTO.setTransferSettings(transferSettings); InitOperationOptions operationOptions = new InitOperationOptions(); operationOptions.setLocalDir(tempLocalDir); operationOptions.setConfigTO(configTO); operationOptions.setRepoTO(repoTO); operationOptions.setEncryptionEnabled(cryptoEnabled); operationOptions.setCipherSpecs(CipherSpecs.getDefaultCipherSpecs()); operationOptions.setPassword(cryptoEnabled ? "some password" : null); return operationOptions; }