Skip to content

Commit d01cb29

Browse files
author
Alexandr Pliushchou
committed
create package-private AESCipherCBCnoPad, update documentation
DEVSIX-8933
1 parent 8af5aef commit d01cb29

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

kernel/src/main/java/com/itextpdf/kernel/crypto/AESCipherCBCnoPad.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ This file is part of the iText (R) project.
3434

3535
/**
3636
* Creates an AES Cipher with CBC and no padding.
37+
* @deprecated the AES-CBC cipher is a low-level cryptographic primitive
38+
* that requires careful understanding to use it safely.
39+
* This class is only a thin wrapper and is not intended for general use.
40+
* Instead, use API provided by cryptography libraries directly
41+
* or rely on high-level PDF encryption functionality.
3742
*/
43+
@Deprecated
3844
public class AESCipherCBCnoPad {
3945

4046
private static final String CIPHER_WITHOUT_PADDING = "AES/CBC/NoPadding";
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2025 Apryse Group NV
4+
Authors: Apryse Software.
5+
6+
This program is offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
package com.itextpdf.kernel.crypto.securityhandler;
24+
25+
/**
26+
* Creates an AES Cipher with CBC and no padding.
27+
*/
28+
class AESCipherCBCnoPad {
29+
30+
com.itextpdf.kernel.crypto.AESCipherCBCnoPad aESCipherCBCnoPad;
31+
32+
/**
33+
* Creates a new instance of AESCipher with CBC and no padding
34+
*
35+
* @param forEncryption if true the cipher is initialised for
36+
* encryption, if false for decryption
37+
* @param key the key to be used in the cipher
38+
*/
39+
AESCipherCBCnoPad(boolean forEncryption, byte[] key) {
40+
aESCipherCBCnoPad = new com.itextpdf.kernel.crypto.AESCipherCBCnoPad(forEncryption, key);
41+
}
42+
43+
/**
44+
* Creates a new instance of AESCipher with CBC and no padding
45+
*
46+
* @param forEncryption if true the cipher is initialised for
47+
* encryption, if false for decryption
48+
* @param key the key to be used in the cipher
49+
* @param initVector initialization vector to be used in cipher
50+
*/
51+
AESCipherCBCnoPad(boolean forEncryption, byte[] key, byte[] initVector) {
52+
aESCipherCBCnoPad = new com.itextpdf.kernel.crypto.AESCipherCBCnoPad(forEncryption, key, initVector);
53+
}
54+
55+
byte[] processBlock(byte[] inp, int inpOff, int inpLen) {
56+
return aESCipherCBCnoPad.processBlock(inp, inpOff, inpLen);
57+
}
58+
}

kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAes256.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ This file is part of the iText (R) project.
2525
import com.itextpdf.io.logs.IoLogMessageConstant;
2626
import com.itextpdf.io.util.StreamUtil;
2727
import com.itextpdf.kernel.exceptions.PdfException;
28-
import com.itextpdf.kernel.crypto.AESCipherCBCnoPad;
2928
import com.itextpdf.kernel.crypto.AesDecryptor;
3029
import com.itextpdf.kernel.exceptions.BadPasswordException;
3130
import com.itextpdf.kernel.crypto.IDecryptor;

0 commit comments

Comments
 (0)