Examples of CipherInputStream


Examples of ch.ethz.ssh2.crypto.cipher.CipherInputStream

  final SecureRandom rnd;

  public TransportConnection(InputStream is, OutputStream os, SecureRandom rnd)
  {
    this.cis = new CipherInputStream(new NullCipher(), is);
    this.cos = new CipherOutputStream(new NullCipher(), os);
    this.rnd = rnd;
  }
View Full Code Here

Examples of com.trilead.ssh2.crypto.cipher.CipherInputStream

  final SecureRandom rnd;

  public TransportConnection(InputStream is, OutputStream os, SecureRandom rnd)
  {
    this.cis = new CipherInputStream(new NullCipher(), is);
    this.cos = new CipherOutputStream(new NullCipher(), os);
    this.rnd = rnd;
  }
View Full Code Here

Examples of javax.crypto.CipherInputStream

      System.out.println("TEST: preserving flag          : " + flag);
      System.out.println("TEST: preserving inFileName    : " + inFileName);
      System.out.println("TEST: preserving X-String      : " + X);

      // start encryption
      final InputStream  fin  = new CipherInputStream(new FileInputStream(inFile), ecipher);
      final OutputStream fout = new FileOutputStream(outFileName);

      // write magic and properties of original file
      // - we encrypt the original date, the encryption date, the file size, the flag
      //   and file name together to the string A and calculate the length AL of that string
      // - the length of the file name is therefore equal to AL-(17+17+11+1) = AL-46
      // - AL is then b64-ed and also encrypted which results into string B
      // - the length of B is BL; BL is then b64-ed to a string C of fixed length 1
      // - after the magic String we write C, B and A
      try {
    final String A = UTF8.String(ecipher.doFinal(X.getBytes("UTF8")));
    final String B = UTF8.String(ecipher.doFinal(Base64Order.standardCoder.encodeLongSB(A.length(), 2).toString().getBytes("UTF8"))); // most probable not longer than 4
    final String C = Base64Order.standardCoder.encodeLongSB(B.length(), 1).toString(); // fixed length 1 (6 bits, that should be enough)
    fout.write(UTF8.getBytes(magicString)); // the magic string, used to identify a 'crypt'-file
    fout.write(UTF8.getBytes(C));
    fout.write(UTF8.getBytes(B));
    fout.write(UTF8.getBytes(A));

    // write content of file
    copy(fout, fin, 512);
      }
      catch (final javax.crypto.IllegalBlockSizeException e) {System.err.println("ERROR:" + e.getMessage());}
      catch (final javax.crypto.BadPaddingException e) {System.err.println("ERROR:" + e.getMessage());}
      // finished files
      fin.close();
      fout.close();
  } catch (final FileNotFoundException e) {
      System.err.println("ERROR: file '" + inFileName + "' not found");
  } catch (final IOException e) {
      System.err.println("ERROR: IO trouble");
View Full Code Here

Examples of javax.crypto.CipherInputStream

        }

        try {
            inCipher.init(Cipher.DECRYPT_MODE, key);

            return new CipherInputStream(in, inCipher);
        } catch (java.security.InvalidKeyException e) {
            throw Error.error(ErrorCode.X_S0531, e);
        }
    }
View Full Code Here

Examples of javax.crypto.CipherInputStream

    public InputStream getDataStream(DirectoryNode dir) throws IOException, GeneralSecurityException {
        DocumentInputStream dis = dir.createDocumentInputStream("EncryptedPackage");

        long size = dis.readLong();

        return new CipherInputStream(dis, getCipher());
    }
View Full Code Here

Examples of javax.crypto.CipherInputStream

        } else {
            try {
                InputStream fileInputStream = new TransferableFileInputStream(tempFile);
                streamList.add(fileInputStream);
                if (cipherTransformation != null) {
                    fileInputStream = new CipherInputStream(fileInputStream, ciphers.getDecryptor()) {
                        boolean closed;
                        public void close() throws IOException {
                            if (!closed) {
                                super.close();
                                closed = true;
View Full Code Here

Examples of javax.crypto.CipherInputStream

    }

    private InputStream createInputStream(File file) throws IOException {
        InputStream in = new FileInputStream(file);
        if (cipherTransformation != null) {
            in = new CipherInputStream(in, ciphers.getDecryptor()) {
                boolean closed;
                public void close() throws IOException {
                    if (!closed) {
                        super.close();
                        closed = true;
View Full Code Here

Examples of javax.crypto.CipherInputStream

      catch(Exception e)
      {
         e.printStackTrace();
         throw new IOException("Failed to init cipher: "+e.getMessage());
      }
      CipherInputStream cis = new CipherInputStream(is, cipher);
      return cis;
   }
View Full Code Here

Examples of javax.crypto.CipherInputStream

      InvalidKeyException, InvalidAlgorithmParameterException, NoSuchProviderException
  {
    Cipher cipher = Cipher.getInstance(CIPHER_TRANSFORMATION);
    cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(iv));
   
    return new CipherInputStream(in, cipher);
  }
View Full Code Here

Examples of javax.crypto.CipherInputStream

      InvalidKeyException, InvalidAlgorithmParameterException, NoSuchProviderException
  {
    Cipher cipher = Cipher.getInstance(CIPHER_TRANSFORMATION);
    cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(iv));
   
    return new CipherInputStream(in, cipher);
  }
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.