diff --git a/core/java/src/gnu/crypto/hash/BaseHashStandalone.java b/core/java/src/gnu/crypto/hash/BaseHashStandalone.java index 26d51158f..4c77ff9d3 100644 --- a/core/java/src/gnu/crypto/hash/BaseHashStandalone.java +++ b/core/java/src/gnu/crypto/hash/BaseHashStandalone.java @@ -51,7 +51,9 @@ package gnu.crypto.hash; * See SHA256Generator for more information. * * @version $Revision: 1.1 $ + * @deprecated to be removed in 0.9.27 */ +@Deprecated public abstract class BaseHashStandalone implements IMessageDigestStandalone { // Constants and variables diff --git a/core/java/src/gnu/crypto/hash/IMessageDigestStandalone.java b/core/java/src/gnu/crypto/hash/IMessageDigestStandalone.java index dbba10bb8..b19b3ac8b 100644 --- a/core/java/src/gnu/crypto/hash/IMessageDigestStandalone.java +++ b/core/java/src/gnu/crypto/hash/IMessageDigestStandalone.java @@ -54,7 +54,9 @@ package gnu.crypto.hash; * See SHA256Generator for more information. * * @version $Revision: 1.1 $ + * @deprecated to be removed in 0.9.27 */ +@Deprecated public interface IMessageDigestStandalone extends Cloneable { // Constants diff --git a/core/java/src/gnu/crypto/hash/Sha256Standalone.java b/core/java/src/gnu/crypto/hash/Sha256Standalone.java index 465675cd3..a966b20cf 100644 --- a/core/java/src/gnu/crypto/hash/Sha256Standalone.java +++ b/core/java/src/gnu/crypto/hash/Sha256Standalone.java @@ -64,7 +64,9 @@ package gnu.crypto.hash; * See SHA256Generator for more information. * * @version $Revision: 1.2 $ + * @deprecated to be removed in 0.9.27 */ +@Deprecated public class Sha256Standalone extends BaseHashStandalone { // Constants and variables // ------------------------------------------------------------------------- diff --git a/core/java/src/net/i2p/crypto/SHA256Generator.java b/core/java/src/net/i2p/crypto/SHA256Generator.java index 66d630087..e3facad9e 100644 --- a/core/java/src/net/i2p/crypto/SHA256Generator.java +++ b/core/java/src/net/i2p/crypto/SHA256Generator.java @@ -1,7 +1,5 @@ package net.i2p.crypto; -import gnu.crypto.hash.Sha256Standalone; - import java.security.DigestException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -14,25 +12,13 @@ import net.i2p.data.Hash; * Defines a wrapper for SHA-256 operation. * * As of release 0.8.7, uses java.security.MessageDigest by default. - * If that is unavailable, it uses + * As of release 0.9.25, uses only MessageDigest. * GNU-Crypto {@link gnu.crypto.hash.Sha256Standalone} + * is deprecated. */ public final class SHA256Generator { private final LinkedBlockingQueue _digests; - private static final boolean _useGnu; - - static { - boolean useGnu = false; - try { - MessageDigest.getInstance("SHA-256"); - } catch (NoSuchAlgorithmException e) { - useGnu = true; - System.out.println("INFO: Using GNU SHA-256"); - } - _useGnu = useGnu; - } - /** * @param context unused */ @@ -96,45 +82,14 @@ public final class SHA256Generator { } /** - * Return a new MessageDigest from the system libs unless unavailable - * in this JVM, in that case return a wrapped GNU Sha256Standalone + * Return a new MessageDigest from the system libs. * @since 0.8.7, public since 0.8.8 for FortunaStandalone */ public static MessageDigest getDigestInstance() { - if (!_useGnu) { - try { - return MessageDigest.getInstance("SHA-256"); - } catch (NoSuchAlgorithmException e) {} - } - return new GnuMessageDigest(); - } - - /** - * Wrapper to make Sha256Standalone a MessageDigest - * @since 0.8.7 - */ - private static class GnuMessageDigest extends MessageDigest { - private final Sha256Standalone _gnu; - - protected GnuMessageDigest() { - super("SHA-256"); - _gnu = new Sha256Standalone(); - } - - protected byte[] engineDigest() { - return _gnu.digest(); - } - - protected void engineReset() { - _gnu.reset(); - } - - protected void engineUpdate(byte input) { - _gnu.update(input); - } - - protected void engineUpdate(byte[] input, int offset, int len) { - _gnu.update(input, offset, len); + try { + return MessageDigest.getInstance("SHA-256"); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); } } diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java index a9689add7..dcd1ce71c 100644 --- a/core/java/src/net/i2p/data/DataHelper.java +++ b/core/java/src/net/i2p/data/DataHelper.java @@ -1324,8 +1324,9 @@ public class DataHelper { * * @param hash null OK * @return null on EOF - * @deprecated use MessageDigest version + * @deprecated use MessageDigest version to be removed in 0.9.27 */ + @Deprecated public static String readLine(InputStream in, Sha256Standalone hash) throws IOException { StringBuilder buf = new StringBuilder(128); boolean ok = readLine(in, buf, hash); @@ -1380,7 +1381,7 @@ public class DataHelper { * * @return true if the line was read, false if eof was reached on an empty line * (returns true for non-empty last line without a newline) - * @deprecated use StringBuilder / MessageDigest version + * @deprecated use StringBuilder / MessageDigest version, to be removed in 0.9.27 */ @Deprecated public static boolean readLine(InputStream in, StringBuffer buf, Sha256Standalone hash) throws IOException { @@ -1420,8 +1421,9 @@ public class DataHelper { * @param hash null OK * @return true if the line was read, false if eof was reached on an empty line * (returns true for non-empty last line without a newline) - * @deprecated use MessageDigest version + * @deprecated use MessageDigest version, to be removed in 0.9.27 */ + @Deprecated public static boolean readLine(InputStream in, StringBuilder buf, Sha256Standalone hash) throws IOException { int c = -1; int i = 0; @@ -1463,8 +1465,9 @@ public class DataHelper { /** * update the hash along the way - * @deprecated use MessageDigest version + * @deprecated use MessageDigest version, to be removed in 0.9.27 */ + @Deprecated public static void write(OutputStream out, byte data[], Sha256Standalone hash) throws IOException { hash.update(data); out.write(data);