harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r390246 [6/15] - in /incubator/harmony/enhanced/classlib/trunk: archive/modules/security/src/main/java/java/security/ modules/archive/src/main/java/java/util/jar/ modules/archive/src/test/java/tests/api/java/util/zip/ modules/beans/src/main...
Date Thu, 30 Mar 2006 21:34:28 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/AlgorithmParameters.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/AlgorithmParameters.java?rev=390246&r1=390245&r2=390246&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/AlgorithmParameters.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/AlgorithmParameters.java Thu Mar 30 13:34:23 2006
@@ -1,231 +1,231 @@
-/*
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed 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 Boris V. Kuznetsov
-* @version $Revision$
-*/
-
-package java.security;
-
-import java.io.IOException;
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.InvalidParameterSpecException;
-
-import org.apache.harmony.security.fortress.Engine;
-
-
-/**
- * @com.intel.drl.spec_ref
- * 
- */
-
-public class AlgorithmParameters {
-    /**
-     * The service name.
-     */
-    private static final String SEVICE = "AlgorithmParameters";
-
-    /**
-     * Used to accesess common engine functionality
-     */
-    private static Engine engine = new Engine(SEVICE);
-
-    /**
-     * The provider
-     */
-    private Provider provider;
-
-    /**
-     * The SPI implementation.
-     */
-    private AlgorithmParametersSpi spiImpl;
-
-    /**
-     * The algorithm.
-     */
-    private String algorithm;
-
-    /**
-     * The initialisation state
-     */
-    private boolean initialized; // = false;
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    protected AlgorithmParameters(AlgorithmParametersSpi keyFacSpi,
-            Provider provider, String algorithm) {
-        this.provider = provider;
-        this.algorithm = algorithm;
-        this.spiImpl = keyFacSpi;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public static AlgorithmParameters getInstance(String algorithm)
-            throws NoSuchAlgorithmException {
-        if (algorithm == null) {
-            throw new NullPointerException("Algorithm is null");
-        }
-        synchronized (engine) {       
-            engine.getInstance(algorithm, null);
-            return new AlgorithmParameters((AlgorithmParametersSpi) engine.spi,
-                    engine.provider, algorithm);
-        }
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public static AlgorithmParameters getInstance(String algorithm,
-            String provider) throws NoSuchAlgorithmException,
-            NoSuchProviderException {
-        if ((provider == null) || (provider.length() == 0)) {
-            throw new IllegalArgumentException(
-                    "Provider is null or empty string");
-        }
-        Provider p = Security.getProvider(provider);
-        if (p == null) {
-            throw new NoSuchProviderException("Provider " + provider
-                    + " is not available");
-        }
-        return getInstance(algorithm, p);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public static AlgorithmParameters getInstance(String algorithm,
-            Provider provider) throws NoSuchAlgorithmException {
-        if (provider == null) {
-            throw new IllegalArgumentException("Provider is null");
-        }
-        if (algorithm == null) {
-            throw new NullPointerException("Algorithm is null");
-        }
-        synchronized (engine) {
-            engine.getInstance(algorithm, provider, null);
-            return new AlgorithmParameters((AlgorithmParametersSpi) engine.spi,
-                    provider, algorithm);
-        }
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final Provider getProvider() {
-        return provider;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final String getAlgorithm() {
-        return algorithm;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final void init(AlgorithmParameterSpec paramSpec)
-            throws InvalidParameterSpecException {
-        if (initialized) {
-            throw new InvalidParameterSpecException(
-                    "Parameter has already been initialized");
-        }
-        spiImpl.engineInit(paramSpec);
-        initialized = true;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final void init(byte[] params) throws IOException {
-        if (initialized) {
-            throw new IOException("Parameter has already been initialized");
-        }
-        spiImpl.engineInit(params);
-        initialized = true;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final void init(byte[] params, String format) throws IOException {
-        if (initialized) {
-            throw new IOException("Parameter has already been initialized");
-        }
-        spiImpl.engineInit(params, format);
-        initialized = true;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final AlgorithmParameterSpec getParameterSpec(Class paramSpec)
-            throws InvalidParameterSpecException {
-        if (!initialized) {
-            throw new InvalidParameterSpecException(
-                    "Parameter has not been initialized");
-        }
-        return spiImpl.engineGetParameterSpec(paramSpec);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final byte[] getEncoded() throws IOException {
-        if (!initialized) {
-            throw new IOException("Parameter has not been initialized");
-        }
-        return spiImpl.engineGetEncoded();
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final byte[] getEncoded(String format) throws IOException {
-        if (!initialized) {
-            throw new IOException("Parameter has not been initialized");
-        }
-        return spiImpl.engineGetEncoded(format);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final String toString() {
-        if (!initialized) {
-            return null;
-        }
-        return spiImpl.engineToString();
-    }
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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 Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package java.security;
+
+import java.io.IOException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
+
+import org.apache.harmony.security.fortress.Engine;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ * 
+ */
+
+public class AlgorithmParameters {
+    /**
+     * The service name.
+     */
+    private static final String SEVICE = "AlgorithmParameters";
+
+    /**
+     * Used to access common engine functionality
+     */
+    private static Engine engine = new Engine(SEVICE);
+
+    /**
+     * The provider
+     */
+    private Provider provider;
+
+    /**
+     * The SPI implementation.
+     */
+    private AlgorithmParametersSpi spiImpl;
+
+    /**
+     * The algorithm.
+     */
+    private String algorithm;
+
+    /**
+     * The initialisation state
+     */
+    private boolean initialized; // = false;
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    protected AlgorithmParameters(AlgorithmParametersSpi keyFacSpi,
+            Provider provider, String algorithm) {
+        this.provider = provider;
+        this.algorithm = algorithm;
+        this.spiImpl = keyFacSpi;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public static AlgorithmParameters getInstance(String algorithm)
+            throws NoSuchAlgorithmException {
+        if (algorithm == null) {
+            throw new NullPointerException("Algorithm is null");
+        }
+        synchronized (engine) {       
+            engine.getInstance(algorithm, null);
+            return new AlgorithmParameters((AlgorithmParametersSpi) engine.spi,
+                    engine.provider, algorithm);
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public static AlgorithmParameters getInstance(String algorithm,
+            String provider) throws NoSuchAlgorithmException,
+            NoSuchProviderException {
+        if ((provider == null) || (provider.length() == 0)) {
+            throw new IllegalArgumentException(
+                    "Provider is null or empty string");
+        }
+        Provider p = Security.getProvider(provider);
+        if (p == null) {
+            throw new NoSuchProviderException("Provider " + provider
+                    + " is not available");
+        }
+        return getInstance(algorithm, p);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public static AlgorithmParameters getInstance(String algorithm,
+            Provider provider) throws NoSuchAlgorithmException {
+        if (provider == null) {
+            throw new IllegalArgumentException("Provider is null");
+        }
+        if (algorithm == null) {
+            throw new NullPointerException("Algorithm is null");
+        }
+        synchronized (engine) {
+            engine.getInstance(algorithm, provider, null);
+            return new AlgorithmParameters((AlgorithmParametersSpi) engine.spi,
+                    provider, algorithm);
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final Provider getProvider() {
+        return provider;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final String getAlgorithm() {
+        return algorithm;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final void init(AlgorithmParameterSpec paramSpec)
+            throws InvalidParameterSpecException {
+        if (initialized) {
+            throw new InvalidParameterSpecException(
+                    "Parameter has already been initialized");
+        }
+        spiImpl.engineInit(paramSpec);
+        initialized = true;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final void init(byte[] params) throws IOException {
+        if (initialized) {
+            throw new IOException("Parameter has already been initialized");
+        }
+        spiImpl.engineInit(params);
+        initialized = true;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final void init(byte[] params, String format) throws IOException {
+        if (initialized) {
+            throw new IOException("Parameter has already been initialized");
+        }
+        spiImpl.engineInit(params, format);
+        initialized = true;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final AlgorithmParameterSpec getParameterSpec(Class paramSpec)
+            throws InvalidParameterSpecException {
+        if (!initialized) {
+            throw new InvalidParameterSpecException(
+                    "Parameter has not been initialized");
+        }
+        return spiImpl.engineGetParameterSpec(paramSpec);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final byte[] getEncoded() throws IOException {
+        if (!initialized) {
+            throw new IOException("Parameter has not been initialized");
+        }
+        return spiImpl.engineGetEncoded();
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final byte[] getEncoded(String format) throws IOException {
+        if (!initialized) {
+            throw new IOException("Parameter has not been initialized");
+        }
+        return spiImpl.engineGetEncoded(format);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final String toString() {
+        if (!initialized) {
+            return null;
+        }
+        return spiImpl.engineToString();
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/KeyFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/KeyFactory.java?rev=390246&r1=390245&r2=390246&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/KeyFactory.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/KeyFactory.java Thu Mar 30 13:34:23 2006
@@ -1,166 +1,166 @@
-/*
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed 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 Boris V. Kuznetsov
-* @version $Revision$
-*/
-
-package java.security;
-
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.KeySpec;
-
-import org.apache.harmony.security.fortress.Engine;
-
-
-/**
- * @com.intel.drl.spec_ref
- * 
- */
-
-public class KeyFactory {
-    // The service name.
-    private static final String SERVICE = "KeyFactory";
-    
-    // The provider
-    private Provider provider;
-    
-    
-    // Used to accesess common engine functionality
-    static private Engine engine = new Engine(SERVICE);
-    
-    // The SPI implementation.
-    private KeyFactorySpi spiImpl; 
-    
-    // The algorithm.
-    private String algorithm;
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    protected KeyFactory(KeyFactorySpi keyFacSpi, 
-                         Provider provider,
-                         String algorithm) {
-        this.provider = provider;
-        this. algorithm = algorithm;
-        this.spiImpl = keyFacSpi;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public static KeyFactory getInstance(String algorithm)
-                                throws NoSuchAlgorithmException {
-        if (algorithm == null) {
-            throw new NullPointerException("Algorithm is null");
-        }
-        synchronized (engine) {
-            engine.getInstance(algorithm, null);
-            return new KeyFactory((KeyFactorySpi)engine.spi, engine.provider, algorithm);
-        }
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public static KeyFactory getInstance(String algorithm, String provider)
-                                throws NoSuchAlgorithmException, NoSuchProviderException {
-        if ((provider == null) || (provider.length() == 0)) {
-            throw new IllegalArgumentException(
-                    "Provider is null or empty string");
-        }
-        Provider p = Security.getProvider(provider);
-        if (p == null) {
-            throw new NoSuchProviderException("Provider "+ provider + " is not available"); 
-        }
-        return getInstance(algorithm, p);    
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public static KeyFactory getInstance(String algorithm, Provider provider)
-                                 throws NoSuchAlgorithmException {
-        if (provider == null) {
-            throw new IllegalArgumentException("provider is null");
-        }
-        if (algorithm == null) {
-            throw new NullPointerException("Algorithm is null");
-        }
-        synchronized (engine) {
-            engine.getInstance(algorithm, provider, null);
-            return new KeyFactory((KeyFactorySpi)engine.spi, provider, algorithm);
-        }
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public final Provider getProvider() {
-        return provider;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public final String getAlgorithm() {
-        return algorithm;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public final PublicKey generatePublic(KeySpec keySpec)
-                                throws InvalidKeySpecException {
-        return spiImpl.engineGeneratePublic(keySpec);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public final PrivateKey generatePrivate(KeySpec keySpec)
-                                throws InvalidKeySpecException {
-        return spiImpl.engineGeneratePrivate(keySpec);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public final KeySpec getKeySpec(Key key,
-                                    Class keySpec)
-                            throws InvalidKeySpecException {
-        return spiImpl.engineGetKeySpec(key, keySpec);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public final Key translateKey(Key key)
-                        throws InvalidKeyException {
-        return spiImpl.engineTranslateKey(key);
-    }
-}
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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 Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package java.security;
+
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.KeySpec;
+
+import org.apache.harmony.security.fortress.Engine;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ * 
+ */
+
+public class KeyFactory {
+    // The service name.
+    private static final String SERVICE = "KeyFactory";
+    
+    // The provider
+    private Provider provider;
+    
+    
+    // Used to access common engine functionality
+    static private Engine engine = new Engine(SERVICE);
+    
+    // The SPI implementation.
+    private KeyFactorySpi spiImpl; 
+    
+    // The algorithm.
+    private String algorithm;
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    protected KeyFactory(KeyFactorySpi keyFacSpi, 
+                         Provider provider,
+                         String algorithm) {
+        this.provider = provider;
+        this. algorithm = algorithm;
+        this.spiImpl = keyFacSpi;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public static KeyFactory getInstance(String algorithm)
+                                throws NoSuchAlgorithmException {
+        if (algorithm == null) {
+            throw new NullPointerException("Algorithm is null");
+        }
+        synchronized (engine) {
+            engine.getInstance(algorithm, null);
+            return new KeyFactory((KeyFactorySpi)engine.spi, engine.provider, algorithm);
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public static KeyFactory getInstance(String algorithm, String provider)
+                                throws NoSuchAlgorithmException, NoSuchProviderException {
+        if ((provider == null) || (provider.length() == 0)) {
+            throw new IllegalArgumentException(
+                    "Provider is null or empty string");
+        }
+        Provider p = Security.getProvider(provider);
+        if (p == null) {
+            throw new NoSuchProviderException("Provider "+ provider + " is not available"); 
+        }
+        return getInstance(algorithm, p);    
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public static KeyFactory getInstance(String algorithm, Provider provider)
+                                 throws NoSuchAlgorithmException {
+        if (provider == null) {
+            throw new IllegalArgumentException("provider is null");
+        }
+        if (algorithm == null) {
+            throw new NullPointerException("Algorithm is null");
+        }
+        synchronized (engine) {
+            engine.getInstance(algorithm, provider, null);
+            return new KeyFactory((KeyFactorySpi)engine.spi, provider, algorithm);
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public final Provider getProvider() {
+        return provider;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public final String getAlgorithm() {
+        return algorithm;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public final PublicKey generatePublic(KeySpec keySpec)
+                                throws InvalidKeySpecException {
+        return spiImpl.engineGeneratePublic(keySpec);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public final PrivateKey generatePrivate(KeySpec keySpec)
+                                throws InvalidKeySpecException {
+        return spiImpl.engineGeneratePrivate(keySpec);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public final KeySpec getKeySpec(Key key,
+                                    Class keySpec)
+                            throws InvalidKeySpecException {
+        return spiImpl.engineGetKeySpec(key, keySpec);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public final Key translateKey(Key key)
+                        throws InvalidKeyException {
+        return spiImpl.engineTranslateKey(key);
+    }
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/KeyPairGenerator.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/KeyPairGenerator.java?rev=390246&r1=390245&r2=390246&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/KeyPairGenerator.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/KeyPairGenerator.java Thu Mar 30 13:34:23 2006
@@ -1,236 +1,236 @@
-/*
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed 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 Vera Y. Petrashkova
-* @version $Revision$
-*/
-
-package java.security;
-
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.apache.harmony.security.fortress.Engine;
-
-
-/**
- * 
- * @com.intel.drl.spec_ref
- * 
- */
-public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
-
-    // Store KeyPairGenerator SERVICE name
-    private static final String SERVICE = "KeyPairGenerator";
-
-    // Used to accesess common engine functionality
-    private static Engine engine = new Engine(SERVICE);
-
-    // Store SecureRandom
-    private static SecureRandom random = new SecureRandom();
-
-    // Store used ptovider
-    private Provider provider;
-
-    // Store used algorithm
-    private String algorithm;
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    protected KeyPairGenerator(String algorithm) {
-        this.algorithm = algorithm;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public String getAlgorithm() {
-        return algorithm;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     * throws NullPointerException when algorithm is null
-     */
-    public static KeyPairGenerator getInstance(String algorithm)
-            throws NoSuchAlgorithmException {
-        if (algorithm == null) {
-            throw new NullPointerException("algorithm is null");
-        }
-        KeyPairGenerator result;
-        synchronized (engine) {
-            engine.getInstance(algorithm, null);
-            if (engine.spi instanceof KeyPairGenerator) {
-                result = (KeyPairGenerator) engine.spi;
-                result.algorithm = algorithm;
-                result.provider = engine.provider;
-                return result;
-            } else {
-                result = new KeyPairGeneratorImpl((KeyPairGeneratorSpi) engine.spi,
-                        engine.provider, algorithm);
-                return result;
-            }
-        }
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     * throws NullPointerException if algorithm is null (instead of
-     * NoSuchAlgorithmException) as in 1.4 release
-     */
-    public static KeyPairGenerator getInstance(String algorithm, String provider)
-            throws NoSuchAlgorithmException, NoSuchProviderException {
-        if ((provider == null) || (provider.length() == 0)) {
-            throw new IllegalArgumentException(
-                    "Provider is null or empty string");
-        }
-        Provider impProvider = Security.getProvider(provider);
-        if (impProvider == null) {
-            throw new NoSuchProviderException(provider);
-        }
-        return getInstance(algorithm, impProvider);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     * throws NullPointerException if algorithm is null (instead of
-     * NoSuchAlgorithmException) as in 1.4 release
-     */
-    public static KeyPairGenerator getInstance(String algorithm,
-            Provider provider) throws NoSuchAlgorithmException {
-        if (provider == null) {
-            throw new IllegalArgumentException("Provider is null");
-        }
-        if (algorithm == null) {
-            throw new NullPointerException("algorithm is null");
-        }
-        KeyPairGenerator result;
-        synchronized (engine) {
-            engine.getInstance(algorithm, provider, null);
-            if (engine.spi instanceof KeyPairGenerator) {
-                result = (KeyPairGenerator) engine.spi;
-                result.algorithm = algorithm;
-                result.provider = provider;
-                return result;
-            } else {
-                result = new KeyPairGeneratorImpl((KeyPairGeneratorSpi) engine.spi,
-                        provider, algorithm);
-                return result;
-            }
-        }
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final Provider getProvider() {
-        return provider;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public void initialize(int keysize) {
-        initialize(keysize, random);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public void initialize(AlgorithmParameterSpec param)
-            throws InvalidAlgorithmParameterException {
-        initialize(param, random);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final KeyPair genKeyPair() {
-        return generateKeyPair();
-    }
-
-    public KeyPair generateKeyPair() {
-        return null;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public void initialize(int keysize, SecureRandom random) {
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public void initialize(AlgorithmParameterSpec param, SecureRandom random)
-            throws InvalidAlgorithmParameterException {
-    }
-
-    /**
-     * 
-     * Internal class: KeyPairGenerator implementation
-     * 
-     */
-    private static class KeyPairGeneratorImpl extends KeyPairGenerator {
-        // Save KeyPairGeneratorSpi
-        private KeyPairGeneratorSpi spiImpl;
-
-        // Implementation of KeyPaiGenerator constructor
-        // 
-        // @param KeyPairGeneratorSpi
-        // @param provider
-        // @param algorithm
-        private KeyPairGeneratorImpl(KeyPairGeneratorSpi keyPairGeneratorSpi,
-                Provider provider, String algorithm) {
-            super(algorithm);
-            super.provider = provider;
-            spiImpl = keyPairGeneratorSpi;
-        }
-
-        // implementation of initialize(int keysize, SecureRandom random)
-        // using corresponding spi initialize() method
-        public void initialize(int keysize, SecureRandom random) {
-            spiImpl.initialize(keysize, random);
-        }
-
-        // implementation of generateKeyPair()
-        // using corresponding spi generateKeyPair() method
-        public KeyPair generateKeyPair() {
-            return spiImpl.generateKeyPair();
-        }
-
-        // implementation of initialize(int keysize, SecureRandom random)
-        // using corresponding spi initialize() method
-        public void initialize(AlgorithmParameterSpec param, SecureRandom random)
-                throws InvalidAlgorithmParameterException {
-            spiImpl.initialize(param, random);
-        }
-
-    }
-
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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 Vera Y. Petrashkova
+* @version $Revision$
+*/
+
+package java.security;
+
+import java.security.spec.AlgorithmParameterSpec;
+
+import org.apache.harmony.security.fortress.Engine;
+
+
+/**
+ * 
+ * @com.intel.drl.spec_ref
+ * 
+ */
+public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
+
+    // Store KeyPairGenerator SERVICE name
+    private static final String SERVICE = "KeyPairGenerator";
+
+    // Used to access common engine functionality
+    private static Engine engine = new Engine(SERVICE);
+
+    // Store SecureRandom
+    private static SecureRandom random = new SecureRandom();
+
+    // Store used ptovider
+    private Provider provider;
+
+    // Store used algorithm
+    private String algorithm;
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    protected KeyPairGenerator(String algorithm) {
+        this.algorithm = algorithm;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public String getAlgorithm() {
+        return algorithm;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     * throws NullPointerException when algorithm is null
+     */
+    public static KeyPairGenerator getInstance(String algorithm)
+            throws NoSuchAlgorithmException {
+        if (algorithm == null) {
+            throw new NullPointerException("algorithm is null");
+        }
+        KeyPairGenerator result;
+        synchronized (engine) {
+            engine.getInstance(algorithm, null);
+            if (engine.spi instanceof KeyPairGenerator) {
+                result = (KeyPairGenerator) engine.spi;
+                result.algorithm = algorithm;
+                result.provider = engine.provider;
+                return result;
+            } else {
+                result = new KeyPairGeneratorImpl((KeyPairGeneratorSpi) engine.spi,
+                        engine.provider, algorithm);
+                return result;
+            }
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     * throws NullPointerException if algorithm is null (instead of
+     * NoSuchAlgorithmException) as in 1.4 release
+     */
+    public static KeyPairGenerator getInstance(String algorithm, String provider)
+            throws NoSuchAlgorithmException, NoSuchProviderException {
+        if ((provider == null) || (provider.length() == 0)) {
+            throw new IllegalArgumentException(
+                    "Provider is null or empty string");
+        }
+        Provider impProvider = Security.getProvider(provider);
+        if (impProvider == null) {
+            throw new NoSuchProviderException(provider);
+        }
+        return getInstance(algorithm, impProvider);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     * throws NullPointerException if algorithm is null (instead of
+     * NoSuchAlgorithmException) as in 1.4 release
+     */
+    public static KeyPairGenerator getInstance(String algorithm,
+            Provider provider) throws NoSuchAlgorithmException {
+        if (provider == null) {
+            throw new IllegalArgumentException("Provider is null");
+        }
+        if (algorithm == null) {
+            throw new NullPointerException("algorithm is null");
+        }
+        KeyPairGenerator result;
+        synchronized (engine) {
+            engine.getInstance(algorithm, provider, null);
+            if (engine.spi instanceof KeyPairGenerator) {
+                result = (KeyPairGenerator) engine.spi;
+                result.algorithm = algorithm;
+                result.provider = provider;
+                return result;
+            } else {
+                result = new KeyPairGeneratorImpl((KeyPairGeneratorSpi) engine.spi,
+                        provider, algorithm);
+                return result;
+            }
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final Provider getProvider() {
+        return provider;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public void initialize(int keysize) {
+        initialize(keysize, random);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public void initialize(AlgorithmParameterSpec param)
+            throws InvalidAlgorithmParameterException {
+        initialize(param, random);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final KeyPair genKeyPair() {
+        return generateKeyPair();
+    }
+
+    public KeyPair generateKeyPair() {
+        return null;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public void initialize(int keysize, SecureRandom random) {
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public void initialize(AlgorithmParameterSpec param, SecureRandom random)
+            throws InvalidAlgorithmParameterException {
+    }
+
+    /**
+     * 
+     * Internal class: KeyPairGenerator implementation
+     * 
+     */
+    private static class KeyPairGeneratorImpl extends KeyPairGenerator {
+        // Save KeyPairGeneratorSpi
+        private KeyPairGeneratorSpi spiImpl;
+
+        // Implementation of KeyPaiGenerator constructor
+        // 
+        // @param KeyPairGeneratorSpi
+        // @param provider
+        // @param algorithm
+        private KeyPairGeneratorImpl(KeyPairGeneratorSpi keyPairGeneratorSpi,
+                Provider provider, String algorithm) {
+            super(algorithm);
+            super.provider = provider;
+            spiImpl = keyPairGeneratorSpi;
+        }
+
+        // implementation of initialize(int keysize, SecureRandom random)
+        // using corresponding spi initialize() method
+        public void initialize(int keysize, SecureRandom random) {
+            spiImpl.initialize(keysize, random);
+        }
+
+        // implementation of generateKeyPair()
+        // using corresponding spi generateKeyPair() method
+        public KeyPair generateKeyPair() {
+            return spiImpl.generateKeyPair();
+        }
+
+        // implementation of initialize(int keysize, SecureRandom random)
+        // using corresponding spi initialize() method
+        public void initialize(AlgorithmParameterSpec param, SecureRandom random)
+                throws InvalidAlgorithmParameterException {
+            spiImpl.initialize(param, random);
+        }
+
+    }
+
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/KeyStore.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/KeyStore.java?rev=390246&r1=390245&r2=390246&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/KeyStore.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/KeyStore.java Thu Mar 30 13:34:23 2006
@@ -50,7 +50,7 @@
     // Store KeyStore SERVICE name
     private static final String SERVICE = "KeyStore";
 
-    // Used to accesess common engine functionality
+    // Used to access common engine functionality
     private static Engine engine = new Engine(SERVICE);
 
     //  Store KeyStore property name
@@ -113,7 +113,7 @@
     public static KeyStore getInstance(String type, String provider)
             throws KeyStoreException, NoSuchProviderException {
         if ((provider == null) || (provider.length() == 0)) {
-            throw new IllegalArgumentException("Proveder is null or empty");
+            throw new IllegalArgumentException("Provider is null or empty");
         }
         Provider impProvider = Security.getProvider(provider);
         if (impProvider == null) {
@@ -136,7 +136,7 @@
             throws KeyStoreException {
         // check parameters
         if (provider == null) {
-            throw new IllegalArgumentException("Proveder is null");
+            throw new IllegalArgumentException("Provider is null");
         }
         if (type == null) {
             throw new NullPointerException("type is null");

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/MessageDigest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/MessageDigest.java?rev=390246&r1=390245&r2=390246&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/MessageDigest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/MessageDigest.java Thu Mar 30 13:34:23 2006
@@ -1,330 +1,330 @@
-/*
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed 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 Boris V. Kuznetsov
-* @version $Revision$
-*/
-
-package java.security;
-
-import java.nio.ByteBuffer;
-
-import org.apache.harmony.security.fortress.Engine;
-
-
-/**
- * @com.intel.drl.spec_ref
- * 
- */
-
-public abstract class MessageDigest extends MessageDigestSpi {
-    
-    // The service name
-    private static final String SERVICE = "MessageDigest";
-
-    // Used to accesess common engine functionality
-    private static Engine engine = new Engine(SERVICE);
-
-    // The provider
-    private Provider provider;
-
-    // The algorithm.
-    private String algorithm;
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    protected MessageDigest(String algorithm) {
-        this.algorithm = algorithm;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public static MessageDigest getInstance(String algorithm)
-            throws NoSuchAlgorithmException {
-        if (algorithm == null) {
-            throw new NullPointerException("Algorithm is null");
-        }
-        MessageDigest result;
-        synchronized (engine) {
-            engine.getInstance(algorithm, null);
-            if (engine.spi instanceof MessageDigest) {
-                result = (MessageDigest) engine.spi;
-                result.algorithm = algorithm;
-                result.provider = engine.provider;
-                return result;
-            } else {
-                result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
-                        engine.provider, algorithm);
-                return result;
-            }
-        }
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public static MessageDigest getInstance(String algorithm, String provider)
-            throws NoSuchAlgorithmException, NoSuchProviderException {
-        if ((provider == null) || (provider.length() == 0)) {
-            throw new IllegalArgumentException(
-                    "Provider is null or empty string");
-        }
-        Provider p = Security.getProvider(provider);
-        if (p == null) {
-            throw new NoSuchProviderException("Provider " + provider
-                    + " is not available");
-        }
-        return getInstance(algorithm, p);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public static MessageDigest getInstance(String algorithm, Provider provider)
-            throws NoSuchAlgorithmException {
-        if (provider == null) {
-            throw new IllegalArgumentException("Provider is null");
-        }
-        if (algorithm == null) {
-            throw new NullPointerException("Algorithm is null");
-        }
-        MessageDigest result;
-        synchronized (engine) {
-            engine.getInstance(algorithm, provider, null);
-            if (engine.spi instanceof MessageDigest) {
-                result = (MessageDigest) engine.spi;
-                result.algorithm = algorithm;
-                result.provider = provider;
-                return result;
-            } else {
-                result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
-                        provider, algorithm);
-                return result;
-            }
-        }
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public void reset() {
-        engineReset();
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public void update(byte arg0) {
-        engineUpdate(arg0);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public void update(byte[] input, int offset, int len) {
-        if (input == null || offset < 0 || len < 0 ||
-                offset + len > input.length) {
-            throw new IllegalArgumentException(
-                    "Incorrect offset/len parameters");
-        }
-        engineUpdate(input, offset, len);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public void update(byte[] input) {
-        if (input == null) {
-            throw new NullPointerException("Null input parameter");
-        }
-        engineUpdate(input, 0, input.length);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public byte[] digest() {
-        return engineDigest();
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public int digest(byte[] buf, int offset, int len) throws DigestException {
-        if (buf == null || offset < 0 || len < 0 ||
-                offset + len > buf.length) {
-            throw new IllegalArgumentException(
-                    "Incorrect offset/len parameters");
-        }
-        return engineDigest(buf, offset, len);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public byte[] digest(byte[] input) {
-        update(input);
-        return digest();
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public String toString() {
-        return "MESSAGE DIGEST " + algorithm;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public static boolean isEqual(byte[] digesta, byte[] digestb) {
-        if (digesta.length != digestb.length) {
-            return false;
-        }
-        for (int i = 0; i < digesta.length; i++) {
-            if (digesta[i] != digestb[i]) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final String getAlgorithm() {
-        return algorithm;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final Provider getProvider() {
-        return provider;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final int getDigestLength() {
-        int l = engineGetDigestLength();
-        if (l != 0) {
-            return l;
-        }
-        if (!(this instanceof Cloneable)) {
-            return 0;
-        }
-        try {
-            MessageDigest md = (MessageDigest) clone();
-            return md.digest().length;
-        } catch (CloneNotSupportedException e) {
-            return 0;
-        }
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public Object clone() throws CloneNotSupportedException {
-        if (this instanceof Cloneable) {
-            return super.clone();
-        } else {
-            throw new CloneNotSupportedException();
-        }
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     *  
-     */
-    public final void update(ByteBuffer input) {
-        engineUpdate(input);
-    }
-
-    /**
-     * 
-     * The internal MessageDigest implementation
-     * 
-     */
-    private static class MessageDigestImpl extends MessageDigest {
-        
-        // MessageDigestSpi implementation
-        private MessageDigestSpi spiImpl;
-
-        // MessageDigestImpl ctor
-        private MessageDigestImpl(MessageDigestSpi messageDigestSpi,
-                Provider provider, String algorithm) {
-            super(algorithm);
-            super.provider = provider;
-            spiImpl = messageDigestSpi;
-        }
-
-        // engineReset() implementation
-        protected void engineReset() {
-            spiImpl.engineReset();
-        }
-
-        // engineDigest() implementation
-        protected byte[] engineDigest() {
-            return spiImpl.engineDigest();
-        }
-
-        // engineGetDigestLength() implementation
-        protected int engineGetDigestLength() {
-            return spiImpl.engineGetDigestLength();
-        }
-
-        // engineUpdate() implementation
-        protected void engineUpdate(byte arg0) {
-            spiImpl.engineUpdate(arg0);
-        }
-
-        // engineUpdate() implementation
-        protected void engineUpdate(byte[] arg0, int arg1, int arg2) {
-            spiImpl.engineUpdate(arg0, arg1, arg2);
-        }
-
-        // Returns a clone if the spiImpl is cloneable
-        public Object clone() throws CloneNotSupportedException {
-            if (spiImpl instanceof Cloneable) {
-                MessageDigestSpi spi = (MessageDigestSpi) spiImpl.clone();
-                return new MessageDigestImpl(spi, getProvider(), getAlgorithm());
-            } else {
-                throw new CloneNotSupportedException();
-            }
-        }
-    }
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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 Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package java.security;
+
+import java.nio.ByteBuffer;
+
+import org.apache.harmony.security.fortress.Engine;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ * 
+ */
+
+public abstract class MessageDigest extends MessageDigestSpi {
+    
+    // The service name
+    private static final String SERVICE = "MessageDigest";
+
+    // Used to access common engine functionality
+    private static Engine engine = new Engine(SERVICE);
+
+    // The provider
+    private Provider provider;
+
+    // The algorithm.
+    private String algorithm;
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    protected MessageDigest(String algorithm) {
+        this.algorithm = algorithm;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public static MessageDigest getInstance(String algorithm)
+            throws NoSuchAlgorithmException {
+        if (algorithm == null) {
+            throw new NullPointerException("Algorithm is null");
+        }
+        MessageDigest result;
+        synchronized (engine) {
+            engine.getInstance(algorithm, null);
+            if (engine.spi instanceof MessageDigest) {
+                result = (MessageDigest) engine.spi;
+                result.algorithm = algorithm;
+                result.provider = engine.provider;
+                return result;
+            } else {
+                result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
+                        engine.provider, algorithm);
+                return result;
+            }
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public static MessageDigest getInstance(String algorithm, String provider)
+            throws NoSuchAlgorithmException, NoSuchProviderException {
+        if ((provider == null) || (provider.length() == 0)) {
+            throw new IllegalArgumentException(
+                    "Provider is null or empty string");
+        }
+        Provider p = Security.getProvider(provider);
+        if (p == null) {
+            throw new NoSuchProviderException("Provider " + provider
+                    + " is not available");
+        }
+        return getInstance(algorithm, p);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public static MessageDigest getInstance(String algorithm, Provider provider)
+            throws NoSuchAlgorithmException {
+        if (provider == null) {
+            throw new IllegalArgumentException("Provider is null");
+        }
+        if (algorithm == null) {
+            throw new NullPointerException("Algorithm is null");
+        }
+        MessageDigest result;
+        synchronized (engine) {
+            engine.getInstance(algorithm, provider, null);
+            if (engine.spi instanceof MessageDigest) {
+                result = (MessageDigest) engine.spi;
+                result.algorithm = algorithm;
+                result.provider = provider;
+                return result;
+            } else {
+                result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
+                        provider, algorithm);
+                return result;
+            }
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public void reset() {
+        engineReset();
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public void update(byte arg0) {
+        engineUpdate(arg0);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public void update(byte[] input, int offset, int len) {
+        if (input == null || offset < 0 || len < 0 ||
+                offset + len > input.length) {
+            throw new IllegalArgumentException(
+                    "Incorrect offset/len parameters");
+        }
+        engineUpdate(input, offset, len);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public void update(byte[] input) {
+        if (input == null) {
+            throw new NullPointerException("Null input parameter");
+        }
+        engineUpdate(input, 0, input.length);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public byte[] digest() {
+        return engineDigest();
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public int digest(byte[] buf, int offset, int len) throws DigestException {
+        if (buf == null || offset < 0 || len < 0 ||
+                offset + len > buf.length) {
+            throw new IllegalArgumentException(
+                    "Incorrect offset/len parameters");
+        }
+        return engineDigest(buf, offset, len);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public byte[] digest(byte[] input) {
+        update(input);
+        return digest();
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public String toString() {
+        return "MESSAGE DIGEST " + algorithm;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public static boolean isEqual(byte[] digesta, byte[] digestb) {
+        if (digesta.length != digestb.length) {
+            return false;
+        }
+        for (int i = 0; i < digesta.length; i++) {
+            if (digesta[i] != digestb[i]) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final String getAlgorithm() {
+        return algorithm;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final Provider getProvider() {
+        return provider;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final int getDigestLength() {
+        int l = engineGetDigestLength();
+        if (l != 0) {
+            return l;
+        }
+        if (!(this instanceof Cloneable)) {
+            return 0;
+        }
+        try {
+            MessageDigest md = (MessageDigest) clone();
+            return md.digest().length;
+        } catch (CloneNotSupportedException e) {
+            return 0;
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public Object clone() throws CloneNotSupportedException {
+        if (this instanceof Cloneable) {
+            return super.clone();
+        } else {
+            throw new CloneNotSupportedException();
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    public final void update(ByteBuffer input) {
+        engineUpdate(input);
+    }
+
+    /**
+     * 
+     * The internal MessageDigest implementation
+     * 
+     */
+    private static class MessageDigestImpl extends MessageDigest {
+        
+        // MessageDigestSpi implementation
+        private MessageDigestSpi spiImpl;
+
+        // MessageDigestImpl ctor
+        private MessageDigestImpl(MessageDigestSpi messageDigestSpi,
+                Provider provider, String algorithm) {
+            super(algorithm);
+            super.provider = provider;
+            spiImpl = messageDigestSpi;
+        }
+
+        // engineReset() implementation
+        protected void engineReset() {
+            spiImpl.engineReset();
+        }
+
+        // engineDigest() implementation
+        protected byte[] engineDigest() {
+            return spiImpl.engineDigest();
+        }
+
+        // engineGetDigestLength() implementation
+        protected int engineGetDigestLength() {
+            return spiImpl.engineGetDigestLength();
+        }
+
+        // engineUpdate() implementation
+        protected void engineUpdate(byte arg0) {
+            spiImpl.engineUpdate(arg0);
+        }
+
+        // engineUpdate() implementation
+        protected void engineUpdate(byte[] arg0, int arg1, int arg2) {
+            spiImpl.engineUpdate(arg0, arg1, arg2);
+        }
+
+        // Returns a clone if the spiImpl is cloneable
+        public Object clone() throws CloneNotSupportedException {
+            if (spiImpl instanceof Cloneable) {
+                MessageDigestSpi spi = (MessageDigestSpi) spiImpl.clone();
+                return new MessageDigestImpl(spi, getProvider(), getAlgorithm());
+            } else {
+                throw new CloneNotSupportedException();
+            }
+        }
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/SecureRandom.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/SecureRandom.java?rev=390246&r1=390245&r2=390246&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/SecureRandom.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/java/security/SecureRandom.java Thu Mar 30 13:34:23 2006
@@ -1,354 +1,354 @@
-/*
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed 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 Boris V. Kuznetsov
-* @version $Revision$
-*/
-
-package java.security;
-
-import java.util.Iterator;
-import java.util.Random;
-import java.util.Set;
-
-import org.apache.harmony.security.fortress.Engine;
-import org.apache.harmony.security.fortress.Services;
-
-
-/**
- * @com.intel.drl.spec_ref
- * 
- */
-
-public class SecureRandom extends Random {
-    
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    private static final long serialVersionUID = 4940670005562187L;
-    
-    // The service name.
-    private static final transient String SERVICE = "SecureRandom";
-    
-    // Used to accesess common engine functionality
-    private static transient Engine engine = new Engine(SERVICE);
-    
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    private Provider provider;
-    
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    private SecureRandomSpi secureRandomSpi; 
-    
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    private String algorithm;
-    
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    private byte[] state;
-    
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    private byte[] randomBytes;
-    
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    private int randomBytesUsed;
-    
-    /**
-     * @com.intel.drl.spec_ref
-     */
-    private long counter;
-    
-    // Internal SecureRandom used for getSeed(int)
-    private static transient SecureRandom internalSecureRandom;
-    
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public SecureRandom() {
-        super(0);
-        Provider.Service service = findService();
-        if (service == null) {
-            this.provider = null;
-            this.secureRandomSpi = new DummySecureRandom();
-            this.algorithm = "java.util.Random";
-        } else {
-            try {
-                this.provider = service.getProvider();
-                this.secureRandomSpi = (SecureRandomSpi)service.newInstance(null);
-                this.algorithm = service.getAlgorithm();
-            } catch (Exception e) {
-                throw new RuntimeException(e);
-            }            
-        }    
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public SecureRandom(byte[] seed) {
-        this();
-        setSeed(seed);
-    }
-    
-    //Find SecureRandom service.
-    private Provider.Service findService() {
-        Set s;
-        Provider.Service service;
-        for (Iterator it1 = Services.getProvidersList().iterator(); it1.hasNext();) {
-            service = ((Provider)it1.next()).getService("SecureRandom");
-            if (service != null) {
-                return service;
-            }
-        }
-        return null;
-    }
-    
-    // Returns secureRandomSpi
-    private SecureRandomSpi getSpi() {
-        return secureRandomSpi;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    protected SecureRandom(SecureRandomSpi secureRandomSpi,
-                           Provider provider) {
-        this(secureRandomSpi, provider, null);
-    }
-    
-    // Constructor
-    private SecureRandom(SecureRandomSpi secureRandomSpi,
-                         Provider provider,
-                         String algorithm) {
-        super(0);
-        this.provider = provider;
-        this. algorithm = algorithm;
-        this.secureRandomSpi = secureRandomSpi;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public static SecureRandom getInstance(String algorithm)
-                                throws NoSuchAlgorithmException {
-        if (algorithm == null) {
-            throw new NullPointerException("Algorithm is null");
-        }
-        synchronized (engine) {
-            engine.getInstance(algorithm, null);
-            return new SecureRandom((SecureRandomSpi)engine.spi, engine.provider, algorithm);
-        }
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public static SecureRandom getInstance(String algorithm, String provider)
-                                throws NoSuchAlgorithmException, NoSuchProviderException {
-        if ((provider == null) || (provider.length() == 0)) {
-            throw new IllegalArgumentException(
-                    "Provider is null or empty string");
-        }
-        Provider p = Security.getProvider(provider);
-        if (p == null) {
-            throw new NoSuchProviderException("Provider "+ provider + " is not available"); 
-        }
-        return getInstance(algorithm, p);    
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public static SecureRandom getInstance(String algorithm, Provider provider)
-                                throws NoSuchAlgorithmException {
-        if (provider == null) {
-            throw new IllegalArgumentException("Provider is null");
-        }
-        if (algorithm == null) {
-            throw new NullPointerException("Algorithm is null");
-        }
-        synchronized (engine) {
-            engine.getInstance(algorithm, provider, null);
-            return new SecureRandom((SecureRandomSpi)engine.spi, provider, algorithm);
-        }
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public final Provider getProvider() {
-        return provider;
-    }
-    
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public String getAlgorithm() {
-        return algorithm;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public synchronized void setSeed(byte[] seed) {
-        secureRandomSpi.engineSetSeed(seed);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public void setSeed(long seed) {
-        if (seed == 0) {    // skip call from Random
-            return;
-        }
-        byte[] byteSeed = {
-                (byte)((seed >> 56) & 0xFF),
-                (byte)((seed >> 48) & 0xFF),
-                (byte)((seed >> 40) & 0xFF),
-                (byte)((seed >> 32) & 0xFF),
-                (byte)((seed >> 24) & 0xFF),
-                (byte)((seed >> 16) & 0xFF),
-                (byte)((seed >> 8) & 0xFF),
-                (byte)((seed) & 0xFF)
-        };
-        setSeed(byteSeed);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public synchronized void nextBytes(byte[] bytes) {
-        secureRandomSpi.engineNextBytes(bytes);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    protected final int next(int numBits) {
-        if (numBits < 0) {
-            numBits = 0;
-        } else {
-            if (numBits > 32) {
-                numBits = 32;
-            }
-        }
-        int bytes = (numBits+7)/8;
-        byte[] next = new byte[bytes];
-        int ret = 0;
-         
-        nextBytes(next);
-        for (int i = 0; i < bytes; i++) {
-            ret = (next[i] & 0xFF) | (ret << 8);
-        }    
-        ret = ret >> (bytes*8 - numBits);
-        return ret;
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public static byte[] getSeed(int numBytes) {
-        if (internalSecureRandom == null) {
-            internalSecureRandom = new SecureRandom();
-        }
-        return internalSecureRandom.generateSeed(numBytes);
-    }
-
-    /**
-     * @com.intel.drl.spec_ref
-     * 
-     */
-    public byte[] generateSeed(int numBytes) {
-        return secureRandomSpi.engineGenerateSeed(numBytes);
-    }
-    
-    /**
-     * 
-     * Dummy SecureRandom based on Random
-     * 
-     */
-    private class DummySecureRandom extends SecureRandomSpi {
-        
-        Random rand;
-        
-        // Creates SecureRandomSpi object
-        public DummySecureRandom() {
-            rand = new Random();
-        }
-        
-        // Creates SecureRandomSpi object
-        public DummySecureRandom(long seed) {
-            rand = new Random(seed);
-        }
-
-        // Sets the seed of this random number generator 
-        public void engineSetSeed(byte[] seed) {
-            long l = 0;
-            int length = 8;
-            
-            if (seed.length < 8) {
-                length = seed.length;
-            }
-            for (int i = 0; i < length; i++) {
-                l = (l << 8) | (seed[i] & 0xFF);
-            }        
-            rand.setSeed(l);
-        }
-        
-        // Generates random bytes and places them into a byte array
-        public void engineNextBytes(byte[] bytes) {
-            rand.nextBytes(bytes);
-        }
-        
-        // Generates random bytes
-        //
-        // @param numBytes
-        // @return An array of random bytes
-        public byte[] engineGenerateSeed(int numBytes) {
-            if (numBytes < 1) {
-                return null;
-            }
-            byte[] next = new byte[numBytes]; 
-            nextBytes(next);
-            return next;
-        }
-    }
-}
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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 Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package java.security;
+
+import java.util.Iterator;
+import java.util.Random;
+import java.util.Set;
+
+import org.apache.harmony.security.fortress.Engine;
+import org.apache.harmony.security.fortress.Services;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ * 
+ */
+
+public class SecureRandom extends Random {
+    
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    private static final long serialVersionUID = 4940670005562187L;
+    
+    // The service name.
+    private static final transient String SERVICE = "SecureRandom";
+    
+    // Used to access common engine functionality
+    private static transient Engine engine = new Engine(SERVICE);
+    
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    private Provider provider;
+    
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    private SecureRandomSpi secureRandomSpi; 
+    
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    private String algorithm;
+    
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    private byte[] state;
+    
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    private byte[] randomBytes;
+    
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    private int randomBytesUsed;
+    
+    /**
+     * @com.intel.drl.spec_ref
+     */
+    private long counter;
+    
+    // Internal SecureRandom used for getSeed(int)
+    private static transient SecureRandom internalSecureRandom;
+    
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public SecureRandom() {
+        super(0);
+        Provider.Service service = findService();
+        if (service == null) {
+            this.provider = null;
+            this.secureRandomSpi = new DummySecureRandom();
+            this.algorithm = "java.util.Random";
+        } else {
+            try {
+                this.provider = service.getProvider();
+                this.secureRandomSpi = (SecureRandomSpi)service.newInstance(null);
+                this.algorithm = service.getAlgorithm();
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }            
+        }    
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public SecureRandom(byte[] seed) {
+        this();
+        setSeed(seed);
+    }
+    
+    //Find SecureRandom service.
+    private Provider.Service findService() {
+        Set s;
+        Provider.Service service;
+        for (Iterator it1 = Services.getProvidersList().iterator(); it1.hasNext();) {
+            service = ((Provider)it1.next()).getService("SecureRandom");
+            if (service != null) {
+                return service;
+            }
+        }
+        return null;
+    }
+    
+    // Returns secureRandomSpi
+    private SecureRandomSpi getSpi() {
+        return secureRandomSpi;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    protected SecureRandom(SecureRandomSpi secureRandomSpi,
+                           Provider provider) {
+        this(secureRandomSpi, provider, null);
+    }
+    
+    // Constructor
+    private SecureRandom(SecureRandomSpi secureRandomSpi,
+                         Provider provider,
+                         String algorithm) {
+        super(0);
+        this.provider = provider;
+        this. algorithm = algorithm;
+        this.secureRandomSpi = secureRandomSpi;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public static SecureRandom getInstance(String algorithm)
+                                throws NoSuchAlgorithmException {
+        if (algorithm == null) {
+            throw new NullPointerException("Algorithm is null");
+        }
+        synchronized (engine) {
+            engine.getInstance(algorithm, null);
+            return new SecureRandom((SecureRandomSpi)engine.spi, engine.provider, algorithm);
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public static SecureRandom getInstance(String algorithm, String provider)
+                                throws NoSuchAlgorithmException, NoSuchProviderException {
+        if ((provider == null) || (provider.length() == 0)) {
+            throw new IllegalArgumentException(
+                    "Provider is null or empty string");
+        }
+        Provider p = Security.getProvider(provider);
+        if (p == null) {
+            throw new NoSuchProviderException("Provider "+ provider + " is not available"); 
+        }
+        return getInstance(algorithm, p);    
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public static SecureRandom getInstance(String algorithm, Provider provider)
+                                throws NoSuchAlgorithmException {
+        if (provider == null) {
+            throw new IllegalArgumentException("Provider is null");
+        }
+        if (algorithm == null) {
+            throw new NullPointerException("Algorithm is null");
+        }
+        synchronized (engine) {
+            engine.getInstance(algorithm, provider, null);
+            return new SecureRandom((SecureRandomSpi)engine.spi, provider, algorithm);
+        }
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public final Provider getProvider() {
+        return provider;
+    }
+    
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public String getAlgorithm() {
+        return algorithm;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public synchronized void setSeed(byte[] seed) {
+        secureRandomSpi.engineSetSeed(seed);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public void setSeed(long seed) {
+        if (seed == 0) {    // skip call from Random
+            return;
+        }
+        byte[] byteSeed = {
+                (byte)((seed >> 56) & 0xFF),
+                (byte)((seed >> 48) & 0xFF),
+                (byte)((seed >> 40) & 0xFF),
+                (byte)((seed >> 32) & 0xFF),
+                (byte)((seed >> 24) & 0xFF),
+                (byte)((seed >> 16) & 0xFF),
+                (byte)((seed >> 8) & 0xFF),
+                (byte)((seed) & 0xFF)
+        };
+        setSeed(byteSeed);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public synchronized void nextBytes(byte[] bytes) {
+        secureRandomSpi.engineNextBytes(bytes);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    protected final int next(int numBits) {
+        if (numBits < 0) {
+            numBits = 0;
+        } else {
+            if (numBits > 32) {
+                numBits = 32;
+            }
+        }
+        int bytes = (numBits+7)/8;
+        byte[] next = new byte[bytes];
+        int ret = 0;
+         
+        nextBytes(next);
+        for (int i = 0; i < bytes; i++) {
+            ret = (next[i] & 0xFF) | (ret << 8);
+        }    
+        ret = ret >> (bytes*8 - numBits);
+        return ret;
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public static byte[] getSeed(int numBytes) {
+        if (internalSecureRandom == null) {
+            internalSecureRandom = new SecureRandom();
+        }
+        return internalSecureRandom.generateSeed(numBytes);
+    }
+
+    /**
+     * @com.intel.drl.spec_ref
+     * 
+     */
+    public byte[] generateSeed(int numBytes) {
+        return secureRandomSpi.engineGenerateSeed(numBytes);
+    }
+    
+    /**
+     * 
+     * Dummy SecureRandom based on Random
+     * 
+     */
+    private class DummySecureRandom extends SecureRandomSpi {
+        
+        Random rand;
+        
+        // Creates SecureRandomSpi object
+        public DummySecureRandom() {
+            rand = new Random();
+        }
+        
+        // Creates SecureRandomSpi object
+        public DummySecureRandom(long seed) {
+            rand = new Random(seed);
+        }
+
+        // Sets the seed of this random number generator 
+        public void engineSetSeed(byte[] seed) {
+            long l = 0;
+            int length = 8;
+            
+            if (seed.length < 8) {
+                length = seed.length;
+            }
+            for (int i = 0; i < length; i++) {
+                l = (l << 8) | (seed[i] & 0xFF);
+            }        
+            rand.setSeed(l);
+        }
+        
+        // Generates random bytes and places them into a byte array
+        public void engineNextBytes(byte[] bytes) {
+            rand.nextBytes(bytes);
+        }
+        
+        // Generates random bytes
+        //
+        // @param numBytes
+        // @return An array of random bytes
+        public byte[] engineGenerateSeed(int numBytes) {
+            if (numBytes < 1) {
+                return null;
+            }
+            byte[] next = new byte[numBytes]; 
+            nextBytes(next);
+            return next;
+        }
+    }
+}



Mime
View raw message