Package tigase.util
Class Algorithms
java.lang.Object
tigase.util.Algorithms
Describe class Algorithms here.
Created: Wed May 4 13:24:03 2005
- Version:
- $Rev$
- Author:
- Artur Hefczyc
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Describemain
method here.static final String
bytesToHex
(byte[] buff) static final byte[]
static String
generateDialbackKey
(String originatingServer, String receivingServer, String secret, String streamID) Calculates dialback key as decribed in XEP-0185 version 1.0.static final String
This method encodes data using digest algorithm described in JEP-0078 documentation.static String
Calculates SHA-256 hash of given data.
-
Method Details
-
$main
Describemain
method here.- Parameters:
args
- aString[]
value- Throws:
Exception
-
bytesToHex
-
digest
public static final byte[] digest(String id, String secret, String alg) throws NoSuchAlgorithmException - Throws:
NoSuchAlgorithmException
-
generateDialbackKey
public static String generateDialbackKey(String originatingServer, String receivingServer, String secret, String streamID) Calculates dialback key as decribed in XEP-0185 version 1.0.
Implemented algorithm (recomended in XEP-0185):
key = HMAC-SHA256 ( SHA256(Secret), { Receiving Server, ' ', Originating Server, ' ', Stream ID } )
- Parameters:
originatingServer
- the hostname of the Originating ServerreceivingServer
- the hostname of the Receiving Serversecret
- a secret known by the Authoritative Server's networkstreamID
- the Stream ID generated by the Receiving Server- Returns:
- string contains HEX encoded dialback key.
-
hexDigest
public static final String hexDigest(String id, String secret, String alg) throws NoSuchAlgorithmException This method encodes data using digest algorithm described in JEP-0078 documentation. As a result you haveString
containing digest data which can be compared with data sent by the user to authenticate him.- Parameters:
id
- aString
value of some ID value like session ID to concatenate with secret word.secret
- aString
value of a secret word shared between entites.alg
- aString
value of algorithm name to use for generating diffest message.- Returns:
- a
String
value digest message as defined. - Throws:
NoSuchAlgorithmException
- if an error occurs during encoding digest message.
-
sha256
Calculates SHA-256 hash of given data.- Parameters:
data
- data to hash- Returns:
- string contains HEX encoded SHA-256 of data.
-