Package com.itextpdf.signatures
Class PrivateKeySignature
java.lang.Object
com.itextpdf.signatures.PrivateKeySignature
- All Implemented Interfaces:
-
IExternalSignature
Implementation of the
IExternalSignature
interface that can be used when you have a PrivateKey
object.
- Author:
- Paulo Soares
-
Constructor Summary
ConstructorDescriptionPrivateKeySignature
(PrivateKey pk, String hashAlgorithm, String provider) Creates aPrivateKeySignature
instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns the encryption algorithm used for signing.Returns the hash algorithm.byte[]
sign
(byte[] message) Signs the given message using the encryption algorithm in combination with the hash algorithm.
-
Constructor Details
-
PrivateKeySignature
Creates aPrivateKeySignature
instance.- Parameters:
-
pk
- APrivateKey
object. -
hashAlgorithm
- A hash algorithm (e.g. "SHA-1", "SHA-256",...). -
provider
- A security provider (e.g. "BC").
-
-
Method Details
-
getHashAlgorithm
Returns the hash algorithm.- Specified by:
-
getHashAlgorithm
in interfaceIExternalSignature
- Returns:
- The hash algorithm (e.g. "SHA-1", "SHA-256,...").
-
getEncryptionAlgorithm
Returns the encryption algorithm used for signing.- Specified by:
-
getEncryptionAlgorithm
in interfaceIExternalSignature
- Returns:
- The encryption algorithm ("RSA" or "DSA").
-
sign
Signs the given message using the encryption algorithm in combination with the hash algorithm.- Specified by:
-
sign
in interfaceIExternalSignature
- Parameters:
-
message
- The message you want to be hashed and signed. - Returns:
- A signed message digest.
- Throws:
-
GeneralSecurityException
- when requested cryptographic algorithm or security provider is not available
-