Есть библиотека, уровнем выше.
Вот с таким интерфейсом.
Подойдет?
public class CryptoCore : global::System.IDisposable {
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
protected bool swigCMemOwn;
internal CryptoCore(global::System.IntPtr cPtr, bool cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CryptoCore obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
~CryptoCore() {
Dispose();
}
public virtual void Dispose() {
lock(this) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwn) {
swigCMemOwn = false;
rtpkicorePINVOKE.delete_CryptoCore(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
global::System.GC.SuppressFinalize(this);
}
}
public static CryptoCore getInstance() {
CryptoCore ret = new CryptoCore(rtpkicorePINVOKE.CryptoCore_getInstance(), false);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public LongVector enumerateDevices() {
LongVector ret = new LongVector(rtpkicorePINVOKE.CryptoCore_enumerateDevices(swigCPtr), true);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public DeviceInfo getDeviceInfo(uint deviceId) {
DeviceInfo ret = new DeviceInfo(rtpkicorePINVOKE.CryptoCore_getDeviceInfo(swigCPtr, deviceId), true);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public void login(uint deviceId, string pin) {
rtpkicorePINVOKE.CryptoCore_login(swigCPtr, deviceId, pin);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
}
public void logout(uint deviceId) {
rtpkicorePINVOKE.CryptoCore_logout(swigCPtr, deviceId);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
}
public StringVector enumerateKeys(uint deviceId, string marker) {
StringVector ret = new StringVector(rtpkicorePINVOKE.CryptoCore_enumerateKeys(swigCPtr, deviceId, marker), true);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string generateKeyPair(uint deviceId, string arg1, string marker, OptionsMap options) {
string ret = rtpkicorePINVOKE.CryptoCore_generateKeyPair(swigCPtr, deviceId, arg1, marker, OptionsMap.getCPtr(options));
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string getKeyLabel(uint deviceId, string keyId) {
string ret = rtpkicorePINVOKE.CryptoCore_getKeyLabel(swigCPtr, deviceId, keyId);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public void setKeyLabel(uint deviceId, string keyId, string label) {
rtpkicorePINVOKE.CryptoCore_setKeyLabel(swigCPtr, deviceId, keyId, label);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
}
public bool deviceState(uint deviceId) {
bool ret = rtpkicorePINVOKE.CryptoCore_deviceState(swigCPtr, deviceId);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public void changePin(uint deviceId, string oldPin, string newPin) {
rtpkicorePINVOKE.CryptoCore_changePin(swigCPtr, deviceId, oldPin, newPin);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
}
public void deleteKeyPair(uint deviceId, string keyId) {
rtpkicorePINVOKE.CryptoCore_deleteKeyPair(swigCPtr, deviceId, keyId);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
}
public string createPkcs10(uint deviceId, string keyId, DN subject, ExtensionsMap extensions, bool includeSubjSignTool) {
string ret = rtpkicorePINVOKE.CryptoCore_createPkcs10__SWIG_0(swigCPtr, deviceId, keyId, DN.getCPtr(subject), ExtensionsMap.getCPtr(extensions), includeSubjSignTool);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string createPkcs10(uint deviceId, string keyId, DN subject, ExtensionsMap extensions, bool includeSubjSignTool, StringMap customExtensions) {
string ret = rtpkicorePINVOKE.CryptoCore_createPkcs10__SWIG_1(swigCPtr, deviceId, keyId, DN.getCPtr(subject), ExtensionsMap.getCPtr(extensions), includeSubjSignTool, StringMap.getCPtr(customExtensions));
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string importCertificate(uint deviceId, string certificate, uint category) {
string ret = rtpkicorePINVOKE.CryptoCore_importCertificate(swigCPtr, deviceId, certificate, category);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public StringVector enumerateCertificates(uint deviceId, uint category) {
StringVector ret = new StringVector(rtpkicorePINVOKE.CryptoCore_enumerateCertificates(swigCPtr, deviceId, category), true);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public void deleteCertificate(uint deviceId, string certId) {
rtpkicorePINVOKE.CryptoCore_deleteCertificate(swigCPtr, deviceId, certId);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
}
public string sign(uint deviceId, string certId, string data, OptionsMap options, StringVector additionalCerts) {
string ret = rtpkicorePINVOKE.CryptoCore_sign(swigCPtr, deviceId, certId, data, OptionsMap.getCPtr(options), StringVector.getCPtr(additionalCerts));
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public bool verify(uint deviceId, string cms, string data, StringVector userCerts, StringVector ca, StringVector crl, OptionsMap options) {
bool ret = rtpkicorePINVOKE.CryptoCore_verify(swigCPtr, deviceId, cms, data, StringVector.getCPtr(userCerts), StringVector.getCPtr(ca), StringVector.getCPtr(crl), OptionsMap.getCPtr(options));
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string authenticate(uint deviceId, string certId, string salt) {
string ret = rtpkicorePINVOKE.CryptoCore_authenticate(swigCPtr, deviceId, certId, salt);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string getKeyByCertificate(uint deviceId, string certId) {
string ret = rtpkicorePINVOKE.CryptoCore_getKeyByCertificate(swigCPtr, deviceId, certId);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string getCertificate(uint deviceId, string certId) {
string ret = rtpkicorePINVOKE.CryptoCore_getCertificate(swigCPtr, deviceId, certId);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string cmsDecrypt(uint deviceId, string keyId, string cmsData, OptionsMap options) {
string ret = rtpkicorePINVOKE.CryptoCore_cmsDecrypt(swigCPtr, deviceId, keyId, cmsData, OptionsMap.getCPtr(options));
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string cmsEncrypt(uint deviceId, string certId, string recipientCert, string data, OptionsMap options) {
string ret = rtpkicorePINVOKE.CryptoCore_cmsEncrypt(swigCPtr, deviceId, certId, recipientCert, data, OptionsMap.getCPtr(options));
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string rawSign(uint deviceId, string keyId, string data, OptionsMap options) {
string ret = rtpkicorePINVOKE.CryptoCore_rawSign(swigCPtr, deviceId, keyId, data, OptionsMap.getCPtr(options));
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public CertFields parseCertificate(uint deviceId, string certId) {
CertFields ret = new CertFields(rtpkicorePINVOKE.CryptoCore_parseCertificate(swigCPtr, deviceId, certId), true);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public CertFields parseCertificateFromString(string certString) {
CertFields ret = new CertFields(rtpkicorePINVOKE.CryptoCore_parseCertificateFromString(swigCPtr, certString), true);
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string getPublicKeyValue(uint deviceId, string keyId, OptionsMap options) {
string ret = rtpkicorePINVOKE.CryptoCore_getPublicKeyValue(swigCPtr, deviceId, keyId, OptionsMap.getCPtr(options));
if (rtpkicorePINVOKE.SWIGPendingException.Pending) throw rtpkicorePINVOKE.SWIGPendingException.Retrieve();
return ret;
}