Пример #1
0
 /// <summary>Creates the keyring files using the given <see cref="PGPSystem"/>, if they do not already exist or if
 /// <paramref name="overwrite"/> is true.
 /// </summary>
 public void Create(PGPSystem system, bool overwrite)
 {
   if(system == null) throw new ArgumentNullException();
   if(overwrite || !File.Exists(PublicFile)) system.CreatePublicKeyring(PublicFile);
   if(SecretFile  != null && (overwrite || !File.Exists(SecretFile)))  system.CreateSecretKeyring(SecretFile);
   if(TrustDbFile != null && (overwrite || !File.Exists(TrustDbFile))) system.CreateTrustDatabase(TrustDbFile);
 }
Пример #2
0
  /// <summary>Initializes this form with the <see cref="PGPSystem"/> that will be used to edit the key, and the key to
  /// edit.
  /// </summary>
  public void Initialize(PGPSystem pgp, PrimaryKey key)
  {
    if(pgp == null || key == null) throw new ArgumentNullException();
    this.pgp = pgp;
    this.key = key;

    btnAddPhotoId.Enabled = btnAddUserId.Enabled = key.HasSecretKey;

    if(Visible) ReloadKey();
  }
Пример #3
0
  /// <summary>Initializes a new <see cref="KeyServerSearchForm"/> with the <see cref="PGPSystem"/> that will be used
  /// to search for keys. Keys selected by the user will be added to the given keyring.
  /// </summary>
  public KeyServerSearchForm(PGPSystem pgp, Keyring importKeyring)
  {
    InitializeComponent();

    keyservers.Items.Clear();
    keyservers.Items.AddRange(PGPUI.GetDefaultKeyServers());
    keyservers.SelectedIndex = 0;

    this.pgp     = pgp;
    this.keyring = importKeyring;
  }
Пример #4
0
  /// <summary>Initializes a new <see cref="NewSubkeyForm"/> with the <see cref="PGPSystem"/> that will be used to
  /// create the subkey.
  /// </summary>
  public void Initialize(PGPSystem pgp)
  {
    if(pgp == null) throw new ArgumentNullException();
    this.pgp = pgp;

    KeyCapabilities signOnly = KeyCapabilities.Sign;
    KeyCapabilities encryptOnly = KeyCapabilities.Encrypt;
    KeyCapabilities signAndEncrypt = signOnly | encryptOnly;

    bool supportsDSA = false, supportsELG = false, supportsRSA = false;
    foreach(string type in pgp.GetSupportedKeyTypes())
    {
      if(!supportsDSA && string.Equals(type, PGP.KeyType.DSA, StringComparison.OrdinalIgnoreCase))
      {
        supportsDSA = true;
      }
      else if(!supportsELG && string.Equals(type, PGP.KeyType.ElGamal, StringComparison.OrdinalIgnoreCase))
      {
        supportsELG = true;
      }
      else if(!supportsRSA && string.Equals(type, PGP.KeyType.RSA, StringComparison.OrdinalIgnoreCase))
      {
        supportsRSA = true;
      }
    }

    keyType.Items.Clear();
    if(supportsELG) keyType.Items.Add(new KeyTypeItem(PGP.KeyType.ElGamal, encryptOnly, "El Gamal (encryption only)"));
    if(supportsRSA) keyType.Items.Add(new KeyTypeItem(PGP.KeyType.RSA, encryptOnly, "RSA (encryption only)"));
    if(supportsDSA) keyType.Items.Add(new KeyTypeItem(PGP.KeyType.DSA, signOnly, "DSA (signing only)"));
    if(supportsRSA)
    {
      keyType.Items.Add(new KeyTypeItem(PGP.KeyType.RSA, signOnly, "RSA (signing only)"));
      keyType.Items.Add(new KeyTypeItem(PGP.KeyType.RSA, signAndEncrypt, "RSA (sign and encrypt)"));
    }
    keyType.SelectedIndex = 0;

    // OpenPGP currently supports a maximum expiration date of February 25, 2174. we'll use the 24th to avoid
    // local <-> UTC conversion problems
    keyExpiration.MinDate = DateTime.Now.Date.AddDays(1);
    keyExpiration.MaxDate = new DateTime(2174, 2, 24, 0, 0, 0, DateTimeKind.Local);
    keyExpiration.Value = DateTime.UtcNow.Date.AddYears(5); // by default, the subkey expires in 5 years
  }
