コード例 #1
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));
 }
コード例 #2
0
 /// <summary>
 /// Test of doesKeyExist method, of class FilePrivateKeyStorage.
 /// </summary>
 ///
 public void testDoesKeyExist()
 {
     FilePrivateKeyStorage instance = new FilePrivateKeyStorage();
     AssertTrue(instance.doesKeyExist(new Name("/test/KEY/123"),
             net.named_data.jndn.security.KeyClass.PRIVATE));
     AssertFalse(instance.doesKeyExist(new Name("/unknown"),
             net.named_data.jndn.security.KeyClass.PRIVATE));
 }
コード例 #3
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"));
         instance.deleteKey(new Name("/test/KEY/temp1"));
     } catch (Exception e) {
         System.Console.Error.WriteLine("Failed to clean up generated keys");
     }
 }
コード例 #4
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;
     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;
     AssertTrue(createdFileCount - 2 == deletedfileCount);
 }
コード例 #5
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);
     AssertNotNull(result);
 }
コード例 #6
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"));
     AssertNotNull(result);
 }