예제 #1
0
  /// <summary>Initializes this form with the given key pair.</summary>
  public void Initialize(PrimaryKey key)
  {
    if(key == null) throw new ArgumentNullException();

    txtPrimaryId.Text   = key.PrimaryUserId.Name;
    txtKeyId.Text       = key.ShortKeyId +
                          (key.KeyId.Length > 8 ? " (long ID: " + key.KeyId + ")" : null);
    txtKeyType.Text     = (key.HasSecretKey ? "public key" : "public and secret key pair");
    txtKeyValidity.Text = PGPUI.GetKeyValidityDescription(key);
    txtOwnerTrust.Text  = PGPUI.GetTrustDescription(key.OwnerTrust);
    txtFingerprint.Text = key.Fingerprint;

    List<string> capabilities = new List<string>();
    if(key.HasCapabilities(KeyCapabilities.Authenticate)) capabilities.Add("authenticate");
    if(key.HasCapabilities(KeyCapabilities.Certify)) capabilities.Add("certify");
    if(key.HasCapabilities(KeyCapabilities.Encrypt)) capabilities.Add("encrypt");
    if(key.HasCapabilities(KeyCapabilities.Sign)) capabilities.Add("sign");
    txtCapabilities.Text = capabilities.Count == 0 ? "none" : string.Join(", ", capabilities.ToArray());

    keyList.Items.Clear();
    keyList.AddKey(key);
    foreach(Subkey subkey in key.Subkeys) keyList.AddKey(subkey);
  }
예제 #2
0
 /// <summary>Given a <see cref="Key"/>, gets a string that describes the validity of a key.</summary>
 public static string GetKeyValidityDescription(Key key)
 {
   if(key == null) throw new ArgumentNullException();
   return key.Revoked ? "revoked" : key.Expired ? "expired" : PGPUI.GetTrustDescription(key.CalculatedTrust);
 }