Mon Feb 2 20:13:59 2009 UTC ()
Add a --version command to the openpgp utility, and document it. The
version is grabbed from the openpgpsdk library.

Make openpgp just include the one catch-all openpgpsdk header file.


(agc)
diff -r1.6 -r1.7 src/crypto/external/bsd/openpgpsdk/dist/include/openpgpsdk/util.h
diff -r1.11 -r1.12 src/crypto/external/bsd/openpgpsdk/dist/src/app/openpgp.c
diff -r1.7 -r1.8 src/crypto/external/bsd/openpgpsdk/dist/src/lib/openssl_crypto.c
diff -r1.8 -r1.9 src/crypto/external/bsd/openpgpsdk/dist/src/lib/util.c

cvs diff -r1.6 -r1.7 src/crypto/external/bsd/openpgpsdk/dist/include/openpgpsdk/Attic/util.h (expand / switch to unified diff)

--- src/crypto/external/bsd/openpgpsdk/dist/include/openpgpsdk/Attic/util.h 2009/01/31 01:20:32 1.6
+++ src/crypto/external/bsd/openpgpsdk/dist/include/openpgpsdk/Attic/util.h 2009/02/02 20:13:59 1.7
@@ -43,18 +43,24 @@ void hexdump(const unsigned c @@ -43,18 +43,24 @@ void hexdump(const unsigned c
43#ifndef CHECKED_PTR_OF 43#ifndef CHECKED_PTR_OF
44#define CHECKED_PTR_OF(type, p) ((void*) (1 ? p : (type *)0)) 44#define CHECKED_PTR_OF(type, p) ((void*) (1 ? p : (type *)0))
45#endif 45#endif
46#define CHECKED_INSTANCE_OF(type, p) (1 ? p : (type)0) 46#define CHECKED_INSTANCE_OF(type, p) (1 ? p : (type)0)
47 47
48/* number of elements in an array */ 48/* number of elements in an array */
49#define OPS_ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a))) 49#define OPS_ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a)))
50 50
51const char *ops_str_from_map(int, ops_map_t *); 51const char *ops_str_from_map(int, ops_map_t *);
52 52
53int ops_set_debug_level(const char *); 53int ops_set_debug_level(const char *);
54int ops_get_debug_level(const char *); 54int ops_get_debug_level(const char *);
55 55
 56#ifndef PACKAGE_VERSION
 57#define PACKAGE_VERSION "20090201"
 58#endif
 59
 60const char *ops_get_version(void);
 61
56#ifndef __UNCONST 62#ifndef __UNCONST
57#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) 63#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
58#endif 64#endif
59 65
60#endif 66#endif

cvs diff -r1.11 -r1.12 src/crypto/external/bsd/openpgpsdk/dist/src/app/Attic/openpgp.c (expand / switch to unified diff)

--- src/crypto/external/bsd/openpgpsdk/dist/src/app/Attic/openpgp.c 2009/01/31 01:20:32 1.11
+++ src/crypto/external/bsd/openpgpsdk/dist/src/app/Attic/openpgp.c 2009/02/02 20:13:59 1.12
@@ -20,34 +20,27 @@ @@ -20,34 +20,27 @@
20 */ 20 */
21 21
22/** 22/**
23 \file Command line program to perform openpgp operations 23 \file Command line program to perform openpgp operations
24*/ 24*/
25 25
26#include <stdio.h> 26#include <stdio.h>
27#include <stdlib.h> 27#include <stdlib.h>
28#include <string.h> 28#include <string.h>
29#include <getopt.h> 29#include <getopt.h>
30#include <libgen.h> 30#include <libgen.h>
31#include <unistd.h> 31#include <unistd.h>
32 32
33#include <openpgpsdk/keyring.h> 33#include <openpgpsdk/openpgpsdk.h>
34#include <openpgpsdk/crypto.h> 
35#include <openpgpsdk/signature.h> 
36#include <openpgpsdk/validate.h> 
37#include <openpgpsdk/readerwriter.h> 
38#include <openpgpsdk/std_print.h> 
39#include <openpgpsdk/packet-show.h> 
40#include <openpgpsdk/util.h> 
41 34
42#define DEFAULT_NUMBITS 2048 35#define DEFAULT_NUMBITS 2048
43 36
44#define MAXBUF 1024 37#define MAXBUF 1024
45 38
46static const char *usage = "%s --list-keys | --list-packets | --encrypt | --decrypt | --sign | --clearsign | --verify [--keyring=<keyring>] [--userid=<userid>] [--armour] [--homedir=<homedir>] files...\n"; 39static const char *usage = "%s --list-keys | --list-packets | --encrypt | --decrypt | --sign | --clearsign | --verify [--keyring=<keyring>] [--userid=<userid>] [--armour] [--homedir=<homedir>] files...\n";
47static const char *usage_find_key = "%s --find-key --userid=<userid> [--keyring=<keyring>] \n"; 40static const char *usage_find_key = "%s --find-key --userid=<userid> [--keyring=<keyring>] \n";
48static const char *usage_export_key = "%s --export-key --userid=<userid> [--keyring=<keyring>] \n"; 41static const char *usage_export_key = "%s --export-key --userid=<userid> [--keyring=<keyring>] \n";
49static const char *usage_encrypt = "%s --encrypt --userid=<userid> [--armour] [--homedir=<homedir>] files...\n"; 42static const char *usage_encrypt = "%s --encrypt --userid=<userid> [--armour] [--homedir=<homedir>] files...\n";
50static const char *usage_sign = "%s --sign --userid=<userid> [--armour] [--homedir=<homedir>] files...\n"; 43static const char *usage_sign = "%s --sign --userid=<userid> [--armour] [--homedir=<homedir>] files...\n";
51static const char *usage_clearsign = "%s --clearsign --userid=<userid> [--homedir=<homedir>] files...\n"; 44static const char *usage_clearsign = "%s --clearsign --userid=<userid> [--homedir=<homedir>] files...\n";
52 45
53static char *pname; 46static char *pname;
@@ -55,26 +48,27 @@ static char *pname; @@ -55,26 +48,27 @@ static char *pname;
55enum optdefs { 48enum optdefs {
56 /* commands */ 49 /* commands */
57 LIST_KEYS = 1, 50 LIST_KEYS = 1,
58 FIND_KEY, 51 FIND_KEY,
59 EXPORT_KEY, 52 EXPORT_KEY,
60 IMPORT_KEY, 53 IMPORT_KEY,
61 GENERATE_KEY, 54 GENERATE_KEY,
62 ENCRYPT, 55 ENCRYPT,
63 DECRYPT, 56 DECRYPT,
64 SIGN, 57 SIGN,
65 CLEARSIGN, 58 CLEARSIGN,
66 VERIFY, 59 VERIFY,
67 LIST_PACKETS, 60 LIST_PACKETS,
 61 VERSION,
68 62
69 /* options */ 63 /* options */
70 KEYRING, 64 KEYRING,
71 USERID, 65 USERID,
72 PASSPHRASE, 66 PASSPHRASE,
73 ARMOUR, 67 ARMOUR,
74 HOMEDIR, 68 HOMEDIR,
75 NUMBITS, 69 NUMBITS,
76 70
77 /* debug */ 71 /* debug */
78 OPS_DEBUG 72 OPS_DEBUG
79 73
80}; 74};
@@ -92,26 +86,28 @@ static struct option long_options[] = { @@ -92,26 +86,28 @@ static struct option long_options[] = {
92 {"find-key", no_argument, NULL, FIND_KEY}, 86 {"find-key", no_argument, NULL, FIND_KEY},
93 {"export-key", no_argument, NULL, EXPORT_KEY}, 87 {"export-key", no_argument, NULL, EXPORT_KEY},
94 {"import-key", no_argument, NULL, IMPORT_KEY}, 88 {"import-key", no_argument, NULL, IMPORT_KEY},
95 {"generate-key", no_argument, NULL, GENERATE_KEY}, 89 {"generate-key", no_argument, NULL, GENERATE_KEY},
96 90
97 {"encrypt", no_argument, NULL, ENCRYPT}, 91 {"encrypt", no_argument, NULL, ENCRYPT},
98 {"decrypt", no_argument, NULL, DECRYPT}, 92 {"decrypt", no_argument, NULL, DECRYPT},
99 {"sign", no_argument, NULL, SIGN}, 93 {"sign", no_argument, NULL, SIGN},
100 {"clearsign", no_argument, NULL, CLEARSIGN}, 94 {"clearsign", no_argument, NULL, CLEARSIGN},
101 {"verify", no_argument, NULL, VERIFY}, 95 {"verify", no_argument, NULL, VERIFY},
102 96
103 {"list-packets", no_argument, NULL, LIST_PACKETS}, 97 {"list-packets", no_argument, NULL, LIST_PACKETS},
104 98
 99 {"version", no_argument, NULL, VERSION},
 100
105 /* options */ 101 /* options */
106 {"keyring", required_argument, NULL, KEYRING}, 102 {"keyring", required_argument, NULL, KEYRING},
107 {"userid", required_argument, NULL, USERID}, 103 {"userid", required_argument, NULL, USERID},
108 {"passphrase", required_argument, NULL, PASSPHRASE}, 104 {"passphrase", required_argument, NULL, PASSPHRASE},
109 {"homedir", required_argument, NULL, HOMEDIR}, 105 {"homedir", required_argument, NULL, HOMEDIR},
110 {"armor", no_argument, NULL, ARMOUR}, 106 {"armor", no_argument, NULL, ARMOUR},
111 {"armour", no_argument, NULL, ARMOUR}, 107 {"armour", no_argument, NULL, ARMOUR},
112 {"numbits", required_argument, NULL, NUMBITS}, 108 {"numbits", required_argument, NULL, NUMBITS},
113 109
114 /* debug */ 110 /* debug */
115 {"debug", required_argument, NULL, OPS_DEBUG}, 111 {"debug", required_argument, NULL, OPS_DEBUG},
116 112
117 { NULL, 0, NULL, 0}, 113 { NULL, 0, NULL, 0},
@@ -448,26 +444,30 @@ main(int argc, char **argv) @@ -448,26 +444,30 @@ main(int argc, char **argv)
448 case FIND_KEY: 444 case FIND_KEY:
449 case EXPORT_KEY: 445 case EXPORT_KEY:
450 case IMPORT_KEY: 446 case IMPORT_KEY:
451 case GENERATE_KEY: 447 case GENERATE_KEY:
452 case ENCRYPT: 448 case ENCRYPT:
453 case DECRYPT: 449 case DECRYPT:
454 case SIGN: 450 case SIGN:
455 case CLEARSIGN: 451 case CLEARSIGN:
456 case VERIFY: 452 case VERIFY:
457 case LIST_PACKETS: 453 case LIST_PACKETS:
458 p.cmd = long_options[optindex].val; 454 p.cmd = long_options[optindex].val;
459 break; 455 break;
460 456
 457 case VERSION:
 458 printf("%s version: %s\n", *argv, ops_get_version());
 459 exit(EXIT_SUCCESS);
 460
461 /* option */ 461 /* option */
462 462
463 case KEYRING: 463 case KEYRING:
464 if (optarg == NULL) { 464 if (optarg == NULL) {
465 (void) fprintf(stderr, "No keyring argument provided\n"); 465 (void) fprintf(stderr, "No keyring argument provided\n");
466 exit(EXIT_ERROR); 466 exit(EXIT_ERROR);
467 } 467 }
468 snprintf(p.keyring, MAXBUF, "%s", optarg); 468 snprintf(p.keyring, MAXBUF, "%s", optarg);
469 break; 469 break;
470 470
471 case USERID: 471 case USERID:
472 if (optarg == NULL) { 472 if (optarg == NULL) {
473 (void) fprintf(stderr, "No userid argument provided\n"); 473 (void) fprintf(stderr, "No userid argument provided\n");

cvs diff -r1.7 -r1.8 src/crypto/external/bsd/openpgpsdk/dist/src/lib/Attic/openssl_crypto.c (expand / switch to unified diff)

--- src/crypto/external/bsd/openpgpsdk/dist/src/lib/Attic/openssl_crypto.c 2009/01/30 04:16:15 1.7
+++ src/crypto/external/bsd/openpgpsdk/dist/src/lib/Attic/openssl_crypto.c 2009/02/02 20:13:59 1.8
@@ -532,27 +532,29 @@ ops_rsa_private_decrypt(unsigned char *o @@ -532,27 +532,29 @@ ops_rsa_private_decrypt(unsigned char *o
532 orsa->n = rsa->n; /* XXX: do we need n? */ 532 orsa->n = rsa->n; /* XXX: do we need n? */
533 orsa->d = srsa->d; 533 orsa->d = srsa->d;
534 orsa->p = srsa->q; 534 orsa->p = srsa->q;
535 orsa->q = srsa->p; 535 orsa->q = srsa->p;
536 536
537 /* debug */ 537 /* debug */
538 orsa->e = rsa->e; 538 orsa->e = rsa->e;
539 assert(RSA_check_key(orsa) == 1); 539 assert(RSA_check_key(orsa) == 1);
540 orsa->e = NULL; 540 orsa->e = NULL;
541 /* end debug */ 541 /* end debug */
542 542
543 n = RSA_private_decrypt(length, in, out, orsa, RSA_NO_PADDING); 543 n = RSA_private_decrypt(length, in, out, orsa, RSA_NO_PADDING);
544 544
545 /* printf("ops_rsa_private_decrypt: n=%d\n",n); */ 545 if (ops_get_debug_level(__FILE__)) {
 546 printf("ops_rsa_private_decrypt: n=%d\n",n);
 547 }
546 548
547 errbuf[0] = '\0'; 549 errbuf[0] = '\0';
548 if (n == -1) { 550 if (n == -1) {
549 unsigned long err = ERR_get_error(); 551 unsigned long err = ERR_get_error();
550 ERR_error_string(err, &errbuf[0]); 552 ERR_error_string(err, &errbuf[0]);
551 fprintf(stderr, "openssl error : %s\n", errbuf); 553 fprintf(stderr, "openssl error : %s\n", errbuf);
552 } 554 }
553 orsa->n = orsa->d = orsa->p = orsa->q = NULL; 555 orsa->n = orsa->d = orsa->p = orsa->q = NULL;
554 RSA_free(orsa); 556 RSA_free(orsa);
555 557
556 return n; 558 return n;
557} 559}
558 560

cvs diff -r1.8 -r1.9 src/crypto/external/bsd/openpgpsdk/dist/src/lib/Attic/util.c (expand / switch to unified diff)

--- src/crypto/external/bsd/openpgpsdk/dist/src/lib/Attic/util.c 2009/01/31 01:44:31 1.8
+++ src/crypto/external/bsd/openpgpsdk/dist/src/lib/Attic/util.c 2009/02/02 20:13:59 1.9
@@ -229,13 +229,20 @@ ops_get_debug_level(const char *f) @@ -229,13 +229,20 @@ ops_get_debug_level(const char *f)
229 if ((name = strrchr(f, '/')) == NULL) { 229 if ((name = strrchr(f, '/')) == NULL) {
230 name = f; 230 name = f;
231 } else { 231 } else {
232 name += 1; 232 name += 1;
233 } 233 }
234 for (i = 0; i < debugc; i++) { 234 for (i = 0; i < debugc; i++) {
235 if (strcmp(debugv[i], "all") == 0 || 235 if (strcmp(debugv[i], "all") == 0 ||
236 strcmp(debugv[i], name) == 0) { 236 strcmp(debugv[i], name) == 0) {
237 return 1; 237 return 1;
238 } 238 }
239 } 239 }
240 return 0; 240 return 0;
241} 241}
 242
 243/* return the version for the library */
 244const char *
 245ops_get_version(void)
 246{
 247 return PACKAGE_VERSION;
 248}