public void TestGetPrimary() { // based on the checked in files, we know version 2 is primary. var reader = new FileSystemKeySet(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())); }
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, Does.Contain(KeyczarTool.Localized.MsgCreatedKeySet)); result = Util.KeyczarTool(addkey: null, location: path, status: "primary", padding: "PKCS", size: "1024"); Expect(result, Does.Contain(KeyczarTool.Localized.MsgCreatedKey)); var ks = new FileSystemKeySet(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, Does.Contain(KeyczarTool.Localized.MsgNewPublicKeySet)); var ks2 = new FileSystemKeySet(path); dynamic key2 = ks2.GetKey(1); Expect((int)key2.Size, Is.EqualTo(1024)); Expect((string)key2.Padding, Is.EqualTo("PKCS")); Directory.Delete(path2, true); Directory.Delete(path, true); }