Package net.schmizz.sshj.signature
Class AbstractSignature
- java.lang.Object
-
- net.schmizz.sshj.signature.AbstractSignature
-
- All Implemented Interfaces:
Signature
- Direct Known Subclasses:
SignatureDSA,SignatureECDSA,SignatureEdDSA,SignatureRSA
public abstract class AbstractSignature extends java.lang.Object implements Signature
An abstract class forSignaturethat implements common functionality.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.security.Signaturesignature
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSignature(java.lang.String algorithm)protectedAbstractSignature(java.security.Signature signatureEngine)
-
Method Summary
Modifier and Type Method Description protected byte[]extractSig(byte[] sig, java.lang.String expectedKeyAlgorithm)Check whether the signature is generated using the expected algorithm, and if so, return the signature blobvoidinitSign(java.security.PrivateKey privateKey)Initialize this signature with the given private key for signing.voidinitVerify(java.security.PublicKey publicKey)Initialize this signature with the given public key for signature verification.byte[]sign()Compute the signature.voidupdate(byte[] foo)Convenience method, same as callingSignature.update(byte[], int, int)with offset as0andH.length.voidupdate(byte[] foo, int off, int len)Update the computed signature with the given data.
-
-
-
Method Detail
-
initVerify
public void initVerify(java.security.PublicKey publicKey)
Description copied from interface:SignatureInitialize 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:
initVerifyin interfaceSignature- Parameters:
publicKey- the public key to use for signature verification
-
initSign
public void initSign(java.security.PrivateKey privateKey)
Description copied from interface:SignatureInitialize 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:SignatureConvenience method, same as callingSignature.update(byte[], int, int)with offset as0andH.length.
-
update
public void update(byte[] foo, int off, int len)Description copied from interface:SignatureUpdate the computed signature with the given data.
-
sign
public byte[] sign()
Description copied from interface:SignatureCompute the signature.
-
extractSig
protected byte[] extractSig(byte[] sig, java.lang.String expectedKeyAlgorithm)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
-
-