Skip to content

Commit 0e88a50

Browse files
author
gefeili
committed
Add Mayo to BouncyCastleProvider
1 parent 9d39e6f commit 0e88a50

File tree

1 file changed

+43
-37
lines changed

1 file changed

+43
-37
lines changed

prov/src/main/java/org/bouncycastle/jce/provider/BouncyCastleProvider.java

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.bouncycastle.pqc.jcajce.provider.hqc.HQCKeyFactorySpi;
3939
import org.bouncycastle.pqc.jcajce.provider.kyber.KyberKeyFactorySpi;
4040
import org.bouncycastle.pqc.jcajce.provider.lms.LMSKeyFactorySpi;
41+
import org.bouncycastle.pqc.jcajce.provider.mayo.MayoKeyFactorySpi;
4142
import org.bouncycastle.pqc.jcajce.provider.newhope.NHKeyFactorySpi;
4243
import org.bouncycastle.pqc.jcajce.provider.ntru.NTRUKeyFactorySpi;
4344
import org.bouncycastle.pqc.jcajce.provider.picnic.PicnicKeyFactorySpi;
@@ -92,73 +93,73 @@ public final class BouncyCastleProvider extends Provider
9293
private static final String SYMMETRIC_PACKAGE = "org.bouncycastle.jcajce.provider.symmetric.";
9394

9495
private static final String[] SYMMETRIC_GENERIC =
95-
{
96-
"PBEPBKDF1", "PBEPBKDF2", "PBEPKCS12", "TLSKDF", "SCRYPT"
97-
};
96+
{
97+
"PBEPBKDF1", "PBEPBKDF2", "PBEPKCS12", "TLSKDF", "SCRYPT"
98+
};
9899

99100
private static final String[] SYMMETRIC_MACS =
100-
{
101-
"SipHash", "SipHash128", "Poly1305"
102-
};
101+
{
102+
"SipHash", "SipHash128", "Poly1305"
103+
};
103104

104105
private static final CryptoServiceProperties[] SYMMETRIC_CIPHERS =
105-
{
106-
// TODO: these numbers need a bit more work, we cap at 256 bits.
107-
service("AES", 256), service("ARC4", 20), service("ARIA", 256), service("Blowfish", 128), service("Camellia", 256),
108-
service("CAST5", 128), service("CAST6", 256), service("ChaCha", 128), service("DES", 56), service("DESede", 112),
109-
service("GOST28147", 128), service("Grainv1", 128), service("Grain128", 128), service("HC128", 128), service("HC256", 256),
110-
service("IDEA", 128), service("Noekeon", 128), service("RC2", 128), service("RC5", 128), service("RC6", 256),
111-
service("Rijndael", 256), service("Salsa20", 128), service("SEED", 128), service("Serpent", 256), service("Shacal2", 128),
112-
service("Skipjack", 80), service("SM4", 128), service("TEA", 128), service("Twofish", 256), service("Threefish", 128),
113-
service("VMPC", 128), service("VMPCKSA3", 128), service("XTEA", 128), service("XSalsa20", 128), service("OpenSSLPBKDF", 128),
114-
service("DSTU7624", 256), service("GOST3412_2015", 256), service("Zuc", 128)
115-
};
116-
117-
/*
106+
{
107+
// TODO: these numbers need a bit more work, we cap at 256 bits.
108+
service("AES", 256), service("ARC4", 20), service("ARIA", 256), service("Blowfish", 128), service("Camellia", 256),
109+
service("CAST5", 128), service("CAST6", 256), service("ChaCha", 128), service("DES", 56), service("DESede", 112),
110+
service("GOST28147", 128), service("Grainv1", 128), service("Grain128", 128), service("HC128", 128), service("HC256", 256),
111+
service("IDEA", 128), service("Noekeon", 128), service("RC2", 128), service("RC5", 128), service("RC6", 256),
112+
service("Rijndael", 256), service("Salsa20", 128), service("SEED", 128), service("Serpent", 256), service("Shacal2", 128),
113+
service("Skipjack", 80), service("SM4", 128), service("TEA", 128), service("Twofish", 256), service("Threefish", 128),
114+
service("VMPC", 128), service("VMPCKSA3", 128), service("XTEA", 128), service("XSalsa20", 128), service("OpenSSLPBKDF", 128),
115+
service("DSTU7624", 256), service("GOST3412_2015", 256), service("Zuc", 128)
116+
};
117+
118+
/*
118119
* Configurable asymmetric ciphers
119120
*/
120121
private static final String ASYMMETRIC_PACKAGE = "org.bouncycastle.jcajce.provider.asymmetric.";
121122

