Hello,
I am not sure if I understood you correctly, but I will try to answer:
Except hash the password(which I don't think make any difference since the hash operation can't be occurred after JTAG connection but before password inquire), how can I make sure that user code can't read or change the password?
First of all SPC560P40 is device produced by STMicro and not NXP.
Second, this very old device apply only 1 protection to user code and that is censorship.
You can protect memory to be read out by setting JTAG/serial access password.
But if the application which is already in device has backdoors, it can remove/disable the censorship protection.
Have in mind that this is 20 years old design, where no security was required by customers...
In new devices, there is complex security scheme applied.
Best regards,
Peter