Package net.schmizz.sshj.signature
Class AbstractSignature
java.lang.Object
net.schmizz.sshj.signature.AbstractSignature
- All Implemented Interfaces:
Signature
- Direct Known Subclasses:
AbstractSignatureDSA
,SignatureEdDSA
,SignatureRSA
An abstract class for
Signature
that implements common functionality.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractSignature
(String algorithm, String signatureName) protected
AbstractSignature
(Signature signatureEngine, String signatureName) -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]
extractSig
(byte[] sig, String expectedKeyAlgorithm) Check whether the signature is generated using the expected algorithm, and if so, return the signature blobvoid
initSign
(PrivateKey privateKey) Initialize this signature with the given private key for signing.void
initVerify
(PublicKey publicKey) Initialize this signature with the given public key for signature verification.byte[]
sign()
Compute the signature.void
update
(byte[] foo) Convenience method, same as callingSignature.update(byte[], int, int)
with offset as0
andH.length
.void
update
(byte[] foo, int off, int len) Update the computed signature with the given data.
-
Field Details
-
signature
-
signatureName
-
-
Constructor Details
-
AbstractSignature
-
AbstractSignature
-
-
Method Details
-
getSignatureName
- Specified by:
getSignatureName
in interfaceSignature
-
initVerify
Description copied from interface:Signature
Initialize this signature with the given public key for signature verification. Note that subsequent calls to eitherSignature.initVerify(PublicKey)
orSignature.initSign(PrivateKey)
will overwrite prior initialization.- Specified by:
initVerify
in interfaceSignature
- Parameters:
publicKey
- the public key to use for signature verification
-
initSign
Description copied from interface:Signature
Initialize this signature with the given private key for signing. Note that subsequent calls to eitherSignature.initVerify(PublicKey)
orSignature.initSign(PrivateKey)
will overwrite prior initialization. -
update
public void update(byte[] foo) Description copied from interface:Signature
Convenience method, same as callingSignature.update(byte[], int, int)
with offset as0
andH.length
. -
update
public void update(byte[] foo, int off, int len) Description copied from interface:Signature
Update the computed signature with the given data. -
sign
public byte[] sign()Description copied from interface:Signature
Compute the signature. -
extractSig
Check whether the signature is generated using the expected algorithm, and if so, return the signature blob- Parameters:
sig
- The full signatureexpectedKeyAlgorithm
- The expected key algorithm- Returns:
- The blob part of the signature
-