本文整理汇总了Java中org.whispersystems.libaxolotl.IdentityKeyPair类的典型用法代码示例。如果您正苦于以下问题:Java IdentityKeyPair类的具体用法?Java IdentityKeyPair怎么用?Java IdentityKeyPair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IdentityKeyPair类属于org.whispersystems.libaxolotl包,在下文中一共展示了IdentityKeyPair类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handleCommonRegistration
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
private void handleCommonRegistration(MasterSecret masterSecret, TextSecureAccountManager accountManager, String number)
throws IOException
{
setState(new RegistrationState(RegistrationState.STATE_GENERATING_KEYS, number));
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(this, masterSecret);
List<PreKeyRecord> records = PreKeyUtil.generatePreKeys(this, masterSecret);
PreKeyRecord lastResort = PreKeyUtil.generateLastResortKey(this, masterSecret);
SignedPreKeyRecord signedPreKey = PreKeyUtil.generateSignedPreKey(this, masterSecret, identityKey);
accountManager.setPreKeys(identityKey.getPublicKey(),lastResort, signedPreKey, records);
setState(new RegistrationState(RegistrationState.STATE_GCM_REGISTERING, number));
String gcmRegistrationId = GoogleCloudMessaging.getInstance(this).register(GcmRefreshJob.REGISTRATION_ID);
TextSecurePreferences.setGcmRegistrationId(this, gcmRegistrationId);
accountManager.setGcmId(Optional.of(gcmRegistrationId));
DirectoryHelper.refreshDirectory(this, accountManager, number);
DirectoryRefreshListener.schedule(this);
}
开发者ID:redcracker,项目名称:TextSecure,代码行数:21,代码来源:RegistrationService.java
示例2: getIdentityKeyPair
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
public static IdentityKeyPair getIdentityKeyPair(Context context,
MasterSecret masterSecret)
{
if (!hasIdentityKey(context))
return null;
try {
MasterCipher masterCipher = new MasterCipher(masterSecret);
IdentityKey publicKey = getIdentityKey(context);
ECPrivateKey privateKey = masterCipher.decryptKey(Base64.decode(retrieve(context, IDENTITY_PRIVATE_KEY_DJB_PREF)));
return new IdentityKeyPair(publicKey, privateKey);
} catch (IOException | InvalidKeyException e) {
throw new AssertionError(e);
}
}
开发者ID:redcracker,项目名称:TextSecure,代码行数:17,代码来源:IdentityKeyUtil.java
示例3: generateSignedPreKey
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
public static SignedPreKeyRecord generateSignedPreKey(Context context, MasterSecret masterSecret,
IdentityKeyPair identityKeyPair)
{
try {
SignedPreKeyStore signedPreKeyStore = new TextSecurePreKeyStore(context, masterSecret);
int signedPreKeyId = getNextSignedPreKeyId(context);
ECKeyPair keyPair = Curve25519.generateKeyPair();
byte[] signature = Curve.calculateSignature(identityKeyPair.getPrivateKey(), keyPair.getPublicKey().serialize());
SignedPreKeyRecord record = new SignedPreKeyRecord(signedPreKeyId, System.currentTimeMillis(), keyPair, signature);
signedPreKeyStore.storeSignedPreKey(signedPreKeyId, record);
setNextSignedPreKeyId(context, (signedPreKeyId + 1) % Medium.MAX_VALUE);
return record;
} catch (InvalidKeyException e) {
throw new AssertionError(e);
}
}
开发者ID:redcracker,项目名称:TextSecure,代码行数:19,代码来源:PreKeyUtil.java
示例4: onRun
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws IOException {
if (!TextSecurePreferences.isPushRegistered(context)) return;
int availableKeys = accountManager.getPreKeysCount();
if (availableKeys >= PREKEY_MINIMUM && TextSecurePreferences.isSignedPreKeyRegistered(context)) {
Log.w(TAG, "Available keys sufficient: " + availableKeys);
return;
}
List<PreKeyRecord> preKeyRecords = PreKeyUtil.generatePreKeys(context, masterSecret);
PreKeyRecord lastResortKeyRecord = PreKeyUtil.generateLastResortKey(context, masterSecret);
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(context, masterSecret);
SignedPreKeyRecord signedPreKeyRecord = PreKeyUtil.generateSignedPreKey(context, masterSecret, identityKey);
Log.w(TAG, "Registering new prekeys...");
accountManager.setPreKeys(identityKey.getPublicKey(), lastResortKeyRecord, signedPreKeyRecord, preKeyRecords);
TextSecurePreferences.setSignedPreKeyRegistered(context, true);
ApplicationContext.getInstance(context)
.getJobManager()
.add(new CleanPreKeysJob(context));
}
开发者ID:redcracker,项目名称:TextSecure,代码行数:27,代码来源:RefreshPreKeysJob.java
示例5: handleCommonRegistration
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
private void handleCommonRegistration(MasterSecret masterSecret, TextSecureAccountManager accountManager, String number)
throws IOException
{
setState(new RegistrationState(RegistrationState.STATE_GENERATING_KEYS, number));
Recipient self = RecipientFactory.getRecipientsFromString(this, number, false).getPrimaryRecipient();
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(this, masterSecret);
List<PreKeyRecord> records = PreKeyUtil.generatePreKeys(this, masterSecret);
PreKeyRecord lastResort = PreKeyUtil.generateLastResortKey(this, masterSecret);
SignedPreKeyRecord signedPreKey = PreKeyUtil.generateSignedPreKey(this, masterSecret, identityKey);
accountManager.setPreKeys(identityKey.getPublicKey(),lastResort, signedPreKey, records);
setState(new RegistrationState(RegistrationState.STATE_GCM_REGISTERING, number));
String gcmRegistrationId = GoogleCloudMessaging.getInstance(this).register(GcmRefreshJob.REGISTRATION_ID);
accountManager.setGcmId(Optional.of(gcmRegistrationId));
TextSecurePreferences.setGcmRegistrationId(this, gcmRegistrationId);
TextSecurePreferences.setWebsocketRegistered(this, true);
DatabaseFactory.getIdentityDatabase(this).saveIdentity(masterSecret, self.getRecipientId(), identityKey.getPublicKey());
DirectoryHelper.refreshDirectory(this, accountManager, number);
DirectoryRefreshListener.schedule(this);
}
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:25,代码来源:RegistrationService.java
示例6: generateSignedPreKey
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
public static SignedPreKeyRecord generateSignedPreKey(Context context, MasterSecret masterSecret,
IdentityKeyPair identityKeyPair)
{
try {
SignedPreKeyStore signedPreKeyStore = new TextSecurePreKeyStore(context, masterSecret);
int signedPreKeyId = getNextSignedPreKeyId(context);
ECKeyPair keyPair = Curve.generateKeyPair();
byte[] signature = Curve.calculateSignature(identityKeyPair.getPrivateKey(), keyPair.getPublicKey().serialize());
SignedPreKeyRecord record = new SignedPreKeyRecord(signedPreKeyId, System.currentTimeMillis(), keyPair, signature);
signedPreKeyStore.storeSignedPreKey(signedPreKeyId, record);
setNextSignedPreKeyId(context, (signedPreKeyId + 1) % Medium.MAX_VALUE);
return record;
} catch (InvalidKeyException e) {
throw new AssertionError(e);
}
}
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:19,代码来源:PreKeyUtil.java
示例7: setPendingKeyExchange
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
public void setPendingKeyExchange(int sequence,
ECKeyPair ourBaseKey,
ECKeyPair ourRatchetKey,
IdentityKeyPair ourIdentityKey)
{
PendingKeyExchange structure =
PendingKeyExchange.newBuilder()
.setSequence(sequence)
.setLocalBaseKey(ByteString.copyFrom(ourBaseKey.getPublicKey().serialize()))
.setLocalBaseKeyPrivate(ByteString.copyFrom(ourBaseKey.getPrivateKey().serialize()))
.setLocalRatchetKey(ByteString.copyFrom(ourRatchetKey.getPublicKey().serialize()))
.setLocalRatchetKeyPrivate(ByteString.copyFrom(ourRatchetKey.getPrivateKey().serialize()))
.setLocalIdentityKey(ByteString.copyFrom(ourIdentityKey.getPublicKey().serialize()))
.setLocalIdentityKeyPrivate(ByteString.copyFrom(ourIdentityKey.getPrivateKey().serialize()))
.build();
this.sessionStructure = this.sessionStructure.toBuilder()
.setPendingKeyExchange(structure)
.build();
}
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:21,代码来源:SessionState.java
示例8: AliceAxolotlParameters
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
private AliceAxolotlParameters(IdentityKeyPair ourIdentityKey, ECKeyPair ourBaseKey,
IdentityKey theirIdentityKey, ECPublicKey theirSignedPreKey,
ECPublicKey theirRatchetKey, Optional<ECPublicKey> theirOneTimePreKey)
{
this.ourIdentityKey = ourIdentityKey;
this.ourBaseKey = ourBaseKey;
this.theirIdentityKey = theirIdentityKey;
this.theirSignedPreKey = theirSignedPreKey;
this.theirRatchetKey = theirRatchetKey;
this.theirOneTimePreKey = theirOneTimePreKey;
if (ourIdentityKey == null || ourBaseKey == null || theirIdentityKey == null ||
theirSignedPreKey == null || theirRatchetKey == null || theirOneTimePreKey == null)
{
throw new IllegalArgumentException("Null values!");
}
}
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:18,代码来源:AliceAxolotlParameters.java
示例9: SymmetricAxolotlParameters
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
SymmetricAxolotlParameters(ECKeyPair ourBaseKey, ECKeyPair ourRatchetKey,
IdentityKeyPair ourIdentityKey, ECPublicKey theirBaseKey,
ECPublicKey theirRatchetKey, IdentityKey theirIdentityKey)
{
this.ourBaseKey = ourBaseKey;
this.ourRatchetKey = ourRatchetKey;
this.ourIdentityKey = ourIdentityKey;
this.theirBaseKey = theirBaseKey;
this.theirRatchetKey = theirRatchetKey;
this.theirIdentityKey = theirIdentityKey;
if (ourBaseKey == null || ourRatchetKey == null || ourIdentityKey == null ||
theirBaseKey == null || theirRatchetKey == null || theirIdentityKey == null)
{
throw new IllegalArgumentException("Null values!");
}
}
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:18,代码来源:SymmetricAxolotlParameters.java
示例10: BobAxolotlParameters
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
BobAxolotlParameters(IdentityKeyPair ourIdentityKey, ECKeyPair ourSignedPreKey,
ECKeyPair ourRatchetKey, Optional<ECKeyPair> ourOneTimePreKey,
IdentityKey theirIdentityKey, ECPublicKey theirBaseKey)
{
this.ourIdentityKey = ourIdentityKey;
this.ourSignedPreKey = ourSignedPreKey;
this.ourRatchetKey = ourRatchetKey;
this.ourOneTimePreKey = ourOneTimePreKey;
this.theirIdentityKey = theirIdentityKey;
this.theirBaseKey = theirBaseKey;
if (ourIdentityKey == null || ourSignedPreKey == null || ourRatchetKey == null ||
ourOneTimePreKey == null || theirIdentityKey == null || theirBaseKey == null)
{
throw new IllegalArgumentException("Null value!");
}
}
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:18,代码来源:BobAxolotlParameters.java
示例11: handleCommonRegistration
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
private void handleCommonRegistration(MasterSecret masterSecret, TextSecureAccountManager accountManager, String number) throws IOException {
setState(new RegistrationState(RegistrationState.STATE_GENERATING_KEYS, number));
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(this, masterSecret);
List<PreKeyRecord> records = PreKeyUtil.generatePreKeys(this, masterSecret);
PreKeyRecord lastResort = PreKeyUtil.generateLastResortKey(this, masterSecret);
SignedPreKeyRecord signedPreKey = PreKeyUtil.generateSignedPreKey(this, masterSecret, identityKey);
accountManager.setPreKeys(identityKey.getPublicKey(),lastResort, signedPreKey, records);
setState(new RegistrationState(RegistrationState.STATE_GCM_REGISTERING, number));
String gcmRegistrationId = GoogleCloudMessaging.getInstance(this).register("225505072490");
TextSecurePreferences.setGcmRegistrationId(this, gcmRegistrationId);
accountManager.setGcmId(Optional.of(gcmRegistrationId));
DirectoryHelper.refreshDirectory(this, accountManager, number);
DirectoryRefreshListener.schedule(this);
}
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:19,代码来源:RegistrationService.java
示例12: loadIdentityKeyPair
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
private IdentityKeyPair loadIdentityKeyPair() {
IdentityKeyPair ownKey = mXmppConnectionService.databaseBackend.loadOwnIdentityKeyPair(account);
if (ownKey != null) {
return ownKey;
} else {
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Could not retrieve own IdentityKeyPair");
ownKey = generateIdentityKeyPair();
mXmppConnectionService.databaseBackend.storeOwnIdentityKeyPair(account, ownKey);
}
return ownKey;
}
开发者ID:xavierle,项目名称:messengerxmpp,代码行数:13,代码来源:SQLiteAxolotlStore.java
示例13: getIdentityKeyPair
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
/**
* Get the local client's identity key pair.
*
* @return The local client's persistent identity key pair.
*/
@Override
public IdentityKeyPair getIdentityKeyPair() {
if (identityKeyPair == null) {
identityKeyPair = loadIdentityKeyPair();
}
return identityKeyPair;
}
开发者ID:xavierle,项目名称:messengerxmpp,代码行数:13,代码来源:SQLiteAxolotlStore.java
示例14: onRun
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
@Override
public void onRun() throws IOException {
MasterSecret masterSecret = ParcelUtil.deserialize(getEncryptionKeys().getEncoded(), MasterSecret.CREATOR);
if (TextSecurePreferences.isSignedPreKeyRegistered(context)) {
Log.w(TAG, "Signed prekey already registered...");
return;
}
IdentityKeyPair identityKeyPair = IdentityKeyUtil.getIdentityKeyPair(context, masterSecret);
SignedPreKeyRecord signedPreKeyRecord = PreKeyUtil.generateSignedPreKey(context, masterSecret, identityKeyPair);
accountManager.setSignedPreKey(signedPreKeyRecord);
TextSecurePreferences.setSignedPreKeyRegistered(context, true);
}
开发者ID:redcracker,项目名称:TextSecure,代码行数:16,代码来源:CreateSignedPreKeyJob.java
示例15: getIdentityKeyPair
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
@Override
public IdentityKeyPair getIdentityKeyPair() {
try {
final byte[] keyPairBytes = SettingsService.getIdentityKeyPair();
if (keyPairBytes == null) {
return null;
}
return new IdentityKeyPair(keyPairBytes);
} catch (final InvalidKeyException e) {
LOGGER.error("Identity key pair received from database was invalid.", e);
Errors.showError(translate("unexpected_quit"));
Errors.stopApplication();
throw new UnreachableCodeException();
}
}
开发者ID:connorlanigan,项目名称:norvos,代码行数:16,代码来源:IdentityKeyStore.java
示例16: initialize
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
public void initialize(final IdentityKeyPair identityKeyPair, final int signedPreKeyId) {
try {
storeSignedPreKey(signedPreKeyId, KeyHelper.generateSignedPreKey(identityKeyPair, signedPreKeyId));
} catch (final InvalidKeyException e) {
LOGGER.error("Identity key pair for storage in SignedPreKeyStore was invalid.", e);
Errors.showError(translate("unexpected_quit"));
Errors.stopApplication();
throw new UnreachableCodeException();
}
}
开发者ID:connorlanigan,项目名称:norvos,代码行数:11,代码来源:SignedPreKeyStore.java
示例17: initialize
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
/**
* Initialize the Registrator. This will generate new keys, and a new
* installation ID.<br>
* <strong>Warning: All existing user data is possibly destroyed after
* calling this method.</strong>
*/
public static void initialize() {
IdentityKeyStore.getInstance().initialize();
oneTimePreKeys = PreKeyStore.getInstance().initialize();
final IdentityKeyPair identityKeyPair = IdentityKeyStore.getInstance().getIdentityKeyPair();
SignedPreKeyStore.getInstance().initialize(identityKeyPair, initialSignedKeyID);
SettingsService.setPassword(RandomUtils.randomAlphanumerical(passwordLength));
SettingsService.setSignalingKey(RandomUtils.randomAlphanumerical(52));
SettingsService.setInstallID(RandomUtils.generateInstallId());
initialized = true;
}
开发者ID:connorlanigan,项目名称:norvos,代码行数:20,代码来源:Registrator.java
示例18: signedPreKey
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
@Test
public void signedPreKey() throws InvalidKeyException, InvalidKeyIdException {
final Random r = new Random();
final IdentityKeyPair identityKey = KeyHelper.generateIdentityKeyPair();
final SignedPreKeyRecord key = KeyHelper.generateSignedPreKey(identityKey, r.nextInt(Integer.MAX_VALUE));
store.storeSignedPreKey(key.getId(), key);
assertTrue(store.containsSignedPreKey(key.getId()));
assertFalse(store.containsSignedPreKey(key.getId() + 1));
assertArrayEquals(key.serialize(), store.loadSignedPreKey(key.getId()).serialize());
store.removeSignedPreKey(key.getId());
assertFalse(store.containsSignedPreKey(key.getId()));
}
开发者ID:connorlanigan,项目名称:norvos,代码行数:16,代码来源:AxolotlStoreTest.java
示例19: getPendingKeyExchangeIdentityKey
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
public IdentityKeyPair getPendingKeyExchangeIdentityKey() throws InvalidKeyException {
IdentityKey publicKey = new IdentityKey(sessionStructure.getPendingKeyExchange()
.getLocalIdentityKey().toByteArray(), 0);
ECPrivateKey privateKey = Curve.decodePrivatePoint(sessionStructure.getPendingKeyExchange()
.getLocalIdentityKeyPrivate()
.toByteArray());
return new IdentityKeyPair(publicKey, privateKey);
}
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:11,代码来源:SessionState.java
示例20: initializeSessionsV2
import org.whispersystems.libaxolotl.IdentityKeyPair; //导入依赖的package包/类
private void initializeSessionsV2(SessionState aliceSessionState, SessionState bobSessionState)
throws InvalidKeyException
{
ECKeyPair aliceIdentityKeyPair = Curve.generateKeyPair();
IdentityKeyPair aliceIdentityKey = new IdentityKeyPair(new IdentityKey(aliceIdentityKeyPair.getPublicKey()),
aliceIdentityKeyPair.getPrivateKey());
ECKeyPair aliceBaseKey = Curve.generateKeyPair();
ECKeyPair aliceEphemeralKey = Curve.generateKeyPair();
ECKeyPair bobIdentityKeyPair = Curve.generateKeyPair();
IdentityKeyPair bobIdentityKey = new IdentityKeyPair(new IdentityKey(bobIdentityKeyPair.getPublicKey()),
bobIdentityKeyPair.getPrivateKey());
ECKeyPair bobBaseKey = Curve.generateKeyPair();
ECKeyPair bobEphemeralKey = bobBaseKey;
AliceAxolotlParameters aliceParameters = AliceAxolotlParameters.newBuilder()
.setOurIdentityKey(aliceIdentityKey)
.setOurBaseKey(aliceBaseKey)
.setTheirIdentityKey(bobIdentityKey.getPublicKey())
.setTheirSignedPreKey(bobEphemeralKey.getPublicKey())
.setTheirRatchetKey(bobEphemeralKey.getPublicKey())
.setTheirOneTimePreKey(Optional.<ECPublicKey>absent())
.create();
BobAxolotlParameters bobParameters = BobAxolotlParameters.newBuilder()
.setOurIdentityKey(bobIdentityKey)
.setOurOneTimePreKey(Optional.<ECKeyPair>absent())
.setOurRatchetKey(bobEphemeralKey)
.setOurSignedPreKey(bobBaseKey)
.setTheirBaseKey(aliceBaseKey.getPublicKey())
.setTheirIdentityKey(aliceIdentityKey.getPublicKey())
.create();
RatchetingSession.initializeSession(aliceSessionState, 2, aliceParameters);
RatchetingSession.initializeSession(bobSessionState, 2, bobParameters);
}
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:37,代码来源:SessionCipherTest.java
注:本文中的org.whispersystems.libaxolotl.IdentityKeyPair类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论