public class ZRTPTransformEngine extends SinglePacketTransformer implements SrtpControl.TransformEngine, gnu.java.zrtp.ZrtpCallback
+---------------------------+ | ZrtpTransformConnector | | extends TransformConnector| | implements RTPConnector | +---------------------------+ | | uses | +----------------+ +-----+---------------+ | Application | | | +----------------+ | instantiates | uses | ZRTPTransformEngine | uses | | | a ZRTP Session +------+ implements +------+ GNU ZRTP4J | | and provides | | ZrtpCallback | | core | |ZrtpUserCallback| | | | implementation | +----------------+ +---------------------+ | (ZRtp et al) | | | +----------------+The following short code snippets show how an application could instantiate a ZrtpTransformConnector, get the ZRTP4J engine and initialize it. Then the code get a RTP manager instance and initializes it with the ZRTPTransformConnector. Please note: setting the target must be done with the connector, not with the RTP manager.
... transConnector = (ZrtpTransformConnector)TransformManager .createZRTPConnector(sa); zrtpEngine = transConnector.getEngine(); zrtpEngine.setUserCallback(new MyCallback()); if (!zrtpEngine.initialize("test_t.zid")) System.out.println("initialize failed"); // initialize the RTPManager using the ZRTP connector mgr = RTPManager.newInstance(); mgr.initialize(transConnector); mgr.addSessionListener(this); mgr.addReceiveStreamListener(this); transConnector.addTarget(target); zrtpEngine.startZrtp(); ...The demo folder contains a small example that shows how to use GNU ZRTP4J. This ZRTPTransformEngine documentation shows the ZRTP specific extensions and describes overloaded methods and a possible different behaviour.
Modifier and Type | Field and Description |
---|---|
protected static int |
ZRTP_PACKET_HEADER
Each ZRTP packet has a fixed header of 12 bytes.
|
Constructor and Description |
---|
ZRTPTransformEngine()
Construct a ZRTPTransformEngine.
|
Modifier and Type | Method and Description |
---|---|
void |
acceptEnrollment(boolean accepted)
Used to accept a PBX enrollment request
(The PBX part needs further development)
|
int |
activateTimer(int time)
Activate timer.
|
int |
cancelTimer()
Cancel the active timer.
|
boolean |
checkSASSignature(byte[] sasHash) |
void |
cleanup()
Cleanup function for any remaining timers
|
void |
close()
Close the transformer and underlying transform engine.
|
int |
getCurrentProtocolVersion()
Get negotiated ZRTP protocol version.
|
java.lang.String |
getHelloHash(int index)
Gets the Hello packet Hash
|
java.lang.String[] |
getHelloHashSep(int index)
Get the ZRTP Hello Hash data - separate strings.
|
byte[] |
getMultiStrParams()
Gets the multistream params
|
int |
getNumberSupportedVersions()
Get number of supported ZRTP protocol versions.
|
java.lang.String |
getPeerHelloHash()
Get the peer's Hello Hash data.
|
byte[] |
getPeerZid()
Get other party's ZID (ZRTP Identifier) data
This functions returns the other party's ZID that was receivied
during ZRTP processing.
|
ZRTCPTransformer |
getRTCPTransformer()
Returns an instance of ZRTPCTransformer.
|
PacketTransformer |
getRTPTransformer()
Returns this RTPTransformer.
|
byte[] |
getSasHash()
Get the computed SAS hash for this ZRTP session.
|
gnu.java.zrtp.ZrtpConstants.SupportedSASTypes |
getSasType()
Get the commited SAS rendering algorithm for this ZRTP session.
|
boolean |
getSecureCommunicationStatus()
Method for getting the default secure status value for communication
|
byte[] |
getSignatureData()
Gets signature data
|
int |
getSignatureLength()
Gets signature length
|
SecurityEventManager |
getUserCallback()
Gets the user callback used to manage the GUI part of ZRTP
|
void |
handleGoClear()
Method called by the Zrtp class as result of a GoClear request from the
other peer.
|
void |
handleTimeout()
Timeout handling function.
|
boolean |
initialize(java.lang.String zidFilename)
Default engine initialization method.
|
boolean |
initialize(java.lang.String zidFilename,
boolean autoEnable)
Engine initialization method.
|
boolean |
initialize(java.lang.String zidFilename,
boolean autoEnable,
gnu.java.zrtp.ZrtpConfigure config)
Custom engine initialization method.
|
boolean |
initialize(java.lang.String zidFilename,
gnu.java.zrtp.ZrtpConfigure config)
Engine initialization method.
|
boolean |
isEnableZrtp()
Returns the enableZrtp flag.
|
boolean |
isEnrollmentMode()
Check the state of the enrollment mode.
|
boolean |
isMitmMode()
Check the state of the MitM mode flag.
|
boolean |
isMultiStream()
Gets the multistream flag
(The multistream part needs further development)
|
boolean |
isParanoidMode()
Check status of paranoid mode.
|
boolean |
isStarted()
Returns the current status of the ZRTP engine
|
void |
requestGoClear()
Method called when the user requests through GUI to switch a secured call
to unsecure mode.
|
void |
requestGoSecure()
Method called when the user requests through GUI to switch a previously
unsecured call back to secure mode.
|
void |
resetSASVerified()
Resets the internal engine SAS verified flag
|
RawPacket |
reverseTransform(RawPacket pkt)
The input data stream calls this method to transform
incoming packets.
|
void |
SASVerified()
Set the SAS as verified internally if the user confirms it
|
boolean |
sendDataZRTP(byte[] data)
The callback method required by the ZRTP implementation.
|
void |
sendInfo(gnu.java.zrtp.ZrtpCodes.MessageSeverity severity,
java.util.EnumSet<?> subCode)
Send information messages to the hosting environment.
|
boolean |
sendSASRelayPacket(byte[] sh,
gnu.java.zrtp.ZrtpConstants.SupportedSASTypes render)
Send the SAS relay packet.
|
void |
setAuxSecret(byte[] data)
Sets the auxilliary secret data
|
void |
setClientId(java.lang.String id)
Sets the client ID
|
void |
setConnector(AbstractRTPConnector connector)
Sets the RTP connector using this ZRTP engine
|
void |
setEnableZrtp(boolean onOff)
Sets the enableZrtp flag.
|
void |
setEnrollmentMode(boolean enrollmentMode)
Set the state of the enrollment mode.
|
void |
setMitmMode(boolean mitmMode)
Set the state of the MitM mode flag.
|
void |
setMultiStrParams(byte[] parameters)
Sets the multistream params
(The multistream part needs further development)
|
void |
setOwnSSRC(long ssrc)
Set the SSRC of the RTP transmitter stream.
|
void |
setParanoidMode(boolean yesNo)
Enables or disables paranoid mode.
|
boolean |
setSignatureData(byte[] data)
Sets signature data for the Confirm packets
|
void |
setStartMuted(boolean startMuted) |
void |
setUserCallback(SecurityEventManager ub)
Sets the user callback class used to maintain the GUI ZRTP part
|
void |
signSAS(byte[] sasHash) |
void |
srtpSecretsOff(gnu.java.zrtp.ZrtpCallback.EnableSecurity part)
This method shall clear the ZRTP secrets.
|
void |
srtpSecretsOn(java.lang.String c,
java.lang.String s,
boolean verified)
Switch on the security.
|
boolean |
srtpSecretsReady(gnu.java.zrtp.ZrtpSrtpSecrets secrets,
gnu.java.zrtp.ZrtpCallback.EnableSecurity part)
Switch on the security for the defined part.
|
void |
startZrtp()
Start the ZRTP stack immediately, not autosensing mode.
|
void |
stopZrtp()
Stop ZRTP engine.
|
RawPacket |
transform(RawPacket pkt)
The data output stream calls this method to transform outgoing
packets.
|
void |
zrtpAskEnrollment(gnu.java.zrtp.ZrtpCodes.InfoEnrollment info)
Zrtp ask for Enrollment.
|
void |
zrtpInformEnrollment(gnu.java.zrtp.ZrtpCodes.InfoEnrollment info) |
void |
zrtpNegotiationFailed(gnu.java.zrtp.ZrtpCodes.MessageSeverity severity,
java.util.EnumSet<?> subCode)
Comes a message that zrtp negotiation has failed.
|
void |
zrtpNotSuppOther()
The other part doesn't support zrtp.
|
reverseTransform, transform
protected static final int ZRTP_PACKET_HEADER
public ZRTPTransformEngine()
public ZRTCPTransformer getRTCPTransformer()
getRTCPTransformer
in interface TransformEngine
TransformEngine.getRTCPTransformer()
public PacketTransformer getRTPTransformer()
getRTPTransformer
in interface TransformEngine
TransformEngine.getRTPTransformer()
public boolean initialize(java.lang.String zidFilename, gnu.java.zrtp.ZrtpConfigure config)
zidFilename
- The ZID file nameconfig
- The configuration datapublic boolean initialize(java.lang.String zidFilename, boolean autoEnable)
zidFilename
- The ZID file nameautoEnable
- If true start with auto-sensing mode.public boolean initialize(java.lang.String zidFilename)
zidFilename
- The ZID file namepublic boolean initialize(java.lang.String zidFilename, boolean autoEnable, gnu.java.zrtp.ZrtpConfigure config)
zidFilename
- The ZID file nameautoEnable
- Set this true to start with auto-sensing and false to
disable it.config
- the zrtp config to usepublic void setStartMuted(boolean startMuted)
startMuted
- whether to be started as muted if no secure
communication is establishedpublic boolean getSecureCommunicationStatus()
public void startZrtp()
public void close()
close
in interface PacketTransformer
close
in class SinglePacketTransformer
public void stopZrtp()
public void cleanup()
cleanup
in interface SrtpControl.TransformEngine
public void setOwnSSRC(long ssrc)
ssrc
- SSRC to setpublic RawPacket transform(RawPacket pkt)
transform
in class SinglePacketTransformer
pkt
- the packet to be transformed.PacketTransformer#transform(RawPacket)
public RawPacket reverseTransform(RawPacket pkt)
reverseTransform
in class SinglePacketTransformer
pkt
- the transformed packet to be restored.PacketTransformer#reverseTransform(RawPacket)
public boolean sendDataZRTP(byte[] data)
sendDataZRTP
in interface gnu.java.zrtp.ZrtpCallback
data
- The ZRTP packet datapublic boolean srtpSecretsReady(gnu.java.zrtp.ZrtpSrtpSecrets secrets, gnu.java.zrtp.ZrtpCallback.EnableSecurity part)
srtpSecretsReady
in interface gnu.java.zrtp.ZrtpCallback
secrets
- The secret keys and salt negotiated by ZRTPpart
- An enum that defines sender, receiver, or both.public void srtpSecretsOn(java.lang.String c, java.lang.String s, boolean verified)
srtpSecretsOn
in interface gnu.java.zrtp.ZrtpCallback
c
- The name of the used cipher algorithm and mode, or NULL.s
- The SAS string.verified
- if verified
is true then SAS was
verified by both parties during a previous call.ZrtpCallback.srtpSecretsOn(java.lang.String,
java.lang.String, boolean)
public void srtpSecretsOff(gnu.java.zrtp.ZrtpCallback.EnableSecurity part)
srtpSecretsOff
in interface gnu.java.zrtp.ZrtpCallback
part
- Defines for which part (sender or receiver) to switch on
securitypublic int activateTimer(int time)
activateTimer
in interface gnu.java.zrtp.ZrtpCallback
time
- The time in ms for the timer.public int cancelTimer()
cancelTimer
in interface gnu.java.zrtp.ZrtpCallback
public void handleTimeout()
public void sendInfo(gnu.java.zrtp.ZrtpCodes.MessageSeverity severity, java.util.EnumSet<?> subCode)
sendInfo
in interface gnu.java.zrtp.ZrtpCallback
severity
- This defines the message's severitysubCode
- The message code.public void zrtpNegotiationFailed(gnu.java.zrtp.ZrtpCodes.MessageSeverity severity, java.util.EnumSet<?> subCode)
zrtpNegotiationFailed
in interface gnu.java.zrtp.ZrtpCallback
severity
- This defines the message's severitysubCode
- The message code.public void zrtpNotSuppOther()
zrtpNotSuppOther
in interface gnu.java.zrtp.ZrtpCallback
public void zrtpAskEnrollment(gnu.java.zrtp.ZrtpCodes.InfoEnrollment info)
zrtpAskEnrollment
in interface gnu.java.zrtp.ZrtpCallback
info
- supplied info.public void zrtpInformEnrollment(gnu.java.zrtp.ZrtpCodes.InfoEnrollment info)
zrtpInformEnrollment
in interface gnu.java.zrtp.ZrtpCallback
info
- ZrtpCallback.zrtpInformEnrollment(
gnu.java.zrtp.ZrtpCodes.InfoEnrollment)
public void signSAS(byte[] sasHash)
signSAS
in interface gnu.java.zrtp.ZrtpCallback
sas
- gnu.java.zrtp.ZrtpCallback#signSAS(java.lang.String)
public boolean checkSASSignature(byte[] sasHash)
checkSASSignature
in interface gnu.java.zrtp.ZrtpCallback
sas
- gnu.java.zrtp.ZrtpCallback#checkSASSignature(java.lang.String)
public void setEnableZrtp(boolean onOff)
onOff
- The value for the enableZrtp flag.public boolean isEnableZrtp()
public void SASVerified()
public void resetSASVerified()
public void requestGoClear()
public void requestGoSecure()
public void setAuxSecret(byte[] data)
data
- The auxilliary secret datapublic void setClientId(java.lang.String id)
id
- The client IDpublic java.lang.String getHelloHash(int index)
index
- Hello hash of the Hello packet identified by index. Index must
be 0 <= index < SUPPORTED_ZRTP_VERSIONS.public java.lang.String[] getHelloHashSep(int index)
index
- Hello hash of the Hello packet identfied by index. Index must
be 0 <= index < SUPPORTED_ZRTP_VERSIONS.null
if ZRTP is not available.public java.lang.String getPeerHelloHash()
public byte[] getMultiStrParams()
public void setMultiStrParams(byte[] parameters)
parameters
- the multistream paramspublic boolean isMultiStream()
public void acceptEnrollment(boolean accepted)
accepted
- The boolean value indicating if the request is acceptedpublic gnu.java.zrtp.ZrtpConstants.SupportedSASTypes getSasType()
public byte[] getSasHash()
public boolean sendSASRelayPacket(byte[] sh, gnu.java.zrtp.ZrtpConstants.SupportedSASTypes render)
sh
- the full SAS hash valuerender
- the SAS rendering algorithmpublic boolean isMitmMode()
public void setMitmMode(boolean mitmMode)
mitmMode
- defines the new state of the mitmMode flagpublic void setParanoidMode(boolean yesNo)
yesNo
- If set to true then paranoid mode is enabled.public boolean isParanoidMode()
public boolean isEnrollmentMode()
public void setEnrollmentMode(boolean enrollmentMode)
enrollmentMode
- defines the new state of the enrollmentMode flagpublic boolean setSignatureData(byte[] data)
data
- the signature datapublic byte[] getSignatureData()
public int getSignatureLength()
public void handleGoClear()
handleGoClear
in interface gnu.java.zrtp.ZrtpCallback
public void setConnector(AbstractRTPConnector connector)
connector
- the connector to setpublic void setUserCallback(SecurityEventManager ub)
ub
- The user callback classpublic boolean isStarted()
public SecurityEventManager getUserCallback()
public byte[] getPeerZid()
public int getNumberSupportedVersions()
public int getCurrentProtocolVersion()
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.