Functions of justice and legality as the principles of law