Ejemplo n.º 1
0
        public void _03_UintAttributeTest()
        {
            Helpers.CheckPlatform();

            NativeULong value = NativeLongUtils.ConvertFromCKO(CKO.CKO_DATA);

            // Create attribute with NativeULong value
            using (ObjectAttribute attr = new ObjectAttribute(CKA.CKA_CLASS, value))
            {
                Assert.IsTrue(attr.Type == NativeLongUtils.ConvertFromCKA(CKA.CKA_CLASS));
                Assert.IsTrue(attr.GetValueAsNativeUlong() == value);
            }
        }
Ejemplo n.º 2
0
        public void _07_GetObjectAttributes()
        {
            Helpers.CheckPlatform();

            string uri = @"pkcs11:object=foo;type=private;id=%01%02%03";

            Pkcs11Uri pkcs11uri = new Pkcs11Uri(uri);

            List <ObjectAttribute> attributes = null;

            Pkcs11UriUtils.GetObjectAttributes(pkcs11uri, out attributes);

            Assert.IsTrue(attributes != null);
            Assert.IsTrue(attributes.Count == 3);

            Assert.IsTrue(attributes[0].Type == NativeLongUtils.ConvertFromCKA(CKA.CKA_CLASS));
            Assert.IsTrue(attributes[0].GetValueAsNativeUlong() == NativeLongUtils.ConvertFromCKO(CKO.CKO_PRIVATE_KEY));

            Assert.IsTrue(attributes[1].Type == NativeLongUtils.ConvertFromCKA(CKA.CKA_LABEL));
            Assert.IsTrue(attributes[1].GetValueAsString() == "foo");

            Assert.IsTrue(attributes[2].Type == NativeLongUtils.ConvertFromCKA(CKA.CKA_ID));
            Assert.IsTrue(Common.Helpers.ByteArraysMatch(attributes[2].GetValueAsByteArray(), new byte[] { 0x01, 0x02, 0x03 }));
        }