Java Code Examples for org.whispersystems.libsignal.util.KeyHelper#generateRegistrationId()
The following examples show how to use
org.whispersystems.libsignal.util.KeyHelper#generateRegistrationId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SignalBot.java From signal-bot with GNU General Public License v3.0 | 5 votes |
public void verify(String verificationCode) throws IOException { String username = prefs.get("LOCAL_USERNAME", null); String password = prefs.get("LOCAL_PASSWORD", null); logger.info("Verifying user " + username + " with code " + verificationCode + "..."); String code = verificationCode.replace("-", ""); int registrationId = KeyHelper.generateRegistrationId(false); prefs.putInt("REGISTRATION_ID", registrationId); byte[] profileKey = Util.getSecretBytes(32); byte[] unidentifiedAccessKey = UnidentifiedAccess.deriveAccessKeyFrom(profileKey); accountManager = new SignalServiceAccountManager(config, username, password, USER_AGENT); accountManager.verifyAccountWithCode(code, null, registrationId, true, null, unidentifiedAccessKey, false); }
Example 2
Source File: Manager.java From signald with GNU General Public License v3.0 | 5 votes |
public void createNewIdentity() { IdentityKeyPair identityKey = KeyHelper.generateIdentityKeyPair(); int registrationId = KeyHelper.generateRegistrationId(false); accountData.axolotlStore = new SignalProtocolStore(identityKey, registrationId); accountData.registered = false; accountData.init(); }
Example 3
Source File: ProvisioningManager.java From signal-cli with GNU General Public License v3.0 | 5 votes |
public ProvisioningManager(String settingsPath, SignalServiceConfiguration serviceConfiguration, String userAgent) { this.pathConfig = PathConfig.createDefault(settingsPath); this.serviceConfiguration = serviceConfiguration; this.userAgent = userAgent; identityKey = KeyHelper.generateIdentityKeyPair(); registrationId = KeyHelper.generateRegistrationId(false); password = KeyUtils.createPassword(); final SleepTimer timer = new UptimeSleepTimer(); accountManager = new SignalServiceAccountManager(serviceConfiguration, null, null, password, SignalServiceAddress.DEFAULT_DEVICE_ID, userAgent, timer); }
Example 4
Source File: CodeVerificationRequest.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private static void verifyAccount(@NonNull Context context, @NonNull Credentials credentials, @NonNull String code, @Nullable String pin, @Nullable TokenResponse kbsTokenResponse, @Nullable String kbsStorageCredentials, @Nullable String fcmToken) throws IOException, KeyBackupSystemWrongPinException, KeyBackupSystemNoDataException { boolean isV2RegistrationLock = kbsTokenResponse != null; int registrationId = KeyHelper.generateRegistrationId(false); boolean universalUnidentifiedAccess = TextSecurePreferences.isUniversalUnidentifiedAccess(context); ProfileKey profileKey = findExistingProfileKey(context, credentials.getE164number()); if (profileKey == null) { profileKey = ProfileKeyUtil.createNew(); Log.i(TAG, "No profile key found, created a new one"); } byte[] unidentifiedAccessKey = UnidentifiedAccess.deriveAccessKeyFrom(profileKey); TextSecurePreferences.setLocalRegistrationId(context, registrationId); SessionUtil.archiveAllSessions(context); SignalServiceAccountManager accountManager = AccountManagerFactory.createUnauthenticated(context, credentials.getE164number(), credentials.getPassword()); KbsPinData kbsData = isV2RegistrationLock ? PinState.restoreMasterKey(pin, kbsStorageCredentials, kbsTokenResponse) : null; String registrationLockV2 = kbsData != null ? kbsData.getMasterKey().deriveRegistrationLock() : null; String registrationLockV1 = isV2RegistrationLock ? null : pin; boolean hasFcm = fcmToken != null; Log.i(TAG, "Calling verifyAccountWithCode(): reglockV1? " + !TextUtils.isEmpty(registrationLockV1) + ", reglockV2? " + !TextUtils.isEmpty(registrationLockV2)); VerifyAccountResponse response = accountManager.verifyAccountWithCode(code, null, registrationId, !hasFcm, registrationLockV1, registrationLockV2, unidentifiedAccessKey, universalUnidentifiedAccess, AppCapabilities.getCapabilities(true)); UUID uuid = UuidUtil.parseOrThrow(response.getUuid()); boolean hasPin = response.isStorageCapable(); IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(context); List<PreKeyRecord> records = PreKeyUtil.generatePreKeys(context); SignedPreKeyRecord signedPreKey = PreKeyUtil.generateSignedPreKey(context, identityKey, true); accountManager = AccountManagerFactory.createAuthenticated(context, uuid, credentials.getE164number(), credentials.getPassword()); accountManager.setPreKeys(identityKey.getPublicKey(), signedPreKey, records); if (hasFcm) { accountManager.setGcmId(Optional.fromNullable(fcmToken)); } RecipientDatabase recipientDatabase = DatabaseFactory.getRecipientDatabase(context); RecipientId selfId = recipientDatabase.getOrInsertFromE164(credentials.getE164number()); recipientDatabase.setProfileSharing(selfId, true); recipientDatabase.markRegistered(selfId, uuid); TextSecurePreferences.setLocalNumber(context, credentials.getE164number()); TextSecurePreferences.setLocalUuid(context, uuid); recipientDatabase.setProfileKey(selfId, profileKey); ApplicationDependencies.getRecipientCache().clearSelf(); TextSecurePreferences.setFcmToken(context, fcmToken); TextSecurePreferences.setFcmDisabled(context, !hasFcm); TextSecurePreferences.setWebsocketRegistered(context, true); DatabaseFactory.getIdentityDatabase(context) .saveIdentity(selfId, identityKey.getPublicKey(), IdentityDatabase.VerifiedStatus.VERIFIED, true, System.currentTimeMillis(), true); TextSecurePreferences.setVerifying(context, false); TextSecurePreferences.setPushRegistered(context, true); TextSecurePreferences.setPushServerPassword(context, credentials.getPassword()); TextSecurePreferences.setSignedPreKeyRegistered(context, true); TextSecurePreferences.setPromptedPushRegistration(context, true); TextSecurePreferences.setUnauthorizedReceived(context, false); PinState.onRegistration(context, kbsData, pin, hasPin); }
Example 5
Source File: SQLiteAxolotlStore.java From Pix-Art-Messenger with GNU General Public License v3.0 | 4 votes |
private static int generateRegistrationId() { Log.i(Config.LOGTAG, AxolotlService.LOGPREFIX + " : " + "Generating axolotl registration ID..."); return KeyHelper.generateRegistrationId(true); }
Example 6
Source File: TestInMemorySignalProtocolStore.java From libsignal-protocol-java with GNU General Public License v3.0 | 4 votes |
private static int generateRegistrationId() { return KeyHelper.generateRegistrationId(false); }
Example 7
Source File: TestInMemoryIdentityKeyStore.java From libsignal-protocol-java with GNU General Public License v3.0 | 4 votes |
private static int generateRegistrationId() { return KeyHelper.generateRegistrationId(false); }
Example 8
Source File: SQLiteAxolotlStore.java From Conversations with GNU General Public License v3.0 | 4 votes |
private static int generateRegistrationId() { Log.i(Config.LOGTAG, AxolotlService.LOGPREFIX + " : " + "Generating axolotl registration ID..."); return KeyHelper.generateRegistrationId(true); }