Search in sources :

Example 1 with KbsTestVector

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());
    }
}
Also used : KbsTestVector(org.thoughtcrime.securesms.registration.v2.testdata.KbsTestVector) KbsData(org.whispersystems.signalservice.api.kbs.KbsData) HashedPin(org.whispersystems.signalservice.api.kbs.HashedPin) Test(org.junit.Test)

Example 2 with KbsTestVector

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());
    }
}
Also used : KbsTestVector(org.thoughtcrime.securesms.registration.v2.testdata.KbsTestVector) KbsData(org.whispersystems.signalservice.api.kbs.KbsData) HashedPin(org.whispersystems.signalservice.api.kbs.HashedPin) Test(org.junit.Test)

Example 3 with KbsTestVector

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());
    }
}
Also used : KbsTestVector(org.thoughtcrime.securesms.registration.v2.testdata.KbsTestVector) KbsData(org.whispersystems.signalservice.api.kbs.KbsData) HashedPin(org.whispersystems.signalservice.api.kbs.HashedPin) Test(org.junit.Test)

Example 4 with KbsTestVector

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());
    }
}
Also used : KbsTestVector(org.thoughtcrime.securesms.registration.v2.testdata.KbsTestVector) KbsData(org.whispersystems.signalservice.api.kbs.KbsData) HashedPin(org.whispersystems.signalservice.api.kbs.HashedPin) Test(org.junit.Test)

Example 5 with KbsTestVector

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;
    }
}
Also used : KbsTestVector(org.thoughtcrime.securesms.registration.v2.testdata.KbsTestVector) InputStream(java.io.InputStream)

Aggregations

KbsTestVector (org.thoughtcrime.securesms.registration.v2.testdata.KbsTestVector)6 Test (org.junit.Test)4 HashedPin (org.whispersystems.signalservice.api.kbs.HashedPin)4 KbsData (org.whispersystems.signalservice.api.kbs.KbsData)4 InputStream (java.io.InputStream)2