201
367
{ 300, NULL, 0, N_("@Commands:\n ") },
203
369
{ aSign, "sign", 256, N_("|[file]|make a signature")},
204
{ aClearsign, "clearsign", 256, N_("|[file]|make a clear text signature") },
370
{ aClearsign, "clearsign", 256, N_("|[file]|make a clear text signature")},
205
371
{ aDetachedSign, "detach-sign", 256, N_("make a detached signature")},
206
372
{ aEncr, "encrypt", 256, N_("encrypt data")},
373
{ aEncrFiles, "encrypt-files", 256, "@"},
207
374
{ aSym, "symmetric", 256, N_("encryption only with symmetric cipher")},
208
{ aStore, "store", 256, N_("store only")},
375
{ aStore, "store", 256, "@"},
209
376
{ aDecrypt, "decrypt", 256, N_("decrypt data (default)")},
377
{ aDecryptFiles, "decrypt-files", 256, "@"},
210
378
{ aVerify, "verify" , 256, N_("verify a signature")},
211
379
{ aVerifyFiles, "verify-files" , 256, "@" },
212
380
{ aListKeys, "list-keys", 256, N_("list keys")},
213
381
{ aListKeys, "list-public-keys", 256, "@" },
214
382
{ aListSigs, "list-sigs", 256, N_("list keys and signatures")},
215
{ aCheckKeys, "check-sigs",256, N_("check key signatures")},
383
{ aCheckKeys, "check-sigs",256, N_("list and check key signatures")},
216
384
{ oFingerprint, "fingerprint", 256, N_("list keys and fingerprints")},
217
385
{ aListSecretKeys, "list-secret-keys", 256, N_("list secret keys")},
218
386
{ aKeygen, "gen-key", 256, N_("generate a new key pair")},
219
{ aDeleteKey, "delete-key",256, N_("remove key from the public keyring")},
220
{ aDeleteSecretKey, "delete-secret-key",256,
221
N_("remove key from the secret keyring")},
387
{ aDeleteKeys,"delete-keys",256,N_("remove keys from the public keyring")},
388
{ aDeleteSecretKeys, "delete-secret-keys",256,
389
N_("remove keys from the secret keyring")},
222
390
{ aSignKey, "sign-key" ,256, N_("sign a key")},
223
391
{ aLSignKey, "lsign-key" ,256, N_("sign a key locally")},
224
392
{ aEditKey, "edit-key" ,256, N_("sign or edit a key")},
225
393
{ aGenRevoke, "gen-revoke",256, N_("generate a revocation certificate")},
394
{ aDesigRevoke, "desig-revoke",256, "@" },
226
395
{ aExport, "export" , 256, N_("export keys") },
227
396
{ aSendKeys, "send-keys" , 256, N_("export keys to a key server") },
228
397
{ aRecvKeys, "recv-keys" , 256, N_("import keys from a key server") },
229
{ aExportAll, "export-all" , 256, "@" },
398
{ aSearchKeys, "search-keys" , 256,
399
N_("search for keys on a key server") },
400
{ aRefreshKeys, "refresh-keys", 256,
401
N_("update all keys from a keyserver")},
402
{ aFetchKeys, "fetch-keys" , 256, "@" },
230
403
{ aExportSecret, "export-secret-keys" , 256, "@" },
231
404
{ aExportSecretSub, "export-secret-subkeys" , 256, "@" },
232
405
{ aImport, "import", 256 , N_("import/merge keys")},
233
406
{ aFastImport, "fast-import", 256 , "@"},
234
{ aListPackets, "list-packets",256,N_("list only the sequence of packets")},
236
"export-ownertrust", 256, N_("export the ownertrust values")},
238
"import-ownertrust", 256 , N_("import ownertrust values")},
407
#ifdef ENABLE_CARD_SUPPORT
408
{ aCardStatus, "card-status", 256, N_("print the card status")},
409
{ aCardEdit, "card-edit", 256, N_("change data on a card")},
410
{ aChangePIN, "change-pin", 256, N_("change a card's PIN")},
412
{ aListConfig, "list-config", 256, "@"},
413
{ aGPGConfList, "gpgconf-list", 256, "@" },
414
{ aGPGConfTest, "gpgconf-test", 256, "@" },
415
{ aListPackets, "list-packets",256, "@"},
416
{ aExportOwnerTrust, "export-ownertrust", 256, "@"},
417
{ aImportOwnerTrust, "import-ownertrust", 256, "@"},
239
418
{ aUpdateTrustDB,
240
419
"update-trustdb",0 , N_("update the trust database")},
242
"check-trustdb",0 , N_("|[NAMES]|check the trust database")},
243
{ aFixTrustDB, "fix-trustdb",0 , N_("fix a corrupted trust database")},
244
{ aDeArmor, "dearmor", 256, N_("De-Armor a file or stdin") },
245
{ aDeArmor, "dearmour", 256, "@" },
246
{ aEnArmor, "enarmor", 256, N_("En-Armor a file or stdin") },
247
{ aEnArmor, "enarmour", 256, "@" },
420
{ aCheckTrustDB, "check-trustdb", 0, "@"},
421
{ aFixTrustDB, "fix-trustdb", 0, "@"},
422
{ aDeArmor, "dearmor", 256, "@"},
423
{ aDeArmor, "dearmour", 256, "@"},
424
{ aEnArmor, "enarmor", 256, "@"},
425
{ aEnArmor, "enarmour", 256, "@"},
248
426
{ aPrintMD, "print-md" , 256, N_("|algo [files]|print message digests")},
249
{ aPrintHMAC, "print-hmac" , 256, "@"},
250
427
{ aPrimegen, "gen-prime" , 256, "@" },
251
{ aGenRandom, "gen-random" , 256, "@" },
428
{ aGenRandom, "gen-random", 256, "@" },
429
{ aServer, "server", 256, N_("run in server mode")},
253
431
{ 301, NULL, 0, N_("@\nOptions:\n ") },
255
433
{ oArmor, "armor", 0, N_("create ascii armored output")},
256
434
{ oArmor, "armour", 0, "@" },
257
435
{ oRecipient, "recipient", 2, N_("|NAME|encrypt for NAME")},
436
{ oHiddenRecipient, "hidden-recipient", 2, "@" },
258
437
{ oRecipient, "remote-user", 2, "@"}, /* old option name */
259
{ oDefRecipient, "default-recipient" ,2,
260
N_("|NAME|use NAME as default recipient")},
261
{ oDefRecipientSelf, "default-recipient-self" ,0,
262
N_("use the default key as default recipient")},
438
{ oDefRecipient, "default-recipient", 2, "@"},
439
{ oDefRecipientSelf, "default-recipient-self", 0, "@"},
263
440
{ oNoDefRecipient, "no-default-recipient", 0, "@" },
441
{ oTempDir, "temp-directory", 2, "@" },
442
{ oExecPath, "exec-path", 2, "@" },
264
443
{ oEncryptTo, "encrypt-to", 2, "@" },
444
{ oHiddenEncryptTo, "hidden-encrypt-to", 2, "@" },
265
445
{ oNoEncryptTo, "no-encrypt-to", 0, "@" },
266
{ oUser, "local-user",2, N_("use this user-id to sign or decrypt")},
267
{ oCompress, NULL, 1, N_("|N|set compress level N (0 disables)") },
446
{ oLocalUser, "local-user",2, N_("use this user-id to sign or decrypt")},
447
{ oCompress, NULL, 1, N_("|N|set compress level N (0 disables)") },
448
{ oCompressLevel, "compress-level", 1, "@" },
449
{ oBZ2CompressLevel, "bzip2-compress-level", 1, "@" },
450
{ oBZ2DecompressLowmem, "bzip2-decompress-lowmem", 0, "@" },
268
451
{ oTextmodeShort, NULL, 0, "@"},
269
452
{ oTextmode, "textmode", 0, N_("use canonical text mode")},
270
{ oOutput, "output", 2, N_("use as output file")},
453
{ oNoTextmode, "no-textmode", 0, "@"},
454
{ oExpert, "expert", 0, "@"},
455
{ oNoExpert, "no-expert", 0, "@"},
456
{ oDefSigExpire, "default-sig-expire", 2, "@"},
457
{ oAskSigExpire, "ask-sig-expire", 0, "@"},
458
{ oNoAskSigExpire, "no-ask-sig-expire", 0, "@"},
459
{ oDefCertExpire, "default-cert-expire", 2, "@"},
460
{ oAskCertExpire, "ask-cert-expire", 0, "@"},
461
{ oNoAskCertExpire, "no-ask-cert-expire", 0, "@"},
462
{ oDefCertLevel, "default-cert-level", 1, "@"},
463
{ oMinCertLevel, "min-cert-level", 1, "@"},
464
{ oAskCertLevel, "ask-cert-level", 0, "@"},
465
{ oNoAskCertLevel, "no-ask-cert-level", 0, "@"},
466
{ oOutput, "output", 2, N_("|FILE|write output to FILE")},
467
{ oMaxOutput, "max-output", 16|4, "@" },
271
468
{ oVerbose, "verbose", 0, N_("verbose") },
272
{ oQuiet, "quiet", 0, N_("be somewhat more quiet") },
273
{ oNoTTY, "no-tty", 0, N_("don't use the terminal at all") },
274
{ oForceV3Sigs, "force-v3-sigs", 0, N_("force v3 signatures") },
275
{ oForceMDC, "force-mdc", 0, N_("always use a MDC for encryption") },
469
{ oQuiet, "quiet", 0, "@"},
470
{ oNoTTY, "no-tty", 0, "@"},
471
{ oForceV3Sigs, "force-v3-sigs", 0, "@"},
472
{ oNoForceV3Sigs, "no-force-v3-sigs", 0, "@"},
473
{ oForceV4Certs, "force-v4-certs", 0, "@"},
474
{ oNoForceV4Certs, "no-force-v4-certs", 0, "@"},
475
{ oForceMDC, "force-mdc", 0, "@"},
476
{ oNoForceMDC, "no-force-mdc", 0, "@" },
477
{ oDisableMDC, "disable-mdc", 0, "@"},
478
{ oNoDisableMDC, "no-disable-mdc", 0, "@" },
276
479
{ oDryRun, "dry-run", 0, N_("do not make any changes") },
277
/*{ oInteractive, "interactive", 0, N_("prompt before overwriting") }, */
278
{ oUseAgent, "use-agent",0, N_("use the gpg-agent")},
279
{ oBatch, "batch", 0, N_("batch mode: never ask")},
280
{ oAnswerYes, "yes", 0, N_("assume yes on most questions")},
281
{ oAnswerNo, "no", 0, N_("assume no on most questions")},
282
{ oKeyring, "keyring" ,2, N_("add this keyring to the list of keyrings")},
283
{ oSecretKeyring, "secret-keyring" ,2, N_("add this secret keyring to the list")},
284
{ oDefaultKey, "default-key" ,2, N_("|NAME|use NAME as default secret key")},
285
{ oKeyServer, "keyserver",2, N_("|HOST|use this keyserver to lookup keys")},
286
{ oCharset, "charset" , 2, N_("|NAME|set terminal charset to NAME") },
287
{ oOptions, "options" , 2, N_("read options from file")},
480
{ oInteractive, "interactive", 0, N_("prompt before overwriting") },
481
{ oUseAgent, "use-agent",0, "@"},
482
{ oNoUseAgent, "no-use-agent",0, "@"},
483
{ oGpgAgentInfo, "gpg-agent-info",2, "@"},
484
{ oBatch, "batch", 0, "@"},
485
{ oAnswerYes, "yes", 0, "@"},
486
{ oAnswerNo, "no", 0, "@"},
487
{ oKeyring, "keyring", 2, "@"},
488
{ oPrimaryKeyring, "primary-keyring",2, "@" },
489
{ oSecretKeyring, "secret-keyring", 2, "@"},
490
{ oShowKeyring, "show-keyring", 0, "@"},
491
{ oDefaultKey, "default-key", 2, "@"},
492
{ oKeyServer, "keyserver", 2, "@"},
493
{ oKeyServerOptions, "keyserver-options",2,"@"},
494
{ oImportOptions, "import-options",2,"@"},
495
{ oExportOptions, "export-options",2,"@"},
496
{ oListOptions, "list-options",2,"@"},
497
{ oVerifyOptions, "verify-options",2,"@"},
498
{ oDisplayCharset, "display-charset", 2, "@"},
499
{ oDisplayCharset, "charset", 2, "@"},
500
{ oOptions, "options", 2, "@"},
289
501
{ oDebug, "debug" ,4|16, "@"},
502
{ oDebugLevel, "debug-level" ,2, "@"},
290
503
{ oDebugAll, "debug-all" ,0, "@"},
291
{ oStatusFD, "status-fd" ,1, N_("|FD|write status info to this FD") },
292
{ oNoComment, "no-comment", 0, "@"},
504
{ oStatusFD, "status-fd" ,1, "@"},
505
{ oStatusFile, "status-file" ,2, "@"},
506
{ oAttributeFD, "attribute-fd" ,1, "@" },
507
{ oAttributeFile, "attribute-file" ,2, "@" },
508
{ oNoop, "sk-comments", 0, "@"},
509
{ oNoop, "no-sk-comments", 0, "@"},
293
510
{ oCompletesNeeded, "completes-needed", 1, "@"},
294
511
{ oMarginalsNeeded, "marginals-needed", 1, "@"},
295
512
{ oMaxCertDepth, "max-cert-depth", 1, "@" },
296
{ oTrustedKey, "trusted-key", 2, N_("|KEYID|ulimately trust this key")},
297
{ oLoadExtension, "load-extension" ,2, N_("|FILE|load extension module FILE")},
298
{ oRFC1991, "rfc1991", 0, N_("emulate the mode described in RFC1991")},
299
{ oOpenPGP, "openpgp", 0, N_("set all packet, cipher and digest options to OpenPGP behavior")},
300
{ oS2KMode, "s2k-mode", 1, N_("|N|use passphrase mode N")},
301
{ oS2KDigest, "s2k-digest-algo",2,
302
N_("|NAME|use message digest algorithm NAME for passphrases")},
303
{ oS2KCipher, "s2k-cipher-algo",2,
304
N_("|NAME|use cipher algorithm NAME for passphrases")},
305
{ oCipherAlgo, "cipher-algo", 2 , N_("|NAME|use cipher algorithm NAME")},
306
{ oDigestAlgo, "digest-algo", 2 , N_("|NAME|use message digest algorithm NAME")},
307
{ oCompressAlgo, "compress-algo", 1 , N_("|N|use compress algorithm N")},
308
{ oThrowKeyid, "throw-keyid", 0, N_("throw keyid field of encrypted packets")},
309
{ oNotation, "notation-data", 2, N_("|NAME=VALUE|use this notation data")},
513
{ oTrustedKey, "trusted-key", 2, "@"},
514
{ oLoadExtension, "load-extension", 2, "@"},
515
{ oGnuPG, "gnupg", 0, "@"},
516
{ oGnuPG, "no-pgp2", 0, "@"},
517
{ oGnuPG, "no-pgp6", 0, "@"},
518
{ oGnuPG, "no-pgp7", 0, "@"},
519
{ oGnuPG, "no-pgp8", 0, "@"},
520
{ oRFC1991, "rfc1991", 0, "@"},
521
{ oRFC2440, "rfc2440", 0, "@" },
522
{ oRFC4880, "rfc4880", 0, "@" },
523
{ oOpenPGP, "openpgp", 0, N_("use strict OpenPGP behavior")},
524
{ oPGP2, "pgp2", 0, N_("generate PGP 2.x compatible messages")},
525
{ oPGP6, "pgp6", 0, "@"},
526
{ oPGP7, "pgp7", 0, "@"},
527
{ oPGP8, "pgp8", 0, "@"},
528
{ oRFC2440Text, "rfc2440-text", 0, "@"},
529
{ oNoRFC2440Text, "no-rfc2440-text", 0, "@"},
530
{ oS2KMode, "s2k-mode", 1, "@"},
531
{ oS2KDigest, "s2k-digest-algo", 2, "@"},
532
{ oS2KCipher, "s2k-cipher-algo", 2, "@"},
533
{ oS2KCount, "s2k-count", 1, "@"},
534
{ oSimpleSKChecksum, "simple-sk-checksum", 0, "@"},
535
{ oCipherAlgo, "cipher-algo", 2, "@"},
536
{ oDigestAlgo, "digest-algo", 2, "@"},
537
{ oCertDigestAlgo, "cert-digest-algo", 2 , "@" },
538
{ oCompressAlgo,"compress-algo", 2, "@"},
539
{ oCompressAlgo, "compression-algo", 2, "@"}, /* Alias */
540
{ oThrowKeyids, "throw-keyid", 0, "@"},
541
{ oThrowKeyids, "throw-keyids", 0, "@"},
542
{ oNoThrowKeyids, "no-throw-keyid", 0, "@" },
543
{ oNoThrowKeyids, "no-throw-keyids", 0, "@" },
544
{ oShowPhotos, "show-photos", 0, "@" },
545
{ oNoShowPhotos, "no-show-photos", 0, "@" },
546
{ oPhotoViewer, "photo-viewer", 2, "@" },
547
{ oSetNotation, "set-notation", 2, "@" },
548
{ oSetNotation, "notation-data", 2, "@" }, /* Alias */
549
{ oSigNotation, "sig-notation", 2, "@" },
550
{ oCertNotation, "cert-notation", 2, "@" },
311
552
{ 302, NULL, 0, N_(
312
553
"@\n(See the man page for a complete listing of all commands and options)\n"
345
594
{ oSkipVerify, "skip-verify",0, "@" },
346
595
{ oCompressKeys, "compress-keys",0, "@"},
347
596
{ oCompressSigs, "compress-sigs",0, "@"},
597
{ oDefCertLevel, "default-cert-check-level", 1, "@"}, /* Old option */
348
598
{ oAlwaysTrust, "always-trust", 0, "@"},
349
{ oRunAsShmCP, "run-as-shm-coprocess", 4, "@" },
599
{ oTrustModel, "trust-model", 2, "@"},
600
{ oForceOwnertrust, "force-ownertrust", 2, "@"},
350
601
{ oSetFilename, "set-filename", 2, "@" },
602
{ oForYourEyesOnly, "for-your-eyes-only", 0, "@" },
603
{ oNoForYourEyesOnly, "no-for-your-eyes-only", 0, "@" },
351
604
{ oSetPolicyURL, "set-policy-url", 2, "@" },
605
{ oSigPolicyURL, "sig-policy-url", 2, "@" },
606
{ oCertPolicyURL, "cert-policy-url", 2, "@" },
607
{ oShowPolicyURL, "show-policy-url", 0, "@" },
608
{ oNoShowPolicyURL, "no-show-policy-url", 0, "@" },
609
{ oSigKeyserverURL, "sig-keyserver-url", 2, "@" },
610
{ oShowNotation, "show-notation", 0, "@" },
611
{ oNoShowNotation, "no-show-notation", 0, "@" },
352
612
{ oComment, "comment", 2, "@" },
353
613
{ oDefaultComment, "default-comment", 0, "@" },
354
{ oNoVersion, "no-version", 0, "@"},
614
{ oNoComments, "no-comments", 0, "@" },
355
615
{ oEmitVersion, "emit-version", 0, "@"},
616
{ oNoEmitVersion, "no-emit-version", 0, "@"},
617
{ oNoEmitVersion, "no-version", 0, "@"}, /* alias */
356
618
{ oNotDashEscaped, "not-dash-escaped", 0, "@" },
357
619
{ oEscapeFrom, "escape-from-lines", 0, "@" },
620
{ oNoEscapeFrom, "no-escape-from-lines", 0, "@" },
358
621
{ oLockOnce, "lock-once", 0, "@" },
359
622
{ oLockMultiple, "lock-multiple", 0, "@" },
360
623
{ oLockNever, "lock-never", 0, "@" },
361
624
{ oLoggerFD, "logger-fd",1, "@" },
625
{ oLoggerFile, "log-file",2, "@" },
626
{ oLoggerFile, "logger-file",2, "@" }, /* For 1.4 compatibility. */
362
627
{ oUseEmbeddedFilename, "use-embedded-filename", 0, "@" },
628
{ oNoUseEmbeddedFilename, "no-use-embedded-filename", 0, "@" },
363
629
{ oUtf8Strings, "utf8-strings", 0, "@" },
364
630
{ oNoUtf8Strings, "no-utf8-strings", 0, "@" },
365
631
{ oWithFingerprint, "with-fingerprint", 0, "@" },
366
632
{ oDisableCipherAlgo, "disable-cipher-algo", 2, "@" },
367
633
{ oDisablePubkeyAlgo, "disable-pubkey-algo", 2, "@" },
368
634
{ oAllowNonSelfsignedUID, "allow-non-selfsigned-uid", 0, "@" },
635
{ oNoAllowNonSelfsignedUID, "no-allow-non-selfsigned-uid", 0, "@" },
369
636
{ oAllowFreeformUID, "allow-freeform-uid", 0, "@" },
637
{ oNoAllowFreeformUID, "no-allow-freeform-uid", 0, "@" },
370
638
{ oNoLiteral, "no-literal", 0, "@" },
371
639
{ oSetFilesize, "set-filesize", 20, "@" },
372
640
{ oHonorHttpProxy,"honor-http-proxy", 0, "@" },
373
641
{ oFastListMode,"fast-list-mode", 0, "@" },
642
{ oFixedListMode,"fixed-list-mode", 0, "@" },
374
643
{ oListOnly, "list-only", 0, "@"},
375
644
{ oIgnoreTimeConflict, "ignore-time-conflict", 0, "@" },
645
{ oIgnoreValidFrom, "ignore-valid-from", 0, "@" },
646
{ oIgnoreCrcError, "ignore-crc-error", 0,"@" },
647
{ oIgnoreMDCError, "ignore-mdc-error", 0,"@" },
648
{ oShowSessionKey, "show-session-key", 0, "@" },
649
{ oOverrideSessionKey, "override-session-key", 2, "@" },
376
650
{ oNoRandomSeedFile, "no-random-seed-file", 0, "@" },
651
{ oAutoKeyRetrieve, "auto-key-retrieve", 0, "@" },
377
652
{ oNoAutoKeyRetrieve, "no-auto-key-retrieve", 0, "@" },
653
{ oNoSigCache, "no-sig-cache", 0, "@" },
654
{ oNoSigCreateCheck, "no-sig-create-check", 0, "@" },
655
{ oAutoCheckTrustDB, "auto-check-trustdb", 0, "@"},
656
{ oNoAutoCheckTrustDB, "no-auto-check-trustdb", 0, "@"},
378
657
{ oMergeOnly, "merge-only", 0, "@" },
658
{ oAllowSecretKeyImport, "allow-secret-key-import", 0, "@" },
379
659
{ oTryAllSecrets, "try-all-secrets", 0, "@" },
380
{ oEmuMDEncodeBug, "emulate-md-encode-bug", 0, "@"},
385
int gpg_errors_seen = 0;
660
{ oEnableSpecialFilenames, "enable-special-filenames", 0, "@" },
661
{ oNoExpensiveTrustChecks, "no-expensive-trust-checks", 0, "@" },
662
{ aDeleteSecretAndPublicKeys, "delete-secret-and-public-keys",256, "@" },
663
{ aRebuildKeydbCaches, "rebuild-keydb-caches", 256, "@"},
664
{ oPreservePermissions, "preserve-permissions", 0, "@"},
665
{ oDefaultPreferenceList, "default-preference-list", 2, "@"},
666
{ oDefaultKeyserverURL, "default-keyserver-url", 2, "@"},
667
{ oPersonalCipherPreferences, "personal-cipher-preferences", 2, "@"},
668
{ oPersonalDigestPreferences, "personal-digest-preferences", 2, "@"},
669
{ oPersonalCompressPreferences, "personal-compress-preferences", 2, "@"},
670
/* Aliases. I constantly mistype these, and assume other people
672
{ oPersonalCipherPreferences, "personal-cipher-prefs", 2, "@"},
673
{ oPersonalDigestPreferences, "personal-digest-prefs", 2, "@"},
674
{ oPersonalCompressPreferences, "personal-compress-prefs", 2, "@"},
675
{ oAgentProgram, "agent-program", 2 , "@" },
676
{ oDisplay, "display", 2, "@" },
677
{ oTTYname, "ttyname", 2, "@" },
678
{ oTTYtype, "ttytype", 2, "@" },
679
{ oLCctype, "lc-ctype", 2, "@" },
680
{ oLCmessages, "lc-messages", 2, "@" },
681
{ oXauthority, "xauthority", 2, "@" },
682
{ oGroup, "group", 2, "@" },
683
{ oUnGroup, "ungroup", 2, "@" },
684
{ oNoGroups, "no-groups", 0, "@" },
685
{ oStrict, "strict", 0, "@" },
686
{ oNoStrict, "no-strict", 0, "@" },
687
{ oMangleDosFilenames, "mangle-dos-filenames", 0, "@" },
688
{ oNoMangleDosFilenames, "no-mangle-dos-filenames", 0, "@" },
689
{ oEnableProgressFilter, "enable-progress-filter", 0, "@" },
690
{ oMultifile, "multifile", 0, "@" },
691
{ oKeyidFormat, "keyid-format", 2, "@" },
692
{ oExitOnStatusWriteError, "exit-on-status-write-error", 0, "@" },
693
{ oLimitCardInsertTries, "limit-card-insert-tries", 1, "@"},
695
{ oAllowMultisigVerification, "allow-multisig-verification", 0, "@"},
696
{ oEnableDSA2, "enable-dsa2", 0, "@"},
697
{ oDisableDSA2, "disable-dsa2", 0, "@"},
698
{ oAllowMultipleMessages, "allow-multiple-messages", 0, "@"},
699
{ oNoAllowMultipleMessages, "no-allow-multiple-messages", 0, "@"},
701
/* These two are aliases to help users of the PGP command line
702
product use gpg with minimal pain. Many commands are common
703
already as they seem to have borrowed commands from us. Now
704
I'm returning the favor. */
705
{ oLocalUser, "sign-with", 2, "@" },
706
{ oRecipient, "user", 2, "@" },
707
{ oRequireCrossCert, "require-backsigs", 0, "@"},
708
{ oRequireCrossCert, "require-cross-certification", 0, "@"},
709
{ oNoRequireCrossCert, "no-require-backsigs", 0, "@"},
710
{ oNoRequireCrossCert, "no-require-cross-certification", 0, "@"},
711
{ oAutoKeyLocate, "auto-key-locate", 2, "@"},
712
{ oNoAutoKeyLocate, "no-auto-key-locate", 0, "@"},
718
#ifdef ENABLE_SELINUX_HACKS
719
#define ALWAYS_ADD_KEYRINGS 1
721
#define ALWAYS_ADD_KEYRINGS 0
725
int g10_errors_seen = 0;
387
727
static int utf8_strings = 0;
388
728
static int maybe_setuid = 1;
390
static char *build_list( const char *text,
730
static char *build_list( const char *text, char letter,
391
731
const char *(*mapf)(int), int (*chkf)(int) );
732
static char *build_lib_list (const char *text);
392
733
static void set_cmd( enum cmd_and_opt_values *ret_cmd,
393
734
enum cmd_and_opt_values new_cmd );
394
static void print_hex( byte *p, size_t n );
395
static void print_mds( const char *fname, int algo, const char *key );
396
static void add_notation_data( const char *string );
397
static int check_policy_url( const char *s );
401
our_pk_test_algo( int algo )
403
return openpgp_pk_test_algo( algo, 0 );
735
static void print_mds( const char *fname, int algo );
736
static void add_notation_data( const char *string, int which );
737
static void add_policy_url( const char *string, int which );
738
static void add_keyserver_url( const char *string, int which );
739
static void emergency_cleanup (void);
406
742
static const char *
407
743
my_strusage( int level )
409
static char *digests, *pubkeys, *ciphers;
745
static char *digests, *pubkeys, *ciphers, *zips, *libs;
411
747
switch( level ) {
412
748
case 11: p = "gpg (GnuPG)";
586
1072
cmd = aSignEncr;
587
1073
else if( cmd == aEncr && new_cmd == aSign )
588
1074
cmd = aSignEncr;
589
else if( cmd == aKMode && new_cmd == aSym )
1075
else if( cmd == aSign && new_cmd == aSym )
1077
else if( cmd == aSym && new_cmd == aSign )
1079
else if( cmd == aSym && new_cmd == aEncr )
1081
else if( cmd == aEncr && new_cmd == aSym )
1083
else if (cmd == aSignEncr && new_cmd == aSym)
1085
else if (cmd == aSignSym && new_cmd == aEncr)
1087
else if (cmd == aEncrSym && new_cmd == aSign)
591
1089
else if( ( cmd == aSign && new_cmd == aClearsign )
592
1090
|| ( cmd == aClearsign && new_cmd == aSign ) )
593
1091
cmd = aClearsign;
595
1093
log_error(_("conflicting commands\n"));
1102
add_group(char *string)
1105
struct groupitem *item;
1107
/* Break off the group name */
1108
name=strsep(&string,"=");
1111
log_error(_("no = sign found in group definition `%s'\n"),name);
1115
trim_trailing_ws(name,strlen(name));
1117
/* Does this group already exist? */
1118
for(item=opt.grouplist;item;item=item->next)
1119
if(strcasecmp(item->name,name)==0)
1124
item=xmalloc(sizeof(struct groupitem));
1126
item->next=opt.grouplist;
1131
/* Break apart the values */
1132
while ((value= strsep(&string," \t")))
1135
add_to_strlist2(&item->values,value,utf8_strings);
1141
rm_group(char *name)
1143
struct groupitem *item,*last=NULL;
1145
trim_trailing_ws(name,strlen(name));
1147
for(item=opt.grouplist;item;last=item,item=item->next)
1149
if(strcasecmp(item->name,name)==0)
1152
last->next=item->next;
1154
opt.grouplist=item->next;
1156
free_strlist(item->values);
1164
/* We need to check three things.
1166
0) The homedir. It must be x00, a directory, and owned by the
1169
1) The options/gpg.conf file. Okay unless it or its containing
1170
directory is group or other writable or not owned by us. Disable
1173
2) Extensions. Same as #1.
1175
Returns true if the item is unsafe. */
1177
check_permissions(const char *path,int item)
1179
#if defined(HAVE_STAT) && !defined(HAVE_DOSISH_SYSTEM)
1180
static int homedir_cache=-1;
1182
struct stat statbuf,dirbuf;
1183
int homedir=0,ret=0,checkonly=0;
1184
int perm=0,own=0,enc_dir_perm=0,enc_dir_own=0;
1186
if(opt.no_perm_warn)
1189
assert(item==0 || item==1 || item==2);
1191
/* extensions may attach a path */
1192
if(item==2 && path[0]!=DIRSEP_C)
1194
if(strchr(path,DIRSEP_C))
1195
tmppath=make_filename(path,NULL);
1197
tmppath=make_filename(gnupg_libdir (),path,NULL);
1200
tmppath=xstrdup(path);
1202
/* If the item is located in the homedir, but isn't the homedir,
1203
don't continue if we already checked the homedir itself. This is
1204
to avoid user confusion with an extra options file warning which
1205
could be rectified if the homedir itself had proper
1207
if(item!=0 && homedir_cache>-1
1208
&& ascii_strncasecmp(opt.homedir,tmppath,strlen(opt.homedir))==0)
1214
/* It's okay if the file or directory doesn't exist */
1215
if(stat(tmppath,&statbuf)!=0)
1221
/* Now check the enclosing directory. Theoretically, we could walk
1222
this test up to the root directory /, but for the sake of sanity,
1223
I'm stopping at one level down. */
1224
dir=make_dirname(tmppath);
1226
if(stat(dir,&dirbuf)!=0 || !S_ISDIR(dirbuf.st_mode))
1235
/* Assume failure */
1240
/* The homedir must be x00, a directory, and owned by the user. */
1242
if(S_ISDIR(statbuf.st_mode))
1244
if(statbuf.st_uid==getuid())
1246
if((statbuf.st_mode & (S_IRWXG|S_IRWXO))==0)
1257
else if(item==1 || item==2)
1259
/* The options or extension file. Okay unless it or its
1260
containing directory is group or other writable or not owned
1263
if(S_ISREG(statbuf.st_mode))
1265
if(statbuf.st_uid==getuid() || statbuf.st_uid==0)
1267
if((statbuf.st_mode & (S_IWGRP|S_IWOTH))==0)
1269
/* it's not writable, so make sure the enclosing
1270
directory is also not writable */
1271
if(dirbuf.st_uid==getuid() || dirbuf.st_uid==0)
1273
if((dirbuf.st_mode & (S_IWGRP|S_IWOTH))==0)
1283
/* it's writable, so the enclosing directory had
1284
better not let people get to it. */
1285
if(dirbuf.st_uid==getuid() || dirbuf.st_uid==0)
1287
if((dirbuf.st_mode & (S_IRWXG|S_IRWXO))==0)
1290
perm=enc_dir_perm=1; /* unclear which one to fix! */
1308
log_info(_("WARNING: unsafe ownership on"
1309
" homedir `%s'\n"),tmppath);
1311
log_info(_("WARNING: unsafe ownership on"
1312
" configuration file `%s'\n"),tmppath);
1314
log_info(_("WARNING: unsafe ownership on"
1315
" extension `%s'\n"),tmppath);
1320
log_info(_("WARNING: unsafe permissions on"
1321
" homedir `%s'\n"),tmppath);
1323
log_info(_("WARNING: unsafe permissions on"
1324
" configuration file `%s'\n"),tmppath);
1326
log_info(_("WARNING: unsafe permissions on"
1327
" extension `%s'\n"),tmppath);
1332
log_info(_("WARNING: unsafe enclosing directory ownership on"
1333
" homedir `%s'\n"),tmppath);
1335
log_info(_("WARNING: unsafe enclosing directory ownership on"
1336
" configuration file `%s'\n"),tmppath);
1338
log_info(_("WARNING: unsafe enclosing directory ownership on"
1339
" extension `%s'\n"),tmppath);
1344
log_info(_("WARNING: unsafe enclosing directory permissions on"
1345
" homedir `%s'\n"),tmppath);
1347
log_info(_("WARNING: unsafe enclosing directory permissions on"
1348
" configuration file `%s'\n"),tmppath);
1350
log_info(_("WARNING: unsafe enclosing directory permissions on"
1351
" extension `%s'\n"),tmppath);
1363
#endif /* HAVE_STAT && !HAVE_DOSISH_SYSTEM */
1370
print_algo_numbers(int (*checker)(int))
1389
print_algo_names(int (*checker)(int),const char *(*mapper)(int))
1401
printf("%s",mapper(i));
1406
/* In the future, we can do all sorts of interesting configuration
1407
output here. For now, just give "group" as the Enigmail folks need
1408
it, and pubkey, cipher, hash, and compress as they may be useful
1411
list_config(char *items)
1413
int show_all=(items==NULL);
1416
if(!opt.with_colons)
1419
while(show_all || (name=strsep(&items," ")))
1423
if(show_all || ascii_strcasecmp(name,"group")==0)
1425
struct groupitem *iter;
1427
for(iter=opt.grouplist;iter;iter=iter->next)
1431
printf("cfg:group:");
1432
print_string(stdout,iter->name,strlen(iter->name),':');
1435
for(sl=iter->values;sl;sl=sl->next)
1437
print_sanitized_string2 (stdout, sl->d, ':',';');
1448
if(show_all || ascii_strcasecmp(name,"version")==0)
1450
printf("cfg:version:");
1451
print_string(stdout,VERSION,strlen(VERSION),':');
1456
if(show_all || ascii_strcasecmp(name,"pubkey")==0)
1458
printf("cfg:pubkey:");
1459
print_algo_numbers (openpgp_pk_test_algo);
1464
if(show_all || ascii_strcasecmp(name,"cipher")==0)
1466
printf("cfg:cipher:");
1467
print_algo_numbers(openpgp_cipher_test_algo);
1472
if (show_all || !ascii_strcasecmp (name,"ciphername"))
1474
printf ("cfg:ciphername:");
1475
print_algo_names (openpgp_cipher_test_algo,openpgp_cipher_algo_name);
1481
|| ascii_strcasecmp(name,"digest")==0
1482
|| ascii_strcasecmp(name,"hash")==0)
1484
printf("cfg:digest:");
1485
print_algo_numbers(openpgp_md_test_algo);
1491
|| !ascii_strcasecmp(name,"digestname")
1492
|| !ascii_strcasecmp(name,"hashname"))
1494
printf ("cfg:digestname:");
1495
print_algo_names (openpgp_md_test_algo, gcry_md_algo_name);
1500
if(show_all || ascii_strcasecmp(name,"compress")==0)
1502
printf("cfg:compress:");
1503
print_algo_numbers(check_compress_algo);
1508
if(show_all || ascii_strcasecmp(name,"ccid-reader-id")==0)
1510
#if defined(ENABLE_CARD_SUPPORT) && defined(HAVE_LIBUSB) \
1511
&& GNUPG_MAJOR_VERSION == 1
1513
char *p, *p2, *list = ccid_get_reader_list ();
1515
for (p=list; p && (p2 = strchr (p, '\n')); p = p2+1)
1518
printf("cfg:ccid-reader-id:%s\n", p);
1529
log_error(_("unknown configuration item `%s'\n"),name);
1534
/* List options and default values in the GPG Conf format. This is a
1535
new tool distributed with gnupg 1.9.x but we also want some limited
1536
support in older gpg versions. The output is the name of the
1537
configuration file and a list of options available for editing by
1540
gpgconf_list (const char *configfile)
1542
char *configfile_esc = percent_escape (configfile, NULL);
1544
printf ("gpgconf-gpg.conf:%lu:\"%s\n",
1545
GC_OPT_FLAG_DEFAULT, configfile_esc ? configfile_esc : "/dev/null");
1546
printf ("verbose:%lu:\n", GC_OPT_FLAG_NONE);
1547
printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE);
1548
printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE);
1549
printf ("reader-port:%lu:\n", GC_OPT_FLAG_NONE);
1550
printf ("default-key:%lu:\n", GC_OPT_FLAG_NONE);
1551
printf ("encrypt-to:%lu:\n", GC_OPT_FLAG_NONE);
1553
xfree (configfile_esc);
1558
parse_subpacket_list(char *list)
1561
byte subpackets[128],i;
1566
/* No arguments means all subpackets */
1567
memset(subpackets+1,1,sizeof(subpackets)-1);
1572
memset(subpackets,0,sizeof(subpackets));
1574
/* Merge with earlier copy */
1575
if(opt.show_subpackets)
1579
for(in=opt.show_subpackets;*in;in++)
1581
if(*in>127 || *in<1)
1584
if(!subpackets[*in])
1590
while((tok=strsep(&list," ,")))
1605
xfree(opt.show_subpackets);
1606
opt.show_subpackets=xmalloc(count+1);
1607
opt.show_subpackets[count--]=0;
1609
for(i=1;i<128 && count>=0;i++)
1611
opt.show_subpackets[count--]=i;
1618
parse_list_options(char *str)
1620
char *subpackets=""; /* something that isn't NULL */
1621
struct parse_options lopts[]=
1623
{"show-photos",LIST_SHOW_PHOTOS,NULL,
1624
N_("display photo IDs during key listings")},
1625
{"show-policy-urls",LIST_SHOW_POLICY_URLS,NULL,
1626
N_("show policy URLs during signature listings")},
1627
{"show-notations",LIST_SHOW_NOTATIONS,NULL,
1628
N_("show all notations during signature listings")},
1629
{"show-std-notations",LIST_SHOW_STD_NOTATIONS,NULL,
1630
N_("show IETF standard notations during signature listings")},
1631
{"show-standard-notations",LIST_SHOW_STD_NOTATIONS,NULL,
1633
{"show-user-notations",LIST_SHOW_USER_NOTATIONS,NULL,
1634
N_("show user-supplied notations during signature listings")},
1635
{"show-keyserver-urls",LIST_SHOW_KEYSERVER_URLS,NULL,
1636
N_("show preferred keyserver URLs during signature listings")},
1637
{"show-uid-validity",LIST_SHOW_UID_VALIDITY,NULL,
1638
N_("show user ID validity during key listings")},
1639
{"show-unusable-uids",LIST_SHOW_UNUSABLE_UIDS,NULL,
1640
N_("show revoked and expired user IDs in key listings")},
1641
{"show-unusable-subkeys",LIST_SHOW_UNUSABLE_SUBKEYS,NULL,
1642
N_("show revoked and expired subkeys in key listings")},
1643
{"show-keyring",LIST_SHOW_KEYRING,NULL,
1644
N_("show the keyring name in key listings")},
1645
{"show-sig-expire",LIST_SHOW_SIG_EXPIRE,NULL,
1646
N_("show expiration dates during signature listings")},
1647
{"show-sig-subpackets",LIST_SHOW_SIG_SUBPACKETS,NULL,
1652
/* C99 allows for non-constant initializers, but we'd like to
1653
compile everywhere, so fill in the show-sig-subpackets argument
1654
here. Note that if the parse_options array changes, we'll have
1655
to change the subscript here. */
1656
lopts[12].value=&subpackets;
1658
if(parse_options(str,&opt.list_options,lopts,1))
1660
if(opt.list_options&LIST_SHOW_SIG_SUBPACKETS)
1662
/* Unset so users can pass multiple lists in. */
1663
opt.list_options&=~LIST_SHOW_SIG_SUBPACKETS;
1664
if(!parse_subpacket_list(subpackets))
1667
else if(subpackets==NULL && opt.show_subpackets)
1669
/* User did 'no-show-subpackets' */
1670
xfree(opt.show_subpackets);
1671
opt.show_subpackets=NULL;
1681
/* Collapses argc/argv into a single string that must be freed */
1683
collapse_args(int argc,char *argv[])
1686
int i,first=1,len=0;
1690
len+=strlen(argv[i])+2;
1691
str=xrealloc(str,len);
1700
strcat(str,argv[i]);
1707
parse_trust_model(const char *model)
1709
if(ascii_strcasecmp(model,"pgp")==0)
1710
opt.trust_model=TM_PGP;
1711
else if(ascii_strcasecmp(model,"classic")==0)
1712
opt.trust_model=TM_CLASSIC;
1713
else if(ascii_strcasecmp(model,"always")==0)
1714
opt.trust_model=TM_ALWAYS;
1715
else if(ascii_strcasecmp(model,"direct")==0)
1716
opt.trust_model=TM_DIRECT;
1717
else if(ascii_strcasecmp(model,"auto")==0)
1718
opt.trust_model=TM_AUTO;
1720
log_error("unknown trust model `%s'\n",model);
1724
/* Pack an s2k iteration count into the form specified in 2440. If
1725
we're in between valid values, round up. */
1726
static unsigned char
1727
encode_s2k_iterations(int iterations)
1729
unsigned char c=0,result;
1732
if(iterations<=1024)
1735
if(iterations>=65011712)
1738
/* Need count to be in the range 16-31 */
1739
for(count=iterations>>6;count>=32;count>>=1)
1742
result=(c<<4)|(count-16);
1744
if(S2K_DECODE_COUNT(result)<iterations)
1751
/* This fucntion called to initialized a new control object. It is
1752
assumed that this object has been zeroed out before calling this
1755
gpg_init_default_ctrl (ctrl_t ctrl)
1760
/* This function is called to deinitialize a control object. It is
1763
gpg_deinit_default_ctrl (ctrl_t ctrl)
1769
get_default_configname (void)
1771
char *configname = NULL;
1772
char *name = xstrdup ("gpg" EXTSEP_S "conf-" SAFE_VERSION);
1773
char *ver = &name[strlen ("gpg" EXTSEP_S "conf-")];
1784
if ((tok = strrchr (ver, SAFE_VERSION_DASH)))
1786
else if ((tok = strrchr (ver, SAFE_VERSION_DOT)))
1792
configname = make_filename (opt.homedir, name, NULL);
1794
while (access (configname, R_OK));
1799
configname = make_filename (opt.homedir, "gpg" EXTSEP_S "conf", NULL);
1800
if (! access (configname, R_OK))
1802
/* Print a warning when both config files are present. */
1803
char *p = make_filename (opt.homedir, "options", NULL);
1804
if (! access (p, R_OK))
1805
log_info (_("NOTE: old default options file `%s' ignored\n"), p);
1810
/* Use the old default only if it exists. */
1811
char *p = make_filename (opt.homedir, "options", NULL);
1812
if (!access (p, R_OK))
605
main( int argc, char **argv )
1826
main (int argc, char **argv)
607
1828
ARGPARSE_ARGS pargs;
758
2072
while( optfile_parse( configfp, configname, &configlineno,
760
switch( pargs.r_opt ) {
761
case aCheckKeys: set_cmd( &cmd, aCheckKeys); break;
762
case aListPackets: set_cmd( &cmd, aListPackets); break;
763
case aImport: set_cmd( &cmd, aImport); break;
764
case aFastImport: set_cmd( &cmd, aFastImport); break;
765
case aSendKeys: set_cmd( &cmd, aSendKeys); break;
766
case aRecvKeys: set_cmd( &cmd, aRecvKeys); break;
767
case aExport: set_cmd( &cmd, aExport); break;
768
case aExportAll: set_cmd( &cmd, aExportAll); break;
769
case aListKeys: set_cmd( &cmd, aListKeys); break;
770
case aListSigs: set_cmd( &cmd, aListSigs); break;
771
case aExportSecret: set_cmd( &cmd, aExportSecret); break;
772
case aExportSecretSub: set_cmd( &cmd, aExportSecretSub); break;
773
case aDeleteSecretKey: set_cmd( &cmd, aDeleteSecretKey);
775
case aDeleteKey: set_cmd( &cmd, aDeleteKey); greeting=1; break;
2075
switch( pargs.r_opt )
2090
#ifdef ENABLE_CARD_SUPPORT
2094
#endif /* ENABLE_CARD_SUPPORT*/
2098
case aExportSecretSub:
2109
case aUpdateTrustDB:
2111
case aListTrustPath:
2118
case aExportOwnerTrust:
2119
case aImportOwnerTrust:
2120
case aRebuildKeydbCaches:
2121
set_cmd (&cmd, pargs.r_opt);
2126
case aDeleteSecretKeys:
2127
case aDeleteSecretAndPublicKeys:
2129
set_cmd (&cmd, pargs.r_opt);
777
2133
case aDetachedSign: detached_sig = 1; set_cmd( &cmd, aSign ); break;
778
case aSym: set_cmd( &cmd, aSym); break;
2135
case aDecryptFiles: multifile=1; /* fall through */
780
2136
case aDecrypt: set_cmd( &cmd, aDecrypt); break;
2138
case aEncrFiles: multifile=1; /* fall through */
782
2139
case aEncr: set_cmd( &cmd, aEncr); break;
783
case aSign: set_cmd( &cmd, aSign ); break;
784
case aKeygen: set_cmd( &cmd, aKeygen); greeting=1; break;
785
case aSignKey: set_cmd( &cmd, aSignKey); break;
786
case aLSignKey: set_cmd( &cmd, aLSignKey); break;
787
case aStore: set_cmd( &cmd, aStore); break;
788
case aEditKey: set_cmd( &cmd, aEditKey); greeting=1; break;
789
case aClearsign: set_cmd( &cmd, aClearsign); break;
790
case aGenRevoke: set_cmd( &cmd, aGenRevoke); break;
2141
case aVerifyFiles: multifile=1; /* fall through */
791
2142
case aVerify: set_cmd( &cmd, aVerify); break;
792
case aVerifyFiles: set_cmd( &cmd, aVerifyFiles); break;
793
case aPrimegen: set_cmd( &cmd, aPrimegen); break;
794
case aGenRandom: set_cmd( &cmd, aGenRandom); break;
795
case aPrintMD: set_cmd( &cmd, aPrintMD); break;
796
case aPrintMDs: set_cmd( &cmd, aPrintMDs); break;
797
case aPrintHMAC: set_cmd( &cmd, aPrintHMAC); break;
798
case aListTrustDB: set_cmd( &cmd, aListTrustDB); break;
799
case aCheckTrustDB: set_cmd( &cmd, aCheckTrustDB); break;
800
case aUpdateTrustDB: set_cmd( &cmd, aUpdateTrustDB); break;
801
case aFixTrustDB: set_cmd( &cmd, aFixTrustDB); break;
802
case aListTrustPath: set_cmd( &cmd, aListTrustPath); break;
803
case aDeArmor: set_cmd( &cmd, aDeArmor); break;
804
case aEnArmor: set_cmd( &cmd, aEnArmor); break;
805
case aExportOwnerTrust: set_cmd( &cmd, aExportOwnerTrust); break;
806
case aImportOwnerTrust: set_cmd( &cmd, aImportOwnerTrust); break;
2145
set_cmd (&cmd, pargs.r_opt);
808
2149
case oArmor: opt.armor = 1; opt.no_armor=0; break;
809
2150
case oOutput: opt.outfile = pargs.r.ret_str; break;
2151
case oMaxOutput: opt.max_output = pargs.r.ret_ulong; break;
810
2152
case oQuiet: opt.quiet = 1; break;
811
2153
case oNoTTY: tty_no_terminal(1); break;
812
2154
case oDryRun: opt.dry_run = 1; break;
813
2155
case oInteractive: opt.interactive = 1; break;
815
opt.verbose++; opt.list_sigs=1;
816
gcry_control( GCRYCTL_SET_VERBOSITY, (int)opt.verbose );
818
case oKOption: set_cmd( &cmd, aKMode ); break;
820
case oBatch: opt.batch = 1; greeting = 0; break;
821
case oUseAgent: opt.use_agent = 1; break;
2158
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
2159
opt.list_options|=LIST_SHOW_UNUSABLE_UIDS;
2160
opt.list_options|=LIST_SHOW_UNUSABLE_SUBKEYS;
2168
case oUseAgent: /* Dummy. */
2171
obsolete_option (configname, configlineno, "--no-use-agent");
2174
obsolete_option (configname, configlineno, "--gpg-agent-info");
822
2177
case oAnswerYes: opt.answer_yes = 1; break;
823
2178
case oAnswerNo: opt.answer_no = 1; break;
824
2179
case oKeyring: append_to_strlist( &nrings, pargs.r.ret_str); break;
2180
case oPrimaryKeyring:
2181
sl=append_to_strlist( &nrings, pargs.r.ret_str);
2185
deprecated_warning(configname,configlineno,"--show-keyring",
2186
"--list-options ","show-keyring");
2187
opt.list_options|=LIST_SHOW_KEYRING;
825
2190
case oDebug: opt.debug |= pargs.r.ret_ulong; break;
826
2191
case oDebugAll: opt.debug = ~0; break;
827
case oStatusFD: set_status_fd( pargs.r.ret_int ); break;
828
case oLoggerFD: log_set_logfile( NULL, pargs.r.ret_int ); break;
2192
case oDebugLevel: debug_level = pargs.r.ret_str; break;
2195
set_status_fd( translate_sys2libc_fd_int (pargs.r.ret_int, 1) );
2198
set_status_fd ( open_info_file (pargs.r.ret_str, 1) );
2201
set_attrib_fd(translate_sys2libc_fd_int (pargs.r.ret_int, 1));
2203
case oAttributeFile:
2204
set_attrib_fd ( open_info_file (pargs.r.ret_str, 1) );
2207
log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
2210
logfile = pargs.r.ret_str;
829
2213
case oWithFingerprint:
830
with_fpr=1; /*fall thru*/
2214
opt.with_fingerprint = 1;
2215
with_fpr=1; /*fall thru*/
831
2216
case oFingerprint: opt.fingerprint++; break;
832
case oSecretKeyring: append_to_strlist( &sec_nrings, pargs.r.ret_str); break;
2217
case oSecretKeyring:
2218
append_to_strlist( &sec_nrings, pargs.r.ret_str);
834
2221
/* config files may not be nested (silently ignore them) */
835
2222
if( !configfp ) {
836
gcry_free(configname);
837
configname = gcry_xstrdup(pargs.r.ret_str);
2224
configname = xstrdup(pargs.r.ret_str);
841
2228
case oNoArmor: opt.no_armor=1; opt.armor=0; break;
842
2229
case oNoDefKeyring: default_keyring = 0; break;
843
2230
case oNoGreeting: nogreeting = 1; break;
845
opt.verbose = 0; opt.list_sigs=0;
846
gcry_control( GCRYCTL_SET_VERBOSITY, (int)opt.verbose );
848
case oNoComment: opt.no_comment=1; break;
849
case oNoVersion: opt.no_version=1; break;
2233
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
2237
gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
850
2239
case oEmitVersion: opt.no_version=0; break;
2240
case oNoEmitVersion: opt.no_version=1; break;
851
2241
case oCompletesNeeded: opt.completes_needed = pargs.r.ret_int; break;
852
2242
case oMarginalsNeeded: opt.marginals_needed = pargs.r.ret_int; break;
853
2243
case oMaxCertDepth: opt.max_cert_depth = pargs.r.ret_int; break;
854
2244
case oTrustDBName: trustdb_name = pargs.r.ret_str; break;
855
2245
case oDefaultKey: opt.def_secret_key = pargs.r.ret_str; break;
856
2246
case oDefRecipient:
857
if( *pargs.r.ret_str )
858
opt.def_recipient = make_username(pargs.r.ret_str);
2247
if( *pargs.r.ret_str )
2248
opt.def_recipient = make_username(pargs.r.ret_str);
860
2250
case oDefRecipientSelf:
861
gcry_free(opt.def_recipient); opt.def_recipient = NULL;
862
opt.def_recipient_self = 1;
2251
xfree(opt.def_recipient); opt.def_recipient = NULL;
2252
opt.def_recipient_self = 1;
864
2254
case oNoDefRecipient:
865
gcry_free(opt.def_recipient); opt.def_recipient = NULL;
866
opt.def_recipient_self = 0;
868
case oNoOptions: break; /* no-options */
869
case oHomedir: opt.homedir = pargs.r.ret_str; break;
2255
xfree(opt.def_recipient); opt.def_recipient = NULL;
2256
opt.def_recipient_self = 0;
2258
case oNoOptions: opt.no_homedir_creation = 1; break; /* no-options */
2259
case oHomedir: break;
870
2260
case oNoBatch: opt.batch = 0; break;
871
2261
case oWithKeyData: opt.with_key_data=1; /* fall thru */
872
2262
case oWithColons: opt.with_colons=':'; break;
874
2264
case oSkipVerify: opt.skip_verify=1; break;
875
case oCompressAlgo: opt.def_compress_algo = pargs.r.ret_int; break;
876
2265
case oCompressKeys: opt.compress_keys = 1; break;
877
2266
case aListSecretKeys: set_cmd( &cmd, aListSecretKeys); break;
878
case oAlwaysTrust: opt.always_trust = 1; break;
2267
/* There are many programs (like mutt) that call gpg with
2268
--always-trust so keep this option around for a long
2270
case oAlwaysTrust: opt.trust_model=TM_ALWAYS; break;
2272
parse_trust_model(pargs.r.ret_str);
2274
case oForceOwnertrust:
2275
log_info(_("NOTE: %s is not for normal use!\n"),
2276
"--force-ownertrust");
2277
opt.force_ownertrust=string_to_trust_value(pargs.r.ret_str);
2278
if(opt.force_ownertrust==-1)
2280
log_error("invalid ownertrust `%s'\n",pargs.r.ret_str);
2281
opt.force_ownertrust=0;
879
2284
case oLoadExtension:
880
register_extension(orig_argc? *orig_argv:NULL, pargs.r.ret_str);
2285
/* Dummy so that gpg 1.4 conf files can work. Should
2286
eventually be removed. */
2289
opt.compliance = CO_RFC1991;
2290
opt.force_v4_certs = 0;
886
2291
opt.escape_from = 1;
2295
/* This is effectively the same as RFC2440, but with
2296
"--enable-dsa2 --no-rfc2440-text --escape-from-lines
2297
--require-cross-certification". */
2298
opt.compliance = CO_RFC4880;
2300
opt.flags.require_cross_cert = 1;
2301
opt.rfc2440_text = 0;
2302
opt.allow_non_selfsigned_uid = 1;
2303
opt.allow_freeform_uid = 1;
2304
opt.pgp2_workarounds = 0;
2305
opt.escape_from = 1;
2306
opt.force_v3_sigs = 0;
2307
opt.compress_keys = 0; /* not mandated, but we do it */
2308
opt.compress_sigs = 0; /* ditto. */
2309
opt.not_dash_escaped = 0;
2310
opt.def_cipher_algo = 0;
2311
opt.def_digest_algo = 0;
2312
opt.cert_digest_algo = 0;
2313
opt.compress_algo = -1;
2314
opt.s2k_mode = 3; /* iterated+salted */
2315
opt.s2k_digest_algo = DIGEST_ALGO_SHA1;
2316
opt.s2k_cipher_algo = CIPHER_ALGO_3DES;
2319
opt.compliance = CO_RFC2440;
2321
opt.rfc2440_text = 1;
2322
opt.allow_non_selfsigned_uid = 1;
2323
opt.allow_freeform_uid = 1;
891
2324
opt.pgp2_workarounds = 0;
892
2325
opt.escape_from = 0;
893
2326
opt.force_v3_sigs = 0;
894
opt.compress_keys = 0; /* not mandated but we do it */
2327
opt.compress_keys = 0; /* not mandated, but we do it */
895
2328
opt.compress_sigs = 0; /* ditto. */
896
2329
opt.not_dash_escaped = 0;
897
2330
opt.def_cipher_algo = 0;
898
2331
opt.def_digest_algo = 0;
899
opt.def_compress_algo = 1;
900
opt.s2k_mode = 3; /* iterated+salted */
901
opt.s2k_digest_algo = GCRY_MD_SHA1;
902
opt.s2k_cipher_algo = GCRY_CIPHER_CAST5;
2332
opt.cert_digest_algo = 0;
2333
opt.compress_algo = -1;
2334
opt.s2k_mode = 3; /* iterated+salted */
2335
opt.s2k_digest_algo = DIGEST_ALGO_SHA1;
2336
opt.s2k_cipher_algo = CIPHER_ALGO_3DES;
904
case oEmuMDEncodeBug: opt.emulate_bugs |= EMUBUG_MDENCODE; break;
2338
case oPGP2: opt.compliance = CO_PGP2; break;
2339
case oPGP6: opt.compliance = CO_PGP6; break;
2340
case oPGP7: opt.compliance = CO_PGP7; break;
2341
case oPGP8: opt.compliance = CO_PGP8; break;
2342
case oGnuPG: opt.compliance = CO_GNUPG; break;
905
2343
case oCompressSigs: opt.compress_sigs = 1; break;
907
#ifndef USE_SHM_COPROCESSING
908
/* not possible in the option file,
909
* but we print the warning here anyway */
910
log_error("shared memory coprocessing is not available\n");
913
case oSetFilename: opt.set_filename = pargs.r.ret_str; break;
914
case oSetPolicyURL: opt.set_policy_url = pargs.r.ret_str; break;
915
case oUseEmbeddedFilename: opt.use_embedded_filename = 1; break;
916
case oComment: opt.comment_string = pargs.r.ret_str; break;
917
case oDefaultComment: opt.comment_string = NULL; break;
918
case oThrowKeyid: opt.throw_keyid = 1; break;
2344
case oRFC2440Text: opt.rfc2440_text=1; break;
2345
case oNoRFC2440Text: opt.rfc2440_text=0; break;
2348
opt.set_filename = pargs.r.ret_str;
2350
opt.set_filename = native_to_utf8(pargs.r.ret_str);
2352
case oForYourEyesOnly: eyes_only = 1; break;
2353
case oNoForYourEyesOnly: eyes_only = 0; break;
2355
add_policy_url(pargs.r.ret_str,0);
2356
add_policy_url(pargs.r.ret_str,1);
2358
case oSigPolicyURL: add_policy_url(pargs.r.ret_str,0); break;
2359
case oCertPolicyURL: add_policy_url(pargs.r.ret_str,1); break;
2360
case oShowPolicyURL:
2361
deprecated_warning(configname,configlineno,"--show-policy-url",
2362
"--list-options ","show-policy-urls");
2363
deprecated_warning(configname,configlineno,"--show-policy-url",
2364
"--verify-options ","show-policy-urls");
2365
opt.list_options|=LIST_SHOW_POLICY_URLS;
2366
opt.verify_options|=VERIFY_SHOW_POLICY_URLS;
2368
case oNoShowPolicyURL:
2369
deprecated_warning(configname,configlineno,"--no-show-policy-url",
2370
"--list-options ","no-show-policy-urls");
2371
deprecated_warning(configname,configlineno,"--no-show-policy-url",
2372
"--verify-options ","no-show-policy-urls");
2373
opt.list_options&=~LIST_SHOW_POLICY_URLS;
2374
opt.verify_options&=~VERIFY_SHOW_POLICY_URLS;
2376
case oSigKeyserverURL: add_keyserver_url(pargs.r.ret_str,0); break;
2377
case oUseEmbeddedFilename:
2378
opt.flags.use_embedded_filename=1;
2380
case oNoUseEmbeddedFilename:
2381
opt.flags.use_embedded_filename=0;
2384
if(pargs.r.ret_str[0])
2385
append_to_strlist(&opt.comments,pargs.r.ret_str);
2387
case oDefaultComment:
2388
deprecated_warning(configname,configlineno,
2389
"--default-comment","--no-comments","");
2392
free_strlist(opt.comments);
2395
case oThrowKeyids: opt.throw_keyid = 1; break;
2396
case oNoThrowKeyids: opt.throw_keyid = 0; break;
2398
deprecated_warning(configname,configlineno,"--show-photos",
2399
"--list-options ","show-photos");
2400
deprecated_warning(configname,configlineno,"--show-photos",
2401
"--verify-options ","show-photos");
2402
opt.list_options|=LIST_SHOW_PHOTOS;
2403
opt.verify_options|=VERIFY_SHOW_PHOTOS;
2406
deprecated_warning(configname,configlineno,"--no-show-photos",
2407
"--list-options ","no-show-photos");
2408
deprecated_warning(configname,configlineno,"--no-show-photos",
2409
"--verify-options ","no-show-photos");
2410
opt.list_options&=~LIST_SHOW_PHOTOS;
2411
opt.verify_options&=~VERIFY_SHOW_PHOTOS;
2413
case oPhotoViewer: opt.photo_viewer = pargs.r.ret_str; break;
919
2414
case oForceV3Sigs: opt.force_v3_sigs = 1; break;
2415
case oNoForceV3Sigs: opt.force_v3_sigs = 0; break;
2416
case oForceV4Certs: opt.force_v4_certs = 1; break;
2417
case oNoForceV4Certs: opt.force_v4_certs = 0; break;
920
2418
case oForceMDC: opt.force_mdc = 1; break;
2419
case oNoForceMDC: opt.force_mdc = 0; break;
2420
case oDisableMDC: opt.disable_mdc = 1; break;
2421
case oNoDisableMDC: opt.disable_mdc = 0; break;
921
2422
case oS2KMode: opt.s2k_mode = pargs.r.ret_int; break;
922
case oS2KDigest: s2k_digest_string = gcry_xstrdup(pargs.r.ret_str); break;
923
case oS2KCipher: s2k_cipher_string = gcry_xstrdup(pargs.r.ret_str); break;
2423
case oS2KDigest: s2k_digest_string = xstrdup(pargs.r.ret_str); break;
2424
case oS2KCipher: s2k_cipher_string = xstrdup(pargs.r.ret_str); break;
2426
opt.s2k_count=encode_s2k_iterations(pargs.r.ret_int);
2428
case oSimpleSKChecksum: opt.simple_sk_checksum = 1; break;
925
2429
case oNoEncryptTo: opt.no_encrypt_to = 1; break;
926
2430
case oEncryptTo: /* store the recipient in the second list */
927
2431
sl = add_to_strlist2( &remusr, pargs.r.ret_str, utf8_strings );
2434
case oHiddenEncryptTo: /* store the recipient in the second list */
2435
sl = add_to_strlist2( &remusr, pargs.r.ret_str, utf8_strings );
930
2438
case oRecipient: /* store the recipient */
931
2439
add_to_strlist2( &remusr, pargs.r.ret_str, utf8_strings );
2440
any_explicit_recipient = 1;
2442
case oHiddenRecipient: /* store the recipient with a flag */
2443
sl = add_to_strlist2( &remusr, pargs.r.ret_str, utf8_strings );
2445
any_explicit_recipient = 1;
933
2447
case oTextmodeShort: opt.textmode = 2; break;
934
2448
case oTextmode: opt.textmode=1; break;
935
case oUser: /* store the local users */
2449
case oNoTextmode: opt.textmode=0; break;
2450
case oExpert: opt.expert = 1; break;
2451
case oNoExpert: opt.expert = 0; break;
2453
if(*pargs.r.ret_str!='\0')
2455
if(parse_expire_string(pargs.r.ret_str)==(u32)-1)
2456
log_error(_("`%s' is not a valid signature expiration\n"),
2459
opt.def_sig_expire=pargs.r.ret_str;
2462
case oAskSigExpire: opt.ask_sig_expire = 1; break;
2463
case oNoAskSigExpire: opt.ask_sig_expire = 0; break;
2464
case oDefCertExpire:
2465
if(*pargs.r.ret_str!='\0')
2467
if(parse_expire_string(pargs.r.ret_str)==(u32)-1)
2468
log_error(_("`%s' is not a valid signature expiration\n"),
2471
opt.def_cert_expire=pargs.r.ret_str;
2474
case oAskCertExpire: opt.ask_cert_expire = 1; break;
2475
case oNoAskCertExpire: opt.ask_cert_expire = 0; break;
2476
case oDefCertLevel: opt.def_cert_level=pargs.r.ret_int; break;
2477
case oMinCertLevel: opt.min_cert_level=pargs.r.ret_int; break;
2478
case oAskCertLevel: opt.ask_cert_level = 1; break;
2479
case oNoAskCertLevel: opt.ask_cert_level = 0; break;
2480
case oLocalUser: /* store the local users */
936
2481
add_to_strlist2( &locusr, pargs.r.ret_str, utf8_strings );
938
case oCompress: opt.compress = pargs.r.ret_int; break;
939
case oPasswdFD: pwfd = pargs.r.ret_int; break;
940
case oCommandFD: opt.command_fd = pargs.r.ret_int; break;
941
case oCipherAlgo: def_cipher_string = gcry_xstrdup(pargs.r.ret_str); break;
942
case oDigestAlgo: def_digest_string = gcry_xstrdup(pargs.r.ret_str); break;
943
case oNoSecmemWarn: gcry_control( GCRYCTL_DISABLE_SECMEM_WARN ); break;
2484
/* this is the -z command line option */
2485
opt.compress_level = opt.bz2_compress_level = pargs.r.ret_int;
2487
case oCompressLevel: opt.compress_level = pargs.r.ret_int; break;
2488
case oBZ2CompressLevel: opt.bz2_compress_level = pargs.r.ret_int; break;
2489
case oBZ2DecompressLowmem: opt.bz2_decompress_lowmem=1; break;
2491
set_passphrase_from_string(pargs.r.ret_str);
2494
pwfd = translate_sys2libc_fd_int (pargs.r.ret_int, 0);
2497
pwfd = open_info_file (pargs.r.ret_str, 0);
2499
case oPasswdRepeat: opt.passwd_repeat=pargs.r.ret_int; break;
2501
opt.command_fd = translate_sys2libc_fd_int (pargs.r.ret_int, 0);
2504
opt.command_fd = open_info_file (pargs.r.ret_str, 0);
2507
def_cipher_string = xstrdup(pargs.r.ret_str);
2510
def_digest_string = xstrdup(pargs.r.ret_str);
2513
/* If it is all digits, stick a Z in front of it for
2514
later. This is for backwards compatibility with
2515
versions that took the compress algorithm number. */
2517
char *pt=pargs.r.ret_str;
2520
if (!isascii (*pt) || !isdigit (*pt))
2528
compress_algo_string=xmalloc(strlen(pargs.r.ret_str)+2);
2529
strcpy(compress_algo_string,"Z");
2530
strcat(compress_algo_string,pargs.r.ret_str);
2533
compress_algo_string = xstrdup(pargs.r.ret_str);
2536
case oCertDigestAlgo:
2537
cert_digest_string = xstrdup(pargs.r.ret_str);
2541
gcry_control (GCRYCTL_DISABLE_SECMEM_WARN);
2544
case oRequireSecmem: require_secmem=1; break;
2545
case oNoRequireSecmem: require_secmem=0; break;
2546
case oNoPermissionWarn: opt.no_perm_warn=1; break;
2547
case oNoMDCWarn: opt.no_mdc_warn=1; break;
2548
case oDisplayCharset:
945
2549
if( set_native_charset( pargs.r.ret_str ) )
946
log_error(_("%s is not a valid character set\n"),
2550
log_error(_("`%s' is not a valid character set\n"),
949
2553
case oNotDashEscaped: opt.not_dash_escaped = 1; break;
950
2554
case oEscapeFrom: opt.escape_from = 1; break;
2555
case oNoEscapeFrom: opt.escape_from = 0; break;
951
2556
case oLockOnce: opt.lock_once = 1; break;
953
#warning no disable_dotlock() yet
954
case oLockNever: disable_dotlock(); break;
956
case oLockMultiple: opt.lock_once = 0; break;
957
case oKeyServer: opt.keyserver_name = pargs.r.ret_str; break;
958
case oNotation: add_notation_data( pargs.r.ret_str ); break;
2563
#else /* __riscos__ */
2564
riscos_not_implemented("lock-multiple");
2565
#endif /* __riscos__ */
2569
struct keyserver_spec *keyserver;
2570
keyserver=parse_keyserver_uri(pargs.r.ret_str,0,
2571
configname,configlineno);
2573
log_error(_("could not parse keyserver URL\n"));
2576
keyserver->next=opt.keyserver;
2577
opt.keyserver=keyserver;
2581
case oKeyServerOptions:
2582
if(!parse_keyserver_options(pargs.r.ret_str))
2585
log_error(_("%s:%d: invalid keyserver options\n"),
2586
configname,configlineno);
2588
log_error(_("invalid keyserver options\n"));
2591
case oImportOptions:
2592
if(!parse_import_options(pargs.r.ret_str,&opt.import_options,1))
2595
log_error(_("%s:%d: invalid import options\n"),
2596
configname,configlineno);
2598
log_error(_("invalid import options\n"));
2601
case oExportOptions:
2602
if(!parse_export_options(pargs.r.ret_str,&opt.export_options,1))
2605
log_error(_("%s:%d: invalid export options\n"),
2606
configname,configlineno);
2608
log_error(_("invalid export options\n"));
2612
if(!parse_list_options(pargs.r.ret_str))
2615
log_error(_("%s:%d: invalid list options\n"),
2616
configname,configlineno);
2618
log_error(_("invalid list options\n"));
2621
case oVerifyOptions:
2623
struct parse_options vopts[]=
2625
{"show-photos",VERIFY_SHOW_PHOTOS,NULL,
2626
N_("display photo IDs during signature verification")},
2627
{"show-policy-urls",VERIFY_SHOW_POLICY_URLS,NULL,
2628
N_("show policy URLs during signature verification")},
2629
{"show-notations",VERIFY_SHOW_NOTATIONS,NULL,
2630
N_("show all notations during signature verification")},
2631
{"show-std-notations",VERIFY_SHOW_STD_NOTATIONS,NULL,
2632
N_("show IETF standard notations during signature verification")},
2633
{"show-standard-notations",VERIFY_SHOW_STD_NOTATIONS,NULL,
2635
{"show-user-notations",VERIFY_SHOW_USER_NOTATIONS,NULL,
2636
N_("show user-supplied notations during signature verification")},
2637
{"show-keyserver-urls",VERIFY_SHOW_KEYSERVER_URLS,NULL,
2638
N_("show preferred keyserver URLs during signature verification")},
2639
{"show-uid-validity",VERIFY_SHOW_UID_VALIDITY,NULL,
2640
N_("show user ID validity during signature verification")},
2641
{"show-unusable-uids",VERIFY_SHOW_UNUSABLE_UIDS,NULL,
2642
N_("show revoked and expired user IDs in signature verification")},
2643
{"show-primary-uid-only",VERIFY_SHOW_PRIMARY_UID_ONLY,NULL,
2644
N_("show only the primary user ID in signature verification")},
2645
{"pka-lookups",VERIFY_PKA_LOOKUPS,NULL,
2646
N_("validate signatures with PKA data")},
2647
{"pka-trust-increase",VERIFY_PKA_TRUST_INCREASE,NULL,
2648
N_("elevate the trust of signatures with valid PKA data")},
2652
if(!parse_options(pargs.r.ret_str,&opt.verify_options,vopts,1))
2655
log_error(_("%s:%d: invalid verify options\n"),
2656
configname,configlineno);
2658
log_error(_("invalid verify options\n"));
2662
case oTempDir: opt.temp_dir=pargs.r.ret_str; break;
2664
if(set_exec_path(pargs.r.ret_str))
2665
log_error(_("unable to set exec-path to %s\n"),pargs.r.ret_str);
2667
opt.exec_path_set=1;
2670
add_notation_data( pargs.r.ret_str, 0 );
2671
add_notation_data( pargs.r.ret_str, 1 );
2673
case oSigNotation: add_notation_data( pargs.r.ret_str, 0 ); break;
2674
case oCertNotation: add_notation_data( pargs.r.ret_str, 1 ); break;
2676
deprecated_warning(configname,configlineno,"--show-notation",
2677
"--list-options ","show-notations");
2678
deprecated_warning(configname,configlineno,"--show-notation",
2679
"--verify-options ","show-notations");
2680
opt.list_options|=LIST_SHOW_NOTATIONS;
2681
opt.verify_options|=VERIFY_SHOW_NOTATIONS;
2683
case oNoShowNotation:
2684
deprecated_warning(configname,configlineno,"--no-show-notation",
2685
"--list-options ","no-show-notations");
2686
deprecated_warning(configname,configlineno,"--no-show-notation",
2687
"--verify-options ","no-show-notations");
2688
opt.list_options&=~LIST_SHOW_NOTATIONS;
2689
opt.verify_options&=~VERIFY_SHOW_NOTATIONS;
959
2691
case oUtf8Strings: utf8_strings = 1; break;
960
2692
case oNoUtf8Strings: utf8_strings = 0; break;
961
case oDisableCipherAlgo: {
962
int algo = gcry_cipher_map_name(pargs.r.ret_str);
963
gcry_cipher_ctl( NULL, GCRYCTL_DISABLE_ALGO,
964
&algo, sizeof algo );
967
case oDisablePubkeyAlgo: {
968
int algo = gcry_pk_map_name(pargs.r.ret_str);
969
gcry_pk_ctl( GCRYCTL_DISABLE_ALGO,
970
&algo, sizeof algo );
2693
case oDisableCipherAlgo:
2695
int algo = string_to_cipher_algo (pargs.r.ret_str);
2696
gcry_cipher_ctl (NULL, GCRYCTL_DISABLE_ALGO, &algo, sizeof algo);
2699
case oDisablePubkeyAlgo:
2701
int algo = gcry_pk_map_name (pargs.r.ret_str);
2702
gcry_pk_ctl (GCRYCTL_DISABLE_ALGO, &algo, sizeof algo);
2705
case oNoSigCache: opt.no_sig_cache = 1; break;
2706
case oNoSigCreateCheck: opt.no_sig_create_check = 1; break;
973
2707
case oAllowNonSelfsignedUID: opt.allow_non_selfsigned_uid = 1; break;
2708
case oNoAllowNonSelfsignedUID: opt.allow_non_selfsigned_uid=0; break;
974
2709
case oAllowFreeformUID: opt.allow_freeform_uid = 1; break;
2710
case oNoAllowFreeformUID: opt.allow_freeform_uid = 0; break;
975
2711
case oNoLiteral: opt.no_literal = 1; break;
976
2712
case oSetFilesize: opt.set_filesize = pargs.r.ret_ulong; break;
977
case oHonorHttpProxy: opt.honor_http_proxy = 1; break;
2713
case oHonorHttpProxy:
2714
add_to_strlist(&opt.keyserver_options.other,"http-proxy");
2715
deprecated_warning(configname,configlineno,
2716
"--honor-http-proxy",
2717
"--keyserver-options ","http-proxy");
978
2719
case oFastListMode: opt.fast_list_mode = 1; break;
2720
case oFixedListMode: opt.fixed_list_mode = 1; break;
979
2721
case oListOnly: opt.list_only=1; break;
980
2722
case oIgnoreTimeConflict: opt.ignore_time_conflict = 1; break;
2723
case oIgnoreValidFrom: opt.ignore_valid_from = 1; break;
2724
case oIgnoreCrcError: opt.ignore_crc_error = 1; break;
2725
case oIgnoreMDCError: opt.ignore_mdc_error = 1; break;
981
2726
case oNoRandomSeedFile: use_random_seed = 0; break;
982
case oNoAutoKeyRetrieve: opt.auto_key_retrieve = 0; break;
983
case oMergeOnly: opt.merge_only = 1; break;
2727
case oAutoKeyRetrieve:
2728
case oNoAutoKeyRetrieve:
2729
if(pargs.r_opt==oAutoKeyRetrieve)
2730
opt.keyserver_options.options|=KEYSERVER_AUTO_KEY_RETRIEVE;
2732
opt.keyserver_options.options&=~KEYSERVER_AUTO_KEY_RETRIEVE;
2734
deprecated_warning(configname,configlineno,
2735
pargs.r_opt==oAutoKeyRetrieve?"--auto-key-retrieve":
2736
"--no-auto-key-retrieve","--keyserver-options ",
2737
pargs.r_opt==oAutoKeyRetrieve?"auto-key-retrieve":
2738
"no-auto-key-retrieve");
2740
case oShowSessionKey: opt.show_session_key = 1; break;
2741
case oOverrideSessionKey:
2742
opt.override_session_key = pargs.r.ret_str;
2745
deprecated_warning(configname,configlineno,"--merge-only",
2746
"--import-options ","merge-only");
2747
opt.import_options|=IMPORT_MERGE_ONLY;
2749
case oAllowSecretKeyImport: /* obsolete */ break;
984
2750
case oTryAllSecrets: opt.try_all_secrets = 1; break;
985
2751
case oTrustedKey: register_trusted_key( pargs.r.ret_str ); break;
2752
case oEnableSpecialFilenames:
2753
iobuf_enable_special_filenames (1);
2755
case oNoExpensiveTrustChecks: opt.no_expensive_trust_checks=1; break;
2756
case oAutoCheckTrustDB: opt.no_auto_check_trustdb=0; break;
2757
case oNoAutoCheckTrustDB: opt.no_auto_check_trustdb=1; break;
2758
case oPreservePermissions: opt.preserve_permissions=1; break;
2759
case oDefaultPreferenceList:
2760
opt.def_preference_list = pargs.r.ret_str;
2762
case oDefaultKeyserverURL:
2764
struct keyserver_spec *keyserver;
2765
keyserver=parse_keyserver_uri(pargs.r.ret_str,1,
2766
configname,configlineno);
2768
log_error(_("could not parse keyserver URL\n"));
2770
free_keyserver_spec(keyserver);
2772
opt.def_keyserver_url = pargs.r.ret_str;
2775
case oPersonalCipherPreferences:
2776
pers_cipher_list=pargs.r.ret_str;
2778
case oPersonalDigestPreferences:
2779
pers_digest_list=pargs.r.ret_str;
2781
case oPersonalCompressPreferences:
2782
pers_compress_list=pargs.r.ret_str;
2784
case oAgentProgram: opt.agent_program = pargs.r.ret_str; break;
2785
case oDisplay: opt.display = pargs.r.ret_str; break;
2786
case oTTYname: opt.ttyname = pargs.r.ret_str; break;
2787
case oTTYtype: opt.ttytype = pargs.r.ret_str; break;
2788
case oLCctype: opt.lc_ctype = pargs.r.ret_str; break;
2789
case oLCmessages: opt.lc_messages = pargs.r.ret_str; break;
2790
case oXauthority: opt.xauthority = pargs.r.ret_str; break;
2791
case oGroup: add_group(pargs.r.ret_str); break;
2792
case oUnGroup: rm_group(pargs.r.ret_str); break;
2794
while(opt.grouplist)
2796
struct groupitem *iter=opt.grouplist;
2797
free_strlist(iter->values);
2798
opt.grouplist=opt.grouplist->next;
2808
case oMangleDosFilenames: opt.mangle_dos_filenames = 1; break;
2809
case oNoMangleDosFilenames: opt.mangle_dos_filenames = 0; break;
2810
case oEnableProgressFilter: opt.enable_progress_filter = 1; break;
2811
case oMultifile: multifile=1; break;
2813
if(ascii_strcasecmp(pargs.r.ret_str,"short")==0)
2814
opt.keyid_format=KF_SHORT;
2815
else if(ascii_strcasecmp(pargs.r.ret_str,"long")==0)
2816
opt.keyid_format=KF_LONG;
2817
else if(ascii_strcasecmp(pargs.r.ret_str,"0xshort")==0)
2818
opt.keyid_format=KF_0xSHORT;
2819
else if(ascii_strcasecmp(pargs.r.ret_str,"0xlong")==0)
2820
opt.keyid_format=KF_0xLONG;
2822
log_error("unknown keyid-format `%s'\n",pargs.r.ret_str);
2825
case oExitOnStatusWriteError:
2826
opt.exit_on_status_write_error = 1;
2829
case oLimitCardInsertTries:
2830
opt.limit_card_insert_tries = pargs.r.ret_int;
2833
case oRequireCrossCert: opt.flags.require_cross_cert=1; break;
2834
case oNoRequireCrossCert: opt.flags.require_cross_cert=0; break;
2836
case oAutoKeyLocate:
2837
if(!parse_auto_key_locate(pargs.r.ret_str))
2840
log_error(_("%s:%d: invalid auto-key-locate list\n"),
2841
configname,configlineno);
2843
log_error(_("invalid auto-key-locate list\n"));
2846
case oNoAutoKeyLocate:
2850
case oEnableDSA2: opt.flags.dsa2=1; break;
2851
case oDisableDSA2: opt.flags.dsa2=0; break;
2853
case oAllowMultisigVerification:
2854
case oAllowMultipleMessages:
2855
opt.flags.allow_multiple_messages=1;
2858
case oNoAllowMultipleMessages:
2859
opt.flags.allow_multiple_messages=0;
987
2864
default : pargs.err = configfp? 1:2; break;
990
2869
if( configfp ) {
991
2870
fclose( configfp );
992
2871
configfp = NULL;
993
gcry_free(configname); configname = NULL;
2872
/* Remember the first config file name. */
2873
if (!save_configname)
2874
save_configname = configname;
996
gcry_free( configname ); configname = NULL;
2880
xfree( configname ); configname = NULL;
997
2881
if( log_get_errorcount(0) )
2884
/* The command --gpgconf-list is pretty simple and may be called
2885
directly after the option parsing. */
2886
if (cmd == aGPGConfList)
2888
gpgconf_list (save_configname ? save_configname : default_configname);
2891
xfree (save_configname);
2892
xfree (default_configname);
999
2894
if( nogreeting )
1082
3123
log_error(_("invalid S2K mode; must be 0, 1 or 3\n"));
3126
/* This isn't actually needed, but does serve to error out if the
3127
string is invalid. */
3128
if(opt.def_preference_list &&
3129
keygen_set_std_prefs(opt.def_preference_list,0))
3130
log_error(_("invalid default preferences\n"));
3132
/* We provide defaults for the personal digest list. This is
3134
if(!pers_digest_list)
3135
pers_digest_list="h2";
3137
if(pers_cipher_list &&
3138
keygen_set_std_prefs(pers_cipher_list,PREFTYPE_SYM))
3139
log_error(_("invalid personal cipher preferences\n"));
3141
if(pers_digest_list &&
3142
keygen_set_std_prefs(pers_digest_list,PREFTYPE_HASH))
3143
log_error(_("invalid personal digest preferences\n"));
3145
if(pers_compress_list &&
3146
keygen_set_std_prefs(pers_compress_list,PREFTYPE_ZIP))
3147
log_error(_("invalid personal compress preferences\n"));
3149
/* We don't support all possible commands with multifile yet */
3160
cmdname="--clearsign";
3163
cmdname="--detach-sign";
3166
cmdname="--symmetric";
3169
cmdname="--symmetric --encrypt";
3180
log_error(_("%s does not yet work with %s\n"),cmdname,"--multifile");
1086
3183
if( log_get_errorcount(0) )
1089
/* set the random seed file */
3186
if(opt.compress_level==0)
3187
opt.compress_algo=COMPRESS_ALGO_NONE;
3189
/* Check our chosen algorithms against the list of legal
3194
const char *badalg=NULL;
3195
preftype_t badtype=PREFTYPE_NONE;
3197
if(opt.def_cipher_algo
3198
&& !algo_available(PREFTYPE_SYM,opt.def_cipher_algo,NULL))
3200
badalg = openpgp_cipher_algo_name (opt.def_cipher_algo);
3201
badtype = PREFTYPE_SYM;
3203
else if(opt.def_digest_algo
3204
&& !algo_available(PREFTYPE_HASH,opt.def_digest_algo,NULL))
3206
badalg = gcry_md_algo_name (opt.def_digest_algo);
3207
badtype = PREFTYPE_HASH;
3209
else if(opt.cert_digest_algo
3210
&& !algo_available(PREFTYPE_HASH,opt.cert_digest_algo,NULL))
3212
badalg = gcry_md_algo_name (opt.cert_digest_algo);
3213
badtype = PREFTYPE_HASH;
3215
else if(opt.compress_algo!=-1
3216
&& !algo_available(PREFTYPE_ZIP,opt.compress_algo,NULL))
3218
badalg = compress_algo_to_string(opt.compress_algo);
3219
badtype = PREFTYPE_ZIP;
3227
log_info(_("you may not use cipher algorithm `%s'"
3228
" while in %s mode\n"),
3229
badalg,compliance_option_string());
3232
log_info(_("you may not use digest algorithm `%s'"
3233
" while in %s mode\n"),
3234
badalg,compliance_option_string());
3237
log_info(_("you may not use compression algorithm `%s'"
3238
" while in %s mode\n"),
3239
badalg,compliance_option_string());
3245
compliance_failure();
3249
/* Set the random seed file. */
1090
3250
if( use_random_seed ) {
1091
3251
char *p = make_filename(opt.homedir, "random_seed", NULL );
1093
#warning set_random_seed_file missing
1094
set_random_seed_file(p);
3252
gcry_control (GCRYCTL_SET_RANDOM_SEED_FILE, p);
3253
if (!access (p, F_OK))
3254
register_secured_file (p);
1099
3258
if( !cmd && opt.fingerprint && !with_fpr ) {
1100
3259
set_cmd( &cmd, aListKeys);
1103
if( cmd == aKMode || cmd == aKModeC ) { /* kludge to be compatible to pgp */
1104
if( cmd == aKModeC ) {
1105
opt.fingerprint = 1;
1109
if( opt.verbose > 2 )
1111
if( opt.verbose > 1 )
1114
opt.verbose = opt.verbose > 1;
1115
gcry_control( GCRYCTL_SET_VERBOSITY, (int)opt.verbose );
1119
3262
/* kludge to let -sat generate a clear text signature */
1120
3263
if( opt.textmode == 2 && !detached_sig && opt.armor && cmd == aSign )
3265
log_info ("compatibility note:\n");
3266
log_info ("\"-sat\" won't generate clear signed messages in "
3267
"future versions\n");
3268
log_info ("Use \"--clearsign\" instead of \"-sat\"\n");
1121
3269
cmd = aClearsign;
1123
3272
if( opt.verbose > 1 )
1124
3273
set_packet_list_mode(1);
1126
/* add the keyrings, but not for some special commands and
1127
* not in case of "-kvv userid keyring" */
1128
if( cmd != aDeArmor && cmd != aEnArmor
1129
&& !(cmd == aKMode && argc == 2 ) ) {
1131
if( !sec_nrings && default_keyring ) /* add default secret rings */
1132
add_keyblock_resource("secring.gpg", 0, 1);
1133
for(sl = sec_nrings; sl; sl = sl->next )
1134
add_keyblock_resource( sl->d, 0, 1 );
1135
if( !nrings && default_keyring ) /* add default ring */
1136
add_keyblock_resource("pubring.gpg", 0, 0);
3275
/* Add the keyrings, but not for some special commands. Also
3276
avoid adding the secret keyring for a couple of commands to
3277
avoid unneeded access in case the secrings are stored on a
3280
We always need to add the keyrings if we are running under
3281
SELinux, this is so that the rings are added to the list of
3283
if( ALWAYS_ADD_KEYRINGS
3284
|| (cmd != aDeArmor && cmd != aEnArmor && cmd != aGPGConfTest) )
3286
if (ALWAYS_ADD_KEYRINGS
3287
|| (cmd != aCheckKeys && cmd != aListSigs && cmd != aListKeys
3288
&& cmd != aVerify && cmd != aSym))
3290
if (!sec_nrings || default_keyring) /* add default secret rings */
3291
keydb_add_resource ("secring" EXTSEP_S "gpg", 4, 1);
3292
for (sl = sec_nrings; sl; sl = sl->next)
3293
keydb_add_resource ( sl->d, 0, 1 );
3295
if( !nrings || default_keyring ) /* add default ring */
3296
keydb_add_resource ("pubring" EXTSEP_S "gpg", 4, 0);
1137
3297
for(sl = nrings; sl; sl = sl->next )
1138
add_keyblock_resource( sl->d, 0, 0 );
3298
keydb_add_resource ( sl->d, sl->flags, 0 );
1140
3300
FREE_STRLIST(nrings);
1141
3301
FREE_STRLIST(sec_nrings);
1144
if( pwfd != -1 ) /* read the passphrase now. */
3303
if (cmd == aGPGConfTest)
3307
if( pwfd != -1 ) /* Read the passphrase now. */
1145
3308
read_passphrase_from_fd( pwfd );
1147
3310
fname = argc? *argv : NULL;
3312
if(fname && utf8_strings)
3313
opt.flags.utf8_filename=1;
1149
3315
switch( cmd ) {
1150
3316
case aPrimegen:
1152
3318
case aPrintMDs:
1154
3319
case aGenRandom:
1157
3322
case aFixTrustDB:
1161
case aListSecretKeys:
1163
if( opt.with_colons ) /* need this to list the trust */
1164
rc = setup_trustdb(1, trustdb_name );
1166
3324
case aExportOwnerTrust: rc = setup_trustdb( 0, trustdb_name ); break;
1167
3325
case aListTrustDB: rc = setup_trustdb( argc? 1:0, trustdb_name ); break;
1168
3326
default: rc = setup_trustdb(1, trustdb_name ); break;
1171
log_error(_("failed to initialize the TrustDB: %s\n"), gpg_errstr(rc));
3329
log_error(_("failed to initialize the TrustDB: %s\n"), g10_errstr(rc));
3339
if (!opt.quiet && any_explicit_recipient)
3340
log_info (_("WARNING: recipients (-r) given "
3341
"without using public key encryption\n"));
3351
ctrl_t ctrl = xtrycalloc (1, sizeof *ctrl);
3352
gpg_init_default_ctrl (ctrl);
3354
gpg_deinit_default_ctrl (ctrl);
1175
3359
case aStore: /* only store the file */
1177
3361
wrong_args(_("--store [filename]"));
1178
3362
if( (rc = encode_store(fname)) )
1179
log_error_f( print_fname_stdin(fname),
1180
"store failed: %s\n", gpg_errstr(rc) );
3363
log_error ("storing `%s' failed: %s\n",
3364
print_fname_stdin(fname),g10_errstr(rc) );
1182
3366
case aSym: /* encrypt the given file only with the symmetric cipher */
1184
3368
wrong_args(_("--symmetric [filename]"));
1185
3369
if( (rc = encode_symmetric(fname)) )
1186
log_error_f(print_fname_stdin(fname),
1187
"symmetric encryption failed: %s\n",gpg_errstr(rc) );
3370
log_error (_("symmetric encryption of `%s' failed: %s\n"),
3371
print_fname_stdin(fname),g10_errstr(rc) );
1190
3374
case aEncr: /* encrypt the given file */
3376
encode_crypt_files(argc, argv, remusr);
3380
wrong_args(_("--encrypt [filename]"));
3381
if( (rc = encode_crypt(fname,remusr,0)) )
3382
log_error("%s: encryption failed: %s\n",
3383
print_fname_stdin(fname), g10_errstr(rc) );
3388
/* This works with PGP 8 in the sense that it acts just like a
3389
symmetric message. It doesn't work at all with 2 or 6. It
3390
might work with 7, but alas, I don't have a copy to test
1192
wrong_args(_("--encrypt [filename]"));
1193
if( (rc = encode_crypt(fname,remusr)) )
1194
log_error("%s: encryption failed: %s\n", print_fname_stdin(fname), gpg_errstr(rc) );
3393
wrong_args(_("--symmetric --encrypt [filename]"));
3394
else if(opt.s2k_mode==0)
3395
log_error(_("you cannot use --symmetric --encrypt"
3396
" with --s2k-mode 0\n"));
3397
else if(PGP2 || PGP6 || PGP7 || RFC1991)
3398
log_error(_("you cannot use --symmetric --encrypt"
3399
" while in %s mode\n"),compliance_option_string());
3402
if( (rc = encode_crypt(fname,remusr,1)) )
3403
log_error("%s: encryption failed: %s\n",
3404
print_fname_stdin(fname), g10_errstr(rc) );
1197
3408
case aSign: /* sign the given file */
1621
3939
rc = proc_packets(NULL, a );
1623
log_error("processing message failed: %s\n", gpg_errstr(rc) );
3941
log_error("processing message failed: %s\n", g10_errstr(rc) );
1624
3942
iobuf_close(a);
3948
release_armor_context (afx);
1630
3949
FREE_STRLIST(remusr);
1631
3950
FREE_STRLIST(locusr);
1633
3952
return 8; /*NEVER REACHED*/
3956
/* Note: This function is used by signal handlers!. */
3958
emergency_cleanup (void)
3960
gcry_control (GCRYCTL_TERM_SECMEM );
1641
#warning no update_random_seed_file
1642
update_random_seed_file();
1644
if( opt.debug & DBG_MEMSTAT_VALUE ) {
1645
gcry_control( GCRYCTL_DUMP_MEMORY_STATS );
1646
gcry_control( GCRYCTL_DUMP_RANDOM_STATS );
1649
gcry_control( GCRYCTL_DUMP_SECMEM_STATS );
1650
gcry_control( GCRYCTL_TERM_SECMEM );
1651
rc = rc? rc : log_get_errorcount(0)? 2 :
1652
gpg_errors_seen? 1 : 0;
1653
/*write_status( STATUS_LEAVE );*/
1661
print_hex( byte *p, size_t n )
1666
for(i=0; i < n ; i++, i++, p += 2 ) {
1671
printf("%02X%02X", *p, p[1] );
1674
else if( n == 24 ) {
1675
for(i=0; i < n ; i += 4, p += 4 ) {
1680
printf("%02X%02X%02X%02X", *p, p[1], p[2], p[3] );
1684
for(i=0; i < n ; i++, p++ ) {
1689
printf("%02X", *p );
1695
print_mds( const char *fname, int algo, const char *key )
3967
gcry_control (GCRYCTL_UPDATE_RANDOM_SEED_FILE);
3968
if ( (opt.debug & DBG_MEMSTAT_VALUE) )
3970
gcry_control (GCRYCTL_DUMP_MEMORY_STATS);
3971
gcry_control (GCRYCTL_DUMP_RANDOM_STATS);
3974
gcry_control (GCRYCTL_DUMP_SECMEM_STATS );
3976
emergency_cleanup ();
3978
rc = rc? rc : log_get_errorcount(0)? 2 : g10_errors_seen? 1 : 0;
3983
/* Pretty-print hex hashes. This assumes at least an 80-character
3984
display, but there are a few other similar assumptions in the
3987
print_hex( gcry_md_hd_t md, int algo, const char *fname )
3989
int i,n,count,indent=0;
3993
indent=printf("%s: ",fname);
4001
if(algo==DIGEST_ALGO_RMD160)
4002
indent+=printf("RMD160 = ");
4004
indent+=printf("%6s = ", gcry_md_algo_name (algo));
4010
p = gcry_md_read (md, algo);
4011
n = gcry_md_get_algo_dlen (algo);
4013
count += printf ("%02X",*p++);
4015
for(i=1;i<n;i++,p++)
4021
printf("\n%*s",indent," ");
4036
printf("\n%*s",indent," ");
4052
printf("\n%*s",indent," ");
4060
count+=printf("%02X",*p);
4067
print_hashline( gcry_md_hd_t md, int algo, const char *fname )
4073
for (p = fname; *p; p++ ) {
4074
if ( *p <= 32 || *p > 127 || *p == ':' || *p == '%' )
4075
printf("%%%02X", *p );
4081
printf("%d:", algo );
4082
p = gcry_md_read (md, algo);
4083
n = gcry_md_get_algo_dlen (algo);
4084
for(i=0; i < n ; i++, p++ )
4085
printf("%02X", *p );
4091
print_mds( const char *fname, int algo )
1698
4094
char buf[1024];
1706
#ifdef HAVE_DOSISH_SYSTEM
4100
#ifdef HAVE_DOSISH_SYSTEM
1707
4101
setmode ( fileno(fp) , O_BINARY );
1709
pname = gcry_xstrdup("[stdin]: ");
1712
pname = gcry_xmalloc(strlen(fname)+3);
1713
strcpy(stpcpy(pname,fname),": ");
1714
4105
fp = fopen( fname, "rb" );
4106
if (fp && is_secured_file (fileno (fp)))
1717
log_error("%s%s\n", pname, strerror(errno) );
4114
log_error("%s: %s\n", fname?fname:"[stdin]", strerror(errno) );
1722
md = gcry_md_open( 0, key? GCRY_MD_FLAG_HMAC : 0 );
4118
gcry_md_open (&md, 0, 0);
1724
gcry_md_enable( md, algo );
4120
gcry_md_enable (md, algo);
1726
/* Fixme: this does not work with hmac */
1727
gcry_md_enable( md, GCRY_MD_MD5 );
1728
gcry_md_enable( md, GCRY_MD_SHA1 );
1729
gcry_md_enable( md, GCRY_MD_RMD160 );
1730
have_tiger = !gcry_md_enable( md, GCRY_MD_TIGER );
4122
gcry_md_enable (md, GCRY_MD_MD5);
4123
gcry_md_enable (md, GCRY_MD_SHA1);
4124
gcry_md_enable (md, GCRY_MD_RMD160);
4125
if (!openpgp_md_test_algo (DIGEST_ALGO_SHA224))
4126
gcry_md_enable (md, DIGEST_ALGO_SHA224);
4127
if (!openpgp_md_test_algo (GCRY_MD_SHA256))
4128
gcry_md_enable (md, GCRY_MD_SHA256);
4129
if (!openpgp_md_test_algo (GCRY_MD_SHA384))
4130
gcry_md_enable (md, GCRY_MD_SHA384);
4131
if (!openpgp_md_test_algo (GCRY_MD_SHA512))
4132
gcry_md_enable (md, GCRY_MD_SHA512);
1733
gcry_md_setkey( md, key, strlen(key) );
1735
4135
while( (n=fread( buf, 1, DIM(buf), fp )) )
1736
gcry_md_write( md, buf, n );
4136
gcry_md_write (md, buf, n);
1737
4137
if( ferror(fp) )
1738
log_error("%s%s\n", pname, strerror(errno) );
4138
log_error("%s: %s\n", fname?fname:"[stdin]", strerror(errno) );
1742
fputs( pname, stdout );
1743
print_hex(gcry_md_read(md, algo), gcry_md_get_algo_dlen(algo) );
1746
printf( "%s MD5 = ", fname?pname:"" );
1747
print_hex(gcry_md_read(md, GCRY_MD_MD5), 16 );
1748
printf("\n%s SHA1 = ", fname?pname:"" );
1749
print_hex(gcry_md_read(md, GCRY_MD_SHA1), 20 );
1750
printf("\n%sRMD160 = ", fname?pname:"" );
1751
print_hex(gcry_md_read(md, GCRY_MD_RMD160), 20 );
1753
printf("\n%s TIGER = ", fname?pname:"" );
1754
print_hex(gcry_md_read(md, GCRY_MD_TIGER), 24 );
4141
if ( opt.with_colons ) {
4143
print_hashline( md, algo, fname );
4145
print_hashline( md, GCRY_MD_MD5, fname );
4146
print_hashline( md, GCRY_MD_SHA1, fname );
4147
print_hashline( md, GCRY_MD_RMD160, fname );
4148
if (!gcry_md_test_algo (DIGEST_ALGO_SHA224))
4149
print_hashline (md, DIGEST_ALGO_SHA224, fname);
4150
if (!gcry_md_test_algo (GCRY_MD_SHA256))
4151
print_hashline( md, GCRY_MD_SHA256, fname );
4152
if (!gcry_md_test_algo (GCRY_MD_SHA384))
4153
print_hashline ( md, GCRY_MD_SHA384, fname );
4154
if (!gcry_md_test_algo (GCRY_MD_SHA512))
4155
print_hashline ( md, GCRY_MD_SHA512, fname );
4160
print_hex(md,-algo,fname);
4162
print_hex( md, GCRY_MD_MD5, fname );
4163
print_hex( md, GCRY_MD_SHA1, fname );
4164
print_hex( md, GCRY_MD_RMD160, fname );
4165
if (!gcry_md_test_algo (DIGEST_ALGO_SHA224))
4166
print_hex (md, DIGEST_ALGO_SHA224, fname);
4167
if (!gcry_md_test_algo (GCRY_MD_SHA256))
4168
print_hex( md, GCRY_MD_SHA256, fname );
4169
if (!gcry_md_test_algo (GCRY_MD_SHA384))
4170
print_hex( md, GCRY_MD_SHA384, fname );
4171
if (!gcry_md_test_algo (GCRY_MD_SHA512))
4172
print_hex( md, GCRY_MD_SHA512, fname );
1759
4176
gcry_md_close(md);