use of javax.crypto.ShortBufferException in project platform_frameworks_base by android.
the class AndroidKeyStoreCipherSpiBase method engineUpdate.
@Override
protected final int engineUpdate(ByteBuffer input, ByteBuffer output) throws ShortBufferException {
if (input == null) {
throw new NullPointerException("input == null");
}
if (output == null) {
throw new NullPointerException("output == null");
}
int inputSize = input.remaining();
byte[] outputArray;
if (input.hasArray()) {
outputArray = engineUpdate(input.array(), input.arrayOffset() + input.position(), inputSize);
input.position(input.position() + inputSize);
} else {
byte[] inputArray = new byte[inputSize];
input.get(inputArray);
outputArray = engineUpdate(inputArray, 0, inputSize);
}
int outputSize = (outputArray != null) ? outputArray.length : 0;
if (outputSize > 0) {
int outputBufferAvailable = output.remaining();
try {
output.put(outputArray);
} catch (BufferOverflowException e) {
throw new ShortBufferException("Output buffer too small. Produced: " + outputSize + ", available: " + outputBufferAvailable);
}
}
return outputSize;
}
use of javax.crypto.ShortBufferException in project wildfly by wildfly.
the class CipherAdapter method engineDoFinal.
@Override
protected int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException {
int result = engineGetOutputSize(inputLen);
if ((output.length - outputOffset) < result)
throw new ShortBufferException();
byte[] buf = engineDoFinal(input, inputOffset, inputLen);
result = buf.length;
if ((output.length - outputOffset) < result)
throw new ShortBufferException();
System.arraycopy(buf, 0, output, outputOffset, result);
return result;
}
use of javax.crypto.ShortBufferException in project wildfly by wildfly.
the class CipherAdapter method engineUpdate.
@Override
protected int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException {
int result = engineGetOutputSize(inputLen);
if ((output.length - outputOffset) < result)
throw new ShortBufferException();
byte[] buf = engineUpdate(input, inputOffset, inputLen);
result = buf.length;
if ((output.length - outputOffset) < result)
throw new ShortBufferException();
System.arraycopy(buf, 0, output, outputOffset, result);
return result;
}
use of javax.crypto.ShortBufferException in project android_frameworks_base by DirtyUnicorns.
the class AndroidKeyStoreCipherSpiBase method engineUpdate.
@Override
protected final int engineUpdate(ByteBuffer input, ByteBuffer output) throws ShortBufferException {
if (input == null) {
throw new NullPointerException("input == null");
}
if (output == null) {
throw new NullPointerException("output == null");
}
int inputSize = input.remaining();
byte[] outputArray;
if (input.hasArray()) {
outputArray = engineUpdate(input.array(), input.arrayOffset() + input.position(), inputSize);
input.position(input.position() + inputSize);
} else {
byte[] inputArray = new byte[inputSize];
input.get(inputArray);
outputArray = engineUpdate(inputArray, 0, inputSize);
}
int outputSize = (outputArray != null) ? outputArray.length : 0;
if (outputSize > 0) {
int outputBufferAvailable = output.remaining();
try {
output.put(outputArray);
} catch (BufferOverflowException e) {
throw new ShortBufferException("Output buffer too small. Produced: " + outputSize + ", available: " + outputBufferAvailable);
}
}
return outputSize;
}
use of javax.crypto.ShortBufferException in project android_frameworks_base by AOSPA.
the class AndroidKeyStoreCipherSpiBase method engineUpdate.
@Override
protected final int engineUpdate(ByteBuffer input, ByteBuffer output) throws ShortBufferException {
if (input == null) {
throw new NullPointerException("input == null");
}
if (output == null) {
throw new NullPointerException("output == null");
}
int inputSize = input.remaining();
byte[] outputArray;
if (input.hasArray()) {
outputArray = engineUpdate(input.array(), input.arrayOffset() + input.position(), inputSize);
input.position(input.position() + inputSize);
} else {
byte[] inputArray = new byte[inputSize];
input.get(inputArray);
outputArray = engineUpdate(inputArray, 0, inputSize);
}
int outputSize = (outputArray != null) ? outputArray.length : 0;
if (outputSize > 0) {
int outputBufferAvailable = output.remaining();
try {
output.put(outputArray);
} catch (BufferOverflowException e) {
throw new ShortBufferException("Output buffer too small. Produced: " + outputSize + ", available: " + outputBufferAvailable);
}
}
return outputSize;
}
Aggregations