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.ASN1ObjectIdentifier; |
27 |
|
import org.bouncycastle.asn1.DEROctetString; |
28 |
|
import org.bouncycastle.asn1.pkcs.EncryptionScheme; |
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 |
|
|
41 |
|
|
42 |
|
@version |
43 |
|
@since |
44 |
|
|
45 |
|
@Component(hints = { "PBES2-Blowfish-CBC-Pad", "1.3.6.1.4.1.3029.1.2" }) |
46 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 1 |
|
47 |
|
public class BcPBES2BlowfishCipherFactory extends AbstractBcPBES2CipherFactory |
48 |
|
{ |
49 |
|
private static final ASN1ObjectIdentifier ALG_ID = new ASN1ObjectIdentifier("1.3.6.1.4.1.3029.1.2"); |
50 |
|
|
51 |
|
@Inject |
52 |
|
@Named("Blowfish/CBC/PKCS5Padding") |
53 |
|
private CipherFactory cipherFactory; |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
12 |
@Override... |
56 |
|
protected CipherFactory getCipherFactory() |
57 |
|
{ |
58 |
12 |
return this.cipherFactory; |
59 |
|
} |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
6 |
@Override... |
62 |
|
protected PasswordBasedCipher getPasswordBasedCipher(boolean forEncryption, final KeyDerivationFunction kdf, |
63 |
|
SymmetricCipherParameters params) |
64 |
|
{ |
65 |
6 |
return new AbstractBcPBES2Cipher(getCipherFactory().getInstance(forEncryption, params), kdf, params) |
66 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
7 |
@Override... |
68 |
|
protected EncryptionScheme getScheme(SymmetricCipherParameters parameters) |
69 |
|
{ |
70 |
7 |
return new EncryptionScheme(ALG_ID, |
71 |
|
new DEROctetString(((KeyWithIVParameters) parameters).getIV())); |
72 |
|
} |
73 |
|
}; |
74 |
|
} |
75 |
|
} |