Search in sources :

Example 6 with HashedPin

use of org.whispersystems.signalservice.api.kbs.HashedPin in project Signal-Android by WhisperSystems.

the class PinHashing_hashPin_Test method argon2_hashed_pin_password_with_just_non_arabic_numerals.

@Test
public void argon2_hashed_pin_password_with_just_non_arabic_numerals() throws IOException {
    String pin = " ६१८ ";
    byte[] backupId = Hex.fromStringCondensed("717dc111a98423a57196512606822fca646c653facd037c10728f14ba0be2ab3");
    MasterKey masterKey = new MasterKey(Hex.fromStringCondensed("0432d735b32f66d0e3a70d4f9cc821a8529521a4937d26b987715d8eff4e4c54"));
    HashedPin hashedPin = PinHashing.hashPin(pin, () -> backupId);
    KbsData kbsData = hashedPin.createNewKbsData(masterKey);
    assertArrayEquals(hashedPin.getKbsAccessKey(), kbsData.getKbsAccessKey());
    assertArrayEquals(Hex.fromStringCondensed("d2fedabd0d4c17a371491c9722578843a26be3b4923e28d452ab2fc5491e794b"), kbsData.getKbsAccessKey());
    assertArrayEquals(Hex.fromStringCondensed("877ef871ef1fc668401c717ef21aa12e8523579fb1ff4474b76f28c2293537c80cc7569996c9e0229bea7f378e3a824e"), kbsData.getCipherText());
    assertEquals(masterKey, kbsData.getMasterKey());
    assertEquals("23a75cb1df1a87df45cc2ed167c2bdc85ab1220b847c88761b0005cac907fce5", kbsData.getMasterKey().deriveRegistrationLock());
    String localPinHash = PinHashing.localPinHash(pin);
    assertTrue(PinHashing.verifyLocalPinHash(localPinHash, pin));
}
Also used : KbsData(org.whispersystems.signalservice.api.kbs.KbsData) MasterKey(org.whispersystems.signalservice.api.kbs.MasterKey) HashedPin(org.whispersystems.signalservice.api.kbs.HashedPin) Test(org.junit.Test)

Example 7 with HashedPin

use of org.whispersystems.signalservice.api.kbs.HashedPin in project Signal-Android by WhisperSystems.

the class PinHashing_hashPin_Test method argon2_hashed_pin_another_password.

@Test
public void argon2_hashed_pin_another_password() throws IOException {
    String pin = "anotherpassword";
    byte[] backupId = Hex.fromStringCondensed("202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f");
    MasterKey masterKey = new MasterKey(Hex.fromStringCondensed("88a787415a2ecd79da0d1016a82a27c5c695c9a19b88b0aa1d35683280aa9a67"));
    HashedPin hashedPin = PinHashing.hashPin(pin, () -> backupId);
    KbsData kbsData = hashedPin.createNewKbsData(masterKey);
    assertArrayEquals(hashedPin.getKbsAccessKey(), kbsData.getKbsAccessKey());
    assertArrayEquals(Hex.fromStringCondensed("301d9dd1e96f20ce51083f67d3298fd37b97525de8324d5e12ed2d407d3d927b"), kbsData.getKbsAccessKey());
    assertArrayEquals(Hex.fromStringCondensed("9d9b05402ea39c17ff1c9298c8a0e86784a352aa02a74943bf8bcf07ec0f4b574a5b786ad0182c8d308d9eb06538b8c9"), kbsData.getCipherText());
    assertEquals(masterKey, kbsData.getMasterKey());
    String localPinHash = PinHashing.localPinHash(pin);
    assertTrue(PinHashing.verifyLocalPinHash(localPinHash, pin));
}
Also used : KbsData(org.whispersystems.signalservice.api.kbs.KbsData) MasterKey(org.whispersystems.signalservice.api.kbs.MasterKey) HashedPin(org.whispersystems.signalservice.api.kbs.HashedPin) Test(org.junit.Test)

Example 8 with HashedPin

use of org.whispersystems.signalservice.api.kbs.HashedPin in project Signal-Android by WhisperSystems.

the class PinHashing_hashPin_Test method argon2_hashed_pin_password_with_spaces_diacritics_and_non_arabic_numerals.

@Test
public void argon2_hashed_pin_password_with_spaces_diacritics_and_non_arabic_numerals() throws IOException {
    String pin = " Pass६örd ";
    byte[] backupId = Hex.fromStringCondensed("cba811749042b303a6a7efa5ccd160aea5e3ea243c8d2692bd13d515732f51a8");
    MasterKey masterKey = new MasterKey(Hex.fromStringCondensed("9571f3fde1e58588ba49bcf82be1b301ca3859a6f59076f79a8f47181ef952bf"));
    HashedPin hashedPin = PinHashing.hashPin(pin, () -> backupId);
    KbsData kbsData = hashedPin.createNewKbsData(masterKey);
    assertArrayEquals(hashedPin.getKbsAccessKey(), kbsData.getKbsAccessKey());
    assertArrayEquals(Hex.fromStringCondensed("ab645acdccc1652a48a34b2ac6926340ff35c03034013f68760f20013f028dd8"), kbsData.getKbsAccessKey());
    assertArrayEquals(Hex.fromStringCondensed("11c0ba1834db15e47c172f6c987c64bd4cfc69c6047dd67a022afeec0165a10943f204d5b8f37b3cb7bab21c6dfc39c8"), kbsData.getCipherText());
    assertEquals(masterKey, kbsData.getMasterKey());
    assertEquals("577939bccb2b6638c39222d5a97998a867c5e154e30b82cc120f2dd07a3de987", kbsData.getMasterKey().deriveRegistrationLock());
    String localPinHash = PinHashing.localPinHash(pin);
    assertTrue(PinHashing.verifyLocalPinHash(localPinHash, pin));
}
Also used : KbsData(org.whispersystems.signalservice.api.kbs.KbsData) MasterKey(org.whispersystems.signalservice.api.kbs.MasterKey) HashedPin(org.whispersystems.signalservice.api.kbs.HashedPin) Test(org.junit.Test)

