Exemple #1
0
 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);
 }
Exemple #2
0
        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)
                       ));
        }
Exemple #3
0
        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());
        }
Exemple #4
0
 public void DestroyObject(P11Object obj)
 {
     this.Module.P11Module.DestroyObject(hSession, obj.HObj);
 }
Exemple #5
0
        public P11Object CreateObject(P11Object template)
        {
            uint hObj = this.Module.P11Module.CreateObject(hSession, getAssignedAttributes(template));

            return(P11Object.GetInstance(this, hObj));
        }
Exemple #6
0
        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));
        }