mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-30 19:57:45 +00:00
c38a8aa699
1) Generate a Curve25519 identity key. 2) Use Curve25519 ephemerals and identities for v2 3DHE agreements. 3) Initiate v2 key exchange messages. 4) Accept v1 key exchange messages. 5) TOFU Curve25519 identities.
75 lines
2.2 KiB
Java
75 lines
2.2 KiB
Java
/**
|
|
* Copyright (C) 2011 Whisper Systems
|
|
* Copyright (C) 2013 Open Whisper Systems
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package org.thoughtcrime.securesms.crypto;
|
|
|
|
import org.whispersystems.textsecure.crypto.ecc.Curve;
|
|
import org.whispersystems.textsecure.crypto.ecc.ECPrivateKey;
|
|
import org.whispersystems.textsecure.crypto.ecc.ECPublicKey;
|
|
|
|
/**
|
|
* When a user first initializes TextSecure, a few secrets
|
|
* are generated. These are:
|
|
*
|
|
* 1) A 128bit symmetric encryption key.
|
|
* 2) A 160bit symmetric MAC key.
|
|
* 3) An ECC keypair.
|
|
*
|
|
* The first two, along with the ECC keypair's private key, are
|
|
* then encrypted on disk using PBE.
|
|
*
|
|
* This class represents the ECC keypair.
|
|
*
|
|
* @author Moxie Marlinspike
|
|
*
|
|
*/
|
|
|
|
public class AsymmetricMasterSecret {
|
|
|
|
private final ECPublicKey djbPublicKey;
|
|
private final ECPrivateKey djbPrivateKey;
|
|
|
|
private final ECPublicKey nistPublicKey;
|
|
private final ECPrivateKey nistPrivateKey;
|
|
|
|
public AsymmetricMasterSecret(ECPublicKey djbPublicKey, ECPrivateKey djbPrivateKey,
|
|
ECPublicKey nistPublicKey, ECPrivateKey nistPrivateKey)
|
|
{
|
|
this.djbPublicKey = djbPublicKey;
|
|
this.djbPrivateKey = djbPrivateKey;
|
|
this.nistPublicKey = nistPublicKey;
|
|
this.nistPrivateKey = nistPrivateKey;
|
|
}
|
|
|
|
public ECPublicKey getDjbPublicKey() {
|
|
return djbPublicKey;
|
|
}
|
|
|
|
public ECPublicKey getNistPublicKey() {
|
|
return nistPublicKey;
|
|
}
|
|
|
|
public ECPrivateKey getPrivateKey(int type) {
|
|
if (type == Curve.DJB_TYPE) {
|
|
return djbPrivateKey;
|
|
} else {
|
|
return nistPrivateKey;
|
|
}
|
|
}
|
|
|
|
}
|