4589N/A * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * RSA signature implementation. Supports RSA signing using PKCS#1 v1.5 padding. 0N/A * Objects should be instantiated by calling Signature.getInstance() using the 0N/A * following algorithm names: 4136N/A * NOTE: RSA keys must be at least 512 bits long. 4136N/A * NOTE: NONEwithRSA must be supplied with a pre-computed message digest. 4136N/A * Only the following digest algorithms are supported: MD5, SHA-1, 4136N/A * SHA-256, SHA-384, SHA-512 and a special-purpose digest algorithm 4136N/A * which is a concatenation of SHA-1 and MD5 digests. 0N/A * @author Stanley Man-Kit Ho 0N/A // message digest implementation we use 4127N/A // flag indicating whether the digest has been reset 0N/A // the verification key 4136N/A * Constructs a new RSASignature. Used by Raw subclass. 4127N/A * Constructs a new RSASignature. Used by subclasses. 4127N/A // Get the digest's canonical name 4136N/A // Nested class for NONEwithRSA signatures 4136N/A // the longest supported digest is 512 bits (SHA-512) 4136N/A // Stores the precomputed message digest value. 4136N/A // Stores the precomputed message digest value. 4136N/A // Stores the precomputed message digest value. 4136N/A // Returns the precomputed message digest value. 4136N/A // Determine the digest algorithm from the digest length 4136N/A "Message digest length is not supported");
4127N/A // initialize for signing. See JCA doc 0N/A // This signature accepts only RSAPublicKey 0N/A // convert key to MSCAPI format 1111N/A // Check against the local and global values to make sure 1111N/A // the sizes are ok. Round up to the nearest byte. 0N/A // Adjust key length due to sign bit 4127N/A // initialize for signing. See JCA doc 0N/A // This signature accepts only RSAPrivateKey 1111N/A // Check against the local and global values to make sure 1111N/A // the sizes are ok. Round up to nearest byte. 4127N/A * Resets the message digest if needed. 0N/A * Updates the data to be signed or verified 0N/A * using the specified byte. 0N/A * @param b the byte to use for the update. 0N/A * @exception SignatureException if the engine is not initialized 0N/A * Updates the data to be signed or verified, using the 0N/A * specified array of bytes, starting at the specified offset. 0N/A * @param b the array of bytes 0N/A * @param off the offset to start from in the array of bytes 0N/A * @param len the number of bytes to use, starting at offset 0N/A * @exception SignatureException if the engine is not initialized 0N/A * Updates the data to be signed or verified, using the 0N/A * specified ByteBuffer. 0N/A * @param input the ByteBuffer 0N/A * Returns the signature bytes of all the data 0N/A * The format of the signature depends on the underlying 0N/A * @return the signature bytes of the signing operation's result. 0N/A * @exception SignatureException if the engine is not 0N/A * initialized properly or if this signature algorithm is unable to 0N/A * process the input data provided. 4136N/A // Omit the hash OID when generating a Raw signature 0N/A // Sign hash using MS Crypto APIs 0N/A // Convert signature array from little endian to big endian 0N/A * Convert array from big endian to little endian, or vice versa. 0N/A // make it big endian 0N/A * Sign hash using Microsoft Crypto API with HCRYPTKEY. 0N/A * The returned data is in little-endian. 0N/A * Verify a signed hash using Microsoft Crypto API with HCRYPTKEY. 0N/A * Verifies the passed-in signature. 0N/A * @param sigBytes the signature bytes to be verified. 0N/A * @return true if the signature was verified, false if not. 0N/A * @exception SignatureException if the engine is not 0N/A * initialized properly, the passed-in signature is improperly 0N/A * encoded or of the wrong type, if this signature algorithm is unable to 0N/A * process the input data provided, etc. 0N/A * Sets the specified algorithm parameter to the specified 0N/A * value. This method supplies a general-purpose mechanism through 0N/A * which it is possible to set the various parameters of this object. 0N/A * A parameter may be any settable parameter for the algorithm, such as 0N/A * a parameter size, or a source of random bits for signature generation 0N/A * (if appropriate), or an indication of whether or not to perform 0N/A * a specific but optional computation. A uniform algorithm-specific 0N/A * naming scheme for each parameter is desirable but left unspecified 0N/A * @param param the string identifier of the parameter. 0N/A * @param value the parameter value. 0N/A * @exception InvalidParameterException if <code>param</code> is an 0N/A * invalid parameter for this signature algorithm engine, 0N/A * the parameter is already set 0N/A * and cannot be set again, a security exception occurs, and so on. 0N/A * @deprecated Replaced by {@link 0N/A * #engineSetParameter(java.security.spec.AlgorithmParameterSpec) 0N/A * engineSetParameter}. 0N/A * Gets the value of the specified algorithm parameter. 0N/A * This method supplies a general-purpose mechanism through which it 0N/A * is possible to get the various parameters of this object. A parameter 0N/A * may be any settable parameter for the algorithm, such as a parameter 0N/A * size, or a source of random bits for signature generation (if 0N/A * appropriate), or an indication of whether or not to perform a 0N/A * specific but optional computation. A uniform algorithm-specific 0N/A * naming scheme for each parameter is desirable but left unspecified 0N/A * @param param the string name of the parameter. 0N/A * @return the object that represents the parameter value, or null if 0N/A * @exception InvalidParameterException if <code>param</code> is an 0N/A * invalid parameter for this engine, or another exception occurs while 0N/A * trying to get this parameter. 0N/A * Generates a public-key BLOB from a key's components. 0N/A * Imports a public-key BLOB.