122123
// this one is required for GNU class path - it needs to be loaded first as the
123124
// later ones configure it.
124125
private static final String[] ASYMMETRIC_GENERIC =
125-
{
126-
"X509", "IES", "COMPOSITE", "EXTERNAL", "CompositeSignatures", "NoSig"
127-
};
126+
{
127+
"X509", "IES", "COMPOSITE", "EXTERNAL", "CompositeSignatures", "NoSig"
128+
};
128129

129130
private static final String[] ASYMMETRIC_CIPHERS =
130-
{
131-
"DSA", "DH", "EC", "RSA", "GOST", "ECGOST", "ElGamal", "DSTU4145", "GM", "EdEC", "LMS", "SPHINCSPlus", "Dilithium", "Falcon", "NTRU", "CONTEXT", "SLHDSA", "MLDSA", "MLKEM"
132-
};
131+
{
132+
"DSA", "DH", "EC", "RSA", "GOST", "ECGOST", "ElGamal", "DSTU4145", "GM", "EdEC", "LMS", "SPHINCSPlus", "Dilithium", "Falcon", "NTRU", "CONTEXT", "SLHDSA", "MLDSA", "MLKEM"
133+
};
133134

134135
/*
135136
* Configurable digests
136137
*/
137138
private static final String DIGEST_PACKAGE = "org.bouncycastle.jcajce.provider.digest.";
138139
private static final String[] DIGESTS =
139-
{
140-
"GOST3411", "Keccak", "MD2", "MD4", "MD5", "SHA1", "RIPEMD128", "RIPEMD160", "RIPEMD256", "RIPEMD320", "SHA224",
141-
"SHA256", "SHA384", "SHA512", "SHA3", "Skein", "SM3", "Tiger", "Whirlpool", "Blake2b", "Blake2s", "DSTU7564",
142-
"Haraka", "Blake3"
143-
};
140+
{
141+
"GOST3411", "Keccak", "MD2", "MD4", "MD5", "SHA1", "RIPEMD128", "RIPEMD160", "RIPEMD256", "RIPEMD320", "SHA224",
142+
"SHA256", "SHA384", "SHA512", "SHA3", "Skein", "SM3", "Tiger", "Whirlpool", "Blake2b", "Blake2s", "DSTU7564",
143+
"Haraka", "Blake3"
144+
};
144145

145146
/*
146147
* Configurable keystores
147148
*/
148149
private static final String KEYSTORE_PACKAGE = "org.bouncycastle.jcajce.provider.keystore.";
149150
private static final String[] KEYSTORES =
150-
{
151-
"BC", "BCFKS", "PKCS12"
152-
};
151+
{
152+
"BC", "BCFKS", "PKCS12"
153+
};
153154

154155
/*
155156
* Configurable secure random
156157
*/
157158
private static final String SECURE_RANDOM_PACKAGE = "org.bouncycastle.jcajce.provider.drbg.";
158159
private static final String[] SECURE_RANDOMS =
159-
{
160-
"DRBG"
161-
};
160+
{
161+
"DRBG"
162+
};
162163

163164
private Map<String, Service> serviceMap = new ConcurrentHashMap<String, Service>();
164165

@@ -437,6 +438,11 @@ private void loadPQCKeys()
437438
addKeyInfoConverter(BCObjectIdentifiers.ntruhps2048677, new NTRUKeyFactorySpi());
438439
addKeyInfoConverter(BCObjectIdentifiers.ntruhps4096821, new NTRUKeyFactorySpi());
439440
addKeyInfoConverter(BCObjectIdentifiers.ntruhrss701, new NTRUKeyFactorySpi());
441+
442+
addKeyInfoConverter(BCObjectIdentifiers.mayo1, new MayoKeyFactorySpi());
443+
addKeyInfoConverter(BCObjectIdentifiers.mayo2, new MayoKeyFactorySpi());
444+
addKeyInfoConverter(BCObjectIdentifiers.mayo3, new MayoKeyFactorySpi());
445+
addKeyInfoConverter(BCObjectIdentifiers.mayo5, new MayoKeyFactorySpi());
440446
}
441447

442448
public void setParameter(String parameterName, Object parameter)
@@ -480,7 +486,7 @@ public void addAlgorithm(String type, ASN1ObjectIdentifier oid, String className
480486
addAttributes(type + "." + oid, attributes);
481487
addAttributes(type + ".OID." + oid, attributes);
482488
}
483-
489+
484490
public void addKeyInfoConverter(ASN1ObjectIdentifier oid, AsymmetricKeyInfoConverter keyInfoConverter)
485491
{
486492
synchronized (keyInfoConverters)

0 commit comments

Comments
 (0)