From: Daniel Kahn Gillmor Date: Fri, 4 Apr 2008 23:29:58 +0000 (-0400) Subject: key translator: cleanup error checking. X-Git-Tag: monkeysphere_0.1-1~88 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=0feae9a3c736f3b034b7f2d9a023b2a1a57d4c1c;p=monkeysphere.git key translator: cleanup error checking. --- diff --git a/main.c b/main.c index 27117ed..8225f0a 100644 --- a/main.c +++ b/main.c @@ -286,28 +286,19 @@ int main(int argc, char* argv[]) { /* write(0, output_data, ods); */ /* } */ - copy_datum(&clean, &data); - copy_datum(&test, &data); - - if (0 != compare_data(&data, &clean)) - err("data do not match after initial copy\n"); /* format could be either: GNUTLS_OPENPGP_FMT_RAW, - GNUTLS_OPENPGP_FMT_BASE64; we'll try them both, raw first */ - - - -/* if (ret = gnutls_openpgp_privkey_import(pgp_privkey, &data, GNUTLS_OPENPGP_FMT_RAW, NULL, 0), ret) */ -/* err("failed to import the OpenPGP private key in RAW format (error: %d)\n", ret); */ -/* if (0 != compare_data(&data, &clean)) */ -/* err("Datum changed after privkey import in raw format!\n"); */ - - - if (ret = gnutls_openpgp_privkey_import (pgp_privkey, &data, GNUTLS_OPENPGP_FMT_BASE64, NULL, 0), ret) - err("failed to import the OpenPGP private key in BASE64 format (error: %d)\n", ret); - if (0 != compare_data(&data, &clean)) - err("Datum changed after privkey import in base64 format!\n"); - + GNUTLS_OPENPGP_FMT_BASE64; if MONKEYSPHERE_RAW is set, use RAW, + otherwise, use BASE64: */ + if (getenv("MONKEYSPHERE_RAW")) { + err("assuming RAW formatted private keys\n"); + if (ret = gnutls_openpgp_privkey_import(pgp_privkey, &data, GNUTLS_OPENPGP_FMT_RAW, NULL, 0), ret) + err("failed to import the OpenPGP private key in RAW format (error: %d)\n", ret); + } else { + err("assuming BASE64 formatted private keys\n"); + if (ret = gnutls_openpgp_privkey_import (pgp_privkey, &data, GNUTLS_OPENPGP_FMT_BASE64, NULL, 0), ret) + err("failed to import the OpenPGP private key in BASE64 format (error: %d)\n", ret); + } pgp_algo = gnutls_openpgp_privkey_get_pk_algorithm(pgp_privkey, &pgp_bits); if (pgp_algo < 0) {