Package org.syncany.crypto

Examples of org.syncany.crypto.CipherSpec


  }
   
  @Test
  public void testCreateDerivedKeys() throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException {
    SaltedSecretKey masterKey = createDummyMasterKey();   
    CipherSpec cipherSpec = CipherSpecs.getCipherSpec(CipherSpecs.AES_128_GCM);
   
    byte[] derivedKeySalt1 = new byte[] { 1, 2, 3 };
    byte[] derivedKeySalt2 = new byte[] { 1, 2, 3, 4 };

    SaltedSecretKey derivedKey1 = CipherUtil.createDerivedKey(masterKey, derivedKeySalt1, cipherSpec);
View Full Code Here


    private void initCipherSpecs(String cipherSpecListStr) throws Exception {
      String[] cipherSpecIdStrs = cipherSpecListStr.split(",");
     
      for (String cipherSpecIdStr : cipherSpecIdStrs) {
        int cipherSpecId = Integer.parseInt(cipherSpecIdStr);
        CipherSpec cipherSpec = CipherSpecs.getCipherSpec(cipherSpecId);
       
        if (cipherSpec == null) {
          throw new Exception("Cannot find cipher suite with ID '"+cipherSpecId+"'");
        }
       
View Full Code Here

  @Test
  public void testCipherSessionWriteKeyReuseCountOfTwo() throws Exception {
    SaltedSecretKey masterKey = createDummyMasterKey();   
    CipherSession cipherSession = new CipherSession(masterKey, 999, 2);
   
    CipherSpec cipherSpecAes128 = CipherSpecs.getCipherSpec(CipherSpecs.AES_128_GCM);
    CipherSpec cipherSpecTwofish128 = CipherSpecs.getCipherSpec(CipherSpecs.TWOFISH_128_GCM);
   
    SaltedSecretKey writeSecretKey1Aes128 = cipherSession.getWriteSecretKey(cipherSpecAes128);
    SaltedSecretKey writeSecretKey2Aes128 = cipherSession.getWriteSecretKey(cipherSpecAes128);
    SaltedSecretKey writeSecretKey3Aes128 = cipherSession.getWriteSecretKey(cipherSpecAes128);
   
View Full Code Here

  @Test
  public void testCipherSessionReadKeyCacheSizeOfThree() throws Exception {
    SaltedSecretKey masterKey = createDummyMasterKey();   
    CipherSession cipherSession = new CipherSession(masterKey, 2, 999);
   
    CipherSpec cipherSpecAes128 = CipherSpecs.getCipherSpec(CipherSpecs.AES_128_GCM);
   
    byte[] readKeySalt1 = CipherUtil.createRandomArray(cipherSpecAes128.getKeySize());
    byte[] readKeySalt2 = CipherUtil.createRandomArray(cipherSpecAes128.getKeySize());
    byte[] readKeySalt3 = CipherUtil.createRandomArray(cipherSpecAes128.getKeySize());       
   
    SaltedSecretKey readSecretKey1Aes128 = cipherSession.getReadSecretKey(cipherSpecAes128, readKeySalt1);
    SaltedSecretKey readSecretKey2Aes128 = cipherSession.getReadSecretKey(cipherSpecAes128, readKeySalt2);
    SaltedSecretKey readSecretKey3Aes128 = cipherSession.getReadSecretKey(cipherSpecAes128, readKeySalt3);
   
View Full Code Here

    assertEquals(availableCipherSpecs.get(CipherSpecs.AES_128_GCM).getAlgorithm(), "AES/GCM/NoPadding");   
  }
 
  @Test
  public void testCipherSpec2() {
    CipherSpec twofish128CipherSpec = CipherSpecs.getCipherSpec(CipherSpecs.TWOFISH_128_GCM);
   
    assertEquals(twofish128CipherSpec.getId(), 2);
    assertEquals(twofish128CipherSpec.getAlgorithm(), "Twofish/GCM/NoPadding");
    assertEquals(twofish128CipherSpec.getKeySize(), 128);
    assertEquals(twofish128CipherSpec.getIvSize(), 128);
    assertEquals(twofish128CipherSpec.needsUnlimitedStrength(), false);
    assertNotNull(twofish128CipherSpec.toString());
  }
View Full Code Here

    assertNotNull(twofish128CipherSpec.toString());
  }
 
  @Test
  public void testCipherSpecHashCodeEquals() {
    CipherSpec cipherSpec1 = CipherSpecs.getCipherSpec(CipherSpecs.AES_128_GCM);
    CipherSpec cipherSpec2 = CipherSpecs.getCipherSpec(CipherSpecs.TWOFISH_128_GCM);
   
    assertNotSame(cipherSpec1.hashCode(), cipherSpec2.hashCode());
    assertNotSame(cipherSpec1, cipherSpec2);
    assertEquals(0x01, cipherSpec1.getId());
  }
View Full Code Here

      // Choose cipher
      try {
        // Add cipher suites
        for (String cipherSpecIdStr : cipherSpecIdStrs) {
          Integer cipherSpecId = Integer.parseInt(cipherSpecIdStr);
          CipherSpec cipherSpec = availableCipherSpecs.get(cipherSpecId);

          if (cipherSpec == null) {
            throw new Exception();
          }

          if (cipherSpec.needsUnlimitedStrength()) {
            unlimitedStrengthNeeded = true;
          }

          cipherSpecs.add(cipherSpec);
        }
View Full Code Here

TOP

Related Classes of org.syncany.crypto.CipherSpec

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.