Use sodium_mlock() and sodium_munlock() to protect keys