I have made a very basic Soft-HSM - only for personal learning purposes. I want to add a PKCS#11 interface to it. Where can I learn about this, or perhaps find something open source already written for studying?
I realize that this could be downvoted just for bringing this up (poor security, etc) but I wanted to ensure that its strictly for learning purposes.
You first need to get familiar with PKCS#11 specificiation. I've created git repository PKCS11-SPECS with all of its versions in one place. I personally consider PKCS#11 v2.20 to be the last "usable" version because in later versions authors removed important parts that are crucial to understand for anyone developing interoperable PKCS#11 libraries (session lifetime etc.). I warned them about removing those part but they didn't seem to care. So IMO PKCS#11 v2.20 is your best bet unless you need to use some other shiny fancy new algorithms that are not present in v2.20.
Another of my projects that you may find useful is EMPTY-PKCS11. It is minimalistic C library that implements PKCS#11 v2.20 API in the simplest possible way - all PKCS#11 functions except C_GetFunctionList
function return CKR_FUNCTION_NOT_SUPPORTED
return value. It has been tested on several desktop and mobile platforms and as such can be used as a lightweight skeleton for the development of portable PKCS#11 libraries.
After that you can also take a look at PKCS11-MOCK which is another minimalistic PKCS#11 v2.20 library. It is not a real cryptographic module but just a dummy mock object designed specifically for unit testing of some of my other projects.
I hope these projects could be a solid solid starting point in your learning process.