Пример #5
0
 /// <summary>Initializes a new <see cref="KeyServerSearchForm"/> with the <see cref="PGPSystem"/> that will be used
 /// to search for keys. Keys selected by the user will be added to the default keyring.
 /// </summary>
 public KeyServerSearchForm(PGPSystem pgp) : this(pgp, null) { }
Пример #6
0
 /// <summary>Initializes a new <see cref="UserIdManagerForm"/> with the <see cref="PGPSystem"/> that will be used to
 /// edit the key, and the key to edit.
 /// </summary>
 public UserIdManagerForm(PGPSystem pgp, PrimaryKey key) : this()
 {
   Initialize(pgp, key);
 }
Пример #7
0
 /// <summary>Initializes this form with the given <see cref="PGPSystem"/> and keyring.</summary>
 public void Initialize(PGPSystem pgp, Keyring keyring)
 {
   if(pgp == null) throw new ArgumentNullException();
   recipients.ShowKeyring(pgp, keyring);
 }
Пример #8
0
 /// <summary>Initializes a new <see cref="RecipientSearchForm"/> with the given <see cref="PGPSystem"/> and keyring.</summary>
 public RecipientSearchForm(PGPSystem pgp, Keyring keyring) : this()
 {
   Initialize(pgp, keyring);
 }
Пример #9
0
 /// <summary>Initializes a new <see cref="RecipientSearchForm"/> with the given <see cref="PGPSystem"/> and the
 /// default keyring.
 /// </summary>
 public RecipientSearchForm(PGPSystem pgp) : this(pgp, null) { }
Пример #10
0
 /// <summary>Initializes a new <see cref="SubkeyManagerForm"/> with the <see cref="PGPSystem"/> that will be used to
 /// edit the key, and the key to edit.
 /// </summary>
 public SubkeyManagerForm(PGPSystem pgp, PrimaryKey publicKey) : this()
 {
   Initialize(pgp, publicKey);
 }
Пример #11
0
 /// <summary>Displays the recipients in the given keyring.</summary>
 public void ShowKeyring(PGPSystem pgp, Keyring keyring)
 {
   if(pgp == null) throw new ArgumentNullException();
   ShowKeys(pgp.GetKeys(keyring, ListOptions.RetrieveSecretKeys | ListOptions.IgnoreUnusableKeys));
 }
Пример #12
0
 /// <summary>Initializes a new <see cref="GenerateKeyForm"/> with the <see cref="PGPSystem"/> that will be used to
 /// generate the keys. The keys will be created in the given keyring, or the default keyring if it is null.
 /// </summary>
 public GenerateKeyForm(PGPSystem pgp, Keyring keyring) : this()
 {
   Initialize(pgp, keyring);
 }
Пример #13
0
 /// <summary>Initializes a new <see cref="GenerateKeyForm"/> with the <see cref="PGPSystem"/> that will be used to
 /// generate the keys. The keys will be created in the default keyring.
 /// </summary>
 public GenerateKeyForm(PGPSystem pgp) : this(pgp, null) { }
Пример #14
0
 /// <summary>Initializes a new <see cref="NewSubkeyForm"/> with the <see cref="PGPSystem"/> that will be used to
 /// create the subkey.
 /// </summary>
 public NewSubkeyForm(PGPSystem pgp) : this()
 {
   Initialize(pgp);
 }