1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.crypto.password.internal.pbe.factory; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Named; |
24 |
|
import javax.inject.Singleton; |
25 |
|
|
26 |
|
import org.bouncycastle.asn1.DEROctetString; |
27 |
|
import org.bouncycastle.asn1.pkcs.EncryptionScheme; |
28 |
|
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; |
29 |
|
import org.xwiki.component.annotation.Component; |
30 |
|
import org.xwiki.crypto.cipher.CipherFactory; |
31 |
|
import org.xwiki.crypto.params.cipher.symmetric.KeyWithIVParameters; |
32 |
|
import org.xwiki.crypto.params.cipher.symmetric.SymmetricCipherParameters; |
33 |
|
import org.xwiki.crypto.password.KeyDerivationFunction; |
34 |
|
import org.xwiki.crypto.password.PasswordBasedCipher; |
35 |
|
import org.xwiki.crypto.password.internal.pbe.AbstractBcPBES2Cipher; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
43 |
|
@Component(hints = { "PBES2-DESede-CBC-Pad", "PBES2-DES-EDE3-CBC-Pad", "1.2.840.113549.3.7" }) |
44 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 1 |
|
45 |
|
public class BcPBES2DesEdeCipherFactory extends AbstractBcPBES2CipherFactory |
46 |
|
{ |
47 |
|
@Inject |
48 |
|
@Named("DESede/CBC/PKCS5Padding") |
49 |
|
private CipherFactory cipherFactory; |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
4 |
@Override... |
52 |
|
protected CipherFactory getCipherFactory() |
53 |
|
{ |
54 |
4 |
return this.cipherFactory; |
55 |
|
} |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
57 |
2 |
@Override... |
58 |
|
protected PasswordBasedCipher getPasswordBasedCipher(boolean forEncryption, KeyDerivationFunction kdf, |
59 |
|
SymmetricCipherParameters params) |
60 |
|
{ |
61 |
2 |
return new AbstractBcPBES2Cipher(getCipherFactory().getInstance(forEncryption, params), kdf, params) |
62 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
1 |
@Override... |
64 |
|
protected EncryptionScheme getScheme(SymmetricCipherParameters parameters) |
65 |
|
{ |
66 |
1 |
return new EncryptionScheme(PKCSObjectIdentifiers.des_EDE3_CBC, |
67 |
|
new DEROctetString(((KeyWithIVParameters) parameters).getIV())); |
68 |
|
} |
69 |
|
}; |
70 |
|
} |
71 |
|
} |