The Royal Navy has signed a major security agreement ahead of an aircraft carrier being deployed next year.