/// <summary> /// Obtains a list of mechanism types supported by a token /// </summary> /// <returns>List of mechanism types supported by a token</returns> public List <CKM> GetMechanismList() { NativeULong mechanismCount = 0; CKR rv = _p11.C_GetMechanismList(_slotId, null, ref mechanismCount); if (rv != CKR.CKR_OK) { throw new Pkcs11Exception("C_GetMechanismList", rv); } if (mechanismCount < 1) { return(new List <CKM>()); } CKM[] mechanismList = new CKM[mechanismCount]; rv = _p11.C_GetMechanismList(_slotId, mechanismList, ref mechanismCount); if (rv != CKR.CKR_OK) { throw new Pkcs11Exception("C_GetMechanismList", rv); } if (mechanismList.Length != NativeLongUtils.ConvertToInt32(mechanismCount)) { Array.Resize(ref mechanismList, NativeLongUtils.ConvertToInt32(mechanismCount)); } return(new List <CKM>(mechanismList)); }
/// <summary> /// Obtains a list of mechanism types supported by a token /// </summary> /// <returns>List of mechanism types supported by a token</returns> public List <CKM> GetMechanismList() { _logger.Debug("Slot({0})::GetMechanismList", _slotId); NativeULong mechanismCount = 0; CKR rv = _p11.C_GetMechanismList(_slotId, null, ref mechanismCount); if (rv != CKR.CKR_OK) { throw new Pkcs11Exception("C_GetMechanismList", rv); } if (mechanismCount < 1) { return(new List <CKM>()); } CKM[] mechanismList = new CKM[mechanismCount]; rv = _p11.C_GetMechanismList(_slotId, mechanismList, ref mechanismCount); if (rv != CKR.CKR_OK) { throw new Pkcs11Exception("C_GetMechanismList", rv); } if (mechanismList.Length != ConvertUtils.UInt32ToInt32(mechanismCount)) { Array.Resize(ref mechanismList, ConvertUtils.UInt32ToInt32(mechanismCount)); } return(new List <CKM>(mechanismList)); }