Examples of BufferedBlockCipher


Examples of org.bouncycastle.crypto.BufferedBlockCipher

            public byte[] recoverKeyData(int encAlgorithm, byte[] key, byte[] iv, byte[] keyData, int keyOff, int keyLen)
                throws PGPException
            {
                try
                {
                    BufferedBlockCipher c = BcUtil.createSymmetricKeyWrapper(false, BcImplProvider.createBlockCipher(encAlgorithm), key, iv);

                    byte[] out = new byte[keyLen];
                    int    outLen = c.processBytes(keyData, keyOff, keyLen, out, 0);

                    outLen += c.doFinal(out, outLen);

                    return out;
                }
                catch (InvalidCipherTextException e)
                {
View Full Code Here

Examples of org.bouncycastle.crypto.BufferedBlockCipher

                    iv = new byte[engine.getBlockSize()];

                    this.random.nextBytes(iv);

                    BufferedBlockCipher c = BcUtil.createSymmetricKeyWrapper(true, engine, key, iv);

                    byte[] out = new byte[keyLen];
                    int    outLen = c.processBytes(keyData, keyOff, keyLen, out, 0);

                    outLen += c.doFinal(out, outLen);

                    return out;
                }
                catch (InvalidCipherTextException e)
                {
View Full Code Here

Examples of org.bouncycastle.crypto.BufferedBlockCipher

        try
        {
            if (secKeyData != null && secKeyData.length > 0)
            {
                BlockCipher engine = BcImplProvider.createBlockCipher(keyAlgorithm);
                BufferedBlockCipher cipher = BcUtil.createSymmetricKeyWrapper(false, engine, key, new byte[engine.getBlockSize()]);

                byte[] out = new byte[secKeyData.length];

                int len = cipher.processBytes(secKeyData, 0, secKeyData.length, out, 0);

                len += cipher.doFinal(out, len);

                return out;
            }
            else
            {
View Full Code Here

Examples of org.bouncycastle.crypto.BufferedBlockCipher

    System.out.println("Response: " + message.toString());

    String streamCipher = VanillaConfiguration.ENCRYPT_STREAM_ALGORITHM.getString();
    String streamWrapper = VanillaConfiguration.ENCRYPT_STREAM_WRAPPER.getString();

    BufferedBlockCipher fromServerCipher = SecurityHandler.getInstance().getSymmetricCipher(streamCipher, streamWrapper);

    final byte[] sharedSecret = SecurityHandler.getInstance().getSymetricKey();
    CipherParameters symmetricKey = new ParametersWithIV(new KeyParameter(sharedSecret), sharedSecret);

    fromServerCipher.init(SecurityHandler.DECRYPT_MODE, symmetricKey);

    EncryptionChannelProcessor fromServerProcessor = new EncryptionChannelProcessor(fromServerCipher, 32);
    message.getProcessorHandler().setProcessor(fromServerProcessor);

    session.send(Session.SendType.FORCE, new PlayerStatusMessage(PlayerStatusMessage.INITIAL_SPAWN)); // Ready to login;
View Full Code Here

Examples of org.bouncycastle.crypto.BufferedBlockCipher

      Runnable runnable = new Runnable() {
        public void run() {
          String streamCipher = VanillaConfiguration.ENCRYPT_STREAM_ALGORITHM.getString();
          String streamWrapper = VanillaConfiguration.ENCRYPT_STREAM_WRAPPER.getString();

          BufferedBlockCipher fromClientCipher = SecurityHandler.getInstance().getSymmetricCipher(streamCipher, streamWrapper);
          BufferedBlockCipher toClientCipher = SecurityHandler.getInstance().getSymmetricCipher(streamCipher, streamWrapper);

          CipherParameters symmetricKey = new ParametersWithIV(new KeyParameter(initialVector), initialVector);

          fromClientCipher.init(SecurityHandler.DECRYPT_MODE, symmetricKey);
          toClientCipher.init(SecurityHandler.ENCRYPT_MODE, symmetricKey);

          EncryptionChannelProcessor fromClientProcessor = new EncryptionChannelProcessor(fromClientCipher, 32);
          EncryptionChannelProcessor toClientProcessor = new EncryptionChannelProcessor(toClientCipher, 32);

          EncryptionKeyResponseMessage response = new EncryptionKeyResponseMessage(false, new byte[0], new byte[0]);
View Full Code Here

Examples of org.bouncycastle.crypto.BufferedBlockCipher

          byte[] encodedToken = cipher.processBlock(message.getVerifyTokenArray(), 0, 4);

          String streamCipher = VanillaConfiguration.ENCRYPT_STREAM_ALGORITHM.getString();
          String streamWrapper = VanillaConfiguration.ENCRYPT_STREAM_WRAPPER.getString();

          BufferedBlockCipher toServerCipher = SecurityHandler.getInstance().getSymmetricCipher(streamCipher, streamWrapper);

          CipherParameters symmetricKey = new ParametersWithIV(new KeyParameter(sharedSecret), sharedSecret);

          toServerCipher.init(SecurityHandler.ENCRYPT_MODE, symmetricKey);
          EncryptionChannelProcessor toServerProcessor = new EncryptionChannelProcessor(toServerCipher, 32);

          EncryptionKeyResponseMessage response = new EncryptionKeyResponseMessage(false, encodedSecret, encodedToken);
          response.setProcessor(toServerProcessor);
View Full Code Here

Examples of org.bouncycastle.crypto.BufferedBlockCipher

    protected AesCipher(PipelinePluginContext context) {
        this.context = context;
    }

    public final void encrypt(InputFiles filesToEncrypt, OutputFiles outputFiles) throws Exception {
        BufferedBlockCipher cipher = createCipher(true);
        for (InputFile inputFile : filesToEncrypt.getFiles()) {
            File file = inputFile.getFile();
            encryptFile(file, cipher);
            outputFiles.add(file, inputFile);
        }
View Full Code Here

Examples of org.bouncycastle.crypto.BufferedBlockCipher

            outputFiles.add(file, inputFile);
        }
    }

    public final void decrypt(InputFiles filesToDecrypt, OutputFiles outputFiles) throws Exception {
        BufferedBlockCipher cipher = createCipher(false);
        for (InputFile inputFile : filesToDecrypt.getFiles()) {
            File file = inputFile.getFile();
            decryptFile(file, cipher);
            outputFiles.add(file, inputFile);
        }
View Full Code Here

Examples of org.bouncycastle.crypto.BufferedBlockCipher

            outputFiles.add(file, inputFile);
        }
    }

    public final String encryptText(String clearText) throws Exception {
        BufferedBlockCipher cipher = createCipher(true);
        byte[] encrypted = encryptBytes(cipher, clearText.getBytes("utf-8"));
        return new String(Base64.encode(encrypted), "utf-8");
    }
View Full Code Here

Examples of org.bouncycastle.crypto.BufferedBlockCipher

        byte[] encrypted = encryptBytes(cipher, clearText.getBytes("utf-8"));
        return new String(Base64.encode(encrypted), "utf-8");
    }

    public final String decryptText(String base64Encrypted) throws Exception {
        BufferedBlockCipher cipher = createCipher(false);
        byte[] encrypted = Base64.decode(base64Encrypted.getBytes("utf-8"));
        byte[] decrypted = decryptBytes(cipher, encrypted);
        return new String(decrypted, "utf-8");
    }
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.