Changeset c6136b5


Ignore:
Timestamp:
Jan 27, 2016 1:47:46 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
3ad1db8
Parents:
d2d5a46
Message:

SHA256Generator: Don't fall back to Sha256Standalone,
SHA-256 support must now be in the JRE.
Deprecate all uses of Sha256Standalone, schedule for removal
in 0.9.27. This will require a new Syndie release.

Location:
core/java/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/gnu/crypto/hash/BaseHashStandalone.java

    rd2d5a46 rc6136b5  
    5252 *
    5353 * @version $Revision: 1.1 $
     54 * @deprecated to be removed in 0.9.27
    5455 */
     56@Deprecated
    5557public abstract class BaseHashStandalone implements IMessageDigestStandalone {
    5658
  • core/java/src/gnu/crypto/hash/IMessageDigestStandalone.java

    rd2d5a46 rc6136b5  
    5555 *
    5656 * @version $Revision: 1.1 $
     57 * @deprecated to be removed in 0.9.27
    5758 */
     59@Deprecated
    5860public interface IMessageDigestStandalone extends Cloneable {
    5961
  • core/java/src/gnu/crypto/hash/Sha256Standalone.java

    rd2d5a46 rc6136b5  
    6565 *
    6666 * @version $Revision: 1.2 $
     67 * @deprecated to be removed in 0.9.27
    6768 */
     69@Deprecated
    6870public class Sha256Standalone extends BaseHashStandalone {
    6971   // Constants and variables
  • core/java/src/net/i2p/crypto/SHA256Generator.java

    rd2d5a46 rc6136b5  
    11package net.i2p.crypto;
    2 
    3 import gnu.crypto.hash.Sha256Standalone;
    42
    53import java.security.DigestException;
     
    1513 *
    1614 * As of release 0.8.7, uses java.security.MessageDigest by default.
    17  * If that is unavailable, it uses
     15 * As of release 0.9.25, uses only MessageDigest.
    1816 * GNU-Crypto {@link gnu.crypto.hash.Sha256Standalone}
     17 * is deprecated.
    1918 */
    2019public final class SHA256Generator {
    2120    private final LinkedBlockingQueue<MessageDigest> _digests;
    22 
    23     private static final boolean _useGnu;
    24 
    25     static {
    26         boolean useGnu = false;
    27         try {
    28             MessageDigest.getInstance("SHA-256");
    29         } catch (NoSuchAlgorithmException e) {
    30             useGnu = true;
    31             System.out.println("INFO: Using GNU SHA-256");
    32         }
    33         _useGnu = useGnu;
    34     }
    3521
    3622    /**
     
    9783   
    9884    /**
    99      *  Return a new MessageDigest from the system libs unless unavailable
    100      *  in this JVM, in that case return a wrapped GNU Sha256Standalone
     85     *  Return a new MessageDigest from the system libs.
    10186     *  @since 0.8.7, public since 0.8.8 for FortunaStandalone
    10287     */
    10388    public static MessageDigest getDigestInstance() {
    104         if (!_useGnu) {
    105             try {
    106                 return MessageDigest.getInstance("SHA-256");
    107             } catch (NoSuchAlgorithmException e) {}
    108         }
    109         return new GnuMessageDigest();
    110     }
    111 
    112     /**
    113      *  Wrapper to make Sha256Standalone a MessageDigest
    114      *  @since 0.8.7
    115      */
    116     private static class GnuMessageDigest extends MessageDigest {
    117         private final Sha256Standalone _gnu;
    118 
    119         protected GnuMessageDigest() {
    120             super("SHA-256");
    121             _gnu = new Sha256Standalone();
    122         }
    123 
    124         protected byte[] engineDigest() {
    125             return _gnu.digest();
    126         }
    127 
    128         protected void engineReset() {
    129             _gnu.reset();
    130         }
    131 
    132         protected void engineUpdate(byte input) {
    133             _gnu.update(input);
    134         }
    135 
    136         protected void engineUpdate(byte[] input, int offset, int len) {
    137             _gnu.update(input, offset, len);
     89        try {
     90            return MessageDigest.getInstance("SHA-256");
     91        } catch (NoSuchAlgorithmException e) {
     92            throw new RuntimeException(e);
    13893        }
    13994    }
  • core/java/src/net/i2p/data/DataHelper.java

    rd2d5a46 rc6136b5  
    13251325     * @param hash null OK
    13261326     * @return null on EOF
    1327      * @deprecated use MessageDigest version
    1328      */
     1327     * @deprecated use MessageDigest version to be removed in 0.9.27
     1328     */
     1329    @Deprecated
    13291330    public static String readLine(InputStream in, Sha256Standalone hash) throws IOException {
    13301331        StringBuilder buf = new StringBuilder(128);
     
    13811382     * @return true if the line was read, false if eof was reached on an empty line
    13821383     *              (returns true for non-empty last line without a newline)
    1383      * @deprecated use StringBuilder / MessageDigest version
     1384     * @deprecated use StringBuilder / MessageDigest version, to be removed in 0.9.27
    13841385     */
    13851386    @Deprecated
     
    14211422     * @return true if the line was read, false if eof was reached on an empty line
    14221423     *              (returns true for non-empty last line without a newline)
    1423      * @deprecated use MessageDigest version
    1424      */
     1424     * @deprecated use MessageDigest version, to be removed in 0.9.27
     1425     */
     1426    @Deprecated
    14251427    public static boolean readLine(InputStream in, StringBuilder buf, Sha256Standalone hash) throws IOException {
    14261428        int c = -1;
     
    14641466    /**
    14651467     *  update the hash along the way
    1466      *  @deprecated use MessageDigest version
    1467      */
     1468     *  @deprecated use MessageDigest version, to be removed in 0.9.27
     1469     */
     1470    @Deprecated
    14681471    public static void write(OutputStream out, byte data[], Sha256Standalone hash) throws IOException {
    14691472        hash.update(data);
Note: See TracChangeset for help on using the changeset viewer.