Ejemplo n.º 1
0
        public void TestGetPrimary()
        {
            // based on the checked in files, we know version 2 is primary.
            var reader          = new KeySet(Util.TestDataPath(TEST_DATA, "rsa"));
            var knownPrimaryKey = reader.GetKey(2 /* primary key version */);
            var readerKey       = new GetPrimary(reader).GetPrimaryExposed();

            Expect(readerKey.GetKeyHash(), Is.EqualTo(knownPrimaryKey.GetKeyHash()));
        }
Ejemplo n.º 2
0
        public void TestAddPadding()
        {
            string result;

            var path  = Util.TestDataPath(TEST_DATA, "padding");
            var path2 = Util.TestDataPath(TEST_DATA, "padding.public");

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
            if (Directory.Exists(path2))
            {
                Directory.Delete(path2, true);
            }

            result = Util.KeyczarTool(create: null, location: path, purpose: "crypt", asymmetric: null);

            Expect(result, Is.StringContaining(KeyczarTool.Localized.MsgCreatedKeySet));

            result = Util.KeyczarTool(addkey: null, location: path, status: "primary", padding: "PKCS", size: "1024");

            Expect(result, Is.StringContaining(KeyczarTool.Localized.MsgCreatedKey));


            var     ks  = new KeySet(path);
            dynamic key = ks.GetKey(1);

            Expect((int)key.Size, Is.EqualTo(1024));
            Expect((string)key.Padding, Is.EqualTo("PKCS"));


            result = Util.KeyczarTool(pubkey: null, location: path, destination: path2);

            Expect(result, Is.StringContaining(KeyczarTool.Localized.MsgNewPublicKeySet));

            var     ks2  = new KeySet(path);
            dynamic key2 = ks2.GetKey(1);

            Expect(key2.Size, Is.EqualTo(1024));
            Expect(key2.Padding, Is.EqualTo("PKCS"));

            Directory.Delete(path2, true);
            Directory.Delete(path, true);
        }
Ejemplo n.º 3
0
 public HDKeyData GetUnused(int lookahead)
 {
     return(KeySet.GetKey(State.NextUnused + lookahead));
 }