1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
package org.bouncycastle.jcajce.provider.symmetric;
// Android-removed: Unsupported algorithms
// import org.bouncycastle.crypto.BlockCipher;
// import org.bouncycastle.crypto.CipherKeyGenerator;
import org.bouncycastle.crypto.engines.TwofishEngine;
// Android-removed: Unsupported algorithms
// import org.bouncycastle.crypto.generators.Poly1305KeyGenerator;
// import org.bouncycastle.crypto.macs.GMac;
import org.bouncycastle.crypto.modes.CBCBlockCipher;
// Android-removed: Unsupported algorithms
// import org.bouncycastle.crypto.modes.GCMBlockCipher;
import org.bouncycastle.jcajce.provider.config.ConfigurableProvider;
import org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher;
// Android-removed: Unsupported algorithms
// import org.bouncycastle.jcajce.provider.symmetric.util.BaseKeyGenerator;
// import org.bouncycastle.jcajce.provider.symmetric.util.BaseMac;
// import org.bouncycastle.jcajce.provider.symmetric.util.BlockCipherProvider;
// import org.bouncycastle.jcajce.provider.symmetric.util.IvAlgorithmParameters;
import org.bouncycastle.jcajce.provider.symmetric.util.PBESecretKeyFactory;
public final class Twofish
{
private Twofish()
{
}
// BEGIN Android-removed: Unsupported algorithms
/*
public static class ECB
extends BaseBlockCipher
{
public ECB()
{
super(new BlockCipherProvider()
{
public BlockCipher get()
{
return new TwofishEngine();
}
});
}
}
public static class KeyGen
extends BaseKeyGenerator
{
public KeyGen()
{
super("Twofish", 256, new CipherKeyGenerator());
}
}
public static class GMAC
extends BaseMac
{
public GMAC()
{
super(new GMac(new GCMBlockCipher(new TwofishEngine())));
}
}
public static class Poly1305
extends BaseMac
{
public Poly1305()
{
super(new org.bouncycastle.crypto.macs.Poly1305(new TwofishEngine()));
}
}
public static class Poly1305KeyGen
extends BaseKeyGenerator
{
public Poly1305KeyGen()
{
super("Poly1305-Twofish", 256, new Poly1305KeyGenerator());
}
}
*/
// END Android-removed: Unsupported algorithms
/**
* PBEWithSHAAndTwofish-CBC
*/
static public class PBEWithSHAKeyFactory
extends PBESecretKeyFactory
{
public PBEWithSHAKeyFactory()
{
super("PBEwithSHAandTwofish-CBC", null, true, PKCS12, SHA1, 256, 128);
}
}
/**
* PBEWithSHAAndTwofish-CBC
*/
static public class PBEWithSHA
extends BaseBlockCipher
{
public PBEWithSHA()
{
super(new CBCBlockCipher(new TwofishEngine()), PKCS12, SHA1, 256, 16);
}
}
// BEGIN Android-removed: Unsupported algorithms
/*
public static class AlgParams
extends IvAlgorithmParameters
{
protected String engineToString()
{
return "Twofish IV";
}
}
*/
// END Android-removed: Unsupported algorithms
public static class Mappings
extends SymmetricAlgorithmProvider
{
private static final String PREFIX = Twofish.class.getName();
public Mappings()
{
}
public void configure(ConfigurableProvider provider)
{
// BEGIN Android-removed: Unsupported algorithms
// provider.addAlgorithm("Cipher.Twofish", PREFIX + "$ECB");
// provider.addAlgorithm("KeyGenerator.Twofish", PREFIX + "$KeyGen");
// provider.addAlgorithm("AlgorithmParameters.Twofish", PREFIX + "$AlgParams");
// END Android-removed: Unsupported algorithms
// Android-note: These algorithms are necessary for KeyStore.BouncyCastle
provider.addAlgorithm("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDTWOFISH", "PKCS12PBE");
provider.addAlgorithm("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDTWOFISH-CBC", "PKCS12PBE");
provider.addAlgorithm("Cipher.PBEWITHSHAANDTWOFISH-CBC", PREFIX + "$PBEWithSHA");
provider.addAlgorithm("SecretKeyFactory.PBEWITHSHAANDTWOFISH-CBC", PREFIX + "$PBEWithSHAKeyFactory");
// BEGIN Android-removed: Unsupported algorithms
// addGMacAlgorithm(provider, "Twofish", PREFIX + "$GMAC", PREFIX + "$KeyGen");
// addPoly1305Algorithm(provider, "Twofish", PREFIX + "$Poly1305", PREFIX + "$Poly1305KeyGen");
// END Android-removed: Unsupported algorithms
}
}
}
|