Ejemplo n.º 1
0
        /// <summary>
        /// Test of getPublicKey method, of class FilePrivateKeyStorage.
        /// </summary>
        ///
        public void testGetPublicKey()
        {
            FilePrivateKeyStorage instance = new FilePrivateKeyStorage();
            PublicKey             result   = instance.getPublicKey(new Name("/test/KEY/123"));

            Assert.AssertNotNull(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a few keys before testing
        /// </summary>
        ///
        /// <exception cref="System.Exception"></exception>
        public static void setUpClass()
        {
            // create some test key files to use in tests
            FilePrivateKeyStorage instance = new FilePrivateKeyStorage();

            instance.generateKeyPair(new Name("/test/KEY/123"), new RsaKeyParams(
                                         2048));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Test of sign method, of class FilePrivateKeyStorage.
        /// </summary>
        ///
        public void testSign()
        {
            int[] data = new int[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
            FilePrivateKeyStorage instance = new FilePrivateKeyStorage();
            Blob result = instance.sign(toBuffer(data), new Name("/test/KEY/123"),
                                        net.named_data.jndn.security.DigestAlgorithm.SHA256);

            Assert.AssertNotNull(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Test of doesKeyExist method, of class FilePrivateKeyStorage.
        /// </summary>
        ///
        public void testDoesKeyExist()
        {
            FilePrivateKeyStorage instance = new FilePrivateKeyStorage();

            Assert.AssertTrue(instance.doesKeyExist(new Name("/test/KEY/123"),
                                                    net.named_data.jndn.security.KeyClass.PRIVATE));
            Assert.AssertFalse(instance.doesKeyExist(new Name("/unknown"),
                                                     net.named_data.jndn.security.KeyClass.PRIVATE));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Delete the keys we created
        /// </summary>
        ///
        public static void tearDownClass()
        {
            // delete all keys when done
            FilePrivateKeyStorage instance = new FilePrivateKeyStorage();

            try {
                instance.deleteKey(new Name("/test/KEY/123"));
            } catch (Exception e) {
                System.Console.Error.WriteLine("Failed to clean up generated keys");
            }

            try {
                instance.deleteKey(new Name("/test/KEY/temp1"));
            } catch (Exception e_0) {
                // Not all tests create this key so ignore if we don't delete it.
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Test of generateKeyPair method, of class FilePrivateKeyStorage.
        /// </summary>
        ///
        public void testGenerateAndDeleteKeys()
        {
            // create some more key files
            FilePrivateKeyStorage instance = new FilePrivateKeyStorage();

            instance.generateKeyPair(new Name("/test/KEY/temp1"), new RsaKeyParams(
                                         2048));
            // check if files created
            FileInfo[] files            = ndnFolder_.listFiles();
            int        createdFileCount = files.Length;

            Assert.AssertTrue(createdFileCount >= 2);             // 2 pre-created + 2 created now + some created by NFD
            // delete these keys
            instance.deleteKey(new Name("/test/KEY/temp1"));
            files = ndnFolder_.listFiles();
            int deletedfileCount = files.Length;

            Assert.AssertTrue(createdFileCount - 2 == deletedfileCount);
        }