def decode_ber(ber):
    """
    Decodes a ber length byte array into an integer
    return: (length, bytes_read) - a tuple of values
    """
    ber = bytearray(ber)
    length = ber[0]
    bytes_read = 1
    if length > 127:
        bytes_read += length & 127 # Strip off the high bit
        length = 0
        for i in range(1, bytes_read):
            length += ber[i] << (8 * (bytes_read - i - 1))
    return length, bytes_read
def decode_ber ( ber ) : ber = bytearray ( ber ) length = ber [ 0 ] bytes_read = 1 if length > 127 : bytes_read += length & 127 length = 0 for i in range ( 1 , bytes_read ) : length += ber [ i ] << ( 8 * ( bytes_read - i - 1 ) ) return length , bytes_read
Decodes a ber length byte array into an integer
    return: (length, bytes_read) - a tuple of values