Skip to content

Commit

Permalink
Merge pull request #871 from prbprbprb/bytebuf_switch
Browse files Browse the repository at this point in the history
Add a boolean to OpenSSLAeadCipher to control optimisations.
  • Loading branch information
prbprbprb committed Aug 13, 2020
2 parents f8e67a8 + f85158c commit 785ead0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions common/src/main/java/org/conscrypt/OpenSSLAeadCipher.java
Expand Up @@ -32,6 +32,11 @@

@Internal
public abstract class OpenSSLAeadCipher extends OpenSSLCipher {
/**
* Controls whether no-copy optimizations for direct ByteBuffers are enabled.
*/
private static final boolean ENABLE_BYTEBUFFER_OPTIMIZATIONS = true;

/**
* The default tag size when one is not specified. Default to
* full-length tags (128-bits or 16 octets).
Expand Down Expand Up @@ -223,6 +228,9 @@ boolean allowsNonceReuse() {
@Override
protected int engineDoFinal(ByteBuffer input, ByteBuffer output) throws ShortBufferException,
IllegalBlockSizeException, BadPaddingException {
if (!ENABLE_BYTEBUFFER_OPTIMIZATIONS) {
return super.engineDoFinal(input, output);
}
if (input == null || output == null) {
throw new NullPointerException("Null ByteBuffer Error");
}
Expand Down

0 comments on commit 785ead0

Please sign in to comment.