API for DKEK shares on HSM

Is there a library or API I can use to create and initialize the HSM with DKEK shares? I am aware that the SC-HSM-TOOL does this but I’m looking to accomplish the same in code.

Are you aware of OpenSC? In case you use Java, you find a JCE Provider as part of Smart Card Shell.