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.MessageDigest
challengeDigest
private static int
FLAG_USER_PRESENCE
private java.lang.String
keyType
private SecurityKeyPublicKey<?>
publicKey
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSecurityKeySignature(java.lang.String keyType)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Signature
getDelegateSignature()
protected abstract java.lang.String
getSignatureKeyType()
void
initSigner(SessionContext session, java.security.PrivateKey key)
void
initVerifier(SessionContext session, java.security.PublicKey key)
byte[]
sign(SessionContext session)
Compute the signaturevoid
update(SessionContext session, byte[] hash, int off, int len)
Update the computed signature with the given databoolean
verify(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:
initVerifier
in interfaceSignature
- Parameters:
session
- TheSessionContext
for calling this method - may benull
if not called within a session contextkey
- ThePublicKey
to 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:Signature
Update the computed signature with the given data- Specified by:
update
in interfaceSignature
- Parameters:
session
- TheSessionContext
for calling this method - may benull
if 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:Signature
Verify against the given signature- Specified by:
verify
in interfaceSignature
- Parameters:
session
- TheSessionContext
for calling this method - may benull
if not called within a session contextsig
- The signed data- Returns:
true
if 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:
initSigner
in interfaceSignature
- Parameters:
session
- TheSessionContext
for calling this method - may benull
if not called within a session contextkey
- ThePrivateKey
to be used for signing
-
sign
public byte[] sign(SessionContext session)
Description copied from interface:Signature
Compute the signature- Specified by:
sign
in interfaceSignature
- Parameters:
session
- TheSessionContext
for calling this method - may benull
if not called within a session context- Returns:
- The signature value
-
-