8179098: Crypto AES/ECB encryption/decryption performance regression (introduced in jdk9b73)

Do bounds check per encryption/decryption call instead of per block

Reviewed-by: ascarpino, redestad
This commit is contained in:
Valerie Peng 2018-07-13 02:36:42 +00:00
parent b8d80042d7
commit b0af57a018
9 changed files with 137 additions and 73 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,9 +26,9 @@
package com.sun.crypto.provider;
import java.security.InvalidKeyException;
import java.util.Objects;
import jdk.internal.HotSpotIntrinsicCandidate;
import sun.security.util.ArrayUtil;
/**
* This class represents ciphers in counter (CTR) mode.
@ -175,8 +175,9 @@ class CounterMode extends FeedbackCipher {
if (len == 0) {
return 0;
}
Objects.checkFromIndexSize(inOff, len, in.length);
Objects.checkFromIndexSize(outOff, len, out.length);
ArrayUtil.nullAndBoundsCheck(in, inOff, len);
ArrayUtil.nullAndBoundsCheck(out, outOff, len);
return implCrypt(in, inOff, len, out, outOff);
}