Remove harmony provider and default SecureRandom impl.

These things are effectively unused and there's no point in
carting around all this excess baggage.

This change also removes some other classes that weren't being
used anywhere.

(cherry picked from commit 04270c61ba90e164732a227aaa40065009a21378)

Change-Id: I3813c06c60f09e3db99544bc0a2dcf569ff2f50e
diff --git a/luni/src/main/java/java/security/SecureRandom.java b/luni/src/main/java/java/security/SecureRandom.java
index 7a03801..8fbcc39 100644
--- a/luni/src/main/java/java/security/SecureRandom.java
+++ b/luni/src/main/java/java/security/SecureRandom.java
@@ -23,7 +23,6 @@
 import libcore.io.SizeOf;
 import org.apache.harmony.security.fortress.Engine;
 import org.apache.harmony.security.fortress.Services;
-import org.apache.harmony.security.provider.crypto.SHA1PRNG_SecureRandomImpl;
 
 /**
  * This class generates cryptographically secure pseudo-random numbers.
@@ -86,12 +85,8 @@
      */
     public SecureRandom() {
         super(0);
-        Provider.Service service = Services.getSecureRandomService();
-        if (service == null) {
-            this.provider = null;
-            this.secureRandomSpi = new SHA1PRNG_SecureRandomImpl();
-            this.algorithm = "SHA1PRNG";
-        } else {
+        final Provider.Service service = Services.getSecureRandomService();
+        if (service != null) {
             try {
                 this.provider = service.getProvider();
                 this.secureRandomSpi = (SecureRandomSpi)service.newInstance(null);
@@ -99,6 +94,8 @@
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }
+        } else {
+            throw new AssertionError("Services.getSecureRandomService() == null");
         }
     }
 
diff --git a/luni/src/main/java/java/security/Security.java b/luni/src/main/java/java/security/Security.java
index b859f9a..e8e9345 100644
--- a/luni/src/main/java/java/security/Security.java
+++ b/luni/src/main/java/java/security/Security.java
@@ -74,8 +74,7 @@
     private static void registerDefaultProviders() {
         secprops.put("security.provider.1", "com.android.org.conscrypt.OpenSSLProvider");
         secprops.put("security.provider.2", "com.android.org.bouncycastle.jce.provider.BouncyCastleProvider");
-        secprops.put("security.provider.3", "org.apache.harmony.security.provider.crypto.CryptoProvider");
-        secprops.put("security.provider.4", "com.android.org.conscrypt.JSSEProvider");
+        secprops.put("security.provider.3", "com.android.org.conscrypt.JSSEProvider");
     }
 
     /**
diff --git a/luni/src/main/java/java/security/security.properties b/luni/src/main/java/java/security/security.properties
index a06283b..289efa9 100644
--- a/luni/src/main/java/java/security/security.properties
+++ b/luni/src/main/java/java/security/security.properties
@@ -22,9 +22,8 @@
 security.provider.1=com.android.org.conscrypt.OpenSSLProvider
 # Android's stripped down BouncyCastle provider
 security.provider.2=com.android.org.bouncycastle.jce.provider.BouncyCastleProvider
-# Remaining Harmony providers
-security.provider.3=org.apache.harmony.security.provider.crypto.CryptoProvider
-security.provider.4=com.android.org.conscrypt.JSSEProvider
+# Android's provider of OpenSSL backed implementations
+security.provider.3=com.android.org.conscrypt.JSSEProvider
 
 
 
diff --git a/luni/src/main/java/org/apache/harmony/security/PrivateKeyImpl.java b/luni/src/main/java/org/apache/harmony/security/PrivateKeyImpl.java
deleted file mode 100644
index 47aceb3..0000000
--- a/luni/src/main/java/org/apache/harmony/security/PrivateKeyImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-
-package org.apache.harmony.security;
-
-import java.security.PrivateKey;
-
-/**
- * PrivateKeyImpl
- */
-public class PrivateKeyImpl implements PrivateKey {
-
-    /*
-     * @serial
-     */
-    private static final long serialVersionUID = 7776497482533790279L;
-
-    private String algorithm;
-
-    private byte[] encoding;
-
-    public PrivateKeyImpl(String algorithm) {
-        this.algorithm = algorithm;
-    }
-
-    public String getAlgorithm() {
-        return algorithm;
-    }
-
-    public String getFormat() {
-        return "PKCS#8";
-    }
-
-    public byte[] getEncoded() {
-
-        byte[] toReturn = new byte[encoding.length];
-        System.arraycopy(encoding, 0, toReturn, 0, encoding.length);
-
-        return toReturn;
-    }
-
-    public void setAlgorithm(String algorithm) {
-        this.algorithm = algorithm;
-    }
-
-    public void setEncoding(byte[] encoding) {
-        this.encoding = new byte[encoding.length];
-        System.arraycopy(encoding, 0, this.encoding, 0, encoding.length);
-    }
-
-}
diff --git a/luni/src/main/java/org/apache/harmony/security/PublicKeyImpl.java b/luni/src/main/java/org/apache/harmony/security/PublicKeyImpl.java
deleted file mode 100644
index dccc72d..0000000
--- a/luni/src/main/java/org/apache/harmony/security/PublicKeyImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-
-package org.apache.harmony.security;
-
-import java.security.PublicKey;
-
-
-/**
- * PublicKeyImpl
- */
-public class PublicKeyImpl implements PublicKey {
-
-    /**
-     * @serial
-     */
-    private static final long serialVersionUID = 7179022516819534075L;
-
-
-    private byte[] encoding;
-
-    private String algorithm;
-
-
-    public PublicKeyImpl(String algorithm) {
-        this.algorithm = algorithm;
-    }
-
-
-    public String getAlgorithm() {
-        return algorithm;
-    }
-
-
-    public String getFormat() {
-        return "X.509";
-    }
-
-
-    public byte[] getEncoded() {
-        byte[] result = new byte[encoding.length];
-        System.arraycopy(encoding, 0, result, 0, encoding.length);
-        return result;
-    }
-
-
-    public void setAlgorithm(String algorithm) {
-        this.algorithm = algorithm;
-    }
-
-
-    public void setEncoding(byte[] encoding) {
-        this.encoding = new byte[encoding.length];
-        System.arraycopy(encoding, 0, this.encoding, 0, encoding.length);
-    }
-}
-
diff --git a/luni/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequest.java b/luni/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequest.java
deleted file mode 100644
index 3d36d37..0000000
--- a/luni/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package org.apache.harmony.security.pkcs10;
-
-import org.apache.harmony.security.asn1.ASN1BitString;
-import org.apache.harmony.security.asn1.ASN1Sequence;
-import org.apache.harmony.security.asn1.ASN1Type;
-import org.apache.harmony.security.asn1.BerInputStream;
-import org.apache.harmony.security.asn1.BitString;
-import org.apache.harmony.security.x509.AlgorithmIdentifier;
-
-/**
- * The class implements the ASN.1 DER encoding and decoding of the PKCS#10
- * Certificate Signing Request (CSR). Its ASN notation is as follows:
- *
- * CertificationRequest ::= SEQUENCE {
- *   certificationRequestInfo CertificationRequestInfo,
- *   signatureAlgorithm SignatureAlgorithmIdentifier,
- *   signature Signature
- * }
- *
- * SignatureAlgorithmIdentifier ::= AlgorithmIdentifier
- *
- * Signature ::= BIT STRING
- */
-public final class CertificationRequest {
-
-    /** the value of certificationRequestInfo field of the structure */
-    private CertificationRequestInfo info;
-
-    /** the value of signatureAlgorithm field of the structure */
-    private AlgorithmIdentifier algId;
-
-    /** the value of signature field of the structure */
-    private byte[] signature;
-
-    /** the ASN.1 encoded form of CertificationRequest */
-    private byte[] encoding;
-
-    public CertificationRequest(CertificationRequestInfo info,
-            AlgorithmIdentifier algId, byte[] signature) {
-        this.info = info;
-        this.algId = algId;
-        this.signature = signature.clone();
-    }
-
-    private CertificationRequest(CertificationRequestInfo info,
-            AlgorithmIdentifier algId, byte[] signature, byte[] encoding) {
-        this(info, algId, signature);
-        this.encoding = encoding;
-    }
-
-    public CertificationRequestInfo getInfo() {
-        return info;
-    }
-
-    public byte[] getSignature() {
-        byte[] result = new byte[signature.length];
-        System.arraycopy(signature, 0, result, 0, signature.length);
-        return result;
-    }
-
-    /**
-     * Returns ASN.1 encoded form of this CertificationRequest value.
-     * @return a byte array containing ASN.1 encode form.
-     */
-    public byte[] getEncoded() {
-        if (encoding == null) {
-            encoding = CertificationRequest.ASN1.encode(this);
-        }
-        return encoding;
-    }
-
-    public static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] {
-            CertificationRequestInfo.ASN1,  // info
-            AlgorithmIdentifier.ASN1,       // signatureAlgorithm
-            ASN1BitString.getInstance() })  // signature
-    {
-
-        public Object getDecodedObject(BerInputStream in) {
-            Object[] values = (Object[]) in.content;
-            return new CertificationRequest(
-                    (CertificationRequestInfo) values[0],
-                    (AlgorithmIdentifier) values[1],
-                    ((BitString) values[2]).bytes,
-                    in.getEncoded());
-        }
-
-        protected void getValues(Object object, Object[] values) {
-            CertificationRequest certReq = (CertificationRequest) object;
-            values[0] = certReq.info;
-            values[1] = certReq.algId;
-            values[2] = new BitString(certReq.signature, 0);
-        }
-    };
-}
-
diff --git a/luni/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequestInfo.java b/luni/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequestInfo.java
deleted file mode 100644
index d13f952..0000000
--- a/luni/src/main/java/org/apache/harmony/security/pkcs10/CertificationRequestInfo.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package org.apache.harmony.security.pkcs10;
-
-import java.util.List;
-import javax.security.auth.x500.X500Principal;
-import org.apache.harmony.security.asn1.ASN1Implicit;
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.asn1.ASN1Sequence;
-import org.apache.harmony.security.asn1.ASN1SetOf;
-import org.apache.harmony.security.asn1.ASN1Type;
-import org.apache.harmony.security.asn1.BerInputStream;
-import org.apache.harmony.security.x501.AttributeTypeAndValue;
-import org.apache.harmony.security.x501.Name;
-import org.apache.harmony.security.x509.SubjectPublicKeyInfo;
-
-/**
- * CertificationRequestInfo ::= SEQUENCE {
- *   version Version,
- *   subject Name,
- *   subjectPublicKeyInfo SubjectPublicKeyInfo,
- *   attributes [0] IMPLICIT Attributes }
- *
- * Version ::= INTEGER
- *
- * Attributes ::= SET OF Attribute
- */
-public final class CertificationRequestInfo {
-    private final int version;
-
-    /** the value of subject field of the structure */
-    private final Name subject;
-
-    /** the value of subjectPublicKeyInfo field of the structure */
-    private final SubjectPublicKeyInfo subjectPublicKeyInfo;
-
-    /** the value of attributes field of the structure */
-    private final List<?> attributes;
-
-    /** the ASN.1 encoded form of CertificationRequestInfo */
-    private byte[] encoding;
-
-    private CertificationRequestInfo(int version, Name subject,
-            SubjectPublicKeyInfo subjectPublicKeyInfo, List<?> attributes, byte [] encoding) {
-        this.version = version;
-        this.subject = subject;
-        this.subjectPublicKeyInfo = subjectPublicKeyInfo;
-        this.attributes = attributes;
-        this.encoding = encoding;
-    }
-
-    public Name getSubject() {
-        return subject;
-    }
-
-    public int getVersion() {
-        return version;
-    }
-
-    /**
-     * Returns ASN.1 encoded form of this CertificationRequestInfo.
-     * @return a byte array containing ASN.1 encode form.
-     */
-    public byte[] getEncoded() {
-        if (encoding == null) {
-            encoding = ASN1.encode(this);
-        }
-        return encoding;
-    }
-
-    @Override public String toString() {
-        StringBuilder res = new StringBuilder();
-        res.append("-- CertificationRequestInfo:");
-        res.append("\n version: ");
-        res.append(version);
-        res.append("\n subject: ");
-        res.append(subject.getName(X500Principal.CANONICAL));
-        res.append("\n subjectPublicKeyInfo: ");
-        res.append("\n\t algorithm: ");
-        res.append(subjectPublicKeyInfo.getAlgorithmIdentifier().getAlgorithm());
-        res.append("\n\t public key: ").append(subjectPublicKeyInfo.getPublicKey());
-        res.append("\n attributes: ");
-        if (attributes != null) {
-            res.append(attributes.toString());
-        } else {
-            res.append("none");
-        }
-        res.append("\n-- CertificationRequestInfo End\n");
-        return res.toString();
-    }
-
-    public static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] {
-            ASN1Integer.getInstance(),              // version
-            Name.ASN1,                              // subject
-            SubjectPublicKeyInfo.ASN1,              // subjectPublicKeyInfo
-            new ASN1Implicit(0, new ASN1SetOf(
-                    AttributeTypeAndValue.ASN1))    // attributes
-            }) {
-
-        @Override protected Object getDecodedObject(BerInputStream in) {
-            Object[] values = (Object[]) in.content;
-            return new CertificationRequestInfo(
-                    ASN1Integer.toIntValue(values[0]),
-                    (Name) values[1],
-                    (SubjectPublicKeyInfo) values[2],
-                    (List<?>) values[3],
-                    in.getEncoded());
-        }
-
-        @Override protected void getValues(Object object, Object[] values) {
-            CertificationRequestInfo certReqInfo = (CertificationRequestInfo) object;
-            values[0] = ASN1Integer.fromIntValue(certReqInfo.version);
-            values[1] = certReqInfo.subject;
-            values[2] = certReqInfo.subjectPublicKeyInfo;
-            values[3] = certReqInfo.attributes;
-        }
-    };
-}
-
diff --git a/luni/src/main/java/org/apache/harmony/security/pkcs8/PrivateKeyInfo.java b/luni/src/main/java/org/apache/harmony/security/pkcs8/PrivateKeyInfo.java
deleted file mode 100644
index 400bf86..0000000
--- a/luni/src/main/java/org/apache/harmony/security/pkcs8/PrivateKeyInfo.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-
-package org.apache.harmony.security.pkcs8;
-
-import java.util.List;
-import org.apache.harmony.security.asn1.ASN1Implicit;
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.asn1.ASN1OctetString;
-import org.apache.harmony.security.asn1.ASN1Sequence;
-import org.apache.harmony.security.asn1.ASN1SetOf;
-import org.apache.harmony.security.asn1.ASN1Type;
-import org.apache.harmony.security.asn1.BerInputStream;
-import org.apache.harmony.security.x501.AttributeTypeAndValue;
-import org.apache.harmony.security.x509.AlgorithmIdentifier;
-
-/**
- * The class implements the ASN.1 DER encoding and decoding of the PKCS#8
- * PrivateKeyInfo having the following ASN.1 notation:
- *
- *  PrivateKeyInfo ::= SEQUENCE {
- *      version Version,
- *      privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
- *      privateKey PrivateKey,
- *      attributes [0] IMPLICIT Attributes OPTIONAL }
- *
- *  Version ::= INTEGER
- *
- *  PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
- *
- *  PrivateKey ::= OCTET STRING
- *
- *  Attributes ::= SET OF Attribute
- */
-public final class PrivateKeyInfo {
-    private final int version;
-    private final AlgorithmIdentifier privateKeyAlgorithm;
-    private final byte[] privateKey;
-    private final List<?> attributes;
-    private byte[] encoding;
-
-    public PrivateKeyInfo(int version, AlgorithmIdentifier privateKeyAlgorithm,
-            byte[] privateKey, List attributes) {
-        this.version = version;
-        this.privateKeyAlgorithm = privateKeyAlgorithm;
-        this.privateKey = privateKey;
-        this.attributes = attributes;
-    }
-
-    private PrivateKeyInfo(int version,
-            AlgorithmIdentifier privateKeyAlgorithm, byte[] privateKey,
-            List attributes, byte[] encoding) {
-        this(version, privateKeyAlgorithm, privateKey, attributes);
-        this.encoding = encoding;
-    }
-
-    public int getVersion() {
-        return version;
-    }
-
-    public AlgorithmIdentifier getAlgorithmIdentifier() {
-        return privateKeyAlgorithm;
-    }
-
-    public List getAttributes() {
-        return attributes;
-    }
-
-    /**
-     * Returns the OCTET STRING.
-     */
-    public byte[] getPrivateKey() {
-        return privateKey;
-    }
-
-    /**
-     * Returns ASN.1 encoded form of this PrivateKeyInfo.
-     */
-    public byte[] getEncoded() {
-        if (encoding == null) {
-            encoding = ASN1.encode(this);
-        }
-        return encoding;
-    }
-
-    public static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] {
-
-    ASN1Integer.getInstance(), // version
-            AlgorithmIdentifier.ASN1, // AlgorithmIdentifier
-            ASN1OctetString.getInstance(), // privateKey
-
-            new ASN1Implicit(0, new ASN1SetOf(AttributeTypeAndValue.ASN1)) // attributes
-            }) {
-
-        {
-            setOptional(3); // attributes are OPTIONAL
-        }
-
-        protected Object getDecodedObject(BerInputStream in) {
-            Object[] values = (Object[]) in.content;
-            return new PrivateKeyInfo(ASN1Integer.toIntValue(values[0]),
-                    (AlgorithmIdentifier) values[1], (byte[]) values[2],
-                    (List) values[3], in.getEncoded());
-        }
-
-        protected void getValues(Object object, Object[] values) {
-            PrivateKeyInfo privateKeyInfo = (PrivateKeyInfo) object;
-            values[0] = ASN1Integer.fromIntValue(privateKeyInfo.version);
-            values[1] = privateKeyInfo.privateKeyAlgorithm;
-            values[2] = privateKeyInfo.privateKey;
-            values[3] = privateKeyInfo.attributes;
-        }
-    };
-}
diff --git a/luni/src/main/java/org/apache/harmony/security/provider/crypto/CryptoProvider.java b/luni/src/main/java/org/apache/harmony/security/provider/crypto/CryptoProvider.java
deleted file mode 100644
index ad5ac7d..0000000
--- a/luni/src/main/java/org/apache/harmony/security/provider/crypto/CryptoProvider.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.harmony.security.provider.crypto;
-
-import java.security.Provider;
-
-/**
- * Implementation of Provider for SecureRandom. The implementation supports the
- * "SHA1PRNG" algorithm described in JavaTM Cryptography Architecture, API
- * Specification & Reference
- */
-
-public final class CryptoProvider extends Provider {
-
-    private static final long serialVersionUID = 7991202868423459598L;
-
-    /**
-     * Creates a Provider and puts parameters
-     */
-    public CryptoProvider() {
-        super("Crypto", 1.0, "HARMONY (SHA1 digest; SecureRandom; SHA1withDSA signature)");
-
-        put("SecureRandom.SHA1PRNG",
-                "org.apache.harmony.security.provider.crypto.SHA1PRNG_SecureRandomImpl");
-        put("SecureRandom.SHA1PRNG ImplementedIn", "Software");
-    }
-}
diff --git a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Constants.java b/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Constants.java
deleted file mode 100644
index fc6a847..0000000
--- a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Constants.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-/**
-* @author Yuri A. Kropachev
-* @version $Revision$
-*/
-
-
-package org.apache.harmony.security.provider.crypto;
-
-
-/**
- * This interface contains : <BR>
- * - a set of constant values, H0-H4, defined in "SECURE HASH STANDARD", FIPS PUB 180-2 ;<BR>
- * - implementation constant values to use in classes using SHA-1 algorithm.    <BR>
- */
-public final class SHA1Constants {
-    private SHA1Constants() {
-    }
-
-    /**
-     *  constant defined in "SECURE HASH STANDARD"
-     */
-    public static final int H0 = 0x67452301;
-
-
-    /**
-     *  constant defined in "SECURE HASH STANDARD"
-     */
-    public static final int H1 = 0xEFCDAB89;
-
-
-    /**
-     *  constant defined in "SECURE HASH STANDARD"
-     */
-    public static final int H2 = 0x98BADCFE;
-
-
-    /**
-     *  constant defined in "SECURE HASH STANDARD"
-     */
-    public static final int H3 = 0x10325476;
-
-
-    /**
-     *  constant defined in "SECURE HASH STANDARD"
-     */
-    public static final int H4 = 0xC3D2E1F0;
-
-
-    /**
-     * offset in buffer to store number of bytes in 0-15 word frame
-     */
-    public static final int BYTES_OFFSET = 81;
-
-
-    /**
-     * offset in buffer to store current hash value
-     */
-    public static final int HASH_OFFSET = 82;
-
-
-    /**
-     * # of bytes in H0-H4 words; <BR>
-     * in this implementation # is set to 20 (in general # varies from 1 to 20)
-     */
-    public static final int DIGEST_LENGTH = 20;
-}
diff --git a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Impl.java b/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Impl.java
deleted file mode 100644
index 57b9005..0000000
--- a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1Impl.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-/**
-* @author Yuri A. Kropachev
-* @version $Revision$
-*/
-
-
-package org.apache.harmony.security.provider.crypto;
-
-import static org.apache.harmony.security.provider.crypto.SHA1Constants.*;
-
-/**
- * This class contains methods providing SHA-1 functionality to use in classes. <BR>
- * The methods support the algorithm described in "SECURE HASH STANDARD", FIPS PUB 180-2, <BR>
- * "http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf"      <BR>
- * <BR>
- * The class contains two package level access methods, -
- * "void updateHash(int[], byte[], int, int)" and "void computeHash(int[])", -
- * performing the following operations. <BR>
- * <BR>
- * The "updateHash(..)" method appends new bytes to existing ones
- * within limit of a frame of 64 bytes (16 words).
- * Once a length of accumulated bytes reaches the limit
- * the "computeHash(int[])" method is invoked on the frame to compute updated hash,
- * and the number of bytes in the frame is set to 0.
- * Thus, after appending all bytes, the frame contain only those bytes
- * that were not used in computing final hash value yet. <BR>
- * <BR>
- * The "computeHash(..)" method generates a 160 bit hash value using
- * a 512 bit message stored in first 16 words of int[] array argument and
- * current hash value stored in five words, beginning HASH_OFFSET, of the array argument.
- * Computation is done according to SHA-1 algorithm. <BR>
- * <BR>
- * The resulting hash value replaces the previous hash value in the array;
- * original bits of the message are not preserved.
- */
-public class SHA1Impl {
-
-
-    /**
-     * The method generates a 160 bit hash value using
-     * a 512 bit message stored in first 16 words of int[] array argument and
-     * current hash value stored in five words, beginning OFFSET+1, of the array argument.
-     * Computation is done according to SHA-1 algorithm.
-     *
-     * The resulting hash value replaces the previous hash value in the array;
-     * original bits of the message are not preserved.
-     *
-     * No checks on argument supplied, that is,
-     * a calling method is responsible for such checks.
-     * In case of incorrect array passed to the method
-     * either NPE or IndexOutOfBoundException gets thrown by JVM.
-     *
-     * @params
-     *        arrW - integer array; arrW.length >= (BYTES_OFFSET+6); <BR>
-     *               only first (BYTES_OFFSET+6) words are used
-     */
-    static void computeHash(int[] arrW) {
-
-        int  a = arrW[HASH_OFFSET   ];
-        int  b = arrW[HASH_OFFSET +1];
-        int  c = arrW[HASH_OFFSET +2];
-        int  d = arrW[HASH_OFFSET +3];
-        int  e = arrW[HASH_OFFSET +4];
-
-        int temp;
-
-        // In this implementation the "d. For t = 0 to 79 do" loop
-        // is split into four loops. The following constants:
-        //     K = 5A827999   0 <= t <= 19
-        //     K = 6ED9EBA1  20 <= t <= 39
-        //     K = 8F1BBCDC  40 <= t <= 59
-        //     K = CA62C1D6  60 <= t <= 79
-        // are hex literals in the loops.
-
-        for ( int t = 16; t < 80 ; t++ ) {
-
-            temp  = arrW[t-3] ^ arrW[t-8] ^ arrW[t-14] ^ arrW[t-16];
-            arrW[t] = ( temp<<1 ) | ( temp>>>31 );
-        }
-
-        for ( int t = 0 ; t < 20 ; t++ ) {
-
-            temp = ( ( a<<5 ) | ( a>>>27 )   ) +
-                   ( ( b & c) | ((~b) & d)   ) +
-                   ( e + arrW[t] + 0x5A827999 ) ;
-            e = d;
-            d = c;
-            c = ( b<<30 ) | ( b>>>2 ) ;
-            b = a;
-            a = temp;
-        }
-        for ( int t = 20 ; t < 40 ; t++ ) {
-
-            temp = ((( a<<5 ) | ( a>>>27 ))) + (b ^ c ^ d) + (e + arrW[t] + 0x6ED9EBA1) ;
-            e = d;
-            d = c;
-            c = ( b<<30 ) | ( b>>>2 ) ;
-            b = a;
-            a = temp;
-        }
-        for ( int t = 40 ; t < 60 ; t++ ) {
-
-            temp = (( a<<5 ) | ( a>>>27 )) + ((b & c) | (b & d) | (c & d)) +
-                                                             (e + arrW[t] + 0x8F1BBCDC) ;
-            e = d;
-            d = c;
-            c = ( b<<30 ) | ( b>>>2 ) ;
-            b = a;
-            a = temp;
-        }
-        for ( int t = 60 ; t < 80 ; t++ ) {
-
-            temp = ((( a<<5 ) | ( a>>>27 ))) + (b ^ c ^ d) + (e + arrW[t] + 0xCA62C1D6) ;
-            e = d;
-            d = c;
-            c = ( b<<30 ) | ( b>>>2 ) ;
-            b = a;
-            a = temp;
-        }
-
-        arrW[HASH_OFFSET   ] += a;
-        arrW[HASH_OFFSET +1] += b;
-        arrW[HASH_OFFSET +2] += c;
-        arrW[HASH_OFFSET +3] += d;
-        arrW[HASH_OFFSET +4] += e;
-    }
-
-    /**
-     * The method appends new bytes to existing ones
-     * within limit of a frame of 64 bytes (16 words).
-     *
-     * Once a length of accumulated bytes reaches the limit
-     * the "computeHash(int[])" method is invoked on the array to compute updated hash,
-     * and the number of bytes in the frame is set to 0.
-     * Thus, after appending all bytes, the array contain only those bytes
-     * that were not used in computing final hash value yet.
-     *
-     * No checks on arguments passed to the method, that is,
-     * a calling method is responsible for such checks.
-     *
-     * @params
-     *        intArray  - int array containing bytes to which to append;
-     *                    intArray.length >= (BYTES_OFFSET+6)
-     * @params
-     *        byteInput - array of bytes to use for the update
-     * @params
-     *        from      - the offset to start in the "byteInput" array
-     * @params
-     *        to        - a number of the last byte in the input array to use,
-     *                that is, for first byte "to"==0, for last byte "to"==input.length-1
-     */
-    static void updateHash(int[] intArray, byte[] byteInput, int fromByte, int toByte) {
-
-        // As intArray contains a packed bytes
-        // the buffer's index is in the intArray[BYTES_OFFSET] element
-
-        int index = intArray[BYTES_OFFSET];
-        int i = fromByte;
-        int maxWord;
-        int nBytes;
-
-        int wordIndex = index >>2;
-        int byteIndex = index & 0x03;
-
-        intArray[BYTES_OFFSET] = ( index + toByte - fromByte + 1 ) & 077 ;
-
-        // In general case there are 3 stages :
-        // - appending bytes to non-full word,
-        // - writing 4 bytes into empty words,
-        // - writing less than 4 bytes in last word
-
-        if ( byteIndex != 0 ) {       // appending bytes in non-full word (as if)
-
-            for ( ; ( i <= toByte ) && ( byteIndex < 4 ) ; i++ ) {
-                intArray[wordIndex] |= ( byteInput[i] & 0xFF ) << ((3 - byteIndex)<<3) ;
-                byteIndex++;
-            }
-            if ( byteIndex == 4 ) {
-                wordIndex++;
-                if ( wordIndex == 16 ) {          // intArray is full, computing hash
-
-                    computeHash(intArray);
-                    wordIndex = 0;
-                }
-            }
-            if ( i > toByte ) {                 // all input bytes appended
-                return ;
-            }
-        }
-
-        // writing full words
-
-        maxWord = (toByte - i + 1) >> 2;           // # of remaining full words, may be "0"
-        for ( int k = 0; k < maxWord ; k++ ) {
-
-            intArray[wordIndex] = ( ((int) byteInput[i   ] & 0xFF) <<24 ) |
-                                  ( ((int) byteInput[i +1] & 0xFF) <<16 ) |
-                                  ( ((int) byteInput[i +2] & 0xFF) <<8  ) |
-                                  ( ((int) byteInput[i +3] & 0xFF)      )  ;
-            i += 4;
-            wordIndex++;
-
-            if ( wordIndex < 16 ) {     // buffer is not full yet
-                continue;
-            }
-            computeHash(intArray);      // buffer is full, computing hash
-            wordIndex = 0;
-        }
-
-        // writing last incomplete word
-        // after writing free byte positions are set to "0"s
-
-        nBytes = toByte - i +1;
-        if ( nBytes != 0 ) {
-
-            int w =  ((int) byteInput[i] & 0xFF) <<24 ;
-
-            if ( nBytes != 1 ) {
-                w |= ((int) byteInput[i +1] & 0xFF) <<16 ;
-                if ( nBytes != 2) {
-                    w |= ((int) byteInput[i +2] & 0xFF) <<8 ;
-                }
-            }
-            intArray[wordIndex] = w;
-        }
-
-        return ;
-    }
-
-}
diff --git a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1PRNG_SecureRandomImpl.java b/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1PRNG_SecureRandomImpl.java
deleted file mode 100644
index 5c0e328..0000000
--- a/luni/src/main/java/org/apache/harmony/security/provider/crypto/SHA1PRNG_SecureRandomImpl.java
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-
-package org.apache.harmony.security.provider.crypto;
-
-import dalvik.system.BlockGuard;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.security.InvalidParameterException;
-import java.security.ProviderException;
-import java.security.SecureRandomSpi;
-import libcore.io.Streams;
-import libcore.util.EmptyArray;
-
-import static org.apache.harmony.security.provider.crypto.SHA1Constants.*;
-
-/**
- * This class extends the SecureRandomSpi class implementing all its abstract methods.
- *
- * <p>To generate pseudo-random bits, the implementation uses technique described in
- * the "Random Number Generator (RNG) algorithms" section, Appendix A,
- * JavaTM Cryptography Architecture, API Specification & Reference.
- */
-public class SHA1PRNG_SecureRandomImpl extends SecureRandomSpi implements Serializable {
-
-    private static final long serialVersionUID = 283736797212159675L;
-
-    private static FileInputStream devURandom;
-    static {
-        try {
-            devURandom = new FileInputStream(new File("/dev/urandom"));
-        } catch (IOException ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    // constants to use in expressions operating on bytes in int and long variables:
-    // END_FLAGS - final bytes in words to append to message;
-    //             see "ch.5.1 Padding the Message, FIPS 180-2"
-    // RIGHT1    - shifts to right for left half of long
-    // RIGHT2    - shifts to right for right half of long
-    // LEFT      - shifts to left for bytes
-    // MASK      - mask to select counter's bytes after shift to right
-
-    private static final int[] END_FLAGS = { 0x80000000, 0x800000, 0x8000, 0x80 };
-
-    private static final int[] RIGHT1 = { 0, 40, 48, 56 };
-
-    private static final int[] RIGHT2 = { 0, 8, 16, 24 };
-
-    private static final int[] LEFT = { 0, 24, 16, 8 };
-
-    private static final int[] MASK = { 0xFFFFFFFF, 0x00FFFFFF, 0x0000FFFF,
-            0x000000FF };
-
-    // HASHBYTES_TO_USE defines # of bytes returned by "computeHash(byte[])"
-    // to use to form byte array returning by the "nextBytes(byte[])" method
-    // Note, that this implementation uses more bytes than it is defined
-    // in the above specification.
-    private static final int HASHBYTES_TO_USE = 20;
-
-    // value of 16 defined in the "SECURE HASH STANDARD", FIPS PUB 180-2
-    private static final int FRAME_LENGTH = 16;
-
-    // miscellaneous constants defined in this implementation:
-    // COUNTER_BASE - initial value to set to "counter" before computing "nextBytes(..)";
-    //                note, that the exact value is not defined in STANDARD
-    // HASHCOPY_OFFSET   - offset for copy of current hash in "copies" array
-    // EXTRAFRAME_OFFSET - offset for extra frame in "copies" array;
-    //                     as the extra frame follows the current hash frame,
-    //                     EXTRAFRAME_OFFSET is equal to length of current hash frame
-    // FRAME_OFFSET      - offset for frame in "copies" array
-    // MAX_BYTES - maximum # of seed bytes processing which doesn't require extra frame
-    //             see (1) comments on usage of "seed" array below and
-    //             (2) comments in "engineNextBytes(byte[])" method
-    //
-    // UNDEFINED  - three states of engine; initially its state is "UNDEFINED"
-    // SET_SEED     call to "engineSetSeed"  sets up "SET_SEED" state,
-    // NEXT_BYTES   call to "engineNextByte" sets up "NEXT_BYTES" state
-
-    private static final int COUNTER_BASE = 0;
-
-    private static final int HASHCOPY_OFFSET = 0;
-
-    private static final int EXTRAFRAME_OFFSET = 5;
-
-    private static final int FRAME_OFFSET = 21;
-
-    private static final int MAX_BYTES = 48;
-
-    private static final int UNDEFINED = 0;
-
-    private static final int SET_SEED = 1;
-
-    private static final int NEXT_BYTES = 2;
-
-    private static SHA1PRNG_SecureRandomImpl myRandom;
-
-    // Structure of "seed" array:
-    // -  0-79 - words for computing hash
-    // - 80    - unused
-    // - 81    - # of seed bytes in current seed frame
-    // - 82-86 - 5 words, current seed hash
-    private transient int[] seed;
-
-    // total length of seed bytes, including all processed
-    private transient long seedLength;
-
-    // Structure of "copies" array
-    // -  0-4  - 5 words, copy of current seed hash
-    // -  5-20 - extra 16 words frame;
-    //           is used if final padding exceeds 512-bit length
-    // - 21-36 - 16 word frame to store a copy of remaining bytes
-    private transient int[] copies;
-
-    // ready "next" bytes; needed because words are returned
-    private transient byte[] nextBytes;
-
-    // index of used bytes in "nextBytes" array
-    private transient int nextBIndex;
-
-    // variable required according to "SECURE HASH STANDARD"
-    private transient long counter;
-
-    // contains int value corresponding to engine's current state
-    private transient int state;
-
-    // The "seed" array is used to compute both "current seed hash" and "next bytes".
-    //
-    // As the "SHA1" algorithm computes a hash of entire seed by splitting it into
-    // a number of the 512-bit length frames (512 bits = 64 bytes = 16 words),
-    // "current seed hash" is a hash (5 words, 20 bytes) for all previous full frames;
-    // remaining bytes are stored in the 0-15 word frame of the "seed" array.
-    //
-    // As for calculating "next bytes",
-    // both remaining bytes and "current seed hash" are used,
-    // to preserve the latter for following "setSeed(..)" commands,
-    // the following technique is used:
-    // - upon getting "nextBytes(byte[])" invoked, single or first in row,
-    //   which requires computing new hash, that is,
-    //   there is no more bytes remaining from previous "next bytes" computation,
-    //   remaining bytes are copied into the 21-36 word frame of the "copies" array;
-    // - upon getting "setSeed(byte[])" invoked, single or first in row,
-    //   remaining bytes are copied back.
-
-    /**
-     *  Creates object and sets implementation variables to their initial values
-     */
-    public SHA1PRNG_SecureRandomImpl() {
-
-        seed = new int[HASH_OFFSET + EXTRAFRAME_OFFSET];
-        seed[HASH_OFFSET] = H0;
-        seed[HASH_OFFSET + 1] = H1;
-        seed[HASH_OFFSET + 2] = H2;
-        seed[HASH_OFFSET + 3] = H3;
-        seed[HASH_OFFSET + 4] = H4;
-
-        seedLength = 0;
-        copies = new int[2 * FRAME_LENGTH + EXTRAFRAME_OFFSET];
-        nextBytes = new byte[DIGEST_LENGTH];
-        nextBIndex = HASHBYTES_TO_USE;
-        counter = COUNTER_BASE;
-        state = UNDEFINED;
-    }
-
-    /*
-     * The method invokes the SHA1Impl's "updateHash(..)" method
-     * to update current seed frame and
-     * to compute new intermediate hash value if the frame is full.
-     *
-     * After that it computes a length of whole seed.
-     */
-    private void updateSeed(byte[] bytes) {
-
-        // on call:   "seed" contains current bytes and current hash;
-        // on return: "seed" contains new current bytes and possibly new current hash
-        //            if after adding, seed bytes overfill its buffer
-        SHA1Impl.updateHash(seed, bytes, 0, bytes.length - 1);
-
-        seedLength += bytes.length;
-    }
-
-    /**
-     * Changes current seed by supplementing a seed argument to the current seed,
-     * if this already set;
-     * the argument is used as first seed otherwise. <BR>
-     *
-     * The method overrides "engineSetSeed(byte[])" in class SecureRandomSpi.
-     *
-     * @param
-     *       seed - byte array
-     * @throws
-     *       NullPointerException - if null is passed to the "seed" argument
-     */
-    protected synchronized void engineSetSeed(byte[] seed) {
-
-        if (seed == null) {
-            throw new NullPointerException("seed == null");
-        }
-
-        if (state == NEXT_BYTES) { // first setSeed after NextBytes; restoring hash
-            System.arraycopy(copies, HASHCOPY_OFFSET, this.seed, HASH_OFFSET,
-                    EXTRAFRAME_OFFSET);
-        }
-        state = SET_SEED;
-
-        if (seed.length != 0) {
-            updateSeed(seed);
-        }
-    }
-
-    /**
-     * Returns a required number of random bytes. <BR>
-     *
-     * The method overrides "engineGenerateSeed (int)" in class SecureRandomSpi. <BR>
-     *
-     * @param
-     *       numBytes - number of bytes to return; should be >= 0.
-     * @return
-     *       byte array containing bits in order from left to right
-     * @throws
-     *       InvalidParameterException - if numBytes < 0
-     */
-    protected synchronized byte[] engineGenerateSeed(int numBytes) {
-
-        byte[] myBytes; // byte[] for bytes returned by "nextBytes()"
-
-        if (numBytes < 0) {
-            throw new NegativeArraySizeException(Integer.toString(numBytes));
-        }
-        if (numBytes == 0) {
-            return EmptyArray.BYTE;
-        }
-
-        if (myRandom == null) {
-            myRandom = new SHA1PRNG_SecureRandomImpl();
-            myRandom.engineSetSeed(getRandomBytes(DIGEST_LENGTH));
-        }
-
-        myBytes = new byte[numBytes];
-        myRandom.engineNextBytes(myBytes);
-
-        return myBytes;
-    }
-
-    /**
-     * Writes random bytes into an array supplied.
-     * Bits in a byte are from left to right. <BR>
-     *
-     * To generate random bytes, the "expansion of source bits" method is used,
-     * that is,
-     * the current seed with a 64-bit counter appended is used to compute new bits.
-     * The counter is incremented by 1 for each 20-byte output. <BR>
-     *
-     * The method overrides engineNextBytes in class SecureRandomSpi.
-     *
-     * @param
-     *       bytes - byte array to be filled in with bytes
-     * @throws
-     *       NullPointerException - if null is passed to the "bytes" argument
-     */
-    protected synchronized void engineNextBytes(byte[] bytes) {
-
-        int i, n;
-
-        long bits; // number of bits required by Secure Hash Standard
-        int nextByteToReturn; // index of ready bytes in "bytes" array
-        int lastWord; // index of last word in frame containing bytes
-        final int extrabytes = 7;// # of bytes to add in order to computer # of 8 byte words
-
-        if (bytes == null) {
-            throw new NullPointerException("bytes == null");
-        }
-
-        lastWord = seed[BYTES_OFFSET] == 0 ? 0
-                : (seed[BYTES_OFFSET] + extrabytes) >> 3 - 1;
-
-        if (state == UNDEFINED) {
-
-            // no seed supplied by user, hence it is generated thus randomizing internal state
-            updateSeed(getRandomBytes(DIGEST_LENGTH));
-            nextBIndex = HASHBYTES_TO_USE;
-
-            // updateSeed(...) updates where the last word of the seed is, so we
-            // have to read it again.
-            lastWord = seed[BYTES_OFFSET] == 0 ? 0
-                    : (seed[BYTES_OFFSET] + extrabytes) >> 3 - 1;
-
-        } else if (state == SET_SEED) {
-
-            System.arraycopy(seed, HASH_OFFSET, copies, HASHCOPY_OFFSET,
-                    EXTRAFRAME_OFFSET);
-
-            // possible cases for 64-byte frame:
-            //
-            // seed bytes < 48      - remaining bytes are enough for all, 8 counter bytes,
-            //                        0x80, and 8 seedLength bytes; no extra frame required
-            // 48 < seed bytes < 56 - remaining 9 bytes are for 0x80 and 8 counter bytes
-            //                        extra frame contains only seedLength value at the end
-            // seed bytes > 55      - extra frame contains both counter's bytes
-            //                        at the beginning and seedLength value at the end;
-            //                        note, that beginning extra bytes are not more than 8,
-            //                        that is, only 2 extra words may be used
-
-            // no need to set to "0" 3 words after "lastWord" and
-            // more than two words behind frame
-            for (i = lastWord + 3; i < FRAME_LENGTH + 2; i++) {
-                seed[i] = 0;
-            }
-
-            bits = (seedLength << 3) + 64; // transforming # of bytes into # of bits
-
-            // putting # of bits into two last words (14,15) of 16 word frame in
-            // seed or copies array depending on total length after padding
-            if (seed[BYTES_OFFSET] < MAX_BYTES) {
-                seed[14] = (int) (bits >>> 32);
-                seed[15] = (int) (bits & 0xFFFFFFFF);
-            } else {
-                copies[EXTRAFRAME_OFFSET + 14] = (int) (bits >>> 32);
-                copies[EXTRAFRAME_OFFSET + 15] = (int) (bits & 0xFFFFFFFF);
-            }
-
-            nextBIndex = HASHBYTES_TO_USE; // skipping remaining random bits
-        }
-        state = NEXT_BYTES;
-
-        if (bytes.length == 0) {
-            return;
-        }
-
-        nextByteToReturn = 0;
-
-        // possibly not all of HASHBYTES_TO_USE bytes were used previous time
-        n = (HASHBYTES_TO_USE - nextBIndex) < (bytes.length - nextByteToReturn) ? HASHBYTES_TO_USE
-                - nextBIndex
-                : bytes.length - nextByteToReturn;
-        if (n > 0) {
-            System.arraycopy(nextBytes, nextBIndex, bytes, nextByteToReturn, n);
-            nextBIndex += n;
-            nextByteToReturn += n;
-        }
-
-        if (nextByteToReturn >= bytes.length) {
-            return; // return because "bytes[]" are filled in
-        }
-
-        n = seed[BYTES_OFFSET] & 0x03;
-        for (;;) {
-            if (n == 0) {
-
-                seed[lastWord] = (int) (counter >>> 32);
-                seed[lastWord + 1] = (int) (counter & 0xFFFFFFFF);
-                seed[lastWord + 2] = END_FLAGS[0];
-
-            } else {
-
-                seed[lastWord] |= (int) ((counter >>> RIGHT1[n]) & MASK[n]);
-                seed[lastWord + 1] = (int) ((counter >>> RIGHT2[n]) & 0xFFFFFFFF);
-                seed[lastWord + 2] = (int) ((counter << LEFT[n]) | END_FLAGS[n]);
-            }
-            if (seed[BYTES_OFFSET] > MAX_BYTES) {
-                copies[EXTRAFRAME_OFFSET] = seed[FRAME_LENGTH];
-                copies[EXTRAFRAME_OFFSET + 1] = seed[FRAME_LENGTH + 1];
-            }
-
-            SHA1Impl.computeHash(seed);
-
-            if (seed[BYTES_OFFSET] > MAX_BYTES) {
-
-                System.arraycopy(seed, 0, copies, FRAME_OFFSET, FRAME_LENGTH);
-                System.arraycopy(copies, EXTRAFRAME_OFFSET, seed, 0,
-                        FRAME_LENGTH);
-
-                SHA1Impl.computeHash(seed);
-                System.arraycopy(copies, FRAME_OFFSET, seed, 0, FRAME_LENGTH);
-            }
-            counter++;
-
-            int j = 0;
-            for (i = 0; i < EXTRAFRAME_OFFSET; i++) {
-                int k = seed[HASH_OFFSET + i];
-                nextBytes[j] = (byte) (k >>> 24); // getting first  byte from left
-                nextBytes[j + 1] = (byte) (k >>> 16); // getting second byte from left
-                nextBytes[j + 2] = (byte) (k >>> 8); // getting third  byte from left
-                nextBytes[j + 3] = (byte) (k); // getting fourth byte from left
-                j += 4;
-            }
-
-            nextBIndex = 0;
-            j = HASHBYTES_TO_USE < (bytes.length - nextByteToReturn) ? HASHBYTES_TO_USE
-                    : bytes.length - nextByteToReturn;
-
-            if (j > 0) {
-                System.arraycopy(nextBytes, 0, bytes, nextByteToReturn, j);
-                nextByteToReturn += j;
-                nextBIndex += j;
-            }
-
-            if (nextByteToReturn >= bytes.length) {
-                break;
-            }
-        }
-    }
-
-    private void writeObject(ObjectOutputStream oos) throws IOException {
-
-        int[] intData = null;
-
-        final int only_hash = EXTRAFRAME_OFFSET;
-        final int hashes_and_frame = EXTRAFRAME_OFFSET * 2 + FRAME_LENGTH;
-        final int hashes_and_frame_extra = EXTRAFRAME_OFFSET * 2 + FRAME_LENGTH
-                * 2;
-
-        oos.writeLong(seedLength);
-        oos.writeLong(counter);
-        oos.writeInt(state);
-        oos.writeInt(seed[BYTES_OFFSET]);
-
-        int nRemaining = (seed[BYTES_OFFSET] + 3) >> 2; // converting bytes in words
-        // result may be 0
-        if (state != NEXT_BYTES) {
-
-            // either the state is UNDEFINED or previous method was "setSeed(..)"
-            // so in "seed[]" to serialize are remaining bytes (seed[0-nRemaining]) and
-            // current hash (seed[82-86])
-
-            intData = new int[only_hash + nRemaining];
-
-            System.arraycopy(seed, 0, intData, 0, nRemaining);
-            System.arraycopy(seed, HASH_OFFSET, intData, nRemaining,
-                    EXTRAFRAME_OFFSET);
-
-        } else {
-            // previous method was "nextBytes(..)"
-            // so, data to serialize are all the above (two first are in "copies" array)
-            // and current words in both frame and extra frame (as if)
-
-            int offset = 0;
-            if (seed[BYTES_OFFSET] < MAX_BYTES) { // no extra frame
-
-                intData = new int[hashes_and_frame + nRemaining];
-
-            } else { // extra frame is used
-
-                intData = new int[hashes_and_frame_extra + nRemaining];
-
-                intData[offset] = seed[FRAME_LENGTH];
-                intData[offset + 1] = seed[FRAME_LENGTH + 1];
-                intData[offset + 2] = seed[FRAME_LENGTH + 14];
-                intData[offset + 3] = seed[FRAME_LENGTH + 15];
-                offset += 4;
-            }
-
-            System.arraycopy(seed, 0, intData, offset, FRAME_LENGTH);
-            offset += FRAME_LENGTH;
-
-            System.arraycopy(copies, FRAME_LENGTH + EXTRAFRAME_OFFSET, intData,
-                    offset, nRemaining);
-            offset += nRemaining;
-
-            System.arraycopy(copies, 0, intData, offset, EXTRAFRAME_OFFSET);
-            offset += EXTRAFRAME_OFFSET;
-
-            System.arraycopy(seed, HASH_OFFSET, intData, offset,
-                    EXTRAFRAME_OFFSET);
-        }
-        for (int i = 0; i < intData.length; i++) {
-            oos.writeInt(intData[i]);
-        }
-
-        oos.writeInt(nextBIndex);
-        oos.write(nextBytes, nextBIndex, HASHBYTES_TO_USE - nextBIndex);
-    }
-
-    private void readObject(ObjectInputStream ois) throws IOException,
-            ClassNotFoundException {
-
-        seed = new int[HASH_OFFSET + EXTRAFRAME_OFFSET];
-        copies = new int[2 * FRAME_LENGTH + EXTRAFRAME_OFFSET];
-        nextBytes = new byte[DIGEST_LENGTH];
-
-        seedLength = ois.readLong();
-        counter = ois.readLong();
-        state = ois.readInt();
-        seed[BYTES_OFFSET] = ois.readInt();
-
-        int nRemaining = (seed[BYTES_OFFSET] + 3) >> 2; // converting bytes in words
-
-        if (state != NEXT_BYTES) {
-
-            for (int i = 0; i < nRemaining; i++) {
-                seed[i] = ois.readInt();
-            }
-            for (int i = 0; i < EXTRAFRAME_OFFSET; i++) {
-                seed[HASH_OFFSET + i] = ois.readInt();
-            }
-        } else {
-            if (seed[BYTES_OFFSET] >= MAX_BYTES) {
-
-                // reading next bytes in seed extra frame
-                seed[FRAME_LENGTH] = ois.readInt();
-                seed[FRAME_LENGTH + 1] = ois.readInt();
-                seed[FRAME_LENGTH + 14] = ois.readInt();
-                seed[FRAME_LENGTH + 15] = ois.readInt();
-            }
-            // reading next bytes in seed frame
-            for (int i = 0; i < FRAME_LENGTH; i++) {
-                seed[i] = ois.readInt();
-            }
-            // reading remaining seed bytes
-            for (int i = 0; i < nRemaining; i++) {
-                copies[FRAME_LENGTH + EXTRAFRAME_OFFSET + i] = ois.readInt();
-            }
-            // reading copy of current hash
-            for (int i = 0; i < EXTRAFRAME_OFFSET; i++) {
-                copies[i] = ois.readInt();
-            }
-            // reading current hash
-            for (int i = 0; i < EXTRAFRAME_OFFSET; i++) {
-                seed[HASH_OFFSET + i] = ois.readInt();
-            }
-        }
-
-        nextBIndex = ois.readInt();
-        Streams.readFully(ois, nextBytes, nextBIndex, HASHBYTES_TO_USE - nextBIndex);
-    }
-
-    private static byte[] getRandomBytes(int byteCount) {
-        if (byteCount <= 0) {
-            throw new IllegalArgumentException("Too few bytes requested: " + byteCount);
-        }
-
-        BlockGuard.Policy originalPolicy = BlockGuard.getThreadPolicy();
-        try {
-            BlockGuard.setThreadPolicy(BlockGuard.LAX_POLICY);
-            byte[] result = new byte[byteCount];
-            Streams.readFully(devURandom, result, 0, byteCount);
-            return result;
-        } catch (Exception ex) {
-            throw new ProviderException("Couldn't read " + byteCount + " random bytes", ex);
-        } finally {
-            BlockGuard.setThreadPolicy(originalPolicy);
-        }
-    }
-}