public P11Attribute Clone() { P11Attribute p11 = GetCkLoadedCopy(); p11.metaData = this.metaData; p11.isAssigned = this.isAssigned; return(p11); }
public static P11Attribute GetAttribute(Session session, uint hObj, P11Attribute attr) { try { uint hSession = session.HSession; Wrapper.Pkcs11Module pm = session.Module.P11Module; CK_ATTRIBUTE tmp = pm.GetAttributeValue(hSession, hObj, new CK_ATTRIBUTE[] { attr.CK_ATTRIBUTE })[0]; P11Attribute p11 = attr.Clone().Load(tmp); p11.MetaData.IsPresent = true; p11.MetaData.IsSensitive = false; return(p11); } catch (TokenException tex) { if (tex.ErrorCode == CKR.ATTRIBUTE_TYPE_INVALID || tex.ErrorCode == CKR.ATTRIBUTE_VALUE_INVALID) { P11Attribute p11 = attr.Clone(); p11.MetaData.IsPresent = false; p11.MetaData.IsSensitive = false; return(p11); } else if (tex.ErrorCode == CKR.ATTRIBUTE_SENSITIVE) { P11Attribute p11 = attr.Clone(); p11.MetaData.IsPresent = true; p11.MetaData.IsSensitive = true; return(p11); } else { throw tex; } } }
protected static P11Attribute AssignAttributeFromObj(Session session, uint hObj, P11Attribute attr) { uint hSession = session.HSession; Wrapper.Pkcs11Module pm = session.Module.P11Module; try { return(attr.Load(pm.GetAttributeValue(hSession, hObj, new CK_ATTRIBUTE[] { attr.CK_ATTRIBUTE })[0])); } catch {//TODO:sadece attribute not found handle et return(null); } }