Package gnu.java.zrtp
Class ZrtpConfigure
- java.lang.Object
-
- gnu.java.zrtp.ZrtpConfigure
-
public class ZrtpConfigure extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static intPREFER_NON_NISTstatic intSTANDARDDefine the algorithm selection policies.
-
Constructor Summary
Constructors Constructor Description ZrtpConfigure()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends Enum<T>>
intaddAlgo(T algo)Add an algorithm to configuration data.<T extends Enum<T>>
intaddAlgoAt(int index, T algo)Add an algorithm to configuration data.intaddAuthLength(ZrtpConstants.SupportedAuthLengths algo)Add a SRTP authentication length to configuration data.intaddAuthLengthAt(int index, ZrtpConstants.SupportedAuthLengths algo)Add a SRTP authentication length to configuration data.intaddHashAlgo(ZrtpConstants.SupportedHashes algo)Add a hash algorithm to configuration data.intaddHashAlgoAt(int index, ZrtpConstants.SupportedHashes algo)Add a hash algorithm to configuration data at defined position.intaddPubKeyAlgo(ZrtpConstants.SupportedPubKeys algo)Add a public key algorithm to configuration data.intaddPubKeyAlgoAt(int index, ZrtpConstants.SupportedPubKeys algo)Add a public key algorithm to configuration data.intaddSasTypeAlgo(ZrtpConstants.SupportedSASTypes algo)Add a SAS type algorithm to configuration data.intaddSasTypeAlgoAt(int index, ZrtpConstants.SupportedSASTypes algo)Add a SAS type algorithm to configuration data.intaddSymCipherAlgo(ZrtpConstants.SupportedSymCiphers algo)Add a symmetric cipher algorithm to configuration data.intaddSymCipherAlgoAt(int index, ZrtpConstants.SupportedSymCiphers algo)Add a symmetric cipher algorithm to configuration data.<T extends Enum<T>>
Iterable<T>algos(T algo)Returns Iterable for SRTP authentication lengths.Iterable<ZrtpConstants.SupportedAuthLengths>authLengths()Returns Iterable for SRTP authentication lengths.voidclear()Clears all configuration data.booleancontainsAuthLength(ZrtpConstants.SupportedAuthLengths length)Check if ZrtpConfigure contains a Auth lengths.<T extends Enum<T>>
booleancontainsAuthLength(T algo)Check if ZrtpConfigure contains an algorithm.booleancontainsCipherAlgo(ZrtpConstants.SupportedSymCiphers cipher)Check if ZrtpConfigure contains a cipher algorithm.booleancontainsHashAlgo(ZrtpConstants.SupportedHashes hash)Check if ZrtpConfigure contains a hash algorithm.booleancontainsPubKeyAlgo(ZrtpConstants.SupportedPubKeys pubkey)Check if ZrtpConfigure contains a Public key algorithm.booleancontainsSasTypeAlgo(ZrtpConstants.SupportedSASTypes sas)Check if ZrtpConfigure contains a SAS algorithm.<T extends Enum<T>>
TgetAlgoAt(int index, T algo)Returns the identifier an algorithm at the given index.ZrtpConstants.SupportedAuthLengthsgetAuthLengthAt(int index)Returns the identifier of the SRTP authentication length at the given index.ZrtpConstants.SupportedHashesgetHashAlgoAt(int index)Returns the identifier of the hash algorithm at the given index.<T extends Enum<T>>
intgetNumConfiguredAlgos(T algo)Returns the number of configured algorithms.intgetNumConfiguredAuthLengths()Returns the number of configured SRTP authentication lengths.intgetNumConfiguredHashes()Returns the number of configured hash algorithms.intgetNumConfiguredPubKeys()Returns the number of configured public key algorithms.intgetNumConfiguredSasTypes()Returns the number of configured SAS type algorithms.intgetNumConfiguredSymCiphers()Returns the number of configured symmetric cipher algorithms.ZrtpConstants.SupportedPubKeysgetPubKeyAlgoAt(int index)Returns the identifier of the public key algorithm at the given index.ZrtpConstants.SupportedSASTypesgetSasTypeAlgoAt(int index)Returns the identifier of the SAS type algorithm at the given index.ZrtpConstants.SupportedSymCiphersgetSymCipherAlgoAt(int index)Returns the identifier of the symmetric cipher algorithm at the given index.Iterable<ZrtpConstants.SupportedHashes>hashes()Returns Iterable for the hashes.booleanisParanoidMode()Check status of paranoid mode.booleanisSasSignature()Check status of SAS signature processing.booleanisTrustedMitM()Check status of trusted MitM processing.Iterable<ZrtpConstants.SupportedPubKeys>publicKeyAlgos()Returns Iterable for public key algorithms.<T extends Enum<T>>
intremoveAlgo(T algo)Remove an algorithm from configuration data.intremoveAuthLength(ZrtpConstants.SupportedAuthLengths algo)Remove a SRTP authentication length from configuration data.intremoveHashAlgo(ZrtpConstants.SupportedHashes algo)Remove a hash algorithm from configuration data.intremovePubKeyAlgo(ZrtpConstants.SupportedPubKeys algo)Remove a public key algorithm from configuration data.intremoveSasTypeAlgo(ZrtpConstants.SupportedSASTypes algo)Remove a SAS type algorithm from configuration data.intremoveSymCipherAlgo(ZrtpConstants.SupportedSymCiphers algo)Remove a symmetric cipher algorithm from configuration data.Iterable<ZrtpConstants.SupportedSASTypes>sasTypes()Returns Iterable for SAS algorithms.voidsetMandatoryOnly()Convenience function that sets the mandatory algorithms only.voidsetMobileConfig()voidsetParanoidMode(boolean yesNo)Enables or disables paranoid mode.voidsetSasSignature(boolean yesNo)Enables or disables SAS signature processing.voidsetStandardConfig()Convenience function that sets a pre-defined standard configuration.voidsetTrustedMitM(boolean yesNo)Enables or disables trusted MitM processing.Iterable<ZrtpConstants.SupportedSymCiphers>symCiphers()Returns Iterable for the symmetric ciphers.
-
-
-
Field Detail
-
STANDARD
public static final int STANDARD
Define the algorithm selection policies.- See Also:
- Constant Field Values
-
PREFER_NON_NIST
public static final int PREFER_NON_NIST
- See Also:
- Constant Field Values
-
-
Method Detail
-
setStandardConfig
public void setStandardConfig()
Convenience function that sets a pre-defined standard configuration. The standard configuration consists of the following algorithms:- Hash: SHA256
- Symmetric Cipher: AES 128, AES 256
- Public Key Algorithm: DH2048, DH3027, Mult
- SAS type: base 32
- SRTP Authentication lengths: 32, 80
-
setMobileConfig
public void setMobileConfig()
-
setMandatoryOnly
public void setMandatoryOnly()
Convenience function that sets the mandatory algorithms only. Mandatory algorithms are:- Hash: SHA256
- Symmetric Cipher: AES 128
- Public Key Algorithm: DH3027, Mult
- SAS type: base 32
- SRTP Authentication lengths: 32, 80
-
clear
public void clear()
Clears all configuration data. This function clears all configuration data. If an application hands over an empty set of configuration data ZRTP does not set any algorithm identifiers in the Hello message. In this case the receiver has to select algorithms from the mandatory set of algorithms.
-
setTrustedMitM
public void setTrustedMitM(boolean yesNo)
Enables or disables trusted MitM processing. For further details of trusted MitM processing refer to ZRTP specification, chapter 7.3- Parameters:
yesNo- If set to true then trusted MitM processing is enabled.
-
isTrustedMitM
public boolean isTrustedMitM()
Check status of trusted MitM processing.- Returns:
- Returns true if trusted MitM processing is enabled.
-
setSasSignature
public void setSasSignature(boolean yesNo)
Enables or disables SAS signature processing. For further details of trusted MitM processing refer to ZRTP specification, chapter 7.2- Parameters:
yesNo- If set to true then certificate processing is enabled.
-
isSasSignature
public boolean isSasSignature()
Check status of SAS signature processing.- Returns:
- Returns true if certificate processing is enabled.
-
setParanoidMode
public void setParanoidMode(boolean yesNo)
Enables or disables paranoid mode. For further explanation of paranoid mode refer to the documentation of ZRtp class.- Parameters:
yesNo- If set to true then paranoid mode is enabled.
-
isParanoidMode
public boolean isParanoidMode()
Check status of paranoid mode.- Returns:
- Returns true if paranoid mode is enabled.
-
addHashAlgo
public int addHashAlgo(ZrtpConstants.SupportedHashes algo)
Add a hash algorithm to configuration data. Adds the specified hash algorithm to the configuration data. If no free configuration data slot is available the function does not add the algorithm and return zero.- Parameters:
algo- The identifier of the hash algorithm to add.- Returns:
- Number of free hash configuration data slots.
-
addHashAlgoAt
public int addHashAlgoAt(int index, ZrtpConstants.SupportedHashes algo)Add a hash algorithm to configuration data at defined position. Adds the specified hash algorithm to the configuration data.- Parameters:
algo- The identifier of the hash algorithm to add.index- The index into the configuration data- Returns:
- Number of free hash configuration data slots.
-
removeHashAlgo
public int removeHashAlgo(ZrtpConstants.SupportedHashes algo)
Remove a hash algorithm from configuration data. Removes the specified algorithm from hash configuration data. If the algorithm was not configured previously the function does not modify the configuration data and return the number of free configuration data slots. If an application removes all algorithms then ZRTP does not include any algorithm into the hello message and falls back to a predefined mandatory algorithm. In this case SHA256.- Parameters:
algo- The identifier of the hash algorithm to remove.- Returns:
- Number of free hash configuration slots.
-
getNumConfiguredHashes
public int getNumConfiguredHashes()
Returns the number of configured hash algorithms.- Returns:
- The number of configured hash algorithms (used configuration data slots)
-
getHashAlgoAt
public ZrtpConstants.SupportedHashes getHashAlgoAt(int index)
Returns the identifier of the hash algorithm at the given index. If the index does not point to a configured slot then the function returns the valueEndSupportedHashes.
-
hashes
public Iterable<ZrtpConstants.SupportedHashes> hashes()
Returns Iterable for the hashes. Use this in for-each loop such asfor (ZrtpConstants.SupportedHashes sh: config.hashes()) {- Returns:
- The hash Iterable.
-
containsHashAlgo
public boolean containsHashAlgo(ZrtpConstants.SupportedHashes hash)
Check if ZrtpConfigure contains a hash algorithm.- Returns:
- True if ZrtpConfigure contains the algorithm.
-
addSymCipherAlgo
public int addSymCipherAlgo(ZrtpConstants.SupportedSymCiphers algo)
Add a symmetric cipher algorithm to configuration data. Adds the specified cipher algorithm to the configuration data. If no free configuration data slot is available the function does not add the algorithm and return zero.- Parameters:
algo- The identifier of the cipher algorithm to add.- Returns:
- Number of free cipher configuration data slots.
-
addSymCipherAlgoAt
public int addSymCipherAlgoAt(int index, ZrtpConstants.SupportedSymCiphers algo)Add a symmetric cipher algorithm to configuration data. Adds the specified cipher algorithm to the configuration data.- Parameters:
algo- The identifier of the cipher algorithm to add.index- The index into the configuration data- Returns:
- Number of free cipher configuration data slots.
-
removeSymCipherAlgo
public int removeSymCipherAlgo(ZrtpConstants.SupportedSymCiphers algo)
Remove a symmetric cipher algorithm from configuration data. Removes the specified algorithm from cipher configuration data. If the algorithm was not configured previously the function does not modify the configuration data and return the number of free configuration data slots. If an application removes all algorithms then ZRTP does not include any algorithm into the hello message and falls back to a predefined mandatory algorithm. In this case AES 128.- Parameters:
algo- The identifier of the cipher algorithm to remove.- Returns:
- Number of free cipher configuration slots.
-
getNumConfiguredSymCiphers
public int getNumConfiguredSymCiphers()
Returns the number of configured symmetric cipher algorithms.- Returns:
- The number of configured cipher algorithms (used configuration data slots)
-
getSymCipherAlgoAt
public ZrtpConstants.SupportedSymCiphers getSymCipherAlgoAt(int index)
Returns the identifier of the symmetric cipher algorithm at the given index. If the index does not point to a configured slot then the function returns the valueEndSupportedSymCiphers.
-
symCiphers
public Iterable<ZrtpConstants.SupportedSymCiphers> symCiphers()
Returns Iterable for the symmetric ciphers. Use this in for-each loop such asfor (ZrtpConstants.SupportedHashes sh: config.symCiphers()) {- Returns:
- The symCiphers Iterable.
-
containsCipherAlgo
public boolean containsCipherAlgo(ZrtpConstants.SupportedSymCiphers cipher)
Check if ZrtpConfigure contains a cipher algorithm.- Returns:
- True if ZrtpConfigure contains the algorithm.
-
addPubKeyAlgo
public int addPubKeyAlgo(ZrtpConstants.SupportedPubKeys algo)
Add a public key algorithm to configuration data. Adds the specified public key algorithm to the configuration data. If no free configuration data slot is available the function does not add the algorithm and return zero.- Parameters:
algo- The identifier of the public key algorithm to add.- Returns:
- Number of free public key configuration data slots.
-
addPubKeyAlgoAt
public int addPubKeyAlgoAt(int index, ZrtpConstants.SupportedPubKeys algo)Add a public key algorithm to configuration data. Adds the specified public key algorithm to the configuration data.- Parameters:
algo- The identifier of the public key algorithm to add.index- The index into the configuration data- Returns:
- Number of free public key configuration data slots.
-
removePubKeyAlgo
public int removePubKeyAlgo(ZrtpConstants.SupportedPubKeys algo)
Remove a public key algorithm from configuration data. Removes the specified algorithm from public key configuration data. If the algorithm was not configured previously the function does not modify the configuration data and return the number of free configuration data slots.- Parameters:
algo- The identifier of the public key algorithm to remove.- Returns:
- Number of free public key configuration slots.
-
getNumConfiguredPubKeys
public int getNumConfiguredPubKeys()
Returns the number of configured public key algorithms.- Returns:
- The number of configured public key algorithms (used configuration data slots)
-
getPubKeyAlgoAt
public ZrtpConstants.SupportedPubKeys getPubKeyAlgoAt(int index)
Returns the identifier of the public key algorithm at the given index. If the index does not point to a configured slot then the function returns the valueEndSupportedPubKeys.
-
publicKeyAlgos
public Iterable<ZrtpConstants.SupportedPubKeys> publicKeyAlgos()
Returns Iterable for public key algorithms. Use this in for-each loop such asfor (ZrtpConstants.SupportedHashes sh: config.publicKeyAlgos()) {- Returns:
- The publicKeyAlgos Iterable.
-
containsPubKeyAlgo
public boolean containsPubKeyAlgo(ZrtpConstants.SupportedPubKeys pubkey)
Check if ZrtpConfigure contains a Public key algorithm.- Returns:
- True if ZrtpConfigure contains the algorithm.
-
addSasTypeAlgo
public int addSasTypeAlgo(ZrtpConstants.SupportedSASTypes algo)
Add a SAS type algorithm to configuration data. Adds the specified SAS type algorithm to the configuration data. If no free configuration data slot is available the function does not add the algorithm and return zero.- Parameters:
algo- The identifier of the SAS type algorithm to add.- Returns:
- Number of free SAS type configuration data slots.
-
addSasTypeAlgoAt
public int addSasTypeAlgoAt(int index, ZrtpConstants.SupportedSASTypes algo)Add a SAS type algorithm to configuration data. Adds the specified SAS type algorithm to the configuration data.- Parameters:
algo- The identifier of the SAS type algorithm to add.index- The index into the configuration data- Returns:
- Number of free SAS type configuration data slots.
-
removeSasTypeAlgo
public int removeSasTypeAlgo(ZrtpConstants.SupportedSASTypes algo)
Remove a SAS type algorithm from configuration data. Removes the specified algorithm from SAS type configuration data. If the algorithm was not configured previously the function does not modify the configuration data and return the number of free configuration data slots. If an application removes all algorithms then ZRTP does not include any algorithm into the hello message and falls back to a predefined mandatory algorithm. In this case base 32.- Parameters:
algo- The identifier of the SAS type algorithm to remove.- Returns:
- Number of free SAS type configuration slots.
-
getNumConfiguredSasTypes
public int getNumConfiguredSasTypes()
Returns the number of configured SAS type algorithms.- Returns:
- The number of configured SAS type algorithms (used configuration data slots)
-
getSasTypeAlgoAt
public ZrtpConstants.SupportedSASTypes getSasTypeAlgoAt(int index)
Returns the identifier of the SAS type algorithm at the given index. If the index does not point to a configured slot then the function returns the valueEndSupportedSASTypes.
-
sasTypes
public Iterable<ZrtpConstants.SupportedSASTypes> sasTypes()
Returns Iterable for SAS algorithms. Use this in for-each loop such asfor (ZrtpConstants.SupportedHashes sh: config.sasTypes()) {- Returns:
- The sasTypes Iterable.
-
containsSasTypeAlgo
public boolean containsSasTypeAlgo(ZrtpConstants.SupportedSASTypes sas)
Check if ZrtpConfigure contains a SAS algorithm.- Returns:
- True if ZrtpConfigure contains the algorithm.
-
addAuthLength
public int addAuthLength(ZrtpConstants.SupportedAuthLengths algo)
Add a SRTP authentication length to configuration data. Adds the specified SRTP authentication length to the configuration data. If no free configuration data slot is available the function does not add the algorithm and return zero.- Parameters:
algo- The identifier of the SRTP authentication length to add.- Returns:
- Number of free SRTP authentication length configuration data slots.
-
addAuthLengthAt
public int addAuthLengthAt(int index, ZrtpConstants.SupportedAuthLengths algo)Add a SRTP authentication length to configuration data. Adds the specified SRTP authentication length to the configuration data. If no free configuration data slot is available the function does not add the algorithm and return zero.- Parameters:
algo- The identifier of the SRTP authentication length to add.index- The index into the configuration data- Returns:
- Number of free SRTP authentication length configuration data slots.
-
removeAuthLength
public int removeAuthLength(ZrtpConstants.SupportedAuthLengths algo)
Remove a SRTP authentication length from configuration data. Removes the specified algorithm from SRTP authentication length configuration data. If the algorithm was not configured previously the function does not modify the configuration data and returns the number of free configuration data slots. If an application removes all algorithms then ZRTP does not include any algorithm into the hello message and falls back to a predefined mandatory algorithm. In this case length 32.- Parameters:
algo- The identifier of the SRTP authentication length to remove.- Returns:
- Number of free SRTP authentication length configuration slots.
-
getNumConfiguredAuthLengths
public int getNumConfiguredAuthLengths()
Returns the number of configured SRTP authentication lengths.- Returns:
- The number of configured SRTP authentication lengths (used configuration data slots)
-
getAuthLengthAt
public ZrtpConstants.SupportedAuthLengths getAuthLengthAt(int index)
Returns the identifier of the SRTP authentication length at the given index. If the index does not point to a configured slot then the function returns the valueEndSupportedAuthLength.
-
authLengths
public Iterable<ZrtpConstants.SupportedAuthLengths> authLengths()
Returns Iterable for SRTP authentication lengths. Use this in for-each loop such asfor (ZrtpConstants.SupportedHashes sh: config.authLengths()) {- Returns:
- The authLengths Iterable.
-
containsAuthLength
public boolean containsAuthLength(ZrtpConstants.SupportedAuthLengths length)
Check if ZrtpConfigure contains a Auth lengths.- Returns:
- True if ZrtpConfigure contains the algorithm.
-
addAlgo
public <T extends Enum<T>> int addAlgo(T algo)
Add an algorithm to configuration data. Adds an length to the configuration data. The function determines which table to access based on the declaring class of the parameter. If no free configuration data slot is available the function does not add the algorithm and return zero.- Parameters:
algo- The identifier of the algorithm to add.- Returns:
- Number of free SRTP authentication length configuration data slots.
-
addAlgoAt
public <T extends Enum<T>> int addAlgoAt(int index, T algo)
Add an algorithm to configuration data. Adds an length to the configuration data. The function determines which table to access based on the declaring class of the parameter. If no free configuration data slot is available the function does not add the algorithm and return zero.- Parameters:
algo- The identifier of the algorithm to add.index- The index into the configuration data- Returns:
- Number of free algorithm configuration data slots.
-
removeAlgo
public <T extends Enum<T>> int removeAlgo(T algo)
Remove an algorithm from configuration data. Removes an length to the configuration data. The function determines which table to access based on the declaring class of the parameter. If the algorithm was not configured previously the function does not modify the configuration data and returns the number of free configuration data slots. If an application removes all algorithms then ZRTP does not include any algorithm into the hello message and falls back to a predefined mandatory algorithm. In this case length 32.- Parameters:
algo- The identifier of the algorithm to remove.- Returns:
- Number of free algorithm configuration slots.
-
getNumConfiguredAlgos
public <T extends Enum<T>> int getNumConfiguredAlgos(T algo)
Returns the number of configured algorithms. The function determines which table to access based on the declaring class of the parameter.- Parameters:
algo- The identifier of the algorithm. Used only to identify configure data.
-
getAlgoAt
public <T extends Enum<T>> T getAlgoAt(int index, T algo)
Returns the identifier an algorithm at the given index. The function determines which table to access based on the declaring class of the parameter.- Parameters:
index- The index into the configuration data.algo- The identifier of the algorithm to get. Used only to identify configure data.- Returns:
- If the index does not point to a configured slot then the function returns null, otherwise the algorithm at that index.
-
algos
public <T extends Enum<T>> Iterable<T> algos(T algo)
Returns Iterable for SRTP authentication lengths. Use this in for-each loop such asfor (ZrtpConstants.SupportedHashes sh: config.authLengths()) {- Parameters:
algo- The identifier of the algorithm to get.- Returns:
- The authLengths Iterable.
-
containsAuthLength
public <T extends Enum<T>> boolean containsAuthLength(T algo)
Check if ZrtpConfigure contains an algorithm.- Returns:
- True if ZrtpConfigure contains the algorithm.
-
-