Example 9 with HashedPin

use of org.whispersystems.signalservice.api.kbs.HashedPin in project Signal-Android by signalapp.

the class PinHashing_hashPin_Test method argon2_hashed_pin_password_with_spaces_diacritics_and_non_arabic_numerals.

@Test
public void argon2_hashed_pin_password_with_spaces_diacritics_and_non_arabic_numerals() throws IOException {
    String pin = " Pass६örd ";
    byte[] backupId = Hex.fromStringCondensed("cba811749042b303a6a7efa5ccd160aea5e3ea243c8d2692bd13d515732f51a8");
    MasterKey masterKey = new MasterKey(Hex.fromStringCondensed("9571f3fde1e58588ba49bcf82be1b301ca3859a6f59076f79a8f47181ef952bf"));
    HashedPin hashedPin = PinHashing.hashPin(pin, () -> backupId);
    KbsData kbsData = hashedPin.createNewKbsData(masterKey);
    assertArrayEquals(hashedPin.getKbsAccessKey(), kbsData.getKbsAccessKey());
    assertArrayEquals(Hex.fromStringCondensed("ab645acdccc1652a48a34b2ac6926340ff35c03034013f68760f20013f028dd8"), kbsData.getKbsAccessKey());
    assertArrayEquals(Hex.fromStringCondensed("11c0ba1834db15e47c172f6c987c64bd4cfc69c6047dd67a022afeec0165a10943f204d5b8f37b3cb7bab21c6dfc39c8"), kbsData.getCipherText());
    assertEquals(masterKey, kbsData.getMasterKey());
    assertEquals("577939bccb2b6638c39222d5a97998a867c5e154e30b82cc120f2dd07a3de987", kbsData.getMasterKey().deriveRegistrationLock());
    String localPinHash = PinHashing.localPinHash(pin);
    assertTrue(PinHashing.verifyLocalPinHash(localPinHash, pin));
}
Also used : KbsData(org.whispersystems.signalservice.api.kbs.KbsData) MasterKey(org.whispersystems.signalservice.api.kbs.MasterKey) HashedPin(org.whispersystems.signalservice.api.kbs.HashedPin) Test(org.junit.Test)

Example 10 with HashedPin

use of org.whispersystems.signalservice.api.kbs.HashedPin in project Signal-Android by signalapp.

the class PinHashing_hashPin_Test method argon2_hashed_pin_password_with_just_non_arabic_numerals.

@Test
public void argon2_hashed_pin_password_with_just_non_arabic_numerals() throws IOException {
    String pin = " ६१८ ";
    byte[] backupId = Hex.fromStringCondensed("717dc111a98423a57196512606822fca646c653facd037c10728f14ba0be2ab3");
    MasterKey masterKey = new MasterKey(Hex.fromStringCondensed("0432d735b32f66d0e3a70d4f9cc821a8529521a4937d26b987715d8eff4e4c54"));
    HashedPin hashedPin = PinHashing.hashPin(pin, () -> backupId);
    KbsData kbsData = hashedPin.createNewKbsData(masterKey);
    assertArrayEquals(hashedPin.getKbsAccessKey(), kbsData.getKbsAccessKey());
    assertArrayEquals(Hex.fromStringCondensed("d2fedabd0d4c17a371491c9722578843a26be3b4923e28d452ab2fc5491e794b"), kbsData.getKbsAccessKey());
    assertArrayEquals(Hex.fromStringCondensed("877ef871ef1fc668401c717ef21aa12e8523579fb1ff4474b76f28c2293537c80cc7569996c9e0229bea7f378e3a824e"), kbsData.getCipherText());
    assertEquals(masterKey, kbsData.getMasterKey());
    assertEquals("23a75cb1df1a87df45cc2ed167c2bdc85ab1220b847c88761b0005cac907fce5", kbsData.getMasterKey().deriveRegistrationLock());
    String localPinHash = PinHashing.localPinHash(pin);
    assertTrue(PinHashing.verifyLocalPinHash(localPinHash, pin));
}
Also used : KbsData(org.whispersystems.signalservice.api.kbs.KbsData) MasterKey(org.whispersystems.signalservice.api.kbs.MasterKey) HashedPin(org.whispersystems.signalservice.api.kbs.HashedPin) Test(org.junit.Test)

Aggregations

HashedPin (org.whispersystems.signalservice.api.kbs.HashedPin)20 Test (org.junit.Test)12 KbsData (org.whispersystems.signalservice.api.kbs.KbsData)12 MasterKey (org.whispersystems.signalservice.api.kbs.MasterKey)12 KbsPinData (org.whispersystems.signalservice.api.KbsPinData)8 KeyBackupService (org.whispersystems.signalservice.api.KeyBackupService)8 WorkerThread (androidx.annotation.WorkerThread)6 NonNull (androidx.annotation.NonNull)4 KbsEnclave (org.thoughtcrime.securesms.KbsEnclave)4 KbsValues (org.thoughtcrime.securesms.keyvalue.KbsValues)4 KbsTestVector (org.thoughtcrime.securesms.registration.v2.testdata.KbsTestVector)4 IOException (java.io.IOException)2 InvalidKeyException (org.whispersystems.libsignal.InvalidKeyException)2 KeyBackupServicePinException (org.whispersystems.signalservice.api.KeyBackupServicePinException)2 UnauthenticatedResponseException (org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException)2