// internal AND protected internal override GpgInterfaceResult ProcessLine(String line) { if (!GNUCheck(ref line)) { return(GpgInterfaceResult.Success); } switch (GetKeyword(ref line)) { case GpgKeyword.GET_LINE: { if (String.Equals(line, "keygen.valid", StringComparison.Ordinal)) { WriteLine(GpgConvert.ToDays(ExpirationDate)); } break; } case GpgKeyword.GET_HIDDEN: { if (String.Equals(line, "passphrase.enter", StringComparison.Ordinal)) { SecureString password = InternalAskPassphrase(KeyId); if (IsNullOrEmpty(password)) { return(GpgInterfaceResult.UserAbort); } WritePassword(password); } break; } case GpgKeyword.BAD_PASSPHRASE: { if (IsMaxTries()) { return(GpgInterfaceResult.BadPassphrase); } break; } } return(GpgInterfaceResult.Success); }
// internal AND protected internal override GpgInterfaceResult ProcessLine(String line) { if (!GNUCheck(ref line)) { return(GpgInterfaceResult.Success); } switch (GetKeyword(ref line)) { case GpgKeyword.GET_LINE: { switch (line) { case "keygen.algo": WriteLine(GpgConvert.ToId(Algorithm)); break; case "keygen.size": WriteLine(Size); break; case "keygen.valid": WriteLine(GpgConvert.ToDays(ExpirationDate)); break; case "keygen.name": WriteLine(EncodeString(Name)); break; case "keygen.email": WriteLine(EncodeString(Email)); break; case "keygen.comment": WriteLine(EncodeString(Comment)); break; } break; } case GpgKeyword.PROGRESS: { String[] parts = line.Split(' '); if (parts.Length >= 4) { switch (parts[0]) { case "primegen": return(new GpgInterfaceResult(GpgInterfaceStatus.Processing, GpgInterfaceMessage.GeneratingPrimeNumbers)); case "pk_dsa": return(new GpgInterfaceResult(GpgInterfaceStatus.Processing, GpgInterfaceMessage.GeneratingDsaKey)); case "pk_elg": return(new GpgInterfaceResult(GpgInterfaceStatus.Processing, GpgInterfaceMessage.GeneratingELGamalKey)); case "need_entropy": return(new GpgInterfaceResult(GpgInterfaceStatus.Processing, GpgInterfaceMessage.NeedEntropy)); } } break; } case GpgKeyword.KEY_CREATED: { String[] parts = line.Split(' '); FingerPrint = parts[1]; break; } case GpgKeyword.KEY_NOT_CREATED: { return(new GpgInterfaceResult(GpgInterfaceStatus.Error, GpgInterfaceMessage.KeyNotCreated)); } case GpgKeyword.GET_HIDDEN: { if (String.Equals(line, "passphrase.enter", StringComparison.Ordinal)) { SecureString password = InternalAskPassphrase(Name, true); if (IsNullOrEmpty(password)) { return(GpgInterfaceResult.UserAbort); } WritePassword(password); } break; } } return(GpgInterfaceResult.Success); }