Beispiel #1
0
def findA_M0():
    prefix = b"\x00" + b"\xf2" + b"\x00" * (256 - 2 - 16)
    c = mysrp.Client()
    import time

    start = time.time()
    num_near_misses = 0
    for count in thencount():
        if count > 300 and count % 500 == 0:
            now = time.time()
            print_(count, "tries", now - start)
            start = now
        if count > 1000000:
            raise ValueError("unable to find suitable value in reasonable time")
        a_str = prefix + binascii.unhexlify("%032x" % count)
        assert len(a_str) == 2048 / 8, (len(a_str), 2048 / 8)
        a = mysrp.bytes_to_long(a_str)
        A = c.one(a)
        # require that the computed M1 has a leading zero
        c.two(B, srpSalt, emailUTF8, srpPW)
        if c._debug_M1_bytes[0:1] != b"\x00":
            continue
        print_("found a on count", count)
        printdec("private a (normally random)", a)
        printhex("private a (hex)", a_str, groups_per_line=2)
        return a, A
Beispiel #2
0
def findA_A0():
    print_("looking for 'a' that yields srpA with leading zero")
    # 'a' is in [1..N-1], so 2048 bits, or 256 bytes
    prefix = b"\x00" + b"\xf2" + b"\x00" * (256 - 2 - 16)
    c = mysrp.Client()
    import time

    start = time.time()
    num_near_misses = 0
    # hm.. this reports an awful lot of consecutive "near-misses". But, this
    # a->A transformation isn't supposed to be strong against related "keys".
    for count in thencount(54231):
        # this processes about 50 per second. 2^16 needs about 20 minutes.
        if count > 300 and count % 500 == 0:
            now = time.time()
            print_(count, "tries", now - start)
            start = now
        if count > 1000000:
            raise ValueError("unable to find suitable value in reasonable time")
        a_str = prefix + binascii.unhexlify("%032x" % count)
        assert len(a_str) == 2048 / 8, (len(a_str), 2048 / 8)
        a = mysrp.bytes_to_long(a_str)
        A = c.one(a)
        if A[0:1] != b"\x00":
            continue
        num_near_misses += 1
        # also require that the computed S has a leading zero
        c.two(B, srpSalt, emailUTF8, srpPW)
        if c._debug_S_bytes[0:1] != b"\x00":
            print_("found good A, but not good S, on count %d (near misses=%d)" % (count, num_near_misses))
            continue
        print_("found a on count", count)
        printdec("private a (normally random)", a)
        printhex("private a (hex)", a_str, groups_per_line=2)
        return a, A
Beispiel #3
0
def findB_any():
    prefix = b"\x00" + b"\xf3" + b"\x00" * (256 - 2 - 16)
    s = mysrp.Server(srpVerifier)
    count = 1
    b_str = prefix + binascii.unhexlify("%032x" % count)
    assert len(b_str) == 2048 / 8, (len(b_str), 2048 / 8)
    b = mysrp.bytes_to_long(b_str)
    B = s.one(b)
    printdec("private b (normally random)", b)
    printhex("private b (hex)", b_str, groups_per_line=2)
    return b, B
Beispiel #4
0
def findB_B0():
    print_("looking for 'b' that yields srpB with leading zero")
    prefix = b"\x00" + b"\xf3" + b"\x00" * (256 - 2 - 16)
    s = mysrp.Server(srpVerifier)
    for count in thencount(15):
        if count > 300 and count % 500 == 0:
            print_(count, "tries")
        if count > 1000000:
            raise ValueError("unable to find suitable value in reasonable time")
        b_str = prefix + binascii.unhexlify("%032x" % count)
        assert len(b_str) == 2048 / 8, (len(b_str), 2048 / 8)
        b = mysrp.bytes_to_long(b_str)
        B = s.one(b)
        if B[0:1] != b"\x00":
            continue
        print_("found b on count", count)
        printdec("private b (normally random)", b)
        printhex("private b (hex)", b_str, groups_per_line=2)
        return b, B