Package org.apache.sshd.common.signature
Class AbstractSecurityKeySignature
- java.lang.Object
-
- org.apache.sshd.common.signature.AbstractSecurityKeySignature
-
- All Implemented Interfaces:
AlgorithmNameProvider,Signature
- Direct Known Subclasses:
SignatureSkECDSA,SignatureSkED25519
public abstract class AbstractSecurityKeySignature extends java.lang.Object implements Signature
-
-
Field Summary
Fields Modifier and Type Field Description private java.security.MessageDigestchallengeDigestprivate static intFLAG_USER_PRESENCEprivate java.lang.StringkeyTypeprivate SecurityKeyPublicKey<?>publicKey
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSecurityKeySignature(java.lang.String keyType)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract SignaturegetDelegateSignature()protected abstract java.lang.StringgetSignatureKeyType()voidinitSigner(SessionContext session, java.security.PrivateKey key)voidinitVerifier(SessionContext session, java.security.PublicKey key)byte[]sign(SessionContext session)Compute the signaturevoidupdate(SessionContext session, byte[] hash, int off, int len)Update the computed signature with the given databooleanverify(SessionContext session, byte[] sig)Verify against the given signature-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.AlgorithmNameProvider
getAlgorithm
-
Methods inherited from interface org.apache.sshd.common.signature.Signature
getSshAlgorithmName, update
-
-
-
-
Field Detail
-
FLAG_USER_PRESENCE
private static final int FLAG_USER_PRESENCE
- See Also:
- Constant Field Values
-
keyType
private final java.lang.String keyType
-
publicKey
private SecurityKeyPublicKey<?> publicKey
-
challengeDigest
private java.security.MessageDigest challengeDigest
-
-
Method Detail
-
initVerifier
public void initVerifier(SessionContext session, java.security.PublicKey key) throws java.security.GeneralSecurityException
- Specified by:
initVerifierin interfaceSignature- Parameters:
session- TheSessionContextfor calling this method - may benullif not called within a session contextkey- ThePublicKeyto be used for verifying signatures- Throws:
java.security.GeneralSecurityException
-
update
public void update(SessionContext session, byte[] hash, int off, int len)
Description copied from interface:SignatureUpdate the computed signature with the given data- Specified by:
updatein interfaceSignature- Parameters:
session- TheSessionContextfor calling this method - may benullif not called within a session contexthash- The hash data bufferoff- Offset of hash data in bufferlen- Length of hash data
-
getSignatureKeyType
protected abstract java.lang.String getSignatureKeyType()
-
getDelegateSignature
protected abstract Signature getDelegateSignature()
-
verify
public boolean verify(SessionContext session, byte[] sig) throws java.lang.Exception
Description copied from interface:SignatureVerify against the given signature- Specified by:
verifyin interfaceSignature- Parameters:
session- TheSessionContextfor calling this method - may benullif not called within a session contextsig- The signed data- Returns:
trueif signature is valid- Throws:
java.lang.Exception- If failed to extract signed data for validation
-
initSigner
public void initSigner(SessionContext session, java.security.PrivateKey key)
- Specified by:
initSignerin interfaceSignature- Parameters:
session- TheSessionContextfor calling this method - may benullif not called within a session contextkey- ThePrivateKeyto be used for signing
-
sign
public byte[] sign(SessionContext session)
Description copied from interface:SignatureCompute the signature- Specified by:
signin interfaceSignature- Parameters:
session- TheSessionContextfor calling this method - may benullif not called within a session context- Returns:
- The signature value
-
-