Package org.syncany.crypto

Examples of org.syncany.crypto.SaltedSecretKey


   
    return decryptedData;
 
 
  private SaltedSecretKey createDummyMasterKey() {
    return new SaltedSecretKey(
      new SecretKeySpec(
        StringUtil.fromHex("44fda24d53b29828b62c362529bd9df5c8a92c2736bcae3a28b3d7b44488e36e246106aa5334813028abb2048eeb5e177df1c702d93cf82aeb7b6d59a8534ff0"),
        "AnyAlgorithm"
      ),
      StringUtil.fromHex("157599349e0f1bc713afff442db9d4c3201324073d51cb33407600f305500aa3fdb31136cb1f37bd51a48f183844257d42010a36133b32b424dd02bc63b349bc")     
View Full Code Here


    // Create config TO
    ConfigTO configTO = new ConfigTO();
    configTO.setMachineName(machineName + CipherUtil.createRandomAlphabeticString(20));

    // Get Masterkey
    SaltedSecretKey masterKey = getMasterKey();
    configTO.setMasterKey(masterKey);

    LocalTransferSettings localConnection = (LocalTransferSettings) connection;
    // Create connection TO
    Map<String, String> localConnectionSettings = new HashMap<String, String>();
View Full Code Here

    // 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);
View Full Code Here

    }

    private static RepoTO loadEncryptedRepoTO(File repoFile, ConfigTO configTO) throws Exception {
      logger.log(Level.INFO, "Loading encrypted repo file from {0} ...", repoFile);

    SaltedSecretKey masterKey = configTO.getMasterKey();

    if (masterKey == null) {
      throw new ConfigException("Repo file is encrypted, but master key not set in config file.");
    }
View Full Code Here

    userConfigTO.getSystemProperties().put("example.property", "This is a demo property. You can delete it.");
    userConfigTO.getSystemProperties().put("syncany.rocks", "Yes, it does!");

    try {
      System.out.println("First launch, creating a secret key (could take a sec)...");
      SaltedSecretKey configEncryptionKey = CipherUtil.createMasterKey(CipherUtil.createRandomAlphabeticString(USER_CONFIG_ENCRYPTION_KEY_LENGTH));

      userConfigTO.setConfigEncryptionKey(configEncryptionKey);
      userConfigTO.save(userConfigFile);
    }
    catch (Exception e) {
View Full Code Here

      TestAssertUtil.assertErrorStackTraceContains("INVALIDXXXX", e);     
   
  } 
 
  private SaltedSecretKey createDummyMasterKey() {
    return new SaltedSecretKey(
      new SecretKeySpec(
        StringUtil.fromHex("44fda24d53b29828b62c362529bd9df5c8a92c2736bcae3a28b3d7b44488e36e246106aa5334813028abb2048eeb5e177df1c702d93cf82aeb7b6d59a8534ff0"),
        "AnyAlgorithm"
      ),
      StringUtil.fromHex("157599349e0f1bc713afff442db9d4c3201324073d51cb33407600f305500aa3fdb31136cb1f37bd51a48f183844257d42010a36133b32b424dd02bc63b349bc")     
View Full Code Here

    File repoFile = new File(appDir, Config.FILE_REPO);
    File masterFile = new File(appDir, Config.FILE_MASTER);

    // Save config.xml and repo file
    if (options.isEncryptionEnabled()) {
      SaltedSecretKey masterKey = createMasterKeyFromPassword(masterKeyPassword); // This takes looong!
      options.getConfigTO().setMasterKey(masterKey);

      new MasterTO(masterKey.getSalt()).save(masterFile);
      options.getRepoTO().save(repoFile, options.getCipherSpecs(), masterKey);
    }
    else {
      options.getRepoTO().save(repoFile);
    }
View Full Code Here

  }

  private SaltedSecretKey createMasterKeyFromPassword(String masterPassword) throws Exception {
    fireNotifyCreateMaster();

    SaltedSecretKey masterKey = CipherUtil.createMasterKey(masterPassword);
    return masterKey;
  }
View Full Code Here

        logger.log(Level.INFO, "- No master key present; Asking for password ...");

        boolean retryPassword = true;

        while (retryPassword) {
          SaltedSecretKey possibleMasterKey = askPasswordAndCreateMasterKey();
          logger.log(Level.INFO, "- Master key created. Now verifying by decrypting repo file...");

          if (decryptAndVerifyRepoFile(tmpRepoFile, possibleMasterKey)) {
            logger.log(Level.INFO, "- SUCCESS: Repo file decrypted successfully.");
View Full Code Here

      if (applicationLink.isEncrypted()) {
        // Non-interactive mode
        if (masterPassword != null) {
          logger.log(Level.INFO, " - Link is encrypted. Password available.");

          SaltedSecretKey masterKey = createMasterKeyFromPassword(masterPassword, applicationLink.getMasterKeySalt());
          TransferSettings transferSettings = applicationLink.createTransferSettings(masterKey);

          configTO.setMasterKey(masterKey);
          configTO.setTransferSettings(transferSettings);
        }
        else {
          logger.log(Level.INFO, " - Link is encrypted. Asking for password.");

          boolean retryPassword = true;

          while (retryPassword) {
            // Ask password
            masterPassword = getOrAskPassword();

            // Generate master key
            SaltedSecretKey masterKey = createMasterKeyFromPassword(masterPassword, applicationLink.getMasterKeySalt());

            // Decrypt config
            try {
              TransferSettings transferSettings = applicationLink.createTransferSettings(masterKey);
View Full Code Here

TOP

Related Classes of org.syncany.crypto.SaltedSecretKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.