73 /**
74 * Initializes this signature object with the specified
75 * public key for verification operations.
76 *
77 * @param publicKey the public key of the identity whose signature is
78 * going to be verified.
79 * @param params the parameters for generating this signature
80 *
81 * @throws InvalidKeyException if the key is improperly
82 * encoded, does not work with the given parameters, and so on.
83 * @throws InvalidAlgorithmParameterException if the given parameters
84 * is invalid.
85 */
86 void engineInitVerify(PublicKey publicKey,
87 AlgorithmParameterSpec params)
88 throws InvalidKeyException, InvalidAlgorithmParameterException {
89 if (params != null) {
90 try {
91 engineSetParameter(params);
92 } catch (UnsupportedOperationException usoe) {
93 // error out if not overrridden
94 throw new InvalidAlgorithmParameterException(usoe);
95 }
96 }
97 engineInitVerify(publicKey);
98 }
99
100 /**
101 * Initializes this signature object with the specified
102 * private key for signing operations.
103 *
104 * @param privateKey the private key of the identity whose signature
105 * will be generated.
106 *
107 * @throws InvalidKeyException if the key is improperly
108 * encoded, parameters are missing, and so on.
109 */
110 protected abstract void engineInitSign(PrivateKey privateKey)
111 throws InvalidKeyException;
112
113 /**
138 * <p>This concrete method has been added to this previously-defined
139 * abstract class. (For backwards compatibility, it cannot be abstract.)
140 *
141 * @param privateKey the private key of the identity whose signature
142 * will be generated.
143 * @param params the parameters for generating this signature
144 * @param random the source of randomness
145 *
146 * @throws InvalidKeyException if the key is improperly
147 * encoded, parameters are missing, and so on.
148 * @throws InvalidAlgorithmParameterException if the parameters is
149 * invalid.
150 */
151 void engineInitSign(PrivateKey privateKey,
152 AlgorithmParameterSpec params, SecureRandom random)
153 throws InvalidKeyException, InvalidAlgorithmParameterException {
154 if (params != null) {
155 try {
156 engineSetParameter(params);
157 } catch (UnsupportedOperationException usoe) {
158 // error out if not overrridden
159 throw new InvalidAlgorithmParameterException(usoe);
160 }
161 }
162 engineInitSign(privateKey, random);
163 }
164
165 /**
166 * Updates the data to be signed or verified
167 * using the specified byte.
168 *
169 * @param b the byte to use for the update.
170 *
171 * @throws SignatureException if the engine is not initialized
172 * properly.
173 */
174 protected abstract void engineUpdate(byte b) throws SignatureException;
175
176 /**
177 * Updates the data to be signed or verified, using the
178 * specified array of bytes, starting at the specified offset.
|
73 /**
74 * Initializes this signature object with the specified
75 * public key for verification operations.
76 *
77 * @param publicKey the public key of the identity whose signature is
78 * going to be verified.
79 * @param params the parameters for generating this signature
80 *
81 * @throws InvalidKeyException if the key is improperly
82 * encoded, does not work with the given parameters, and so on.
83 * @throws InvalidAlgorithmParameterException if the given parameters
84 * is invalid.
85 */
86 void engineInitVerify(PublicKey publicKey,
87 AlgorithmParameterSpec params)
88 throws InvalidKeyException, InvalidAlgorithmParameterException {
89 if (params != null) {
90 try {
91 engineSetParameter(params);
92 } catch (UnsupportedOperationException usoe) {
93 // error out if not overridden
94 throw new InvalidAlgorithmParameterException(usoe);
95 }
96 }
97 engineInitVerify(publicKey);
98 }
99
100 /**
101 * Initializes this signature object with the specified
102 * private key for signing operations.
103 *
104 * @param privateKey the private key of the identity whose signature
105 * will be generated.
106 *
107 * @throws InvalidKeyException if the key is improperly
108 * encoded, parameters are missing, and so on.
109 */
110 protected abstract void engineInitSign(PrivateKey privateKey)
111 throws InvalidKeyException;
112
113 /**
138 * <p>This concrete method has been added to this previously-defined
139 * abstract class. (For backwards compatibility, it cannot be abstract.)
140 *
141 * @param privateKey the private key of the identity whose signature
142 * will be generated.
143 * @param params the parameters for generating this signature
144 * @param random the source of randomness
145 *
146 * @throws InvalidKeyException if the key is improperly
147 * encoded, parameters are missing, and so on.
148 * @throws InvalidAlgorithmParameterException if the parameters is
149 * invalid.
150 */
151 void engineInitSign(PrivateKey privateKey,
152 AlgorithmParameterSpec params, SecureRandom random)
153 throws InvalidKeyException, InvalidAlgorithmParameterException {
154 if (params != null) {
155 try {
156 engineSetParameter(params);
157 } catch (UnsupportedOperationException usoe) {
158 // error out if not overridden
159 throw new InvalidAlgorithmParameterException(usoe);
160 }
161 }
162 engineInitSign(privateKey, random);
163 }
164
165 /**
166 * Updates the data to be signed or verified
167 * using the specified byte.
168 *
169 * @param b the byte to use for the update.
170 *
171 * @throws SignatureException if the engine is not initialized
172 * properly.
173 */
174 protected abstract void engineUpdate(byte b) throws SignatureException;
175
176 /**
177 * Updates the data to be signed or verified, using the
178 * specified array of bytes, starting at the specified offset.
|