Class ProtocolDecoderPHE
- java.lang.Object
-
- com.biglybt.core.networkmanager.impl.ProtocolDecoder
-
- com.biglybt.core.networkmanager.impl.ProtocolDecoderPHE
-
public class ProtocolDecoderPHE extends ProtocolDecoder
-
-
Field Summary
Fields Modifier and Type Field Description private ProtocolDecoderAdapter
adapter
private static int
BLOOM_INCREASE
private static int
BLOOM_RECREATE
private int
bytes_read
private int
bytes_written
private static byte
CRYPTO_AES
private static boolean
crypto_ok
private static byte
CRYPTO_PLAIN
private static byte
CRYPTO_RC4
private static boolean
crypto_setup_done
private static byte
CRYPTO_XOR
private boolean
delay_outbound_4
private static java.lang.String
DH_G
private static java.math.BigInteger
DH_G_BI
private static java.security.KeyPairGenerator
dh_key_generator
private static int
DH_L
private static java.lang.String
DH_P
private static java.math.BigInteger
DH_P_BI
private byte[]
dh_public_key_bytes
private static int
DH_SIZE_BYTES
private TransportHelperFilter
filter
private static BloomFilter
generate_bloom
private static long
generate_bloom_create_time
private static java.util.Map
global_shared_secrets
private boolean
handshake_complete
private java.nio.ByteBuffer
initial_data_in
private java.nio.ByteBuffer
initial_data_out
private javax.crypto.KeyAgreement
key_agreement
static byte[]
KEYA_IV
static byte[]
KEYB_IV
private long
last_read_time
private static LogIDs
LOGID
(package private) static byte
MIN_CRYPTO
static int
MIN_INCOMING_INITIAL_PACKET_SIZE
private byte
my_supported_protocols
private boolean
outbound
private static int
PADDING_MAX
private static int
PADDING_MAX_LIMITED
private static int
PADDING_MAX_NORMAL
private byte[]
padding_skip_marker
private AEMonitor
process_mon
private boolean
processing_complete
private int
protocol_state
private int
protocol_substate
private static int
PS_INBOUND_1
private static int
PS_INBOUND_2
private static int
PS_INBOUND_3
private static int
PS_INBOUND_4
private static int
PS_OUTBOUND_1
private static int
PS_OUTBOUND_2
private static int
PS_OUTBOUND_3
private static int
PS_OUTBOUND_4
private static java.util.Random
random
private static java.lang.String
RC4_STREAM_ALG
private static java.lang.String
RC4_STREAM_CIPHER
private static int
RC4_STREAM_KEY_SIZE
private static int
RC4_STREAM_KEY_SIZE_BYTES
private java.nio.ByteBuffer
read_buffer
private TransportCipher
read_cipher
static byte[]
REQ1_IV
static byte[]
REQ2_IV
static byte[]
REQ3_IV
private byte[]
secret_bytes
private byte
selected_protocol
private byte[]
shared_secret
private static byte
SUPPORTED_PROTOCOLS
private TransportHelper
transport
static byte[]
VC
private java.nio.ByteBuffer
write_buffer
private TransportCipher
write_cipher
-
Fields inherited from class com.biglybt.core.networkmanager.impl.ProtocolDecoder
class_mon, decoders, loop
-
-
Constructor Summary
Constructors Constructor Description ProtocolDecoderPHE(TransportHelper _transport, byte[][] _shared_secrets, java.nio.ByteBuffer _header, java.nio.ByteBuffer _initial_data, ProtocolDecoderAdapter _adapter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addSecretsSupport(byte[][] secrets)
protected byte[]
bigIntegerToBytes(java.math.BigInteger bi, int num_bytes)
protected java.math.BigInteger
bytesToBigInteger(byte[] bytes, int offset, int len)
protected void
complete()
protected void
completeDH(byte[] buffer)
private static boolean
cryptoSetup()
protected void
failed(java.lang.Throwable cause)
protected static java.security.KeyPair
generateDHKeyPair(TransportHelper transport, boolean outbound)
TransportHelperFilter
getFilter()
long
getLastReadTime()
static int
getMaxIncomingInitialPacketSize(boolean min_overheads)
protected int
getPaddingMax()
protected static byte[]
getRandomPadding(int max_len)
java.lang.String
getString()
protected static byte[]
getZeroPadding(int max_len)
protected void
handshakeComplete()
protected void
initCrypto()
boolean
isComplete(long now)
static boolean
isCryptoOK()
protected void
process()
protected void
read(java.nio.ByteBuffer buffer)
static void
removeSecretsSupport(byte[][] secrets)
void
selectFailure(TransportHelper transport, java.lang.Object attachment, java.lang.Throwable msg)
boolean
selectSuccess(TransportHelper transport, java.lang.Object attachment, boolean write_operation)
protected void
setupCrypto()
protected void
write(java.nio.ByteBuffer buffer)
-
Methods inherited from class com.biglybt.core.networkmanager.impl.ProtocolDecoder
addSecrets, removeSecrets
-
-
-
-
Field Detail
-
LOGID
private static final LogIDs LOGID
-
CRYPTO_PLAIN
private static final byte CRYPTO_PLAIN
- See Also:
- Constant Field Values
-
CRYPTO_RC4
private static final byte CRYPTO_RC4
- See Also:
- Constant Field Values
-
CRYPTO_XOR
private static final byte CRYPTO_XOR
- See Also:
- Constant Field Values
-
CRYPTO_AES
private static final byte CRYPTO_AES
- See Also:
- Constant Field Values
-
DH_P
private static final java.lang.String DH_P
- See Also:
- Constant Field Values
-
DH_G
private static final java.lang.String DH_G
- See Also:
- Constant Field Values
-
DH_L
private static final int DH_L
- See Also:
- Constant Field Values
-
DH_SIZE_BYTES
private static final int DH_SIZE_BYTES
-
MIN_INCOMING_INITIAL_PACKET_SIZE
public static final int MIN_INCOMING_INITIAL_PACKET_SIZE
-
DH_P_BI
private static final java.math.BigInteger DH_P_BI
-
DH_G_BI
private static final java.math.BigInteger DH_G_BI
-
dh_key_generator
private static java.security.KeyPairGenerator dh_key_generator
-
BLOOM_RECREATE
private static final int BLOOM_RECREATE
- See Also:
- Constant Field Values
-
BLOOM_INCREASE
private static final int BLOOM_INCREASE
- See Also:
- Constant Field Values
-
generate_bloom
private static BloomFilter generate_bloom
-
generate_bloom_create_time
private static long generate_bloom_create_time
-
crypto_setup_done
private static boolean crypto_setup_done
-
crypto_ok
private static boolean crypto_ok
-
RC4_STREAM_ALG
private static final java.lang.String RC4_STREAM_ALG
- See Also:
- Constant Field Values
-
RC4_STREAM_CIPHER
private static final java.lang.String RC4_STREAM_CIPHER
- See Also:
- Constant Field Values
-
RC4_STREAM_KEY_SIZE
private static final int RC4_STREAM_KEY_SIZE
- See Also:
- Constant Field Values
-
RC4_STREAM_KEY_SIZE_BYTES
private static final int RC4_STREAM_KEY_SIZE_BYTES
- See Also:
- Constant Field Values
-
PADDING_MAX
private static final int PADDING_MAX
- See Also:
- Constant Field Values
-
PADDING_MAX_NORMAL
private static final int PADDING_MAX_NORMAL
- See Also:
- Constant Field Values
-
PADDING_MAX_LIMITED
private static final int PADDING_MAX_LIMITED
- See Also:
- Constant Field Values
-
random
private static final java.util.Random random
-
global_shared_secrets
private static final java.util.Map global_shared_secrets
-
SUPPORTED_PROTOCOLS
private static final byte SUPPORTED_PROTOCOLS
- See Also:
- Constant Field Values
-
MIN_CRYPTO
static byte MIN_CRYPTO
-
PS_OUTBOUND_1
private static final int PS_OUTBOUND_1
- See Also:
- Constant Field Values
-
PS_OUTBOUND_2
private static final int PS_OUTBOUND_2
- See Also:
- Constant Field Values
-
PS_OUTBOUND_3
private static final int PS_OUTBOUND_3
- See Also:
- Constant Field Values
-
PS_OUTBOUND_4
private static final int PS_OUTBOUND_4
- See Also:
- Constant Field Values
-
PS_INBOUND_1
private static final int PS_INBOUND_1
- See Also:
- Constant Field Values
-
PS_INBOUND_2
private static final int PS_INBOUND_2
- See Also:
- Constant Field Values
-
PS_INBOUND_3
private static final int PS_INBOUND_3
- See Also:
- Constant Field Values
-
PS_INBOUND_4
private static final int PS_INBOUND_4
- See Also:
- Constant Field Values
-
KEYA_IV
public static final byte[] KEYA_IV
-
KEYB_IV
public static final byte[] KEYB_IV
-
REQ1_IV
public static final byte[] REQ1_IV
-
REQ2_IV
public static final byte[] REQ2_IV
-
REQ3_IV
public static final byte[] REQ3_IV
-
VC
public static final byte[] VC
-
transport
private TransportHelper transport
-
write_buffer
private java.nio.ByteBuffer write_buffer
-
read_buffer
private java.nio.ByteBuffer read_buffer
-
adapter
private ProtocolDecoderAdapter adapter
-
key_agreement
private javax.crypto.KeyAgreement key_agreement
-
dh_public_key_bytes
private byte[] dh_public_key_bytes
-
shared_secret
private byte[] shared_secret
-
secret_bytes
private byte[] secret_bytes
-
initial_data_out
private java.nio.ByteBuffer initial_data_out
-
initial_data_in
private java.nio.ByteBuffer initial_data_in
-
write_cipher
private TransportCipher write_cipher
-
read_cipher
private TransportCipher read_cipher
-
padding_skip_marker
private byte[] padding_skip_marker
-
my_supported_protocols
private byte my_supported_protocols
-
selected_protocol
private byte selected_protocol
-
outbound
private boolean outbound
-
protocol_state
private int protocol_state
-
protocol_substate
private int protocol_substate
-
handshake_complete
private boolean handshake_complete
-
bytes_read
private int bytes_read
-
bytes_written
private int bytes_written
-
last_read_time
private long last_read_time
-
filter
private TransportHelperFilter filter
-
delay_outbound_4
private boolean delay_outbound_4
-
processing_complete
private boolean processing_complete
-
process_mon
private final AEMonitor process_mon
-
-
Constructor Detail
-
ProtocolDecoderPHE
public ProtocolDecoderPHE(TransportHelper _transport, byte[][] _shared_secrets, java.nio.ByteBuffer _header, java.nio.ByteBuffer _initial_data, ProtocolDecoderAdapter _adapter) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getMaxIncomingInitialPacketSize
public static int getMaxIncomingInitialPacketSize(boolean min_overheads)
-
cryptoSetup
private static boolean cryptoSetup()
-
isCryptoOK
public static boolean isCryptoOK()
-
addSecretsSupport
public static void addSecretsSupport(byte[][] secrets)
-
removeSecretsSupport
public static void removeSecretsSupport(byte[][] secrets)
-
initCrypto
protected void initCrypto() throws java.io.IOException
- Throws:
java.io.IOException
-
completeDH
protected void completeDH(byte[] buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
setupCrypto
protected void setupCrypto() throws java.io.IOException
- Throws:
java.io.IOException
-
handshakeComplete
protected void handshakeComplete() throws java.io.IOException
- Throws:
java.io.IOException
-
process
protected void process() throws java.io.IOException
- Throws:
java.io.IOException
-
read
protected void read(java.nio.ByteBuffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
write
protected void write(java.nio.ByteBuffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
selectSuccess
public boolean selectSuccess(TransportHelper transport, java.lang.Object attachment, boolean write_operation)
-
selectFailure
public void selectFailure(TransportHelper transport, java.lang.Object attachment, java.lang.Throwable msg)
-
bigIntegerToBytes
protected byte[] bigIntegerToBytes(java.math.BigInteger bi, int num_bytes)
-
bytesToBigInteger
protected java.math.BigInteger bytesToBigInteger(byte[] bytes, int offset, int len)
-
getPaddingMax
protected int getPaddingMax()
-
getRandomPadding
protected static byte[] getRandomPadding(int max_len)
-
getZeroPadding
protected static byte[] getZeroPadding(int max_len)
-
generateDHKeyPair
protected static java.security.KeyPair generateDHKeyPair(TransportHelper transport, boolean outbound) throws java.io.IOException
- Throws:
java.io.IOException
-
complete
protected void complete()
-
failed
protected void failed(java.lang.Throwable cause)
-
isComplete
public boolean isComplete(long now)
- Specified by:
isComplete
in classProtocolDecoder
-
getFilter
public TransportHelperFilter getFilter()
- Specified by:
getFilter
in classProtocolDecoder
-
getLastReadTime
public long getLastReadTime()
-
getString
public java.lang.String getString()
-
-