/Mate20-9.0/src/main/java/org/bouncycastle/jcajce/provider/symmetric/Blowfish.java

https://github.com/dstmath/HWFramework · Java · 67 lines · 56 code · 10 blank · 1 comment · 0 complexity · 4f238454a0eab1906279ab048fd857fb MD5 · raw file

  1. package org.bouncycastle.jcajce.provider.symmetric;
  2. import org.bouncycastle.asn1.ASN1ObjectIdentifier;
  3. import org.bouncycastle.asn1.misc.MiscObjectIdentifiers;
  4. import org.bouncycastle.crypto.BlockCipher;
  5. import org.bouncycastle.crypto.CipherKeyGenerator;
  6. import org.bouncycastle.crypto.engines.BlowfishEngine;
  7. import org.bouncycastle.crypto.macs.CMac;
  8. import org.bouncycastle.crypto.modes.CBCBlockCipher;
  9. import org.bouncycastle.jcajce.provider.config.ConfigurableProvider;
  10. import org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher;
  11. import org.bouncycastle.jcajce.provider.symmetric.util.BaseKeyGenerator;
  12. import org.bouncycastle.jcajce.provider.symmetric.util.BaseMac;
  13. import org.bouncycastle.jcajce.provider.symmetric.util.IvAlgorithmParameters;
  14. import org.bouncycastle.jcajce.provider.util.AlgorithmProvider;
  15. public final class Blowfish {
  16. public static class AlgParams extends IvAlgorithmParameters {
  17. /* access modifiers changed from: protected */
  18. public String engineToString() {
  19. return "Blowfish IV";
  20. }
  21. }
  22. public static class CBC extends BaseBlockCipher {
  23. public CBC() {
  24. super((BlockCipher) new CBCBlockCipher(new BlowfishEngine()), 64);
  25. }
  26. }
  27. public static class CMAC extends BaseMac {
  28. public CMAC() {
  29. super(new CMac(new BlowfishEngine()));
  30. }
  31. }
  32. public static class ECB extends BaseBlockCipher {
  33. public ECB() {
  34. super((BlockCipher) new BlowfishEngine());
  35. }
  36. }
  37. public static class KeyGen extends BaseKeyGenerator {
  38. public KeyGen() {
  39. super("Blowfish", 128, new CipherKeyGenerator());
  40. }
  41. }
  42. public static class Mappings extends AlgorithmProvider {
  43. private static final String PREFIX = Blowfish.class.getName();
  44. public void configure(ConfigurableProvider configurableProvider) {
  45. configurableProvider.addAlgorithm("Mac.BLOWFISHCMAC", PREFIX + "$CMAC");
  46. configurableProvider.addAlgorithm("Cipher.BLOWFISH", PREFIX + "$ECB");
  47. ASN1ObjectIdentifier aSN1ObjectIdentifier = MiscObjectIdentifiers.cryptlib_algorithm_blowfish_CBC;
  48. configurableProvider.addAlgorithm("Cipher", aSN1ObjectIdentifier, PREFIX + "$CBC");
  49. configurableProvider.addAlgorithm("KeyGenerator.BLOWFISH", PREFIX + "$KeyGen");
  50. configurableProvider.addAlgorithm("Alg.Alias.KeyGenerator", MiscObjectIdentifiers.cryptlib_algorithm_blowfish_CBC, "BLOWFISH");
  51. configurableProvider.addAlgorithm("AlgorithmParameters.BLOWFISH", PREFIX + "$AlgParams");
  52. configurableProvider.addAlgorithm("Alg.Alias.AlgorithmParameters", MiscObjectIdentifiers.cryptlib_algorithm_blowfish_CBC, "BLOWFISH");
  53. }
  54. }
  55. private Blowfish() {
  56. }
  57. }