< prev index next >

src/java.base/share/classes/java/security/SignatureSpi.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -70,37 +70,10 @@
     protected abstract void engineInitVerify(PublicKey publicKey)
         throws InvalidKeyException;
 
     /**
      * Initializes this signature object with the specified
-     * public key for verification operations.
-     *
-     * @param publicKey the public key of the identity whose signature is
-     * going to be verified.
-     * @param params the parameters for generating this signature
-     *
-     * @exception InvalidKeyException if the key is improperly
-     * encoded, does not work with the given parameters, and so on.
-     * @exception InvalidAlgorithmParameterException if the given parameters
-     * is invalid.
-     */
-    void engineInitVerify(PublicKey publicKey,
-            AlgorithmParameterSpec params)
-            throws InvalidKeyException, InvalidAlgorithmParameterException {
-        if (params != null) {
-            try {
-                engineSetParameter(params);
-            } catch (UnsupportedOperationException usoe) {
-                // error out if not overrridden
-                throw new InvalidAlgorithmParameterException(usoe);
-            }
-        }
-        engineInitVerify(publicKey);
-    }
-
-    /**
-     * Initializes this signature object with the specified
      * private key for signing operations.
      *
      * @param privateKey the private key of the identity whose signature
      * will be generated.
      *

@@ -123,45 +96,14 @@
      *
      * @exception InvalidKeyException if the key is improperly
      * encoded, parameters are missing, and so on.
      */
     protected void engineInitSign(PrivateKey privateKey,
-            SecureRandom random)
-            throws InvalidKeyException {
-        this.appRandom = random;
-        engineInitSign(privateKey);
-    }
-
-    /**
-     * Initializes this signature object with the specified
-     * private key and source of randomness for signing operations.
-     *
-     * <p>This concrete method has been added to this previously-defined
-     * abstract class. (For backwards compatibility, it cannot be abstract.)
-     *
-     * @param privateKey the private key of the identity whose signature
-     * will be generated.
-     * @param params the parameters for generating this signature
-     * @param random the source of randomness
-     *
-     * @exception InvalidKeyException if the key is improperly
-     * encoded, parameters are missing, and so on.
-     * @exception InvalidAlgorithmParameterException if the parameters is
-     * invalid.
-     */
-    void engineInitSign(PrivateKey privateKey,
-            AlgorithmParameterSpec params, SecureRandom random)
-            throws InvalidKeyException, InvalidAlgorithmParameterException {
-        if (params != null) {
-            try {
-                engineSetParameter(params);
-            } catch (UnsupportedOperationException usoe) {
-                // error out if not overrridden
-                throw new InvalidAlgorithmParameterException(usoe);
-            }
-        }
-        engineInitSign(privateKey, random);
+                                  SecureRandom random)
+        throws InvalidKeyException {
+            this.appRandom = random;
+            engineInitSign(privateKey);
     }
 
     /**
      * Updates the data to be signed or verified
      * using the specified byte.

@@ -183,11 +125,11 @@
      *
      * @exception SignatureException if the engine is not initialized
      * properly
      */
     protected abstract void engineUpdate(byte[] b, int off, int len)
-            throws SignatureException;
+        throws SignatureException;
 
     /**
      * Updates the data to be signed or verified using the specified
      * ByteBuffer. Processes the {@code data.remaining()} bytes
      * starting at {@code data.position()}.

@@ -279,11 +221,11 @@
      * than the actual signature length.
      *
      * @since 1.2
      */
     protected int engineSign(byte[] outbuf, int offset, int len)
-             throws SignatureException {
+                        throws SignatureException {
         byte[] sig = engineSign();
         if (len < sig.length) {
                 throw new SignatureException
                     ("partial signatures not returned");
         }

@@ -307,11 +249,11 @@
      * initialized properly, the passed-in signature is improperly
      * encoded or of the wrong type, if this signature algorithm is unable to
      * process the input data provided, etc.
      */
     protected abstract boolean engineVerify(byte[] sigBytes)
-            throws SignatureException;
+        throws SignatureException;
 
     /**
      * Verifies the passed-in signature in the specified array
      * of bytes, starting at the specified offset.
      *

@@ -329,11 +271,11 @@
      * encoded or of the wrong type, if this signature algorithm is unable to
      * process the input data provided, etc.
      * @since 1.4
      */
     protected boolean engineVerify(byte[] sigBytes, int offset, int length)
-            throws SignatureException {
+        throws SignatureException {
         byte[] sigBytesCopy = new byte[length];
         System.arraycopy(sigBytes, offset, sigBytesCopy, 0, length);
         return engineVerify(sigBytesCopy);
     }
 

@@ -361,11 +303,11 @@
      * #engineSetParameter(java.security.spec.AlgorithmParameterSpec)
      * engineSetParameter}.
      */
     @Deprecated
     protected abstract void engineSetParameter(String param, Object value)
-            throws InvalidParameterException;
+        throws InvalidParameterException;
 
     /**
      * <p>This method is overridden by providers to initialize
      * this signature engine with the specified parameter set.
      *

@@ -377,12 +319,12 @@
      * @exception InvalidAlgorithmParameterException if this method is
      * overridden by a provider and the given parameters
      * are inappropriate for this signature engine
      */
     protected void engineSetParameter(AlgorithmParameterSpec params)
-            throws InvalidAlgorithmParameterException {
-        throw new UnsupportedOperationException();
+        throws InvalidAlgorithmParameterException {
+            throw new UnsupportedOperationException();
     }
 
     /**
      * <p>This method is overridden by providers to return the parameters
      * used with this signature engine.
< prev index next >