1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.crypto.cipher.internal.symmetric.factory; |
21 |
|
|
22 |
|
import javax.inject.Singleton; |
23 |
|
|
24 |
|
import org.bouncycastle.crypto.BlockCipher; |
25 |
|
import org.bouncycastle.crypto.engines.RC2Engine; |
26 |
|
import org.bouncycastle.crypto.params.RC2Parameters; |
27 |
|
import org.xwiki.component.annotation.Component; |
28 |
|
import org.xwiki.crypto.params.cipher.symmetric.KeyParameter; |
29 |
|
import org.xwiki.crypto.params.cipher.symmetric.RC2KeyParameters; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
37 |
|
@Component(hints = { "RC2/CBC/PKCS5Padding", "RC2/CBC/PKCS7Padding", "1.2.840.113549.3.2" }) |
38 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 4 |
Complexity Density: 0.8 |
|
39 |
|
public class BcRc2CbcPaddedCipherFactory extends AbstractBcCbcPaddedCipherFactory |
40 |
|
{ |
41 |
|
|
42 |
|
private static final int[] KEY_SIZES = newKeySizeArray(1, 64, 1); |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
44 |
7 |
@Override... |
45 |
|
protected org.bouncycastle.crypto.CipherParameters getBcKeyParameter(KeyParameter parameter) |
46 |
|
{ |
47 |
7 |
if (parameter instanceof RC2KeyParameters) { |
48 |
4 |
return new RC2Parameters(parameter.getKey(), ((RC2KeyParameters) parameter).getEffectiveBits()); |
49 |
|
} else { |
50 |
3 |
return new org.bouncycastle.crypto.params.KeyParameter(parameter.getKey()); |
51 |
|
} |
52 |
|
} |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
9 |
@Override... |
55 |
|
protected BlockCipher getEngineInstance() |
56 |
|
{ |
57 |
9 |
return new RC2Engine(); |
58 |
|
} |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
3 |
@Override... |
61 |
|
public int[] getSupportedKeySizes() |
62 |
|
{ |
63 |
3 |
return KEY_SIZES; |
64 |
|
} |
65 |
|
} |