net.i2p.crypto
public class DHSessionKeyBuilder extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DHSessionKeyBuilder.InvalidPublicParameterException |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_DH_PRECALC_DELAY |
static int |
DEFAULT_DH_PRECALC_MAX |
static int |
DEFAULT_DH_PRECALC_MIN |
static String |
PROP_DH_PRECALC_DELAY |
static String |
PROP_DH_PRECALC_MAX |
static String |
PROP_DH_PRECALC_MIN |
Constructor and Description |
---|
DHSessionKeyBuilder()
Construct a new DH key builder
or pulls a prebuilt one from the queue.
|
Modifier and Type | Method and Description |
---|---|
static DHSessionKeyBuilder |
exchangeKeys(InputStream in,
OutputStream out)
Conduct a DH exchange over the streams, returning the resulting data.
|
BigInteger |
generateMyValue()
Create a new private value for the DH exchange, and return the number to
be exchanged, leaving the actual private value accessible through getMyPrivateValue()
|
ByteArray |
getExtraBytes()
Retrieve the extra bytes beyond the session key resulting from the DH exchange.
|
BigInteger |
getMyPrivateValue()
Retrieve the private value used by the local participant in the DH exchange
|
BigInteger |
getMyPublicValue()
Retrieve the public value used by the local participant in the DH exchange,
generating it if necessary
|
byte[] |
getMyPublicValueBytes()
Return a 256 byte representation of our public key, with leading 0s
if necessary.
|
BigInteger |
getPeerPublicValue() |
byte[] |
getPeerPublicValueBytes() |
SessionKey |
getSessionKey()
Retrieve the session key, calculating it if necessary (and if possible).
|
(package private) static BigInteger |
readBigI(InputStream in) |
void |
setPeerPublicValue(BigInteger peerVal)
Specify the value given by the peer for use in the session key negotiation
|
void |
setPeerPublicValue(byte[] val) |
(package private) static void |
writeBigI(OutputStream out,
BigInteger val)
Write out the integer as a 256 byte value.
|
public static final String PROP_DH_PRECALC_MIN
public static final String PROP_DH_PRECALC_MAX
public static final String PROP_DH_PRECALC_DELAY
public static final int DEFAULT_DH_PRECALC_MIN
public static final int DEFAULT_DH_PRECALC_MAX
public static final int DEFAULT_DH_PRECALC_DELAY
public DHSessionKeyBuilder()
public static DHSessionKeyBuilder exchangeKeys(InputStream in, OutputStream out) throws IOException
IOException
- if there is an error (but does not close the streamsstatic BigInteger readBigI(InputStream in) throws IOException
IOException
static void writeBigI(OutputStream out, BigInteger val) throws IOException
IOException
public BigInteger generateMyValue()
public BigInteger getMyPrivateValue()
public BigInteger getMyPublicValue()
public byte[] getMyPublicValueBytes()
public void setPeerPublicValue(BigInteger peerVal) throws DHSessionKeyBuilder.InvalidPublicParameterException
public void setPeerPublicValue(byte[] val) throws DHSessionKeyBuilder.InvalidPublicParameterException
public BigInteger getPeerPublicValue()
public byte[] getPeerPublicValueBytes()
public SessionKey getSessionKey()
public ByteArray getExtraBytes()