Examples of CipherSpec


Examples of org.jruby.ext.openssl.impl.CipherSpec

            case 3:
                cipher = args[2];
            }
            data = args[1];
            certs = args[0];
            CipherSpec ciph = null;
            if (cipher.isNil()) {
                try {
                    ciph = new CipherSpec(javax.crypto.Cipher.getInstance("RC2/CBC/PKCS5Padding"), Cipher.Algorithm.jsseToOssl("RC2/CBC/PKCS5Padding", 40), 40);
                } catch (GeneralSecurityException gse) {
                    throw newPKCS7Error(recv.getRuntime(), gse.getMessage());
                }
            } else {
                Cipher c = ((Cipher) cipher);
                ciph = new CipherSpec(c.getCipher(), c.getName(), c.getGenerateKeyLen() * 8);
            }
            int flg = flags.isNil() ? 0 : RubyNumeric.fix2int(flags);
            byte[] in = data.convertToString().getBytes();
            List<X509AuxCertificate> x509s = x509_ary2sk(certs);
            try {
View Full Code Here

Examples of org.jruby.ext.openssl.impl.CipherSpec

    @JRubyMethod(name = { "export", "to_pem", "to_s" }, rest = true)
    public IRubyObject export(IRubyObject[] args) {
        StringWriter w = new StringWriter();
        org.jruby.runtime.Arity.checkArgumentCount(getRuntime(), args, 0, 2);
        CipherSpec ciph = null;
        char[] passwd = null;
        if (args.length > 0 && !args[0].isNil()) {
            org.jruby.ext.openssl.Cipher c = (org.jruby.ext.openssl.Cipher) args[0];
            ciph = new CipherSpec(c.getCipher(), c.getName(), c.getKeyLen() * 8);
            if (args.length > 1 && !args[1].isNil()) {
                passwd = args[1].toString().toCharArray();
            }
        }
        try {
View Full Code Here

Examples of org.jruby.ext.openssl.impl.CipherSpec

    @JRubyMethod(name = { "export", "to_pem", "to_s" }, rest = true)
    public IRubyObject export(IRubyObject[] args) {
        StringWriter w = new StringWriter();
        org.jruby.runtime.Arity.checkArgumentCount(getRuntime(), args, 0, 2);
        CipherSpec ciph = null;
        char[] passwd = null;
        if (args.length > 0 && !args[0].isNil()) {
            org.jruby.ext.openssl.Cipher c = (org.jruby.ext.openssl.Cipher) args[0];
            ciph = new CipherSpec(c.getCipher(), c.getName(), c.getKeyLen() * 8);
            if (args.length > 1 && !args[1].isNil()) {
                passwd = args[1].toString().toCharArray();
            }
        }
        try {
View Full Code Here

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

Examples of org.syncany.crypto.CipherSpec

    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

Examples of org.syncany.crypto.CipherSpec

  @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

Examples of org.syncany.crypto.CipherSpec

  @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

Examples of org.syncany.crypto.CipherSpec

    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

Examples of org.syncany.crypto.CipherSpec

    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

Examples of org.syncany.crypto.CipherSpec

      // 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
Copyright © 2018 www.massapi.com. 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.