⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bufferedasymmetricblockcipher.java

📁 进行与数字证书相关开发必须的java源码
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   BufferedAsymmetricBlockCipher.java

package jit.crypto;


// Referenced classes of package jit.crypto:
//            DataLengthException, InvalidCipherTextException, AsymmetricBlockCipher, CipherParameters

public class BufferedAsymmetricBlockCipher
{

    protected byte buf[];
    protected int bufOff;
    private boolean forEncryption;
    private AsymmetricBlockCipher cipher;

    public BufferedAsymmetricBlockCipher(AsymmetricBlockCipher cipher)
    {
        this.cipher = cipher;
    }

    public AsymmetricBlockCipher getUnderlyingCipher()
    {
        return cipher;
    }

    public int getBufferPosition()
    {
        return bufOff;
    }

    public void init(boolean forEncryption, CipherParameters params)
    {
        this.forEncryption = forEncryption;
        reset();
        cipher.init(forEncryption, params);
        buf = new byte[cipher.getInputBlockSize()];
        bufOff = 0;
    }

    public int getInputBlockSize()
    {
        return cipher.getInputBlockSize();
    }

    public int getOutputBlockSize()
    {
        return cipher.getOutputBlockSize();
    }

    public void processByte(byte in)
    {
        if(bufOff > buf.length)
        {
            throw new DataLengthException("attempt to process message to long for cipher");
        } else
        {
            buf[bufOff++] = in;
            return;
        }
    }

    public void processBytes(byte in[], int inOff, int len)
    {
        if(len == 0)
            return;
        if(len < 0)
            throw new IllegalArgumentException("Can't have a negative input length!");
        if(bufOff + len > buf.length)
        {
            throw new DataLengthException("attempt to process message to long for cipher");
        } else
        {
            System.arraycopy(in, inOff, buf, bufOff, len);
            bufOff += len;
            return;
        }
    }

    public byte[] doFinal()
        throws InvalidCipherTextException
    {
        byte out[] = cipher.processBlock(buf, 0, bufOff);
        reset();
        return out;
    }

    public void reset()
    {
        if(buf != null)
        {
            for(int i = 0; i < buf.length; i++)
                buf[0] = 0;

        }
        bufOff = 0;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -