public P11Object[] FindObjects(uint maxCount) { uint[] hObjs = this.Module.P11Module.FindObjects(HSession, maxCount); P11Object[] objs = new P11Object[hObjs.Length]; for (int i = 0; i < hObjs.Length; ++i) { objs[i] = P11Object.GetInstance(this, hObjs[i]); } return(objs); }
public KeyPair GenerateKeyPair(Mechanism mech, P11Object pubTemplate, P11Object privTemplate) { KeyPairHandler hkp = this.Module.P11Module.GenerateKeyPair( hSession, mech.CK_MECHANISM, getAssignedAttributes(pubTemplate), getAssignedAttributes(privTemplate) ); return(new KeyPair( (PublicKey)PublicKey.GetInstance(this, hkp.hPublicKey), (PrivateKey)PrivateKey.GetInstance(this, hkp.hPrivateKey) )); }
private static CK_ATTRIBUTE[] getAssignedAttributes(P11Object obj) { PropertyInfo[] props = obj.GetType().GetProperties(); List <CK_ATTRIBUTE> attrs = new List <CK_ATTRIBUTE>(); for (int i = 0; i < props.Length; i++) { P11Attribute val = props[i].GetValue(obj, null) as P11Attribute; if (val != null && val.IsAssigned) { attrs.Add(val.CK_ATTRIBUTE); } } return(attrs.ToArray()); }
public void DestroyObject(P11Object obj) { this.Module.P11Module.DestroyObject(hSession, obj.HObj); }
public P11Object CreateObject(P11Object template) { uint hObj = this.Module.P11Module.CreateObject(hSession, getAssignedAttributes(template)); return(P11Object.GetInstance(this, hObj)); }
public SecretKey GenerateKey(Mechanism mech, P11Object template) { uint hKey = this.Module.P11Module.GenerateKey(hSession, mech.CK_MECHANISM, getAssignedAttributes(template)); return((SecretKey)SecretKey.GetInstance(this, hKey)); }