If you think the Android project CipherChat listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.desperate.common.replies;
/*www.java2s.com*/import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
import com.desperate.common.SessionKeyRequestInfo;
import com.desperate.common.Utilities;
/**
* In the "Needham-Shroeder revisited" method lectured, represents the reply that KDC sends to A to get a session key to talk with B. Comes ciphered
* with A's Key Encryption Key.
*
* @author SIRS-RAR
*
*/publicclass SessionKeyReplyMessage extends ReplyMessage {
// Ea( Ra, B, Ks, Eb(A, Rb, Ks) )
/** */privatestaticfinallong serialVersionUID = 7773927354068004172L;
/**
* Contains a #{@link com.desperate.common.SessionKeyRequestInfo SessionKeyRequestInfo} ciphered with the requester's KEK.
*/publicbyte[] cipheredPacket;
public SessionKeyRequestInfo getInfo(SecretKeySpec key) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException,
InvalidAlgorithmParameterException, ClassNotFoundException, IOException {
return (SessionKeyRequestInfo) Utilities.decipherObject(cipheredPacket, key);
}
@Override
public String getStringToHMAC() {
try {
return timestamp + new String(cipheredPacket, Utilities.charset);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
thrownew RuntimeException(e);
}
}
}