Modifier and Type | Field and Description |
---|---|
private byte[] |
e_array |
private byte[] |
k_array |
protected javax.crypto.KeyAgreement |
myKeyAgree |
Modifier | Constructor and Description |
---|---|
protected |
AbstractDH() |
Modifier and Type | Method and Description |
---|---|
protected abstract byte[] |
calculateE()
Lazy-called by
getE() if the public key data has not been generated yet. |
protected abstract byte[] |
calculateK()
Lazy-called by
getK() if the shared secret data has not been calculated yet |
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.
|
byte[] |
getE() |
abstract Digest |
getHash() |
byte[] |
getK() |
boolean |
isPublicDataAvailable() |
boolean |
isSharedSecretAvailable() |
void |
putE(Buffer buffer,
byte[] e) |
void |
putF(Buffer buffer,
byte[] f) |
abstract void |
setF(byte[] f) |
static byte[] |
stripLeadingZeroes(byte[] x)
The shared secret returned by
KeyAgreement.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). |
java.lang.String |
toString() |
protected javax.crypto.KeyAgreement myKeyAgree
private byte[] k_array
private byte[] e_array
public abstract void setF(byte[] f)
public boolean isPublicDataAvailable()
protected abstract byte[] calculateE() throws java.lang.Exception
getE()
if the public key data has not been generated yet.java.lang.Exception
- If failed to generate the relevant datapublic byte[] getE() throws java.lang.Exception
java.lang.Exception
- If failed to calculate itpublic void putE(Buffer buffer, byte[] e)
public void putF(Buffer buffer, byte[] f)
public boolean isSharedSecretAvailable()
protected abstract byte[] calculateK() throws java.lang.Exception
getK()
if the shared secret data has not been calculated yetjava.lang.Exception
- If failed to calculate itpublic byte[] getK() throws java.lang.Exception
java.lang.Exception
- If failed to calculate itprotected void checkKeyAgreementNecessity()
public abstract Digest getHash() throws java.lang.Exception
java.lang.Exception
public java.lang.String toString()
toString
in class java.lang.Object
public static byte[] stripLeadingZeroes(byte[] x)
KeyAgreement.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).x
- The original arrayjava.lang.IllegalArgumentException
- If all zeroes array