Fix boundary checks
This commit is contained in:
parent
afc86a3b6d
commit
e685af924d
@ -187,7 +187,7 @@ class AESGCMFallbackCipherState implements CipherState {
|
||||
int space;
|
||||
if (ciphertextOffset < 0 || ciphertextOffset > ciphertext.length)
|
||||
throw new IllegalArgumentException();
|
||||
if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length || length > plaintext.length || (plaintext.length - plaintextOffset) < length)
|
||||
if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length || length > ciphertext.length || (ciphertext.length - ciphertextOffset) < length)
|
||||
throw new IllegalArgumentException();
|
||||
space = ciphertext.length - ciphertextOffset;
|
||||
if (!haskey) {
|
||||
@ -221,7 +221,7 @@ class AESGCMFallbackCipherState implements CipherState {
|
||||
space = ciphertext.length - ciphertextOffset;
|
||||
if (length > space)
|
||||
throw new ShortBufferException();
|
||||
if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length || length > plaintext.length || (plaintext.length - plaintextOffset) < length)
|
||||
if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length || length > ciphertext.length || (ciphertext.length - ciphertextOffset) < length)
|
||||
throw new IllegalArgumentException();
|
||||
space = plaintext.length - plaintextOffset;
|
||||
if (!haskey) {
|
||||
|
||||
@ -220,7 +220,7 @@ class AESGCMOnCtrCipherState implements CipherState {
|
||||
int space;
|
||||
if (ciphertextOffset < 0 || ciphertextOffset > ciphertext.length)
|
||||
throw new IllegalArgumentException();
|
||||
if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length || length > plaintext.length || (plaintext.length - plaintextOffset) < length)
|
||||
if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length || length > ciphertext.length || (ciphertext.length - ciphertextOffset) < length)
|
||||
throw new IllegalArgumentException();
|
||||
space = ciphertext.length - ciphertextOffset;
|
||||
if (keySpec == null) {
|
||||
@ -269,7 +269,7 @@ class AESGCMOnCtrCipherState implements CipherState {
|
||||
space = ciphertext.length - ciphertextOffset;
|
||||
if (length > space)
|
||||
throw new ShortBufferException();
|
||||
if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length || length > plaintext.length || (plaintext.length - plaintextOffset) < length)
|
||||
if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length || length > ciphertext.length || (ciphertext.length - ciphertextOffset) < length)
|
||||
throw new IllegalArgumentException();
|
||||
space = plaintext.length - plaintextOffset;
|
||||
if (keySpec == null) {
|
||||
|
||||
@ -248,7 +248,7 @@ class ChaChaPolyCipherState implements CipherState {
|
||||
space = ciphertext.length - ciphertextOffset;
|
||||
if (length > space)
|
||||
throw new ShortBufferException();
|
||||
if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length || length > plaintext.length || (plaintext.length - plaintextOffset) < length)
|
||||
if (length < 0 || plaintextOffset < 0 || plaintextOffset > plaintext.length || length > ciphertext.length || (ciphertext.length - ciphertextOffset) < length)
|
||||
throw new IllegalArgumentException();
|
||||
space = plaintext.length - plaintextOffset;
|
||||
if (!haskey) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user