PageRenderTime 79ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/external/bouncycastle/bcprov/src/main/java/org/bouncycastle/jcajce/provider/symmetric/Blowfish.java

https://gitlab.com/brian0218/rk3066_r-box_android4.2.2_sdk
Java | 77 lines | 63 code | 11 blank | 3 comment | 0 complexity | f7d5a9205f65d51a4257d0dc4b428f6d MD5 | raw file
  1. package org.bouncycastle.jcajce.provider.symmetric;
  2. import org.bouncycastle.crypto.CipherKeyGenerator;
  3. import org.bouncycastle.crypto.engines.BlowfishEngine;
  4. import org.bouncycastle.crypto.modes.CBCBlockCipher;
  5. import org.bouncycastle.jcajce.provider.config.ConfigurableProvider;
  6. import org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher;
  7. import org.bouncycastle.jcajce.provider.symmetric.util.BaseKeyGenerator;
  8. import org.bouncycastle.jcajce.provider.symmetric.util.IvAlgorithmParameters;
  9. import org.bouncycastle.jcajce.provider.util.AlgorithmProvider;
  10. public final class Blowfish
  11. {
  12. private Blowfish()
  13. {
  14. }
  15. public static class ECB
  16. extends BaseBlockCipher
  17. {
  18. public ECB()
  19. {
  20. super(new BlowfishEngine());
  21. }
  22. }
  23. public static class CBC
  24. extends BaseBlockCipher
  25. {
  26. public CBC()
  27. {
  28. super(new CBCBlockCipher(new BlowfishEngine()), 64);
  29. }
  30. }
  31. public static class KeyGen
  32. extends BaseKeyGenerator
  33. {
  34. public KeyGen()
  35. {
  36. super("Blowfish", 128, new CipherKeyGenerator());
  37. }
  38. }
  39. public static class AlgParams
  40. extends IvAlgorithmParameters
  41. {
  42. protected String engineToString()
  43. {
  44. return "Blowfish IV";
  45. }
  46. }
  47. public static class Mappings
  48. extends AlgorithmProvider
  49. {
  50. private static final String PREFIX = Blowfish.class.getName();
  51. public Mappings()
  52. {
  53. }
  54. public void configure(ConfigurableProvider provider)
  55. {
  56. provider.addAlgorithm("Cipher.BLOWFISH", PREFIX + "$ECB");
  57. // BEGIN android-removed
  58. // provider.addAlgorithm("Cipher.1.3.6.1.4.1.3029.1.2", PREFIX + "$CBC");
  59. // END android-removed
  60. provider.addAlgorithm("KeyGenerator.BLOWFISH", PREFIX + "$KeyGen");
  61. provider.addAlgorithm("Alg.Alias.KeyGenerator.1.3.6.1.4.1.3029.1.2", "BLOWFISH");
  62. provider.addAlgorithm("AlgorithmParameters.BLOWFISH", PREFIX + "$AlgParams");
  63. provider.addAlgorithm("Alg.Alias.AlgorithmParameters.1.3.6.1.4.1.3029.1.2", "BLOWFISH");
  64. }
  65. }
  66. }