Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
BcDesEdeCbcPaddedCipherFactoryTest | 29 | 8 | 0% | 3 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.crypto.cipher.internal.symmetric.factory; | |
21 | ||
22 | import org.junit.Before; | |
23 | import org.junit.Rule; | |
24 | import org.xwiki.crypto.cipher.Cipher; | |
25 | import org.xwiki.crypto.cipher.CipherFactory; | |
26 | import org.xwiki.crypto.params.cipher.symmetric.KeyWithIVParameters; | |
27 | import org.xwiki.test.mockito.MockitoComponentMockingRule; | |
28 | ||
29 | public class BcDesEdeCbcPaddedCipherFactoryTest extends AbstractSymmetricCipherFactoryTest | |
30 | { | |
31 | @Rule | |
32 | public final MockitoComponentMockingRule<CipherFactory> mocker = | |
33 | new MockitoComponentMockingRule<CipherFactory>(BcDesEdeCbcPaddedCipherFactory.class); | |
34 | ||
35 | 12 | { |
36 | 12 | CIPHER_ALGO = "DESede/CBC/PKCS5Padding"; |
37 | 12 | BLOCK_SIZE = 8; |
38 | 12 | KEY_SIZE = 24; |
39 | 12 | SUPPORTED_KEY_SIZE = new int[] { 16, 24 }; |
40 | ||
41 | 12 | BYTES_ENCRYPTED_SIZE = ((BYTES.length / BLOCK_SIZE) * BLOCK_SIZE) + BLOCK_SIZE; |
42 | 12 | ANOTHER_BYTES_ENCRYPTED_SIZE = ((ANOTHER_BYTES.length / BLOCK_SIZE) * BLOCK_SIZE) + BLOCK_SIZE; |
43 | } | |
44 | ||
45 | 12 | @Before |
46 | public void configure() throws Exception | |
47 | { | |
48 | 12 | factory = mocker.getComponentUnderTest(); |
49 | } | |
50 | ||
51 | 2 | @Override |
52 | Cipher getCipherInstance(boolean forEncryption) | |
53 | { | |
54 | 2 | return factory.getInstance(forEncryption, new KeyWithIVParameters(KEY16, IV8)); |
55 | } | |
56 | } |