mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
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:
parent
b8d80042d7
commit
b0af57a018
9 changed files with 137 additions and 73 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
|
@ -27,6 +27,7 @@ package com.sun.crypto.provider;
|
|||
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.ProviderException;
|
||||
import sun.security.util.ArrayUtil;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -136,9 +137,10 @@ final class PCBC extends FeedbackCipher {
|
|||
int encrypt(byte[] plain, int plainOffset, int plainLen,
|
||||
byte[] cipher, int cipherOffset)
|
||||
{
|
||||
if ((plainLen % blockSize) != 0) {
|
||||
throw new ProviderException("Internal error in input buffering");
|
||||
}
|
||||
ArrayUtil.blockSizeCheck(plainLen, blockSize);
|
||||
ArrayUtil.nullAndBoundsCheck(plain, plainOffset, plainLen);
|
||||
ArrayUtil.nullAndBoundsCheck(cipher, cipherOffset, plainLen);
|
||||
|
||||
int i;
|
||||
int endIndex = plainOffset + plainLen;
|
||||
|
||||
|
@ -176,9 +178,10 @@ final class PCBC extends FeedbackCipher {
|
|||
int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
|
||||
byte[] plain, int plainOffset)
|
||||
{
|
||||
if ((cipherLen % blockSize) != 0) {
|
||||
throw new ProviderException("Internal error in input buffering");
|
||||
}
|
||||
ArrayUtil.blockSizeCheck(cipherLen, blockSize);
|
||||
ArrayUtil.nullAndBoundsCheck(cipher, cipherOffset, cipherLen);
|
||||
ArrayUtil.nullAndBoundsCheck(plain, plainOffset, cipherLen);
|
||||
|
||||
int i;
|
||||
int endIndex = cipherOffset + cipherLen;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue