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.kdf; |
21 |
|
|
22 |
|
import java.util.Enumeration; |
23 |
|
|
24 |
|
import org.bouncycastle.asn1.ASN1Encodable; |
25 |
|
import org.bouncycastle.asn1.ASN1EncodableVector; |
26 |
|
import org.bouncycastle.asn1.ASN1Object; |
27 |
|
import org.bouncycastle.asn1.ASN1Primitive; |
28 |
|
import org.bouncycastle.asn1.ASN1Sequence; |
29 |
|
import org.bouncycastle.asn1.DERSequence; |
30 |
|
import org.bouncycastle.asn1.pkcs.EncryptionScheme; |
31 |
|
import org.bouncycastle.asn1.pkcs.KeyDerivationFunc; |
32 |
|
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; |
33 |
|
|
34 |
|
|
35 |
|
@link |
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
|
|
| 82.9% |
Uncovered Elements: 6 (35) |
Complexity: 10 |
Complexity Density: 0.48 |
|
40 |
|
public class PBES2Parameters |
41 |
|
extends ASN1Object |
42 |
|
implements PKCSObjectIdentifiers |
43 |
|
{ |
44 |
|
private KeyDerivationFunc func; |
45 |
|
|
46 |
|
private EncryptionScheme scheme; |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
@param |
52 |
|
@param |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
54 |
25 |
public PBES2Parameters(KeyDerivationFunc keyDevFunc, EncryptionScheme encScheme)... |
55 |
|
{ |
56 |
25 |
this.func = keyDevFunc; |
57 |
25 |
this.scheme = encScheme; |
58 |
|
} |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
@param |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
65 |
26 |
private PBES2Parameters(ASN1Sequence seq)... |
66 |
|
{ |
67 |
26 |
@SuppressWarnings("unchecked") |
68 |
|
Enumeration<ASN1Encodable> e = seq.getObjects(); |
69 |
26 |
ASN1Sequence funcSeq = ASN1Sequence.getInstance(e.nextElement().toASN1Primitive()); |
70 |
|
|
71 |
26 |
if (funcSeq.getObjectAt(0).equals(id_PBKDF2)) { |
72 |
24 |
this.func = new KeyDerivationFunc(id_PBKDF2, PBKDF2Params.getInstance(funcSeq.getObjectAt(1))); |
73 |
|
} else { |
74 |
2 |
this.func = KeyDerivationFunc.getInstance(funcSeq); |
75 |
|
} |
76 |
|
|
77 |
26 |
this.scheme = EncryptionScheme.getInstance(e.nextElement()); |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
@param |
84 |
|
@return |
85 |
|
|
|
|
| 53.8% |
Uncovered Elements: 6 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
86 |
26 |
public static PBES2Parameters getInstance(Object obj)... |
87 |
|
{ |
88 |
26 |
if (obj instanceof PBES2Parameters) { |
89 |
0 |
return (PBES2Parameters) obj; |
90 |
|
} |
91 |
26 |
if (obj instanceof org.bouncycastle.asn1.pkcs.PBES2Parameters) { |
92 |
0 |
return new PBES2Parameters(((org.bouncycastle.asn1.pkcs.PBES2Parameters) obj).getKeyDerivationFunc(), |
93 |
|
((org.bouncycastle.asn1.pkcs.PBES2Parameters) obj).getEncryptionScheme()); |
94 |
|
} |
95 |
26 |
if (obj != null) { |
96 |
26 |
return new PBES2Parameters(ASN1Sequence.getInstance(obj)); |
97 |
|
} |
98 |
0 |
return null; |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
|
@return |
103 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
104 |
13 |
public KeyDerivationFunc getKeyDerivationFunc()... |
105 |
|
{ |
106 |
13 |
return this.func; |
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
|
@return |
111 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
26 |
public EncryptionScheme getEncryptionScheme()... |
113 |
|
{ |
114 |
26 |
return this.scheme; |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
@return |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
120 |
57 |
@Override... |
121 |
|
public ASN1Primitive toASN1Primitive() |
122 |
|
{ |
123 |
57 |
ASN1EncodableVector v = new ASN1EncodableVector(); |
124 |
|
|
125 |
57 |
v.add(this.func); |
126 |
57 |
v.add(this.scheme); |
127 |
|
|
128 |
57 |
return new DERSequence(v); |
129 |
|
} |
130 |
|
} |