zhihengjiang / shadowsocks-java

A Java port of shadowsocks
34 stars 16 forks source link

怎么添加aes-256-gcm #4

Open aaaaaaanthony opened 3 years ago

zhihengjiang commented 3 years ago

目前aes只支持了cfb以及ofb两种模式,gcm还不支持,但很容易进行支持,只需要在现有AESCrypto 类上进行简单地扩展即可

aaaaaaanthony commented 3 years ago
    @Override
    protected StreamCipher createCipher(byte[] iv, boolean encrypt) throws CryptoException {

        GCMBlockCipher cipher = new GCMBlockCipher(new AESEngine());
        AEADParameters parameters = new AEADParameters(new KeyParameter(mKey), 128, iv, null);
        cipher.init(encrypt, parameters);
}

GCMBlockCipher 不继承StreamCipher ...

zhihengjiang commented 3 years ago
    @Override
    protected StreamCipher createCipher(byte[] iv, boolean encrypt) throws CryptoException {

        GCMBlockCipher cipher = new GCMBlockCipher(new AESEngine());
        AEADParameters parameters = new AEADParameters(new KeyParameter(mKey), 128, iv, null);
        cipher.init(encrypt, parameters);
}

GCMBlockCipher 不继承StreamCipher ...

嗯嗯,gcm属于认证加密,确实不能简单基于原来的加密方法来扩展了