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; |
21 |
|
|
22 |
|
import java.math.BigInteger; |
23 |
|
|
24 |
|
import org.bouncycastle.asn1.ASN1EncodableVector; |
25 |
|
import org.bouncycastle.asn1.ASN1Integer; |
26 |
|
import org.bouncycastle.asn1.ASN1Object; |
27 |
|
import org.bouncycastle.asn1.ASN1OctetString; |
28 |
|
import org.bouncycastle.asn1.ASN1Primitive; |
29 |
|
import org.bouncycastle.asn1.ASN1Sequence; |
30 |
|
import org.bouncycastle.asn1.DEROctetString; |
31 |
|
import org.bouncycastle.asn1.DERSequence; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
|
|
| 0% |
Uncovered Elements: 51 (51) |
Complexity: 16 |
Complexity Density: 0.55 |
|
43 |
|
public class RC5CBCParameter extends ASN1Object |
44 |
|
{ |
45 |
|
private ASN1Integer version; |
46 |
|
|
47 |
|
private ASN1Integer rounds; |
48 |
|
|
49 |
|
private ASN1Integer blockSizeInBits; |
50 |
|
|
51 |
|
private ASN1OctetString iv; |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
@param |
57 |
|
@param |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
0 |
public RC5CBCParameter(int rounds, int blockSizeInBits)... |
60 |
|
{ |
61 |
0 |
this(16, rounds, blockSizeInBits, null); |
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
@param |
68 |
|
@param |
69 |
|
@param |
70 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
0 |
public RC5CBCParameter(int rounds, int blockSizeInBits, byte[] iv)... |
72 |
|
{ |
73 |
0 |
this(16, rounds, blockSizeInBits, iv); |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
@param |
80 |
|
@param |
81 |
|
@param |
82 |
|
@param |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
84 |
0 |
public RC5CBCParameter(int parameterVersion, int rounds, int blockSizeInBits, byte[] iv)... |
85 |
|
{ |
86 |
0 |
this.version = new ASN1Integer(parameterVersion); |
87 |
0 |
this.rounds = new ASN1Integer(rounds); |
88 |
0 |
this.blockSizeInBits = new ASN1Integer(blockSizeInBits); |
89 |
0 |
this.iv = (iv != null) ? new DEROctetString(iv) : null; |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
@param |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
97 |
0 |
private RC5CBCParameter(ASN1Sequence seq)... |
98 |
|
{ |
99 |
0 |
this.version = (ASN1Integer) seq.getObjectAt(0); |
100 |
0 |
this.rounds = (ASN1Integer) seq.getObjectAt(1); |
101 |
0 |
this.blockSizeInBits = (ASN1Integer) seq.getObjectAt(2); |
102 |
0 |
if (seq.size() > 3) { |
103 |
0 |
this.iv = (ASN1OctetString) seq.getObjectAt(3); |
104 |
|
} |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
@param |
111 |
|
@return |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
113 |
0 |
public static RC5CBCParameter getInstance(Object obj)... |
114 |
|
{ |
115 |
0 |
if (obj instanceof RC5CBCParameter) { |
116 |
0 |
return (RC5CBCParameter) obj; |
117 |
|
} |
118 |
0 |
if (obj != null) { |
119 |
0 |
return new RC5CBCParameter(ASN1Sequence.getInstance(obj)); |
120 |
|
} |
121 |
0 |
return null; |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
@return |
126 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
127 |
0 |
public BigInteger getRC5ParameterVersion()... |
128 |
|
{ |
129 |
0 |
return this.version.getValue(); |
130 |
|
} |
131 |
|
|
132 |
|
|
133 |
|
@return |
134 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
0 |
public BigInteger getRounds()... |
136 |
|
{ |
137 |
0 |
return this.rounds.getValue(); |
138 |
|
} |
139 |
|
|
140 |
|
|
141 |
|
@return |
142 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
143 |
0 |
public BigInteger getBlockSizeInBits()... |
144 |
|
{ |
145 |
0 |
return this.blockSizeInBits.getValue(); |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
|
@return |
150 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
151 |
0 |
public byte[] getIV()... |
152 |
|
{ |
153 |
0 |
if (this.iv == null) { |
154 |
0 |
return null; |
155 |
|
} |
156 |
0 |
return this.iv.getOctets(); |
157 |
|
} |
158 |
|
|
159 |
|
|
160 |
|
@return |
161 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
162 |
0 |
@Override... |
163 |
|
public ASN1Primitive toASN1Primitive() |
164 |
|
{ |
165 |
0 |
ASN1EncodableVector v = new ASN1EncodableVector(); |
166 |
|
|
167 |
0 |
v.add(this.version); |
168 |
0 |
v.add(this.rounds); |
169 |
0 |
v.add(this.blockSizeInBits); |
170 |
0 |
if (this.iv != null) { |
171 |
0 |
v.add(this.iv); |
172 |
|
} |
173 |
|
|
174 |
0 |
return new DERSequence(v); |
175 |
|
} |
176 |
|
} |