use of im.actor.runtime.crypto.ratchet.RatchetPublicKey in project actor-platform by actorapp.
the class SessionManagerActor method spawnSession.
/**
* Spawn new session
*
* @param uid user's id
* @param ownKeyGroup own key group id
* @param theirKeyGroup their key group Id
* @param ownIdentity own identity private key
* @param theirIdentity their identity public key
* @param ownPreKey own pre key
* @param theirPreKey their pre key
* @return spawned session
*/
private PeerSession spawnSession(int uid, int ownKeyGroup, int theirKeyGroup, PrivateKey ownIdentity, PublicKey theirIdentity, PrivateKey ownPreKey, PublicKey theirPreKey) {
//
// Calculating Master Secret
//
byte[] masterSecret = RatchetMasterSecret.calculateMasterSecret(new RatchetPrivateKey(ownIdentity.getKey()), new RatchetPrivateKey(ownPreKey.getKey()), new RatchetPublicKey(theirIdentity.getPublicKey()), new RatchetPublicKey(theirPreKey.getPublicKey()));
//
// Building Session
//
PeerSession peerSession = new PeerSession(RandomUtils.nextRid(), uid, ownKeyGroup, theirKeyGroup, ownPreKey.getKeyId(), theirPreKey.getKeyId(), masterSecret);
//
// Saving session in sessions storage
//
PeerSessionsStorage sessionsStorage = peerSessions.getValue(uid);
if (sessionsStorage == null) {
sessionsStorage = new PeerSessionsStorage(uid, new ArrayList<PeerSession>());
}
sessionsStorage = sessionsStorage.addSession(peerSession);
peerSessions.addOrUpdateItem(sessionsStorage);
return peerSession;
}
Aggregations