public abstract class RTMPHandshake extends Object implements IHandshake
| Modifier and Type | Field and Description |
|---|---|
protected int |
algorithm |
protected static byte[][] |
BLOWFISH_KEYS
Blowfish keys for RTMPE (RTMP type 0x09) - 16 x 24
|
protected org.apache.mina.core.buffer.IoBuffer |
buffer |
protected Cipher |
cipherIn |
protected Cipher |
cipherOut |
protected static BigInteger |
DH_BASE |
protected static BigInteger |
DH_MODULUS |
protected static byte[] |
DH_MODULUS_BYTES
"Second Oakley Default Group" from RFC2409, section 6.2.
|
protected static int |
DIGEST_LENGTH |
protected boolean |
fp9Handshake |
static byte[] |
GENUINE_FMS_KEY |
static byte[] |
GENUINE_FP_KEY |
static String[] |
HANDSHAKE_TYPES |
protected byte[] |
handshakeBytes |
protected byte |
handshakeType |
protected byte[] |
incomingPublicKey |
protected static int |
KEY_LENGTH |
protected KeyAgreement |
keyAgreement |
protected org.slf4j.Logger |
log |
protected byte[] |
outgoingPublicKey |
protected static Random |
random |
protected int |
swfSize |
protected byte[] |
swfVerificationBytes |
protected static int[][] |
XTEA_KEYS
XTEA keys for RTMPE (RTMP type 0x08) - 16 x 4
|
| Constructor and Description |
|---|
RTMPHandshake() |
RTMPHandshake(byte handshakeType) |
| Modifier and Type | Method and Description |
|---|---|
void |
addBuffer(byte[] in)
Add a byte array to the buffer.
|
void |
addBuffer(org.apache.mina.core.buffer.IoBuffer in)
Add a IoBuffer to the buffer.
|
void |
calculateDigest(int digestPos,
byte[] handshakeMessage,
int handshakeOffset,
byte[] key,
int keyLen,
byte[] digest,
int digestOffset)
Calculates the digest given the its offset in the handshake data.
|
void |
calculateHMAC_SHA256(byte[] message,
int messageOffset,
int messageLen,
byte[] key,
int keyLen,
byte[] digest,
int digestOffset)
Calculates an HMAC SHA256 hash into the digest at the given offset.
|
void |
calculateSwfVerification(byte[] handshakeMessage,
byte[] swfHash,
int swfSize)
Calculates the swf verification token.
|
protected abstract void |
createHandshakeBytes()
Create the initial bytes for a request / response.
|
protected KeyPair |
generateKeyPair()
Creates a Diffie-Hellman key pair.
|
static void |
getBlowfishSignature(byte[] array,
int offset,
int keyid)
RTMPE type 9 uses Blowfish on the regular signature http://en.wikipedia.org/wiki/Blowfish_(cipher)
|
byte[] |
getBuffer()
Returns buffered byte array.
|
org.apache.mina.core.buffer.IoBuffer |
getBufferAsIoBuffer()
Returns buffered IoBuffer itself.
|
int |
getBufferSize()
Returns the buffer size.
|
Cipher |
getCipherIn()
Returns the contained handshake bytes.
|
Cipher |
getCipherOut()
Gets the DH offset in the handshake bytes array based on validation scheme Generates DH keypair Adds public key to handshake bytes
|
int |
getDHOffset(int algorithm,
byte[] handshake,
int bufferOffset)
Returns the DH offset from an array of bytes.
|
protected int |
getDHOffset1(byte[] handshake,
int bufferOffset)
Returns the DH byte offset.
|
protected int |
getDHOffset2(byte[] handshake,
int bufferOffset)
Returns the DH byte offset.
|
int |
getDigestOffset(int algorithm,
byte[] handshake,
int bufferOffset)
Returns the digest offset using current validation scheme.
|
protected int |
getDigestOffset1(byte[] handshake,
int bufferOffset)
Returns a digest byte offset.
|
protected int |
getDigestOffset2(byte[] handshake,
int bufferOffset)
Returns a digest byte offset.
|
byte |
getHandshakeType()
Returns the handshake type.
|
protected byte[] |
getPublicKey(KeyPair keyPair)
Returns the public key for a given key pair.
|
protected byte[] |
getSharedSecret(byte[] publicKeyBytes,
KeyAgreement agreement)
Determines the validation scheme for given input.
|
byte[] |
getSwfVerificationBytes()
Returns the SWF verification bytes.
|
static void |
getXteaSignature(byte[] array,
int offset,
int keyid)
RTMPE type 8 uses XTEA on the regular signature http://en.wikipedia.org/wiki/XTEA
|
protected void |
initRC4Encryption(byte[] sharedSecret)
Prepare the ciphers.
|
void |
setHandshakeType(byte handshakeType)
Sets the handshake type.
|
boolean |
useEncryption()
Whether or not encryptions is in use.
|
abstract boolean |
validate(byte[] handshake)
Determines the validation scheme for given input.
|
static boolean |
validHandshakeType(byte handshakeType)
Returns whether or not a given handshake type is valid.
|
boolean |
verifyDigest(int digestPos,
byte[] handshakeMessage,
byte[] key,
int keyLen)
Verifies the digest.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdoHandshakeprotected org.slf4j.Logger log
public static final String[] HANDSHAKE_TYPES
public static final byte[] GENUINE_FMS_KEY
public static final byte[] GENUINE_FP_KEY
protected static final byte[] DH_MODULUS_BYTES
protected static final int[][] XTEA_KEYS
protected static final byte[][] BLOWFISH_KEYS
protected static final BigInteger DH_MODULUS
protected static final BigInteger DH_BASE
protected static final int DIGEST_LENGTH
protected static final int KEY_LENGTH
protected static final Random random
protected KeyAgreement keyAgreement
protected Cipher cipherOut
protected Cipher cipherIn
protected byte handshakeType
protected byte[] handshakeBytes
protected byte[] incomingPublicKey
protected byte[] outgoingPublicKey
protected int swfSize
protected byte[] swfVerificationBytes
protected int algorithm
protected boolean fp9Handshake
protected org.apache.mina.core.buffer.IoBuffer buffer
public RTMPHandshake()
public RTMPHandshake(byte handshakeType)
protected void initRC4Encryption(byte[] sharedSecret)
sharedSecret - shared secret byte sequenceprotected KeyPair generateKeyPair()
protected byte[] getPublicKey(KeyPair keyPair)
keyPair - key pairprotected byte[] getSharedSecret(byte[] publicKeyBytes,
KeyAgreement agreement)
publicKeyBytes - public key bytesagreement - key agreementprotected abstract void createHandshakeBytes()
public abstract boolean validate(byte[] handshake)
validate in interface IHandshakehandshake - handshake byte sequencepublic void calculateDigest(int digestPos,
byte[] handshakeMessage,
int handshakeOffset,
byte[] key,
int keyLen,
byte[] digest,
int digestOffset)
digestPos - digest positionhandshakeMessage - handshake messagehandshakeOffset - handshake message offsetkey - contains the keykeyLen - the length of the keydigest - contains the calculated digestdigestOffset - digest offsetpublic boolean verifyDigest(int digestPos,
byte[] handshakeMessage,
byte[] key,
int keyLen)
digestPos - digest positionhandshakeMessage - handshake messagekey - contains the keykeyLen - the length of the keypublic void calculateHMAC_SHA256(byte[] message,
int messageOffset,
int messageLen,
byte[] key,
int keyLen,
byte[] digest,
int digestOffset)
message - incoming bytesmessageOffset - message offsetmessageLen - message lengthkey - incoming key byteskeyLen - the length of the keydigest - contains the calculated digestdigestOffset - digest offsetpublic void calculateSwfVerification(byte[] handshakeMessage,
byte[] swfHash,
int swfSize)
handshakeMessage - servers handshake bytesswfHash - hash of swfswfSize - size of swfpublic int getDHOffset(int algorithm,
byte[] handshake,
int bufferOffset)
algorithm - validation algorithmhandshake - handshake sequencebufferOffset - buffer offsetprotected int getDHOffset1(byte[] handshake,
int bufferOffset)
handshake - handshake sequencebufferOffset - buffer offsetprotected int getDHOffset2(byte[] handshake,
int bufferOffset)
handshake - handshake sequencebufferOffset - buffer offsetpublic int getDigestOffset(int algorithm,
byte[] handshake,
int bufferOffset)
algorithm - validation algorithmhandshake - handshake sequencebufferOffset - buffer offsetprotected int getDigestOffset1(byte[] handshake,
int bufferOffset)
handshake - handshake sequencebufferOffset - buffer offsetprotected int getDigestOffset2(byte[] handshake,
int bufferOffset)
handshake - handshake sequencebufferOffset - buffer offsetpublic static final void getXteaSignature(byte[] array,
int offset,
int keyid)
array - array to get signatureoffset - offset to start fromkeyid - ID of XTEA keypublic static final void getBlowfishSignature(byte[] array,
int offset,
int keyid)
array - array to get signatureoffset - offset to start fromkeyid - ID of XTEA keypublic static final boolean validHandshakeType(byte handshakeType)
handshakeType - the type of handshakepublic boolean useEncryption()
useEncryption in interface IHandshakepublic void setHandshakeType(byte handshakeType)
handshakeType - handshake typepublic byte getHandshakeType()
public Cipher getCipherOut()
public Cipher getCipherIn()
public byte[] getSwfVerificationBytes()
public int getBufferSize()
public void addBuffer(byte[] in)
in - incoming bytespublic void addBuffer(org.apache.mina.core.buffer.IoBuffer in)
in - incoming IoBufferpublic org.apache.mina.core.buffer.IoBuffer getBufferAsIoBuffer()
public byte[] getBuffer()
Copyright © 2005–2017 Red5. All rights reserved.