Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libjitsi
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ZRTP
libjitsi
Commits
189e34da
Commit
189e34da
authored
11 years ago
by
Ingo Bauersachs
Browse files
Options
Downloads
Patches
Plain Diff
Fix a spelling mistake
parent
f1ff821a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/org/jitsi/impl/neomedia/transform/sdes/SDesControlImpl.java
+238
-238
238 additions, 238 deletions
...g/jitsi/impl/neomedia/transform/sdes/SDesControlImpl.java
with
238 additions
and
238 deletions
src/org/jitsi/impl/neomedia/transform/sdes/SDesControlImpl.java
+
238
−
238
View file @
189e34da
/*
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
*
* Distributable under LGPL license.
* Distributable under LGPL license.
* See terms of license at gnu.org.
* See terms of license at gnu.org.
*/
*/
package
org.jitsi.impl.neomedia.transform.sdes
;
package
org.jitsi.impl.neomedia.transform.sdes
;
import
gnu.java.zrtp.utils.*
;
import
gnu.java.zrtp.utils.*
;
import
java.util.*
;
import
java.util.*
;
import
org.jitsi.impl.neomedia.*
;
import
org.jitsi.impl.neomedia.*
;
import
org.jitsi.service.neomedia.*
;
import
org.jitsi.service.neomedia.*
;
import
org.jitsi.service.neomedia.event.*
;
import
org.jitsi.service.neomedia.event.*
;
import
ch.imvs.sdes4j.srtp.*
;
import
ch.imvs.sdes4j.srtp.*
;
/**
/**
* Default implementation of {@link SDesControl} that supports the crypto suites
* Default implementation of {@link SDesControl} that supports the crypto suites
* of the original RFC4568 and the KDR parameter, but nothing else.
* of the original RFC4568 and the KDR parameter, but nothing else.
*
*
* @author Ingo Bauersachs
* @author Ingo Bauersachs
*/
*/
public
class
SDesControlImpl
public
class
SDesControlImpl
extends
AbstractSrtpControl
<
SDesTransformEngine
>
extends
AbstractSrtpControl
<
SDesTransformEngine
>
implements
SDesControl
implements
SDesControl
{
{
/**
/**
* List of enabled crypto suites.
* List of enabled crypto suites.
*/
*/
private
final
List
<
String
>
enabledCryptoSuites
=
new
ArrayList
<
String
>(
3
);
private
final
List
<
String
>
enabledCryptoSuites
=
new
ArrayList
<
String
>(
3
);
/**
/**
* List of supported crypto suites.
* List of supported crypto suites.
*/
*/
private
final
List
<
String
>
supportedCryptoSuites
=
new
ArrayList
<
String
>(
3
);
private
final
List
<
String
>
supportedCryptoSuites
=
new
ArrayList
<
String
>(
3
);
private
SrtpCryptoAttribute
[]
attributes
;
private
SrtpCryptoAttribute
[]
attributes
;
private
SrtpSDesFactory
sdesFactory
;
private
SrtpSDesFactory
sdesFactory
;
private
SrtpCryptoAttribute
selectedInAttribute
;
private
SrtpCryptoAttribute
selectedInAttribute
;
private
SrtpCryptoAttribute
selectedOutAttribute
;
private
SrtpCryptoAttribute
selectedOutAttribute
;
/**
/**
* SDESControl
* SDESControl
*/
*/
public
SDesControlImpl
()
public
SDesControlImpl
()
{
{
super
(
SrtpControlType
.
SDES
);
super
(
SrtpControlType
.
SDES
);
{
{
enabledCryptoSuites
.
add
(
SrtpCryptoSuite
.
AES_CM_128_HMAC_SHA1_80
);
enabledCryptoSuites
.
add
(
SrtpCryptoSuite
.
AES_CM_128_HMAC_SHA1_80
);
enabledCryptoSuites
.
add
(
SrtpCryptoSuite
.
AES_CM_128_HMAC_SHA1_32
);
enabledCryptoSuites
.
add
(
SrtpCryptoSuite
.
AES_CM_128_HMAC_SHA1_32
);
enabledCryptoSuites
.
add
(
SrtpCryptoSuite
.
F8_128_HMAC_SHA1_80
);
enabledCryptoSuites
.
add
(
SrtpCryptoSuite
.
F8_128_HMAC_SHA1_80
);
}
}
{
{
supportedCryptoSuites
.
add
(
SrtpCryptoSuite
.
AES_CM_128_HMAC_SHA1_80
);
supportedCryptoSuites
.
add
(
SrtpCryptoSuite
.
AES_CM_128_HMAC_SHA1_80
);
supportedCryptoSuites
.
add
(
SrtpCryptoSuite
.
AES_CM_128_HMAC_SHA1_32
);
supportedCryptoSuites
.
add
(
SrtpCryptoSuite
.
AES_CM_128_HMAC_SHA1_32
);
supportedCryptoSuites
.
add
(
SrtpCryptoSuite
.
F8_128_HMAC_SHA1_80
);
supportedCryptoSuites
.
add
(
SrtpCryptoSuite
.
F8_128_HMAC_SHA1_80
);
}
}
sdesFactory
=
new
SrtpSDesFactory
();
sdesFactory
=
new
SrtpSDesFactory
();
sdesFactory
.
setRandomGenerator
(
sdesFactory
.
setRandomGenerator
(
new
Random
()
new
Random
()
{
{
private
static
final
long
serialVersionUID
=
0L
;
private
static
final
long
serialVersionUID
=
0L
;
@Override
@Override
public
void
nextBytes
(
byte
[]
bytes
)
public
void
nextBytes
(
byte
[]
bytes
)
{
{
ZrtpFortuna
.
getInstance
().
getFortuna
().
nextBytes
(
bytes
);
ZrtpFortuna
.
getInstance
().
getFortuna
().
nextBytes
(
bytes
);
}
}
});
});
}
}
public
SrtpCryptoAttribute
getInAttribute
()
public
SrtpCryptoAttribute
getInAttribute
()
{
{
return
selectedInAttribute
;
return
selectedInAttribute
;
}
}
/**
/**
* Returns the crypto attributes enabled on this computer.
* Returns the crypto attributes enabled on this computer.
*
*
* @return The crypto attributes enabled on this computer.
* @return The crypto attributes enabled on this computer.
*/
*/
public
SrtpCryptoAttribute
[]
getInitiatorCryptoAttributes
()
public
SrtpCryptoAttribute
[]
getInitiatorCryptoAttributes
()
{
{
initAttributes
();
initAttributes
();
return
attributes
;
return
attributes
;
}
}
public
SrtpCryptoAttribute
getOutAttribute
()
public
SrtpCryptoAttribute
getOutAttribute
()
{
{
return
selectedOutAttribute
;
return
selectedOutAttribute
;
}
}
public
boolean
getSecureCommunicationStatus
()
public
boolean
getSecureCommunicationStatus
()
{
{
return
transformEngine
!=
null
;
return
transformEngine
!=
null
;
}
}
public
Iterable
<
String
>
getSupportedCryptoSuites
()
public
Iterable
<
String
>
getSupportedCryptoSuites
()
{
{
return
Collections
.
unmodifiableList
(
supportedCryptoSuites
);
return
Collections
.
unmodifiableList
(
supportedCryptoSuites
);
}
}
/**
/**
* Initializes a new <tt>SDesTransformEngine</tt> instance to be associated
* Initializes a new <tt>SDesTransformEngine</tt> instance to be associated
* with and used by this <tt>SDesControlImpl</tt> instance.
* with and used by this <tt>SDesControlImpl</tt> instance.
*
*
* @return a new <tt>SDesTransformEngine</tt> instance to be associated with
* @return a new <tt>SDesTransformEngine</tt> instance to be associated with
* and used by this <tt>SDesControlImpl</tt> instance
* and used by this <tt>SDesControlImpl</tt> instance
* @see AbstractSrtpControl#createTransformEngine()
* @see AbstractSrtpControl#createTransformEngine()
*/
*/
protected
SDesTransformEngine
createTransformEngine
()
protected
SDesTransformEngine
createTransformEngine
()
{
{
return
return
new
SDesTransformEngine
(
selectedInAttribute
,
selectedOutAttribute
);
new
SDesTransformEngine
(
selectedInAttribute
,
selectedOutAttribute
);
}
}
/**
/**
* Initializes the available SRTP crypto attributes containing: he
* Initializes the available SRTP crypto attributes containing:
t
he
* crypto-suite, the key-param and the session-param.
* crypto-suite, the key-param and the session-param.
*/
*/
private
void
initAttributes
()
private
void
initAttributes
()
{
{
if
(
attributes
==
null
)
if
(
attributes
==
null
)
{
{
attributes
=
new
SrtpCryptoAttribute
[
enabledCryptoSuites
.
size
()];
attributes
=
new
SrtpCryptoAttribute
[
enabledCryptoSuites
.
size
()];
for
(
int
i
=
0
;
i
<
attributes
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
attributes
.
length
;
i
++)
{
{
attributes
[
i
]
attributes
[
i
]
=
sdesFactory
.
createCryptoAttribute
(
=
sdesFactory
.
createCryptoAttribute
(
i
+
1
,
i
+
1
,
enabledCryptoSuites
.
get
(
i
));
enabledCryptoSuites
.
get
(
i
));
}
}
}
}
}
}
/**
/**
* Select the local crypto attribute from the initial offering (@see
* Select the local crypto attribute from the initial offering (@see
* {@link #getInitiatorCryptoAttributes()}) based on the peer's first
* {@link #getInitiatorCryptoAttributes()}) based on the peer's first
* matching cipher suite.
* matching cipher suite.
*
*
* @param peerAttributes The peer's crypto offers.
* @param peerAttributes The peer's crypto offers.
* @return A SrtpCryptoAttribute when a matching cipher suite was found;
* @return A SrtpCryptoAttribute when a matching cipher suite was found;
* <tt>null</tt>, otherwise.
* <tt>null</tt>, otherwise.
*/
*/
public
SrtpCryptoAttribute
initiatorSelectAttribute
(
public
SrtpCryptoAttribute
initiatorSelectAttribute
(
Iterable
<
SrtpCryptoAttribute
>
peerAttributes
)
Iterable
<
SrtpCryptoAttribute
>
peerAttributes
)
{
{
for
(
SrtpCryptoAttribute
peerCA
:
peerAttributes
)
for
(
SrtpCryptoAttribute
peerCA
:
peerAttributes
)
{
{
for
(
SrtpCryptoAttribute
localCA
:
attributes
)
for
(
SrtpCryptoAttribute
localCA
:
attributes
)
{
{
if
(
localCA
.
getCryptoSuite
().
equals
(
peerCA
.
getCryptoSuite
()))
if
(
localCA
.
getCryptoSuite
().
equals
(
peerCA
.
getCryptoSuite
()))
{
{
selectedInAttribute
=
peerCA
;
selectedInAttribute
=
peerCA
;
selectedOutAttribute
=
localCA
;
selectedOutAttribute
=
localCA
;
return
peerCA
;
return
peerCA
;
}
}
}
}
}
}
return
null
;
return
null
;
}
}
/**
/**
* Returns <tt>true</tt>, SDES always requires the secure transport of its
* Returns <tt>true</tt>, SDES always requires the secure transport of its
* keys.
* keys.
*
*
* @return <tt>true</tt>
* @return <tt>true</tt>
*/
*/
public
boolean
requiresSecureSignalingTransport
()
public
boolean
requiresSecureSignalingTransport
()
{
{
return
true
;
return
true
;
}
}
/**
/**
* Chooses a supported crypto attribute from the peer's list of supplied
* Chooses a supported crypto attribute from the peer's list of supplied
* attributes and creates the local crypto attribute. Used when the control
* attributes and creates the local crypto attribute. Used when the control
* is running in the role as responder.
* is running in the role as responder.
*
*
* @param peerAttributes The peer's crypto attribute offering.
* @param peerAttributes The peer's crypto attribute offering.
* @return The local crypto attribute for the answer of the offer or
* @return The local crypto attribute for the answer of the offer or
* <tt>null</tt> if no matching cipher suite could be found.
* <tt>null</tt> if no matching cipher suite could be found.
*/
*/
public
SrtpCryptoAttribute
responderSelectAttribute
(
public
SrtpCryptoAttribute
responderSelectAttribute
(
Iterable
<
SrtpCryptoAttribute
>
peerAttributes
)
Iterable
<
SrtpCryptoAttribute
>
peerAttributes
)
{
{
for
(
SrtpCryptoAttribute
ea
:
peerAttributes
)
for
(
SrtpCryptoAttribute
ea
:
peerAttributes
)
{
{
for
(
String
suite
:
enabledCryptoSuites
)
for
(
String
suite
:
enabledCryptoSuites
)
{
{
if
(
suite
.
equals
(
ea
.
getCryptoSuite
().
encode
()))
if
(
suite
.
equals
(
ea
.
getCryptoSuite
().
encode
()))
{
{
selectedInAttribute
=
ea
;
selectedInAttribute
=
ea
;
selectedOutAttribute
selectedOutAttribute
=
sdesFactory
.
createCryptoAttribute
(
1
,
suite
);
=
sdesFactory
.
createCryptoAttribute
(
1
,
suite
);
return
selectedOutAttribute
;
return
selectedOutAttribute
;
}
}
}
}
}
}
return
null
;
return
null
;
}
}
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*
*
* The implementation of <tt>SDesControlImpl</tt> does nothing because
* The implementation of <tt>SDesControlImpl</tt> does nothing because
* <tt>SDesControlImpl</tt> does not utilize the <tt>RTPConnector</tt>.
* <tt>SDesControlImpl</tt> does not utilize the <tt>RTPConnector</tt>.
*/
*/
public
void
setConnector
(
AbstractRTPConnector
connector
)
public
void
setConnector
(
AbstractRTPConnector
connector
)
{
{
}
}
public
void
setEnabledCiphers
(
Iterable
<
String
>
ciphers
)
public
void
setEnabledCiphers
(
Iterable
<
String
>
ciphers
)
{
{
enabledCryptoSuites
.
clear
();
enabledCryptoSuites
.
clear
();
for
(
String
c
:
ciphers
)
for
(
String
c
:
ciphers
)
enabledCryptoSuites
.
add
(
c
);
enabledCryptoSuites
.
add
(
c
);
}
}
public
void
start
(
MediaType
mediaType
)
public
void
start
(
MediaType
mediaType
)
{
{
SrtpListener
srtpListener
=
getSrtpListener
();
SrtpListener
srtpListener
=
getSrtpListener
();
// in srtp the started and security event is one after another in some
// in srtp the started and security event is one after another in some
// other security mechanisms (e.g. zrtp) there can be started and no
// other security mechanisms (e.g. zrtp) there can be started and no
// security one or security timeout event
// security one or security timeout event
srtpListener
.
securityNegotiationStarted
(
mediaType
,
this
);
srtpListener
.
securityNegotiationStarted
(
mediaType
,
this
);
srtpListener
.
securityTurnedOn
(
srtpListener
.
securityTurnedOn
(
mediaType
,
mediaType
,
selectedInAttribute
.
getCryptoSuite
().
encode
(),
selectedInAttribute
.
getCryptoSuite
().
encode
(),
this
);
this
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment