InsecureCipherFactory.java

  1. /*
  2.  * Copyright (C) 2016, Google Inc. and others
  3.  *
  4.  * This program and the accompanying materials are made available under the
  5.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  6.  * https://www.eclipse.org/org/documents/edl-v10.php.
  7.  *
  8.  * SPDX-License-Identifier: BSD-3-Clause
  9.  */

  10. package org.eclipse.jgit.transport;

  11. import java.security.NoSuchAlgorithmException;

  12. import javax.crypto.Cipher;
  13. import javax.crypto.NoSuchPaddingException;

  14. /**
  15.  * <b>DO NOT USE</b> Factory to create any cipher.
  16.  * <p>
  17.  * This is a hack for {@link WalkEncryption} to create any cipher configured by
  18.  * the end-user. Using this class allows JGit to violate ErrorProne's security
  19.  * recommendations (<a
  20.  * href="https://errorprone.info/bugpattern/InsecureCryptoUsage"
  21.  * >InsecureCryptoUsage</a>), which is not secure.
  22.  */
  23. class InsecureCipherFactory {
  24.     static Cipher create(String algo)
  25.             throws NoSuchAlgorithmException, NoSuchPaddingException {
  26.         return Cipher.getInstance(algo);
  27.     }
  28. }