Separate CKeyStore interface from its basic implementation

And move CCriticalSection cs_KeyStore up from CKeyStore to CBasicKeyStore. 
Also cleanup some dependencies.
This serves as preparation for #5208
When was that introduced? I've seen many other files with the H at the beginning instead of the end, which I find much more convenient when creating new files (just copy from an old file, and replace the end).