Package org.apache.sshd.common.kex
Class AbstractDH
java.lang.Object
org.apache.sshd.common.kex.AbstractDH
Base class for the Diffie-Hellman key agreement.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract byte[]
Lazy-called bygetE()
if the public key data has not been generated yet.protected abstract byte[]
Lazy-called bygetK()
if the shared secret data has not been calculated yetprotected void
Called after either public or private parts have been calculated in order to check if the key-agreement mediator is still required.byte[]
getE()
abstract Digest
getHash()
byte[]
getK()
boolean
boolean
void
void
abstract void
setF
(byte[] f) static byte[]
stripLeadingZeroes
(byte[] x) The shared secret returned byKeyAgreement.generateSecret()
is a byte array, which can (by chance, roughly 1 out of 256 times) begin with zero byte (some JCE providers might strip this, though).toString()
-
Field Details
-
myKeyAgree
-
-
Constructor Details
-
AbstractDH
protected AbstractDH()
-
-
Method Details
-
setF
public abstract void setF(byte[] f) -
isPublicDataAvailable
public boolean isPublicDataAvailable() -
calculateE
Lazy-called bygetE()
if the public key data has not been generated yet.- Returns:
- The calculated public key data
- Throws:
Exception
- If failed to generate the relevant data
-
getE
- Returns:
- The local public key data
- Throws:
Exception
- If failed to calculate it
-
putE
-
putF
-
calculateK
Lazy-called bygetK()
if the shared secret data has not been calculated yet- Returns:
- The shared secret data
- Throws:
Exception
- If failed to calculate it
-
getK
- Returns:
- The shared secret key
- Throws:
Exception
- If failed to calculate it
-
checkKeyAgreementNecessity
protected void checkKeyAgreementNecessity()Called after either public or private parts have been calculated in order to check if the key-agreement mediator is still required. By default, if both public and private parts have been calculated then key-agreement mediator is null-ified to enable GC for it. -
getHash
- Throws:
Exception
-
toString
-
stripLeadingZeroes
public static byte[] stripLeadingZeroes(byte[] x) The shared secret returned byKeyAgreement.generateSecret()
is a byte array, which can (by chance, roughly 1 out of 256 times) begin with zero byte (some JCE providers might strip this, though). In SSH, the shared secret is an integer, so we need to strip the leading zero(es).- Parameters:
x
- The original array- Returns:
- An (possibly) sub-array guaranteed to start with a non-zero byte
- Throws:
IllegalArgumentException
- If all zeroes array- See Also:
-