This commit is contained in:
Looly
2024-01-09 23:15:52 +08:00
parent 64c1dc554b
commit ebf1632f36
6 changed files with 31 additions and 30 deletions

View File

@@ -49,17 +49,17 @@ public class JceCipher extends SimpleWrapper<javax.crypto.Cipher> implements Cip
@Override
public String getAlgorithmName() {
return getRaw().getAlgorithm();
return this.raw.getAlgorithm();
}
@Override
public int getBlockSize() {
return getRaw().getBlockSize();
return this.raw.getBlockSize();
}
@Override
public int getOutputSize(final int len) {
return getRaw().getOutputSize(len);
return this.raw.getOutputSize(len);
}
@Override
@@ -82,7 +82,7 @@ public class JceCipher extends SimpleWrapper<javax.crypto.Cipher> implements Cip
* @throws InvalidKeyException 无效key
*/
public void init(final int mode, final JceParameters jceParameters) throws InvalidAlgorithmParameterException, InvalidKeyException {
final javax.crypto.Cipher cipher = getRaw();
final javax.crypto.Cipher cipher = this.raw;
if (null != jceParameters.parameterSpec) {
if (null != jceParameters.random) {
cipher.init(mode, jceParameters.key, jceParameters.parameterSpec, jceParameters.random);
@@ -101,7 +101,7 @@ public class JceCipher extends SimpleWrapper<javax.crypto.Cipher> implements Cip
@Override
public int process(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) {
try {
return getRaw().update(in, inOff, len, out, outOff);
return this.raw.update(in, inOff, len, out, outOff);
} catch (final ShortBufferException e) {
throw new CryptoException(e);
}
@@ -110,7 +110,7 @@ public class JceCipher extends SimpleWrapper<javax.crypto.Cipher> implements Cip
@Override
public int doFinal(final byte[] out, final int outOff) {
try {
return getRaw().doFinal(out, outOff);
return this.raw.doFinal(out, outOff);
} catch (final Exception e) {
throw new CryptoException(e);
}
@@ -119,7 +119,7 @@ public class JceCipher extends SimpleWrapper<javax.crypto.Cipher> implements Cip
@Override
public byte[] processFinal(final byte[] data) {
try {
return getRaw().doFinal(data);
return this.raw.doFinal(data);
} catch (final Exception e) {
throw new CryptoException(e);
}

View File

@@ -253,7 +253,7 @@ public class Digester extends SimpleWrapper<MessageDigest> implements Serializab
// 加盐在末尾,自动忽略空盐值
result = doDigest(data, this.salt);
} else if (ArrayUtil.isNotEmpty(this.salt)) {
final MessageDigest digest = getRaw();
final MessageDigest digest = this.raw;
// 加盐在中间
digest.update(data, 0, this.saltPosition);
digest.update(this.salt);

View File

@@ -41,29 +41,29 @@ public class BCMacEngine extends SimpleWrapper<Mac> implements MacEngine {
@Override
public void update(final byte[] in, final int inOff, final int len) {
getRaw().update(in, inOff, len);
this.raw.update(in, inOff, len);
}
@Override
public byte[] doFinal() {
final byte[] result = new byte[getMacLength()];
getRaw().doFinal(result, 0);
this.raw.doFinal(result, 0);
return result;
}
@Override
public void reset() {
getRaw().reset();
this.raw.reset();
}
@Override
public int getMacLength() {
return getRaw().getMacSize();
return this.raw.getMacSize();
}
@Override
public String getAlgorithm() {
return getRaw().getAlgorithmName();
return this.raw.getAlgorithmName();
}
/**

View File

@@ -70,32 +70,32 @@ public class JCEMacEngine extends SimpleWrapper<Mac> implements MacEngine {
@Override
public void update(final byte[] in) {
getRaw().update(in);
this.raw.update(in);
}
@Override
public void update(final byte[] in, final int inOff, final int len) {
getRaw().update(in, inOff, len);
this.raw.update(in, inOff, len);
}
@Override
public byte[] doFinal() {
return getRaw().doFinal();
return this.raw.doFinal();
}
@Override
public void reset() {
getRaw().reset();
this.raw.reset();
}
@Override
public int getMacLength() {
return getRaw().getMacLength();
return this.raw.getMacLength();
}
@Override
public String getAlgorithm() {
return getRaw().getAlgorithm();
return this.raw.getAlgorithm();
}
/**