Add explicit vector for numericfingerprintgeneratortest

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2016-08-23 15:24:31 -07:00
parent 8a00482fbd
commit 87fae0f983

View File

@ -8,6 +8,27 @@ import org.whispersystems.libsignal.ecc.ECKeyPair;
public class NumericFingerprintGeneratorTest extends TestCase {
private static final String TAG = NumericFingerprintGeneratorTest.class.getSimpleName();
private static final byte[] ALICE_IDENTITY = {(byte)0x05, (byte)0x06, (byte)0x86, (byte)0x3b, (byte)0xc6, (byte)0x6d, (byte)0x02, (byte)0xb4, (byte)0x0d, (byte)0x27, (byte)0xb8, (byte)0xd4, (byte)0x9c, (byte)0xa7, (byte)0xc0, (byte)0x9e, (byte)0x92, (byte)0x39, (byte)0x23, (byte)0x6f, (byte)0x9d, (byte)0x7d, (byte)0x25, (byte)0xd6, (byte)0xfc, (byte)0xca, (byte)0x5c, (byte)0xe1, (byte)0x3c, (byte)0x70, (byte)0x64, (byte)0xd8, (byte)0x68};
private static final byte[] BOB_IDENTITY = {(byte)0x05, (byte)0xf7, (byte)0x81, (byte)0xb6, (byte)0xfb, (byte)0x32, (byte)0xfe, (byte)0xd9, (byte)0xba, (byte)0x1c, (byte)0xf2, (byte)0xde, (byte)0x97, (byte)0x8d, (byte)0x4d, (byte)0x5d, (byte)0xa2, (byte)0x8d, (byte)0xc3, (byte)0x40, (byte)0x46, (byte)0xae, (byte)0x81, (byte)0x44, (byte)0x02, (byte)0xb5, (byte)0xc0, (byte)0xdb, (byte)0xd9, (byte)0x6f, (byte)0xda, (byte)0x90, (byte)0x7b};
private static final String FINGERPRINT = "300354477692869396892869876765458257569162576843440918079131";
public void testVectors() throws Exception {
IdentityKey aliceIdentityKey = new IdentityKey(ALICE_IDENTITY, 0);
IdentityKey bobIdentityKey = new IdentityKey(BOB_IDENTITY, 0);
NumericFingerprintGenerator generator = new NumericFingerprintGenerator(5200);
Fingerprint aliceFingerprint = generator.createFor("+14152222222", aliceIdentityKey,
"+14153333333", bobIdentityKey);
Fingerprint bobFingerprint = generator.createFor("+14153333333", bobIdentityKey,
"+14152222222", aliceIdentityKey);
assertEquals(aliceFingerprint.getDisplayableFingerprint().getDisplayText(), FINGERPRINT);
assertEquals(bobFingerprint.getDisplayableFingerprint().getDisplayText(), FINGERPRINT);
}
public void testMatchingFingerprints() throws FingerprintVersionMismatchException, FingerprintIdentifierMismatchException, FingerprintParsingException {
ECKeyPair aliceKeyPair = Curve.generateKeyPair();
ECKeyPair bobKeyPair = Curve.generateKeyPair();