use of org.thoughtcrime.securesms.registration.v2.testdata.KbsTestVector in project Signal-Android by WhisperSystems.
the class HashedPinKbsDataTest method vectors_decryptKbsDataIVCipherText.
@Test
public void vectors_decryptKbsDataIVCipherText() throws IOException, InvalidCiphertextException {
for (KbsTestVector vector : getKbsTestVectorList()) {
HashedPin hashedPin = HashedPin.fromArgon2Hash(vector.getArgon2Hash());
KbsData kbsData = hashedPin.decryptKbsDataIVCipherText(vector.getIvAndCipher());
assertArrayEquals(vector.getMasterKey(), kbsData.getMasterKey().serialize());
assertArrayEquals(vector.getIvAndCipher(), kbsData.getCipherText());
assertArrayEquals(vector.getKbsAccessKey(), kbsData.getKbsAccessKey());
assertEquals(vector.getRegistrationLock(), kbsData.getMasterKey().deriveRegistrationLock());
}
}
use of org.thoughtcrime.securesms.registration.v2.testdata.KbsTestVector in project Signal-Android by signalapp.
the class HashedPinKbsDataTest method vectors_decryptKbsDataIVCipherText.
@Test
public void vectors_decryptKbsDataIVCipherText() throws IOException, InvalidCiphertextException {
for (KbsTestVector vector : getKbsTestVectorList()) {
HashedPin hashedPin = HashedPin.fromArgon2Hash(vector.getArgon2Hash());
KbsData kbsData = hashedPin.decryptKbsDataIVCipherText(vector.getIvAndCipher());
assertArrayEquals(vector.getMasterKey(), kbsData.getMasterKey().serialize());
assertArrayEquals(vector.getIvAndCipher(), kbsData.getCipherText());
assertArrayEquals(vector.getKbsAccessKey(), kbsData.getKbsAccessKey());
assertEquals(vector.getRegistrationLock(), kbsData.getMasterKey().deriveRegistrationLock());
}
}
use of org.thoughtcrime.securesms.registration.v2.testdata.KbsTestVector in project Signal-Android by signalapp.
the class HashedPinKbsDataTest method vectors_createNewKbsData.
@Test
public void vectors_createNewKbsData() throws IOException {
for (KbsTestVector vector : getKbsTestVectorList()) {
HashedPin hashedPin = HashedPin.fromArgon2Hash(vector.getArgon2Hash());
KbsData kbsData = hashedPin.createNewKbsData(MasterKey.createNew(mockRandom(vector.getMasterKey())));
assertArrayEquals(vector.getMasterKey(), kbsData.getMasterKey().serialize());
assertArrayEquals(vector.getIvAndCipher(), kbsData.getCipherText());
assertArrayEquals(vector.getKbsAccessKey(), kbsData.getKbsAccessKey());
assertEquals(vector.getRegistrationLock(), kbsData.getMasterKey().deriveRegistrationLock());
}
}
use of org.thoughtcrime.securesms.registration.v2.testdata.KbsTestVector in project Signal-Android by WhisperSystems.
the class HashedPinKbsDataTest method vectors_createNewKbsData.
@Test
public void vectors_createNewKbsData() throws IOException {
for (KbsTestVector vector : getKbsTestVectorList()) {
HashedPin hashedPin = HashedPin.fromArgon2Hash(vector.getArgon2Hash());
KbsData kbsData = hashedPin.createNewKbsData(MasterKey.createNew(mockRandom(vector.getMasterKey())));
assertArrayEquals(vector.getMasterKey(), kbsData.getMasterKey().serialize());
assertArrayEquals(vector.getIvAndCipher(), kbsData.getCipherText());
assertArrayEquals(vector.getKbsAccessKey(), kbsData.getKbsAccessKey());
assertEquals(vector.getRegistrationLock(), kbsData.getMasterKey().deriveRegistrationLock());
}
}
use of org.thoughtcrime.securesms.registration.v2.testdata.KbsTestVector in project Signal-Android by WhisperSystems.
the class HashedPinKbsDataTest method getKbsTestVectorList.
private static KbsTestVector[] getKbsTestVectorList() throws IOException {
try (InputStream resourceAsStream = ClassLoader.getSystemClassLoader().getResourceAsStream("data/kbs_vectors.json")) {
KbsTestVector[] data = JsonUtil.fromJson(StreamUtil.readFullyAsString(resourceAsStream), KbsTestVector[].class);
assertTrue(data.length > 0);
return data;
}
}
Aggregations