PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/prov/src/main/java/org/bouncycastle/jcajce/provider/symmetric/Blowfish.java

https://gitlab.com/edgardo001/bc-java
Java | 88 lines | 76 code | 12 blank | 0 comment | 0 complexity | 53cb41abaa4fb10cf4f967cd4492c3b2 MD5 | raw file
  1. package org.bouncycastle.jcajce.provider.symmetric;
  2. import org.bouncycastle.asn1.misc.MiscObjectIdentifiers;
  3. import org.bouncycastle.crypto.CipherKeyGenerator;
  4. import org.bouncycastle.crypto.engines.BlowfishEngine;
  5. import org.bouncycastle.crypto.macs.CMac;
  6. import org.bouncycastle.crypto.modes.CBCBlockCipher;
  7. import org.bouncycastle.jcajce.provider.config.ConfigurableProvider;
  8. import org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher;
  9. import org.bouncycastle.jcajce.provider.symmetric.util.BaseKeyGenerator;
  10. import org.bouncycastle.jcajce.provider.symmetric.util.BaseMac;
  11. import org.bouncycastle.jcajce.provider.symmetric.util.IvAlgorithmParameters;
  12. import org.bouncycastle.jcajce.provider.util.AlgorithmProvider;
  13. public final class Blowfish
  14. {
  15. private Blowfish()
  16. {
  17. }
  18. public static class ECB
  19. extends BaseBlockCipher
  20. {
  21. public ECB()
  22. {
  23. super(new BlowfishEngine());
  24. }
  25. }
  26. public static class CBC
  27. extends BaseBlockCipher
  28. {
  29. public CBC()
  30. {
  31. super(new CBCBlockCipher(new BlowfishEngine()), 64);
  32. }
  33. }
  34. public static class CMAC
  35. extends BaseMac
  36. {
  37. public CMAC()
  38. {
  39. super(new CMac(new BlowfishEngine()));
  40. }
  41. }
  42. public static class KeyGen
  43. extends BaseKeyGenerator
  44. {
  45. public KeyGen()
  46. {
  47. super("Blowfish", 128, new CipherKeyGenerator());
  48. }
  49. }
  50. public static class AlgParams
  51. extends IvAlgorithmParameters
  52. {
  53. protected String engineToString()
  54. {
  55. return "Blowfish IV";
  56. }
  57. }
  58. public static class Mappings
  59. extends AlgorithmProvider
  60. {
  61. private static final String PREFIX = Blowfish.class.getName();
  62. public Mappings()
  63. {
  64. }
  65. public void configure(ConfigurableProvider provider)
  66. {
  67. provider.addAlgorithm("Mac.BLOWFISHCMAC", PREFIX + "$CMAC");
  68. provider.addAlgorithm("Cipher.BLOWFISH", PREFIX + "$ECB");
  69. provider.addAlgorithm("Cipher", MiscObjectIdentifiers.cryptlib_algorithm_blowfish_CBC, PREFIX + "$CBC");
  70. provider.addAlgorithm("KeyGenerator.BLOWFISH", PREFIX + "$KeyGen");
  71. provider.addAlgorithm("Alg.Alias.KeyGenerator", MiscObjectIdentifiers.cryptlib_algorithm_blowfish_CBC, "BLOWFISH");
  72. provider.addAlgorithm("AlgorithmParameters.BLOWFISH", PREFIX + "$AlgParams");
  73. provider.addAlgorithm("Alg.Alias.AlgorithmParameters", MiscObjectIdentifiers.cryptlib_algorithm_blowfish_CBC, "BLOWFISH");
  74. }
  75. }
  76. }