Net.Pkcs11Interop.HighLevelAPI81.ObjectAttribute.GetValueAsUlongList C# (CSharp) Method

GetValueAsUlongList() public method

Reads value of attribute and returns it as list of ulongs
public GetValueAsUlongList ( ) : List
return List
        public List<ulong> GetValueAsUlongList()
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            ulong[] value = null;
            CkaUtils.ConvertValue(ref _ckAttribute, out value);
            return (value == null) ? null : new List<ulong>(value);
        }

Usage Example

        public void _09_UintArrayAttributeTest()
        {
            if (Platform.UnmanagedLongSize != 8 || Platform.StructPackingSize != 1)
                Assert.Inconclusive("Test cannot be executed on this platform");

            List<ulong> originalValue = new List<ulong>();
            originalValue.Add(333333);
            originalValue.Add(666666);
            
            // Create attribute with ulong array value
            using (ObjectAttribute attr = new ObjectAttribute(CKA.CKA_ALLOWED_MECHANISMS, originalValue))
            {
                Assert.IsTrue(attr.Type == (ulong)CKA.CKA_ALLOWED_MECHANISMS);

                List<ulong> recoveredValue = attr.GetValueAsUlongList();
                for (int i = 0; i < recoveredValue.Count; i++)
                    Assert.IsTrue(originalValue[i] == recoveredValue[i]);
            }

            originalValue = null;

            // Create attribute with null ulong array value
            using (ObjectAttribute attr = new ObjectAttribute(CKA.CKA_ALLOWED_MECHANISMS, originalValue))
            {
                Assert.IsTrue(attr.Type == (ulong)CKA.CKA_ALLOWED_MECHANISMS);
                Assert.IsTrue(attr.GetValueAsUlongList() == originalValue);
            }

            originalValue = new List<ulong>();

            // Create attribute with empty ulong array value
            using (ObjectAttribute attr = new ObjectAttribute(CKA.CKA_ALLOWED_MECHANISMS, originalValue))
            {
                Assert.IsTrue(attr.Type == (ulong)CKA.CKA_ALLOWED_MECHANISMS);
                Assert.IsTrue(attr.GetValueAsUlongList() == null);
            }
        }