From cvs at cvs.gnupg.org Wed Mar 1 12:05:49 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed Mar 1 11:40:46 2006 Subject: [svn] GnuPG - r4030 - in branches/GNUPG-1-9-BRANCH: . scd Message-ID: Author: wk Date: 2006-03-01 12:05:47 +0100 (Wed, 01 Mar 2006) New Revision: 4030 Modified: branches/GNUPG-1-9-BRANCH/TODO branches/GNUPG-1-9-BRANCH/scd/ChangeLog branches/GNUPG-1-9-BRANCH/scd/apdu.c branches/GNUPG-1-9-BRANCH/scd/app.c branches/GNUPG-1-9-BRANCH/scd/ccid-driver.c branches/GNUPG-1-9-BRANCH/scd/command.c Log: Fixed card removal problems Modified: branches/GNUPG-1-9-BRANCH/TODO =================================================================== --- branches/GNUPG-1-9-BRANCH/TODO 2006-02-27 19:31:13 UTC (rev 4029) +++ branches/GNUPG-1-9-BRANCH/TODO 2006-03-01 11:05:47 UTC (rev 4030) @@ -67,7 +67,12 @@ Using the session_list in command.c and the lock_table in app.c. IT would be better to do this just at one place. First we need to see how we can support cards with multiple applications. - +** Detecting a removed card works only after the ticker detected it. + We should check the card status in open-card to make this smoother. + Needs to be integrated with the status file update, though. It is + not a real problem because application will get a card removed status + and should the send a reset to try solving the problem. + * tests ** Makefile.am We use printf(1) to setup the library path, this is not portable. Modified: branches/GNUPG-1-9-BRANCH/scd/ChangeLog =================================================================== --- branches/GNUPG-1-9-BRANCH/scd/ChangeLog 2006-02-27 19:31:13 UTC (rev 4029) +++ branches/GNUPG-1-9-BRANCH/scd/ChangeLog 2006-03-01 11:05:47 UTC (rev 4030) @@ -1,10 +1,26 @@ +2006-03-01 Werner Koch + + * command.c (status_file_update_lock): New. + (scd_update_reader_status_file): Use lock and factor existing code + out to .. + (update_reader_status_file): .. this. + (do_reset): Use the lock and call update_reader_status_file. + +2006-02-20 Werner Koch + + * apdu.c (open_pcsc_reader): Fixed double free. Thanks to Moritz. + 2006-02-09 Werner Koch + * command.c (get_reader_slot, do_reset) + (scd_update_reader_status_file): Rewrote. + * app.c (release_application): Factored code out to .. (deallocate_app): new function. (select_application): Introduce new saved application stuff. (application_notify_card_removed): New. - * command.c (update_card_removed): Call it. + * command.c (update_card_removed): Call it here. + (do_reset): And here. * app.c (check_application_conflict): New. * command.c (open_card): Use it here. Modified: branches/GNUPG-1-9-BRANCH/scd/apdu.c =================================================================== --- branches/GNUPG-1-9-BRANCH/scd/apdu.c 2006-02-27 19:31:13 UTC (rev 4029) +++ branches/GNUPG-1-9-BRANCH/scd/apdu.c 2006-03-01 11:05:47 UTC (rev 4030) @@ -1594,6 +1594,7 @@ } strcpy (reader_table[slot].rdrname, portstr? portstr : list); xfree (list); + list = NULL; err = pcsc_connect (reader_table[slot].pcsc.context, reader_table[slot].rdrname, @@ -1611,7 +1612,6 @@ xfree (reader_table[slot].rdrname); reader_table[slot].rdrname = NULL; reader_table[slot].used = 0; - xfree (list); return -1 /*pcsc_error_to_sw (err)*/; } @@ -2369,7 +2369,7 @@ } /* Shutdown a reader; that is basically the same as a close but keeps - the handle ready for later use. A apdu_reset_header should be used + the handle ready for later use. A apdu_reset_reader should be used to get it active again. */ int apdu_shutdown_reader (int slot) Modified: branches/GNUPG-1-9-BRANCH/scd/app.c =================================================================== --- branches/GNUPG-1-9-BRANCH/scd/app.c 2006-02-27 19:31:13 UTC (rev 4029) +++ branches/GNUPG-1-9-BRANCH/scd/app.c 2006-03-01 11:05:47 UTC (rev 4030) @@ -165,13 +165,17 @@ return; /* Deallocate a saved application for that slot, so that we won't - try to reuse it. */ - if (lock_table[slot].initialized && lock_table[slot].last_app) + try to reuse it. If there is no saved application, set a flag so + that we won't save the current state. */ + if (lock_table[slot].initialized) { app_t app = lock_table[slot].last_app; - lock_table[slot].last_app = NULL; - deallocate_app (app); + if (app) + { + lock_table[slot].last_app = NULL; + deallocate_app (app); + } } } @@ -380,7 +384,7 @@ /* Free the resources associated with the application APP. APP is allowed to be NULL in which case this is a no-op. Note that we are using reference counting to track the users of the application and - actually deferiing the deallcoation to allow for a later resuse by + actually deferring the deallocation to allow for a later reuse by a new connection. */ void release_application (app_t app) Modified: branches/GNUPG-1-9-BRANCH/scd/ccid-driver.c =================================================================== --- branches/GNUPG-1-9-BRANCH/scd/ccid-driver.c 2006-02-27 19:31:13 UTC (rev 4029) +++ branches/GNUPG-1-9-BRANCH/scd/ccid-driver.c 2006-03-01 11:05:47 UTC (rev 4030) @@ -989,7 +989,12 @@ fd = open (transports[i].name, O_RDWR); if (fd == -1) - continue; + { + log_debug ("failed to open `%s': %s\n", + transports[i].name, strerror (errno)); + continue; + } + log_debug ("opened `%s': fd=%d\n", transports[i].name, fd); rid = malloc (strlen (transports[i].name) + 30 + 10); if (!rid) @@ -1042,6 +1047,7 @@ } free (rid); close (fd); + log_debug ("closed fd %d\n", fd); } if (scan_mode) @@ -1202,7 +1208,10 @@ if (idev) usb_close (idev); if (dev_fd != -1) - close (dev_fd); + { + close (dev_fd); + log_debug ("closed fd %d\n", dev_fd); + } free (*handle); *handle = NULL; } @@ -1245,6 +1254,7 @@ if (handle->dev_fd != -1) { close (handle->dev_fd); + log_debug ("closed fd %d\n", handle->dev_fd); handle->dev_fd = -1; } } @@ -1314,7 +1324,10 @@ usb_close (handle->idev); handle->idev = NULL; if (handle->dev_fd != -1) - close (handle->dev_fd); + { + close (handle->dev_fd); + log_debug ("closed fd %d\n", handle->dev_fd); + } handle->dev_fd = -1; } @@ -1327,7 +1340,7 @@ int ccid_close_reader (ccid_driver_t handle) { - if (!handle || !handle->idev) + if (!handle || (!handle->idev && handle->dev_fd == -1)) return 0; do_close_reader (handle); Modified: branches/GNUPG-1-9-BRANCH/scd/command.c =================================================================== --- branches/GNUPG-1-9-BRANCH/scd/command.c 2006-02-27 19:31:13 UTC (rev 4029) +++ branches/GNUPG-1-9-BRANCH/scd/command.c 2006-03-01 11:05:47 UTC (rev 4030) @@ -62,9 +62,26 @@ && (c)->reader_slot == locked_session->ctrl_backlink->reader_slot) +/* This structure is used to keep track of open readers (slots). */ +struct slot_status_s +{ + int valid; /* True if the other objects are valid. */ + int slot; /* Slot number of the reader or -1 if not open. */ + + int reset_failed; /* A reset failed. */ + + int any; /* Flag indicating whether any status check has been + done. This is set once to indicate that the status + tracking for the slot has been initialized. */ + unsigned int status; /* Last status of the slot. */ + unsigned int changed; /* Last change counter of teh slot. */ +}; + + /* Data used to associate an Assuan context with local server data. This object describes the local properties of one session. */ -struct server_local_s { +struct server_local_s +{ /* We keep a list of all active sessions with the anchor at SESSION_LIST (see below). This field is used for linking. */ struct server_local_s *next_session; @@ -86,6 +103,10 @@ }; +/* The table with information on all used slots. */ +static struct slot_status_s slot_table[10]; + + /* To keep track of all running sessions, we link all active server contexts and the anchor in this variable. */ static struct server_local_s *session_list; @@ -94,8 +115,15 @@ in this variable. */ static struct server_local_s *locked_session; +/* While doing a reset we need to make sure that the ticker does not + call scd_update_reader_status_file while we are using it. */ +static pth_mutex_t status_file_update_lock = PTH_MUTEX_INIT; + +/*-- Local prototypes --*/ +static void update_reader_status_file (void); + /* Update the CARD_REMOVED element of all sessions using the reader given by SLOT to VALUE */ @@ -107,7 +135,9 @@ for (sl=session_list; sl; sl = sl->next_session) if (sl->ctrl_backlink && sl->ctrl_backlink->reader_slot == slot) - sl->card_removed = value; + { + sl->card_removed = value; + } if (value) application_notify_card_removed (slot); } @@ -126,69 +156,52 @@ } -/* Reset the card and free the application context. With DO_CLOSE set - to true and this is the last session with a reference to the - reader, close the reader and don't do just a reset. */ +/* Reset the card and free the application context. With SEND_RESET + set to true actually send a RESET to the reader. */ static void -do_reset (ctrl_t ctrl, int do_close) +do_reset (ctrl_t ctrl, int send_reset) { int slot = ctrl->reader_slot; + if (!(slot == -1 || (slot >= 0 && slot < DIM(slot_table)))) + BUG (); + if (ctrl->app_ctx) { release_application (ctrl->app_ctx); ctrl->app_ctx = NULL; } - if (ctrl->reader_slot != -1) + + if (slot != -1 && send_reset && !IS_LOCKED (ctrl) ) { - struct server_local_s *sl; - - /* If we are the only session with the reader open we may close - it. If not, do a reset unless a lock is held on the - reader. */ - for (sl=session_list; sl; sl = sl->next_session) - if (sl != ctrl->server_local - && sl->ctrl_backlink->reader_slot == ctrl->reader_slot) - break; - if (sl) /* There is another session with the reader open. */ + if (apdu_reset (slot)) { - if ( IS_LOCKED (ctrl) ) /* If it is locked, release it. */ - ctrl->reader_slot = -1; - else - { - if (do_close) /* Always mark reader unused. */ - ctrl->reader_slot = -1; - else if (apdu_reset (ctrl->reader_slot)) /* Reset only if - not locked */ - { - /* The reset failed. Mark the reader as closed. */ - ctrl->reader_slot = -1; - } - - if (locked_session && ctrl->server_local == locked_session) - { - locked_session = NULL; - log_debug ("implicitly unlocking due to RESET\n"); - } - } + slot_table[slot].reset_failed = 1; } - else /* No other session has the reader open. */ - { - if (do_close || apdu_reset (ctrl->reader_slot)) - { - apdu_close_reader (ctrl->reader_slot); - ctrl->reader_slot = -1; - } - if ( IS_LOCKED (ctrl) ) - { - log_debug ("WARNING: cleaning up stale session lock\n"); - locked_session = NULL; - } - } } + ctrl->reader_slot = -1; - /* Reset card removed flag for the current reader. */ + /* If we hold a lock, unlock now. */ + if (locked_session && ctrl->server_local == locked_session) + { + locked_session = NULL; + log_info ("implicitly unlocking due to RESET\n"); + } + + /* Reset card removed flag for the current reader. We need to take + the lock here so that the ticker thread won't concurrently try to + update the file. Note that the update function will set the card + removed flag and we will later reset it - not a particualar nice + way of implementing it but it works. */ + if (!pth_mutex_acquire (&status_file_update_lock, 0, NULL)) + { + log_error ("failed to acquire status_fle_update lock\n"); + return; + } + update_reader_status_file (); update_card_removed (slot, 0); + if (!pth_mutex_release (&status_file_update_lock)) + log_error ("failed to release status_file_update lock\n"); } @@ -197,7 +210,7 @@ { ctrl_t ctrl = assuan_get_pointer (ctx); - do_reset (ctrl, 0); + do_reset (ctrl, 1); } @@ -226,18 +239,22 @@ static int get_reader_slot (void) { - struct server_local_s *sl; - int slot= -1; + struct slot_status_s *ss; - for (sl=session_list; sl; sl = sl->next_session) - if (sl->ctrl_backlink - && (slot = sl->ctrl_backlink->reader_slot) != -1) - break; + ss = &slot_table[0]; /* One reader for now. */ - if (slot == -1) - slot = apdu_open_reader (opt.reader_port); + /* Initialize the item if needed. */ + if (!ss->valid) + { + ss->slot = -1; + ss->valid = 1; + } - return slot; + /* Try to open the reader. */ + if (ss->slot == -1) + ss->slot = apdu_open_reader (opt.reader_port); + + return ss->slot; } /* If the card has not yet been opened, do it. Note that this @@ -349,7 +366,7 @@ { if ( IS_LOCKED (ctrl) ) return gpg_error (GPG_ERR_LOCKED); - do_reset (ctrl, 0); + do_reset (ctrl, 1); } if ((rc = open_card (ctrl, *line? line:NULL))) @@ -1305,7 +1322,7 @@ /* RESTART - Restart the current connection; this is a kind of warn reset. It + Restart the current connection; this is a kind of warm reset. It deletes the context used by this connection but does not send a RESET to the card. Thus the card itself won't get reset. @@ -1462,7 +1479,7 @@ } /* Cleanup. */ - do_reset (&ctrl, 1); + do_reset (&ctrl, 0); /* Release the server object. */ if (session_list == ctrl.server_local) @@ -1532,77 +1549,88 @@ } -/* This function is called by the ticker thread to check for changes - of the reader stati. It updates the reader status files and if - requested by the caller also send a signal to the caller. */ -void -scd_update_reader_status_file (void) +/* This is the core of scd_update_reader_status_file but the caller + needs to take care of the locking. */ +static void +update_reader_status_file (void) { - static struct { - int any; - unsigned int status; - unsigned int changed; - } last[10]; - int slot; - int used; + int idx; unsigned int status, changed; /* Note, that we only try to get the status, because it does not make sense to wait here for a operation to complete. If we are busy working with a card, delays in the status file update should be acceptable. */ - for (slot=0; (slot < DIM(last) - &&!apdu_enum_reader (slot, &used)); slot++) - if (used && !apdu_get_status (slot, 0, &status, &changed)) - { - if (!last[slot].any || last[slot].status != status - || last[slot].changed != changed ) - { - char *fname; - char templ[50]; - FILE *fp; - struct server_local_s *sl; + for (idx=0; idx < DIM(slot_table); idx++) + { + struct slot_status_s *ss = slot_table + idx; - log_info ("updating status of slot %d to 0x%04X\n", slot, status); - - sprintf (templ, "reader_%d.status", slot); - fname = make_filename (opt.homedir, templ, NULL ); - fp = fopen (fname, "w"); - if (fp) - { - fprintf (fp, "%s\n", - (status & 1)? "USABLE": - (status & 4)? "ACTIVE": - (status & 2)? "PRESENT": "NOCARD"); - fclose (fp); - } - xfree (fname); + if (!ss->valid || ss->slot == -1) + continue; /* Not valid or reader not yet open. */ + + if ( apdu_get_status (ss->slot, 0, &status, &changed) ) + continue; /* Get status failed. */ - /* Set the card removed flag for all current sessions. We - will set this on any card change because a reset or - SERIALNO request must be done in any case. */ - if (last[slot].any) - update_card_removed (slot, 1); + if (!ss->any || ss->status != status || ss->changed != changed ) + { + char *fname; + char templ[50]; + FILE *fp; + struct server_local_s *sl; - last[slot].any = 1; - last[slot].status = status; - last[slot].changed = changed; + log_info ("updating status of slot %d to 0x%04X\n", + ss->slot, status); + + sprintf (templ, "reader_%d.status", ss->slot); + fname = make_filename (opt.homedir, templ, NULL ); + fp = fopen (fname, "w"); + if (fp) + { + fprintf (fp, "%s\n", + (status & 1)? "USABLE": + (status & 4)? "ACTIVE": + (status & 2)? "PRESENT": "NOCARD"); + fclose (fp); + } + xfree (fname); + + /* Set the card removed flag for all current sessions. We + will set this on any card change because a reset or + SERIALNO request must be done in any case. */ + if (ss->any) + update_card_removed (ss->slot, 1); + + ss->any = 1; + ss->status = status; + ss->changed = changed; - - /* Send a signal to all clients who applied for it. */ - for (sl=session_list; sl; sl = sl->next_session) - if (sl->event_signal && sl->assuan_ctx) - { - pid_t pid = assuan_get_pid (sl->assuan_ctx); - int signo = sl->event_signal; - - log_info ("client pid is %d, sending signal %d\n", - pid, signo); + /* Send a signal to all clients who applied for it. */ + for (sl=session_list; sl; sl = sl->next_session) + if (sl->event_signal && sl->assuan_ctx) + { + pid_t pid = assuan_get_pid (sl->assuan_ctx); + int signo = sl->event_signal; + + log_info ("client pid is %d, sending signal %d\n", + pid, signo); #ifndef HAVE_W32_SYSTEM - if (pid != (pid_t)(-1) && pid && signo > 0) - kill (pid, signo); + if (pid != (pid_t)(-1) && pid && signo > 0) + kill (pid, signo); #endif - } - } - } + } + } + } } + +/* This function is called by the ticker thread to check for changes + of the reader stati. It updates the reader status files and if + requested by the caller also send a signal to the caller. */ +void +scd_update_reader_status_file (void) +{ + if (!pth_mutex_acquire (&status_file_update_lock, 1, NULL)) + return; /* locked - give up. */ + update_reader_status_file (); + if (!pth_mutex_release (&status_file_update_lock)) + log_error ("failed to release status_file_update lock\n"); +} From cvs at cvs.gnupg.org Wed Mar 1 18:05:39 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed Mar 1 17:40:32 2006 Subject: [svn] GnuPG - r4031 - trunk Message-ID: Author: dshaw Date: 2006-03-01 18:05:38 +0100 (Wed, 01 Mar 2006) New Revision: 4031 Modified: trunk/ChangeLog trunk/configure.ac Log: * configure.ac: Fix accidental enabling of SHA-384/512. Noted by Nelson H. F. Beebe. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-01 11:05:47 UTC (rev 4030) +++ trunk/ChangeLog 2006-03-01 17:05:38 UTC (rev 4031) @@ -1,3 +1,8 @@ +2006-03-01 David Shaw + + * configure.ac: Fix accidental enabling of SHA-384/512. Noted by + Nelson H. F. Beebe. + 2006-02-18 David Shaw * configure.ac: Try linking the UINT64_C test program (rather than Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-01 11:05:47 UTC (rev 4030) +++ trunk/configure.ac 2006-03-01 17:05:38 UTC (rev 4031) @@ -842,7 +842,7 @@ use_sha512=no fi -if test x"$use_sha512" ; then +if test x"$use_sha512" = xyes ; then AC_DEFINE(USE_SHA512,1,[Define to include the SHA-384 and SHA-512 digests]) fi From cvs at cvs.gnupg.org Wed Mar 1 19:16:58 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed Mar 1 18:51:51 2006 Subject: [svn] GnuPG - r4032 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-01 19:16:55 +0100 (Wed, 01 Mar 2006) New Revision: 4032 Modified: trunk/g10/ChangeLog trunk/g10/getkey.c trunk/g10/misc.c Log: * getkey.c (parse_auto_key_locate): Error if the user selects "cert" or "pka" when those features are disabled. * misc.c (has_invalid_email_chars): Fix some C syntax that broke the compilers on SGI IRIX MIPS and Compaq/DEC OSF/1 Alpha. Noted by Nelson H. F. Beebe. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-01 17:05:38 UTC (rev 4031) +++ trunk/g10/ChangeLog 2006-03-01 18:16:55 UTC (rev 4032) @@ -1,3 +1,12 @@ +2006-03-01 David Shaw + + * getkey.c (parse_auto_key_locate): Error if the user selects + "cert" or "pka" when those features are disabled. + + * misc.c (has_invalid_email_chars): Fix some C syntax that broke + the compilers on SGI IRIX MIPS and Compaq/DEC OSF/1 Alpha. Noted + by Nelson H. F. Beebe. + 2006-02-27 David Shaw * options.skel: Document auto-key-locate and give a pointer to Modified: trunk/g10/getkey.c =================================================================== --- trunk/g10/getkey.c 2006-03-01 17:05:38 UTC (rev 4031) +++ trunk/g10/getkey.c 2006-03-01 18:16:55 UTC (rev 4032) @@ -2928,14 +2928,18 @@ akl=xmalloc_clear(sizeof(*akl)); - if(ascii_strcasecmp(tok,"cert")==0) + if(ascii_strcasecmp(tok,"ldap")==0) + akl->type=AKL_LDAP; + else if(ascii_strcasecmp(tok,"keyserver")==0) + akl->type=AKL_KEYSERVER; +#ifdef USE_DNS_CERT + else if(ascii_strcasecmp(tok,"cert")==0) akl->type=AKL_CERT; +#endif +#ifdef USE_DNS_PKA else if(ascii_strcasecmp(tok,"pka")==0) akl->type=AKL_PKA; - else if(ascii_strcasecmp(tok,"ldap")==0) - akl->type=AKL_LDAP; - else if(ascii_strcasecmp(tok,"keyserver")==0) - akl->type=AKL_KEYSERVER; +#endif else if((akl->spec=parse_keyserver_uri(tok,1,NULL,0))) akl->type=AKL_SPEC; else Modified: trunk/g10/misc.c =================================================================== --- trunk/g10/misc.c 2006-03-01 17:05:38 UTC (rev 4031) +++ trunk/g10/misc.c 2006-03-01 18:16:55 UTC (rev 4032) @@ -1081,15 +1081,12 @@ } - - int has_invalid_email_chars (const char *s) { int at_seen=0; - static char valid_chars[] = ("01234567890_-." - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + const char *valid_chars= + "01234567890_-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; for ( ; *s; s++ ) { From cvs at cvs.gnupg.org Thu Mar 2 11:31:55 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu Mar 2 11:06:41 2006 Subject: [svn] gpgme - r1161 - tags Message-ID: Author: marcus Date: 2006-03-02 11:31:55 +0100 (Thu, 02 Mar 2006) New Revision: 1161 Added: tags/gpgme-1-1-1/ Log: Tag release 1.1.1. Copied: tags/gpgme-1-1-1 (from rev 1160, trunk) From cvs at cvs.gnupg.org Thu Mar 2 11:32:07 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu Mar 2 11:06:54 2006 Subject: [svn] gpgme - r1162 - tags Message-ID: Author: marcus Date: 2006-03-02 11:32:07 +0100 (Thu, 02 Mar 2006) New Revision: 1162 Added: tags/gpgme-1.1.1/ Log: Tag release 1.1.1. Copied: tags/gpgme-1.1.1 (from rev 1161, trunk) From cvs at cvs.gnupg.org Thu Mar 2 11:40:00 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu Mar 2 11:14:47 2006 Subject: [svn] gpgme - r1163 - trunk Message-ID: Author: marcus Date: 2006-03-02 11:39:59 +0100 (Thu, 02 Mar 2006) New Revision: 1163 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac Log: 2006-03-02 Marcus Brinkmann * configure.ac (LIBGPGME_LT_REVISION): Bump for release. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-02 10:32:07 UTC (rev 1162) +++ trunk/ChangeLog 2006-03-02 10:39:59 UTC (rev 1163) @@ -1,3 +1,7 @@ +2006-03-02 Marcus Brinkmann + + * configure.ac (LIBGPGME_LT_REVISION): Bump for release. + 2006-02-22 Marcus Brinkmann Released 1.1.1. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-02 10:32:07 UTC (rev 1162) +++ trunk/NEWS 2006-03-02 10:39:59 UTC (rev 1163) @@ -1,3 +1,9 @@ +Noteworthy changes in version 1.1.2 (2006-03-02) +------------------------------------------------ + + * Fixed a bug in the W32 glib backend. + + Noteworthy changes in version 1.1.1 (2006-02-23) ------------------------------------------------ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-02 10:32:07 UTC (rev 1162) +++ trunk/configure.ac 2006-03-02 10:39:59 UTC (rev 1163) @@ -36,7 +36,7 @@ # for snapshot releases please do an "svn up" right before recreating # the configure script, so that a proper revision number for all files # is available when running a "make distcheck". -m4_define(my_version, [1.1.1]) +m4_define(my_version, [1.1.2]) #m4_define(my_iscvs, yes) AC_INIT([gpgme], my_version[]m4_ifdef([my_iscvs], [-cvs[]m4_translit( [$Revision$],[Ra-z $:])]), @@ -52,7 +52,7 @@ # Subtract 2 from this value if you want to make the LFS transition an # ABI break. [Note to self: Remove this comment with the next regular break.] LIBGPGME_LT_AGE=6 -LIBGPGME_LT_REVISION=0 +LIBGPGME_LT_REVISION=1 # If the API is changed in an incompatible way: increment the next counter. GPGME_CONFIG_API_VERSION=1 From cvs at cvs.gnupg.org Thu Mar 2 11:41:09 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu Mar 2 11:15:56 2006 Subject: [svn] gpgme - r1164 - tags Message-ID: Author: marcus Date: 2006-03-02 11:41:09 +0100 (Thu, 02 Mar 2006) New Revision: 1164 Removed: tags/gpgme-1.1.1/ Log: Tagged wrong revision. Sigh. From cvs at cvs.gnupg.org Thu Mar 2 11:41:19 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu Mar 2 11:16:05 2006 Subject: [svn] gpgme - r1165 - tags Message-ID: Author: marcus Date: 2006-03-02 11:41:18 +0100 (Thu, 02 Mar 2006) New Revision: 1165 Removed: tags/gpgme-1-1-1/ Log: Tagged wrong revision. Sigh. From cvs at cvs.gnupg.org Thu Mar 2 11:43:16 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu Mar 2 11:18:02 2006 Subject: [svn] gpgme - r1166 - tags Message-ID: Author: marcus Date: 2006-03-02 11:43:16 +0100 (Thu, 02 Mar 2006) New Revision: 1166 Added: tags/gpgme-1-1-1/ Log: Tag release 1.1.1. Copied: tags/gpgme-1-1-1 (from rev 1159, trunk) From cvs at cvs.gnupg.org Thu Mar 2 11:43:39 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu Mar 2 11:18:26 2006 Subject: [svn] gpgme - r1167 - tags Message-ID: Author: marcus Date: 2006-03-02 11:43:38 +0100 (Thu, 02 Mar 2006) New Revision: 1167 Added: tags/gpgme-1.1.1/ Log: Tag release 1.1.1. Copied: tags/gpgme-1.1.1 (from rev 1159, trunk) From cvs at cvs.gnupg.org Thu Mar 2 18:37:01 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu Mar 2 18:11:49 2006 Subject: [svn] gpgme - r1168 - tags Message-ID: Author: marcus Date: 2006-03-02 18:37:01 +0100 (Thu, 02 Mar 2006) New Revision: 1168 Added: tags/gpgme-1-1-2/ Log: Tag release 1.1.2. Copied: tags/gpgme-1-1-2 (from rev 1167, trunk) From cvs at cvs.gnupg.org Fri Mar 3 11:13:50 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri Mar 3 10:48:31 2006 Subject: [svn] gpgme - r1169 - trunk Message-ID: Author: marcus Date: 2006-03-03 11:13:49 +0100 (Fri, 03 Mar 2006) New Revision: 1169 Modified: trunk/NEWS trunk/configure.ac Log: Post-release tweaks. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-02 17:37:01 UTC (rev 1168) +++ trunk/NEWS 2006-03-03 10:13:49 UTC (rev 1169) @@ -1,3 +1,11 @@ +Noteworthy changes in version 1.1.3 (unreleased) +------------------------------------------------ + + * Interface changes relative to the 1.1.1 release: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Noteworthy changes in version 1.1.2 (2006-03-02) ------------------------------------------------ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-02 17:37:01 UTC (rev 1168) +++ trunk/configure.ac 2006-03-03 10:13:49 UTC (rev 1169) @@ -36,8 +36,8 @@ # for snapshot releases please do an "svn up" right before recreating # the configure script, so that a proper revision number for all files # is available when running a "make distcheck". -m4_define(my_version, [1.1.2]) -#m4_define(my_iscvs, yes) +m4_define(my_version, [1.1.3]) +m4_define(my_iscvs, yes) AC_INIT([gpgme], my_version[]m4_ifdef([my_iscvs], [-cvs[]m4_translit( [$Revision$],[Ra-z $:])]), [bug-gpgme@gnupg.org]) From cvs at cvs.gnupg.org Fri Mar 3 15:53:59 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri Mar 3 15:28:43 2006 Subject: [svn] gpg-error - r156 - trunk Message-ID: Author: marcus Date: 2006-03-03 15:53:58 +0100 (Fri, 03 Mar 2006) New Revision: 156 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac Log: 2006-03-03 Marcus Brinkmann * configure.ac (LIBGPG_ERROR_LT_CURRENT, LIBGPG_ERROR_LT_AGE): Bump for release. (LIBGPG_ERROR_LT_REVISION): Reset to 0 for release. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-01-24 20:06:03 UTC (rev 155) +++ trunk/ChangeLog 2006-03-03 14:53:58 UTC (rev 156) @@ -1,3 +1,9 @@ +2006-03-03 Marcus Brinkmann + + * configure.ac (LIBGPG_ERROR_LT_CURRENT, LIBGPG_ERROR_LT_AGE): + Bump for release. + (LIBGPG_ERROR_LT_REVISION): Reset to 0 for release. + 2005-11-02 Werner Koch * src/Makefile.am (gpg_error_SOURCES): Include ARCH_SOURCES. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-01-24 20:06:03 UTC (rev 155) +++ trunk/NEWS 2006-03-03 14:53:58 UTC (rev 156) @@ -1,4 +1,4 @@ -Noteworthy changes in version 1.2 (unreleased) +Noteworthy changes in version 1.2 (2006-03-03) ---------------------------------------------- * New function gpg_err_init, which binds the locale directory to @@ -25,6 +25,7 @@ GPG_ERR_INITIALIZED NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Noteworthy changes in version 1.1 (2005-06-20) ---------------------------------------------- Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-01-24 20:06:03 UTC (rev 155) +++ trunk/configure.ac 2006-03-03 14:53:58 UTC (rev 156) @@ -23,16 +23,16 @@ min_automake_version="1.9.3" # The gettext version is set below using AM_GNU_GETTEXT_VERSION # Version number: Remember to change it immediately *after* a release. -AC_INIT([libgpg-error],[1.2-cvs],[bug-gnupg@gnupg.org]) +AC_INIT([libgpg-error],[1.2],[bug-gnupg@gnupg.org]) # LT Version numbers, remember to change them just *before* a release. # (Code changed: REVISION++) # (Interfaces added/removed/changed: CURRENT++, REVISION=0) # (Interfaces added: AGE++) # (Interfaces removed: AGE=0) -# Note, that added error codes don't constitute an interface change. -LIBGPG_ERROR_LT_CURRENT=1 -LIBGPG_ERROR_LT_AGE=1 -LIBGPG_ERROR_LT_REVISION=4 +# Note that added error codes don't constitute an interface change. +LIBGPG_ERROR_LT_CURRENT=2 +LIBGPG_ERROR_LT_AGE=2 +LIBGPG_ERROR_LT_REVISION=0 AC_SUBST(LIBGPG_ERROR_LT_CURRENT) AC_SUBST(LIBGPG_ERROR_LT_AGE) AC_SUBST(LIBGPG_ERROR_LT_REVISION) From cvs at cvs.gnupg.org Fri Mar 3 16:16:50 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri Mar 3 15:51:31 2006 Subject: [svn] gpg-error - r157 - tags Message-ID: Author: marcus Date: 2006-03-03 16:16:50 +0100 (Fri, 03 Mar 2006) New Revision: 157 Added: tags/libgpg-error-1.2/ Log: Tagging release 1.2. Copied: tags/libgpg-error-1.2 (from rev 156, trunk) From cvs at cvs.gnupg.org Fri Mar 3 16:17:43 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri Mar 3 15:52:23 2006 Subject: [svn] gpg-error - r158 - trunk Message-ID: Author: marcus Date: 2006-03-03 16:17:43 +0100 (Fri, 03 Mar 2006) New Revision: 158 Modified: trunk/NEWS trunk/configure.ac Log: Post-release tweaks. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-03 15:16:50 UTC (rev 157) +++ trunk/NEWS 2006-03-03 15:17:43 UTC (rev 158) @@ -1,3 +1,11 @@ +Noteworthy changes in version 1.3 (unreleased) +---------------------------------------------- + + * Interface changes relative to the 1.2 release: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Noteworthy changes in version 1.2 (2006-03-03) ---------------------------------------------- Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-03 15:16:50 UTC (rev 157) +++ trunk/configure.ac 2006-03-03 15:17:43 UTC (rev 158) @@ -23,7 +23,7 @@ min_automake_version="1.9.3" # The gettext version is set below using AM_GNU_GETTEXT_VERSION # Version number: Remember to change it immediately *after* a release. -AC_INIT([libgpg-error],[1.2],[bug-gnupg@gnupg.org]) +AC_INIT([libgpg-error],[1.3-cvs],[bug-gnupg@gnupg.org]) # LT Version numbers, remember to change them just *before* a release. # (Code changed: REVISION++) # (Interfaces added/removed/changed: CURRENT++, REVISION=0) From cvs at cvs.gnupg.org Fri Mar 3 22:55:39 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Fri Mar 3 22:30:18 2006 Subject: [svn] GnuPG - r4033 - trunk/keyserver Message-ID: Author: dshaw Date: 2006-03-03 22:55:38 +0100 (Fri, 03 Mar 2006) New Revision: 4033 Modified: trunk/keyserver/ChangeLog trunk/keyserver/gpgkeys_ldap.c Log: * gpgkeys_ldap.c (main): Fix build problem with non-OpenLDAP LDAP libraries that have TLS. Modified: trunk/keyserver/ChangeLog =================================================================== --- trunk/keyserver/ChangeLog 2006-03-01 18:16:55 UTC (rev 4032) +++ trunk/keyserver/ChangeLog 2006-03-03 21:55:38 UTC (rev 4033) @@ -1,3 +1,8 @@ +2006-03-03 David Shaw + + * gpgkeys_ldap.c (main): Fix build problem with non-OpenLDAP LDAP + libraries that have TLS. + 2006-02-23 David Shaw * ksutil.c (init_ks_options): Default include-revoked and Modified: trunk/keyserver/gpgkeys_ldap.c =================================================================== --- trunk/keyserver/gpgkeys_ldap.c 2006-03-01 18:16:55 UTC (rev 4032) +++ trunk/keyserver/gpgkeys_ldap.c 2006-03-03 21:55:38 UTC (rev 4033) @@ -1928,7 +1928,8 @@ return KEYSERVER_INTERNAL_ERROR; } -#if defined(HAVE_LDAP_SET_OPTION) && defined(LDAP_OPT_X_TLS_CACERTFILE) +#if defined(LDAP_OPT_X_TLS_CACERTFILE) && defined(HAVE_LDAP_SET_OPTION) + if(opt->ca_cert_file) { err=ldap_set_option(NULL,LDAP_OPT_X_TLS_CACERTFILE,opt->ca_cert_file); @@ -1940,7 +1941,7 @@ goto fail; } } -#endif /* HAVE_LDAP_SET_OPTION && LDAP_OPT_X_TLS_CACERTFILE */ +#endif /* LDAP_OPT_X_TLS_CACERTFILE && HAVE_LDAP_SET_OPTION */ /* SSL trumps TLS */ if(use_ssl) @@ -2104,6 +2105,8 @@ int ver=LDAP_VERSION3; err=ldap_set_option(ldap,LDAP_OPT_PROTOCOL_VERSION,&ver); + +#ifdef LDAP_OPT_X_TLS if(err==LDAP_SUCCESS) { if(opt->flags.check_cert) @@ -2112,10 +2115,12 @@ ver=LDAP_OPT_X_TLS_NEVER; err=ldap_set_option(ldap,LDAP_OPT_X_TLS_REQUIRE_CERT,&ver); - if(err==LDAP_SUCCESS) - err=ldap_start_tls_s(ldap,NULL,NULL); } +#endif + if(err==LDAP_SUCCESS) + err=ldap_start_tls_s(ldap,NULL,NULL); + if(err!=LDAP_SUCCESS) { if(use_tls>=2 || opt->verbose>2) @@ -2128,7 +2133,7 @@ goto fail; } } - else if(err==LDAP_SUCCESS && opt->verbose>1) + else if(opt->verbose>1) fprintf(console,"gpgkeys: TLS started successfully.\n"); #else if(use_tls>=2) From cvs at cvs.gnupg.org Sun Mar 5 16:13:20 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Sun Mar 5 15:47:54 2006 Subject: [svn] GnuPG - r4034 - in trunk: . g10 Message-ID: Author: wk Date: 2006-03-05 16:13:18 +0100 (Sun, 05 Mar 2006) New Revision: 4034 Modified: trunk/THANKS trunk/g10/ChangeLog trunk/g10/apdu.c trunk/g10/cardglue.c trunk/g10/mainproc.c trunk/g10/plaintext.c Log: Replaced an assert and fixed batch mode issue in cardglue. Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2006-03-03 21:55:38 UTC (rev 4033) +++ trunk/THANKS 2006-03-05 15:13:18 UTC (rev 4034) @@ -201,6 +201,7 @@ Steven Bakker steven@icoe.att.com Steven Murdoch sjmurdoch@bigfoot.com Susanne Schultz schultz@hsp.de +Tavis Ormandy taviso@gentoo.org Ted Cabeen secabeen@pobox.com Thiago Jung Bauermann jungmann@cwb.matrix.com.br Thijmen Klok thijmen@xs4all.nl Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-03 21:55:38 UTC (rev 4033) +++ trunk/g10/ChangeLog 2006-03-05 15:13:18 UTC (rev 4034) @@ -1,3 +1,12 @@ +2006-03-05 Werner Koch + + * plaintext.c (handle_plaintext): Replace assert by explict error + conflict message. Reported by Tavis Ormandy. + +2006-03-02 Werner Koch + + * cardglue.c (check_card_serialno): Don't ask in batch mode. + 2006-03-01 David Shaw * getkey.c (parse_auto_key_locate): Error if the user selects @@ -93,6 +102,11 @@ * keyserver.c (parse_keyserver_uri): Include the scheme in the uri even when we've assumed "hkp" when there was no scheme. +2006-02-20 Werner Koch + + * apdu.c (open_pcsc_reader): As a precaution set LIST to NULL + after free. + 2006-02-14 Werner Koch * verify.c (verify_signatures): Print warning also for NO_DATA. Modified: trunk/g10/apdu.c =================================================================== --- trunk/g10/apdu.c 2006-03-03 21:55:38 UTC (rev 4033) +++ trunk/g10/apdu.c 2006-03-05 15:13:18 UTC (rev 4034) @@ -1586,6 +1586,7 @@ } strcpy (reader_table[slot].rdrname, portstr? portstr : list); xfree (list); + list = NULL; err = pcsc_connect (reader_table[slot].pcsc.context, reader_table[slot].rdrname, Modified: trunk/g10/cardglue.c =================================================================== --- trunk/g10/cardglue.c 2006-03-03 21:55:38 UTC (rev 4033) +++ trunk/g10/cardglue.c 2006-03-05 15:13:18 UTC (rev 4034) @@ -1,5 +1,5 @@ /* cardglue.c - mainly dispatcher for card related functions. - * Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. + * Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -29,7 +29,6 @@ #include #include #include - #include "options.h" #include "packet.h" #include "errors.h" @@ -537,7 +536,7 @@ /* Check that the serial number of the current card (as described by APP) matches SERIALNO. If there is no match and we are not in batch mode, present a prompt to insert the desired card. The - function return 0 is the present card is okay, -1 if the user + function returnd 0 if the present card is okay, -1 if the user selected to insert a new card or an error value. Note that the card context will be closed in all cases except for 0 as return value and if it was possible to merely shutdown the reader. */ @@ -569,17 +568,20 @@ did_shutdown = 1; else card_close (); - tty_printf (_("Please remove the current card and " - "insert the one with serial number:\n" - " %.*s\n"), 32, serialno); + if (!opt.batch) + tty_printf (_("Please remove the current card and " + "insert the one with serial number:\n" + " %.*s\n"), 32, serialno); + sprintf (buf, "1 %.32s", serialno); write_status_text (STATUS_CARDCTRL, buf); - if ( cpr_get_answer_okay_cancel ("cardctrl.change_card.okay", - _("Hit return when ready " - "or enter 'c' to cancel: "), - 1) ) + if ( !opt.batch + && cpr_get_answer_okay_cancel ("cardctrl.change_card.okay", + _("Hit return when ready " + "or enter 'c' to cancel: "), + 1) ) { card_close (); return -1; Modified: trunk/g10/mainproc.c =================================================================== --- trunk/g10/mainproc.c 2006-03-03 21:55:38 UTC (rev 4033) +++ trunk/g10/mainproc.c 2006-03-05 15:13:18 UTC (rev 4034) @@ -404,7 +404,7 @@ if( !opt.list_only && opt.override_session_key ) { /* It does not make much sense to store the session key in * secure memory because it has already been passed on the - * command line and the GCHQ knows about it */ + * command line and the GCHQ knows about it. */ c->dek = xmalloc_clear( sizeof *c->dek ); result = get_override_session_key ( c->dek, opt.override_session_key ); if ( result ) { @@ -414,6 +414,8 @@ else if( is_ELGAMAL(enc->pubkey_algo) || enc->pubkey_algo == PUBKEY_ALGO_DSA || is_RSA(enc->pubkey_algo) ) { + /* FIXME: strore this all in a list and process it later */ + if ( !c->dek && ((!enc->keyid[0] && !enc->keyid[1]) || opt.try_all_secrets || !seckey_available( enc->keyid )) ) { @@ -523,6 +525,9 @@ print_pkenc_list ( c->pkenc_list, 0 ); } + /* FIXME: Figure out the session key by looking at all pkenc packets. */ + + write_status( STATUS_BEGIN_DECRYPTION ); /*log_debug("dat: %sencrypted data\n", c->dek?"":"conventional ");*/ Modified: trunk/g10/plaintext.c =================================================================== --- trunk/g10/plaintext.c 2006-03-03 21:55:38 UTC (rev 4033) +++ trunk/g10/plaintext.c 2006-03-05 15:13:18 UTC (rev 4034) @@ -1,6 +1,6 @@ /* plaintext.c - process plaintext packets * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, - * 2005 Free Software Foundation, Inc. + * 2005, 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -177,8 +177,14 @@ #endif /* __riscos__ */ if( !pt->is_partial ) { - /* we have an actual length (which might be zero). */ - assert( !clearsig ); + /* We have an actual length (which might be zero). */ + + if (clearsig) { + log_error ("clearsig encountered while not expected\n"); + rc = G10ERR_UNEXPECTED; + goto leave; + } + if( convert ) { /* text mode */ for( ; pt->len; pt->len-- ) { if( (c = iobuf_get(pt->buf)) == -1 ) { From cvs at cvs.gnupg.org Mon Mar 6 11:09:21 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon Mar 6 10:43:53 2006 Subject: [svn] gpg-error - r159 - trunk Message-ID: Author: marcus Date: 2006-03-06 11:09:15 +0100 (Mon, 06 Mar 2006) New Revision: 159 Modified: trunk/COPYING trunk/ChangeLog trunk/INSTALL trunk/compile trunk/configure.ac trunk/depcomp trunk/install-sh trunk/ltmain.sh trunk/missing trunk/mkinstalldirs Log: 2006-03-06 Marcus Brinkmann * configure.ac (min_automake_version): Bump to 1.9.6. * mkinstalldirs, depcomp, compile, INSTALL, COPYING, missing, install-sh: Update from automake 1.9.6. ltmain.sh: Update from libtool 1.5.22. Modified: trunk/COPYING =================================================================== --- trunk/COPYING 2006-03-03 15:17:43 UTC (rev 158) +++ trunk/COPYING 2006-03-06 10:09:15 UTC (rev 159) @@ -2,7 +2,7 @@ Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -305,7 +305,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-03 15:17:43 UTC (rev 158) +++ trunk/ChangeLog 2006-03-06 10:09:15 UTC (rev 159) @@ -1,3 +1,10 @@ +2006-03-06 Marcus Brinkmann + + * configure.ac (min_automake_version): Bump to 1.9.6. + * mkinstalldirs, depcomp, compile, INSTALL, COPYING, missing, + install-sh: Update from automake 1.9.6. + ltmain.sh: Update from libtool 1.5.22. + 2006-03-03 Marcus Brinkmann * configure.ac (LIBGPG_ERROR_LT_CURRENT, LIBGPG_ERROR_LT_AGE): Modified: trunk/INSTALL =================================================================== --- trunk/INSTALL 2006-03-03 15:17:43 UTC (rev 158) +++ trunk/INSTALL 2006-03-06 10:09:15 UTC (rev 159) @@ -1,7 +1,7 @@ Installation Instructions ************************* -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004 Free +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives @@ -102,16 +102,16 @@ Installation Names ================== -By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PREFIX'. +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PREFIX', the package will -use PREFIX as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular @@ -159,7 +159,7 @@ need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should -use the `--target=TYPE' option to select the type of system they will +use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a @@ -189,9 +189,14 @@ ./configure CC=/usr/local2/bin/gcc -will cause the specified gcc to be used as the C compiler (unless it is -overridden in the site shell script). +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). Here is a another example: + /bin/bash ./configure CONFIG_SHELL=/bin/bash + +Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent +configuration-related scripts to be executed by `/bin/bash'. + `configure' Invocation ====================== Modified: trunk/compile =================================================================== --- trunk/compile 2006-03-03 15:17:43 UTC (rev 158) +++ trunk/compile 2006-03-06 10:09:15 UTC (rev 159) @@ -1,7 +1,7 @@ #! /bin/sh # Wrapper for compilers which do not understand `-c -o'. -scriptversion=2005-02-03.08 +scriptversion=2005-05-14.22 # Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. # Written by Tom Tromey . @@ -18,7 +18,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-03 15:17:43 UTC (rev 158) +++ trunk/configure.ac 2006-03-06 10:09:15 UTC (rev 159) @@ -20,7 +20,7 @@ # (Process this file with autoconf to produce a configure script.) # The following lines are used by ./autogen.sh. AC_PREREQ(2.59) -min_automake_version="1.9.3" +min_automake_version="1.9.6" # The gettext version is set below using AM_GNU_GETTEXT_VERSION # Version number: Remember to change it immediately *after* a release. AC_INIT([libgpg-error],[1.3-cvs],[bug-gnupg@gnupg.org]) Modified: trunk/depcomp =================================================================== --- trunk/depcomp 2006-03-03 15:17:43 UTC (rev 158) +++ trunk/depcomp 2006-03-06 10:09:15 UTC (rev 159) @@ -1,9 +1,9 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2004-05-31.23 +scriptversion=2005-07-09.11 -# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,8 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -50,11 +50,11 @@ Report bugs to . EOF - exit 0 + exit $? ;; -v | --v*) echo "depcomp $scriptversion" - exit 0 + exit $? ;; esac @@ -287,36 +287,43 @@ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then - # Dependencies are output in .lo.d with libtool 1.4. - # With libtool 1.5 they are output both in $dir.libs/$base.o.d - # and in $dir.libs/$base.o.d and $dir$base.o.d. We process the - # latter, because the former will be cleaned when $dir.libs is - # erased. - tmpdepfile1="$dir.libs/$base.lo.d" - tmpdepfile2="$dir$base.o.d" - tmpdepfile3="$dir.libs/$base.d" + # With Tru64 cc, shared objects can also be used to make a + # static library. This mecanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else - tmpdepfile1="$dir$base.o.d" - tmpdepfile2="$dir$base.d" - tmpdepfile3="$dir$base.d" + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi - if test -f "$tmpdepfile1"; then - tmpdepfile="$tmpdepfile1" - elif test -f "$tmpdepfile2"; then - tmpdepfile="$tmpdepfile2" - else - tmpdepfile="$tmpdepfile3" - fi + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. @@ -460,7 +467,8 @@ done "$@" -E | - sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" Modified: trunk/install-sh =================================================================== --- trunk/install-sh 2006-03-03 15:17:43 UTC (rev 158) +++ trunk/install-sh 2006-03-06 10:09:15 UTC (rev 159) @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2004-12-17.09 +scriptversion=2005-05-14.22 # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -109,7 +109,7 @@ shift continue;; - --help) echo "$usage"; exit 0;; + --help) echo "$usage"; exit $?;; -m) chmodcmd="$chmodprog $2" shift @@ -134,7 +134,7 @@ shift continue;; - --version) echo "$0 $scriptversion"; exit 0;; + --version) echo "$0 $scriptversion"; exit $?;; *) # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. Modified: trunk/ltmain.sh =================================================================== --- trunk/ltmain.sh 2006-03-03 15:17:43 UTC (rev 158) +++ trunk/ltmain.sh 2006-03-06 10:09:15 UTC (rev 159) @@ -1,7 +1,7 @@ # ltmain.sh - Provide generalized library-building support services. # NOTE: Changing this file will not affect anything until you rerun configure. # -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004 +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 # Free Software Foundation, Inc. # Originally by Gordon Matzigkeit , 1996 # @@ -17,7 +17,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -43,9 +43,14 @@ PROGRAM=ltmain.sh PACKAGE=libtool -VERSION=1.5.6 -TIMESTAMP=" (1.1220.2.95 2004/04/11 05:50:42) Debian$Rev$" +VERSION="1.5.22 Debian 1.5.22-2" +TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)" +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes. +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi # Check that we have a working $echo. if test "X$1" = X--no-reexec; then @@ -83,14 +88,15 @@ Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' # test EBCDIC or ASCII -case `echo A|tr A '\301'` in - A) # EBCDIC based system - SP2NL="tr '\100' '\n'" - NL2SP="tr '\r\n' '\100\100'" +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + SP2NL='tr \040 \012' + NL2SP='tr \015\012 \040\040' ;; - *) # Assume ASCII based system - SP2NL="tr '\040' '\012'" - NL2SP="tr '\015\012' '\040\040'" + *) # EBCDIC based system + SP2NL='tr \100 \n' + NL2SP='tr \r\n \100\100' ;; esac @@ -107,8 +113,9 @@ fi # Make sure IFS has a sensible default -: ${IFS=" -"} +lt_nl=' +' +IFS=" $lt_nl" if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then $echo "$modename: not configured to build any kind of library" 1>&2 @@ -125,6 +132,8 @@ show="$echo" show_help= execute_dlfiles= +duplicate_deps=no +preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" @@ -132,13 +141,51 @@ # Shell function definitions: # This seems to be the best place for them +# func_mktempdir [string] +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, STRING is the basename for that directory. +func_mktempdir () +{ + my_template="${TMPDIR-/tmp}/${1-$progname}" + + if test "$run" = ":"; then + # Return a directory name, but don't create it in dry-run mode + my_tmpdir="${my_template}-$$" + else + + # If mktemp works, use that first and foremost + my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` + + if test ! -d "$my_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + my_tmpdir="${my_template}-${RANDOM-0}$$" + + save_mktempdir_umask=`umask` + umask 0077 + $mkdir "$my_tmpdir" + umask $save_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$my_tmpdir" || { + $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2 + exit $EXIT_FAILURE + } + fi + + $echo "X$my_tmpdir" | $Xsed +} + + # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. -func_win32_libid () { +func_win32_libid () +{ win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in @@ -149,12 +196,11 @@ if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then win32_nmres=`eval $NM -f posix -A $1 | \ - sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'` - if test "X$win32_nmres" = "Ximport" ; then - win32_libid_type="x86 archive import" - else - win32_libid_type="x86 archive static" - fi + $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'` + case $win32_nmres in + import*) win32_libid_type="x86 archive import";; + *) win32_libid_type="x86 archive static";; + esac fi ;; *DLL*) @@ -178,7 +224,8 @@ # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' -func_infer_tag () { +func_infer_tag () +{ if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do @@ -235,12 +282,116 @@ esac fi } + + +# func_extract_an_archive dir oldlib +func_extract_an_archive () +{ + f_ex_an_ar_dir="$1"; shift + f_ex_an_ar_oldlib="$1" + + $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)" + $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $? + if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2 + exit $EXIT_FAILURE + fi +} + +# func_extract_archives gentop oldlib ... +func_extract_archives () +{ + my_gentop="$1"; shift + my_oldlibs=${1+"$@"} + my_oldobjs="" + my_xlib="" + my_xabs="" + my_xdir="" + my_status="" + + $show "${rm}r $my_gentop" + $run ${rm}r "$my_gentop" + $show "$mkdir $my_gentop" + $run $mkdir "$my_gentop" + my_status=$? + if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then + exit $my_status + fi + + for my_xlib in $my_oldlibs; do + # Extract the objects. + case $my_xlib in + [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; + *) my_xabs=`pwd`"/$my_xlib" ;; + esac + my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'` + my_xdir="$my_gentop/$my_xlib" + + $show "${rm}r $my_xdir" + $run ${rm}r "$my_xdir" + $show "$mkdir $my_xdir" + $run $mkdir "$my_xdir" + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then + exit $exit_status + fi + case $host in + *-darwin*) + $show "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + if test -z "$run"; then + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'` + darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` + if test -n "$darwin_arches"; then + darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + $show "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches ; do + mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}" + lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" + cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" + func_extract_an_archive "`pwd`" "${darwin_base_archive}" + cd "$darwin_curdir" + $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" + done # $darwin_arches + ## Okay now we have a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP` + darwin_file= + darwin_files= + for darwin_file in $darwin_filelist; do + darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` + lipo -create -output "$darwin_file" $darwin_files + done # $darwin_filelist + ${rm}r unfat-$$ + cd "$darwin_orig_dir" + else + cd "$darwin_orig_dir" + func_extract_an_archive "$my_xdir" "$my_xabs" + fi # $darwin_arches + fi # $run + ;; + *) + func_extract_an_archive "$my_xdir" "$my_xabs" + ;; + esac + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + done + func_extract_archives_result="$my_oldobjs" +} # End of Shell function definitions ##################################### # Darwin sucks eval std_shrext=\"$shrext_cmds\" +disable_libs=no + # Parse our command line options once, thoroughly. while test "$#" -gt 0 do @@ -305,10 +456,10 @@ --version) $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" $echo - $echo "Copyright (C) 2003 Free Software Foundation, Inc." + $echo "Copyright (C) 2005 Free Software Foundation, Inc." $echo "This is free software; see the source for copying conditions. There is NO" $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - exit $EXIT_SUCCESS + exit $? ;; --config) @@ -317,7 +468,7 @@ for tagname in $taglist; do ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" done - exit $EXIT_SUCCESS + exit $? ;; --debug) @@ -342,7 +493,7 @@ else $echo "disable static libraries" fi - exit $EXIT_SUCCESS + exit $? ;; --finish) mode="finish" ;; @@ -357,7 +508,11 @@ preserve_args="$preserve_args $arg" ;; - --tag) prevopt="--tag" prev=tag ;; + --tag) + prevopt="--tag" + prev=tag + preserve_args="$preserve_args --tag" + ;; --tag=*) set tag "$optarg" ${1+"$@"} shift @@ -389,6 +544,18 @@ exit $EXIT_FAILURE fi +case $disable_libs in +no) + ;; +shared) + build_libtool_libs=no + build_old_libs=yes + ;; +static) + build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` + ;; +esac + # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. @@ -399,7 +566,7 @@ # Infer the operation mode. if test -z "$mode"; then $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 - $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2 + $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2 case $nonopt in *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) mode=link @@ -465,7 +632,7 @@ for arg do - case "$arg_mode" in + case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" @@ -547,7 +714,10 @@ case $lastarg in # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. + # in scan sets, and some SunOS ksh mistreat backslash-escaping + # in scan sets (worked around with variable expansion), + # and furthermore cannot handle '|' '&' '(' ')' in scan sets + # at all, so we specify them separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") lastarg="\"$lastarg\"" ;; @@ -621,6 +791,14 @@ esac done + qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"` + case $qlibobj in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qlibobj="\"$qlibobj\"" ;; + esac + test "X$libobj" != "X$qlibobj" \ + && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \ + && $echo "$modename: libobj name \`$libobj' may not contain shell special characters." objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$obj"; then @@ -693,12 +871,17 @@ $run $rm $removelist exit $EXIT_FAILURE fi - $echo $srcfile > "$lockfile" + $echo "$srcfile" > "$lockfile" fi if test -n "$fix_srcfile_path"; then eval srcfile=\"$fix_srcfile_path\" fi + qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"` + case $qsrcfile in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qsrcfile="\"$qsrcfile\"" ;; + esac $run $rm "$libobj" "${libobj}T" @@ -720,18 +903,18 @@ fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then - command="$base_compile $srcfile $pic_flag" + command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code - command="$base_compile $srcfile" + command="$base_compile $qsrcfile" fi if test ! -d "${xdir}$objdir"; then $show "$mkdir ${xdir}$objdir" $run $mkdir ${xdir}$objdir - status=$? - if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then - exit $status + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then + exit $exit_status fi fi @@ -803,9 +986,9 @@ if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code - command="$base_compile $srcfile" + command="$base_compile $qsrcfile" else - command="$base_compile $srcfile $pic_flag" + command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then command="$command -o $obj" @@ -934,6 +1117,7 @@ no_install=no objs= non_pic_objects= + notinst_path= # paths that contain not-installed libtool libraries precious_files_regex= prefer_static_libs=no preload=no @@ -962,14 +1146,15 @@ if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi + prefer_static_libs=yes else if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi + prefer_static_libs=built fi build_libtool_libs=no build_old_libs=yes - prefer_static_libs=yes break ;; esac @@ -1144,6 +1329,11 @@ if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" fi else # Only an error if not doing a dry-run. @@ -1227,6 +1417,13 @@ prev= continue ;; + darwin_framework|darwin_framework_skip) + test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + prev= + continue + ;; *) eval "$prev=\"\$arg\"" prev= @@ -1285,6 +1482,18 @@ continue ;; + -framework|-arch|-isysroot) + case " $CC " in + *" ${arg} ${1} "* | *" ${arg} ${1} "*) + prev=darwin_framework_skip ;; + *) compiler_flags="$compiler_flags $arg" + prev=darwin_framework ;; + esac + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + continue + ;; + -inst-prefix-dir) prev=inst_prefix continue @@ -1311,7 +1520,8 @@ absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 - exit $EXIT_FAILURE + absdir="$dir" + notinst_path="$notinst_path $dir" fi dir="$absdir" ;; @@ -1325,10 +1535,15 @@ esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; *) dllsearchpath="$dllsearchpath:$dir";; esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac ;; esac continue @@ -1337,15 +1552,15 @@ -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in - *-*-cygwin* | *-*-pw32* | *-*-beos*) + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*) # These systems don't actually have a C or math library (as such) continue ;; - *-*-mingw* | *-*-os2*) + *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; - *-*-openbsd* | *-*-freebsd*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; @@ -1353,10 +1568,19 @@ # Rhapsody C and math libraries are in the System framework deplibs="$deplibs -framework System" continue + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + test "X$arg" = "X-lc" && continue + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + test "X$arg" = "X-lc" && continue + ;; esac elif test "X$arg" = "X-lc_r"; then case $host in - *-*-openbsd* | *-*-freebsd*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; @@ -1366,8 +1590,20 @@ continue ;; + # Tru64 UNIX uses -model [arg] to determine the layout of C++ + # classes, name mangling, and exception handling. + -model) + compile_command="$compile_command $arg" + compiler_flags="$compiler_flags $arg" + finalize_command="$finalize_command $arg" + prev=xcompiler + continue + ;; + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) - deplibs="$deplibs $arg" + compiler_flags="$compiler_flags $arg" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" continue ;; @@ -1376,13 +1612,19 @@ continue ;; - # gcc -m* arguments should be passed to the linker via $compiler_flags - # in order to pass architecture information to the linker - # (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo - # but this is not reliable with gcc because gcc may use -mfoo to - # select a different linker, different libraries, etc, while - # -Wl,-mfoo simply passes -mfoo to the linker. - -m*) + # -64, -mips[0-9] enable 64-bit mode on the SGI compiler + # -r[0-9][0-9]* specifies the processor on the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler + # +DA*, +DD* enable 64-bit mode on the HP compiler + # -q* pass through compiler args for the IBM compiler + # -m* pass through architecture-specific compiler args for GCC + # -m*, -t[45]*, -txscale* pass through architecture-specific + # compiler args for GCC + # -pg pass through profiling flag for GCC + # @file GCC response files + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \ + -t[45]*|-txscale*|@*) + # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` @@ -1393,9 +1635,7 @@ esac compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" - if test "$with_gcc" = "yes" ; then - compiler_flags="$compiler_flags $arg" - fi + compiler_flags="$compiler_flags $arg" continue ;; @@ -1633,6 +1873,11 @@ if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" fi else # Only an error if not doing a dry-run. @@ -1738,9 +1983,9 @@ if test ! -d "$output_objdir"; then $show "$mkdir $output_objdir" $run $mkdir $output_objdir - status=$? - if test "$status" -ne 0 && test ! -d "$output_objdir"; then - exit $status + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then + exit $exit_status fi fi @@ -1803,7 +2048,6 @@ newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries - notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv link" @@ -1858,7 +2102,7 @@ compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else - deplibs="$deplib $deplibs" + compiler_flags="$compiler_flags $deplib" fi continue ;; @@ -1977,7 +2221,22 @@ fi case $linkmode in lib) - if test "$deplibs_check_method" != pass_all; then + valid_a_lib=no + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method + match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + if eval $echo \"$deplib\" 2>/dev/null \ + | $SED 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + valid_a_lib=yes + fi + ;; + pass_all) + valid_a_lib=yes + ;; + esac + if test "$valid_a_lib" != yes; then $echo $echo "*** Warning: Trying to link with static lib archive $deplib." $echo "*** I have the capability to make that library automatically link in when" @@ -2027,7 +2286,7 @@ esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else - $echo "$modename: cannot find the library \`$lib'" 1>&2 + $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2 exit $EXIT_FAILURE fi @@ -2051,7 +2310,9 @@ # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no + avoidtemprpath= + # Read the .la file case $lib in */* | *\\*) . $lib ;; @@ -2149,11 +2410,19 @@ dir="$libdir" absdir="$libdir" fi + test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - notinst_path="$notinst_path $abs_ladir" + if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then + dir="$ladir" + absdir="$abs_ladir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + fi fi # $installed = yes name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` @@ -2226,12 +2495,12 @@ if test -n "$library_names" && { test "$prefer_static_libs" = no || test -z "$old_library"; }; then # We need to hardcode the library path - if test -n "$shlibpath_var"; then + if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath " in *" $dir "*) ;; *" $absdir "*) ;; - *) temp_rpath="$temp_rpath $dir" ;; + *) temp_rpath="$temp_rpath $absdir" ;; esac fi @@ -2268,8 +2537,12 @@ fi link_static=no # Whether the deplib will be linked statically + use_static_libs=$prefer_static_libs + if test "$use_static_libs" = built && test "$installed" = yes ; then + use_static_libs=no + fi if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + { test "$use_static_libs" = no || test -z "$old_library"; }; then if test "$installed" = no; then notinst_deplibs="$notinst_deplibs $lib" need_relink=yes @@ -2382,11 +2655,15 @@ if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in - *-*-sco3.2v5* ) add_dir="-L$dir" ;; + *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; + *-*-sysv4*uw2*) add_dir="-L$dir" ;; + *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ + *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a module then we can not link against # it, someone is ignoring the new warnings I added - if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then + if /usr/bin/file -L $add 2> /dev/null | + $EGREP ": [^:]* bundle" >/dev/null ; then $echo "** Warning, lib $linklib is a module, not a shared library" if test -z "$old_library" ; then $echo @@ -2417,7 +2694,7 @@ add_dir="-L$dir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then - case "$libdir" in + case $libdir in [\\/]*) add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; @@ -2490,7 +2767,7 @@ add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then - case "$libdir" in + case $libdir in [\\/]*) add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; @@ -2551,8 +2828,6 @@ fi fi else - convenience="$convenience $dir/$old_library" - old_convenience="$old_convenience $dir/$old_library" deplibs="$dir/$old_library $deplibs" link_static=yes fi @@ -2670,13 +2945,13 @@ *) continue ;; esac case " $deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + case " $deplibs " in *" $depdepl "*) ;; *) deplibs="$depdepl $deplibs" ;; esac - case " $deplibs " in - *" $path "*) ;; - *) deplibs="$deplibs $path" ;; - esac done fi # link_all_deplibs != no fi # linkmode = lib @@ -2947,7 +3222,7 @@ case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) - $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 + $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE ;; @@ -2956,7 +3231,7 @@ case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) - $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 + $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE ;; @@ -2965,7 +3240,7 @@ case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) - $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 + $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE ;; @@ -2991,7 +3266,7 @@ versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... minor_current=`expr $current + 1` - verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" ;; freebsd-aout) @@ -3144,9 +3419,9 @@ # Eliminate all temporary directories. for path in $notinst_path; do - lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'` - deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'` - dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` + lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"` + deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"` + dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"` done if test -n "$xrpath"; then @@ -3197,10 +3472,15 @@ *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; - *-*-openbsd* | *-*-freebsd*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then @@ -3243,11 +3523,11 @@ int main() { return 0; } EOF $rm conftest - $LTCC -o conftest conftest.c $deplibs + $LTCC $LTCFLAGS -o conftest conftest.c $deplibs if test "$?" -eq 0 ; then ldd_output=`ldd conftest` for i in $deplibs; do - name="`expr $i : '-l\(.*\)'`" + name=`expr $i : '-l\(.*\)'` # If $name is empty we are operating on a -L argument. if test "$name" != "" && test "$name" -ne "0"; then if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then @@ -3284,11 +3564,11 @@ # Error occurred in the first compile. Let's try to salvage # the situation: Compile a separate program for each library. for i in $deplibs; do - name="`expr $i : '-l\(.*\)'`" + name=`expr $i : '-l\(.*\)'` # If $name is empty we are operating on a -L argument. if test "$name" != "" && test "$name" != "0"; then $rm conftest - $LTCC -o conftest conftest.c $i + $LTCC $LTCFLAGS -o conftest conftest.c $i # Did it work? if test "$?" -eq 0 ; then ldd_output=`ldd conftest` @@ -3336,7 +3616,7 @@ set dummy $deplibs_check_method file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` for a_deplib in $deplibs; do - name="`expr $a_deplib : '-l\(.*\)'`" + name=`expr $a_deplib : '-l\(.*\)'` # If $name is empty we are operating on a -L argument. if test "$name" != "" && test "$name" != "0"; then if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then @@ -3405,7 +3685,7 @@ set dummy $deplibs_check_method match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` for a_deplib in $deplibs; do - name="`expr $a_deplib : '-l\(.*\)'`" + name=`expr $a_deplib : '-l\(.*\)'` # If $name is empty we are operating on a -L argument. if test -n "$name" && test "$name" != "0"; then if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then @@ -3535,6 +3815,35 @@ deplibs=$newdeplibs fi + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + deplibs="$new_libs" + + # All the library-specific variables (install_libdir is set above). library_names= old_library= @@ -3618,6 +3927,7 @@ fi lib="$output_objdir/$realname" + linknames= for link do linknames="$linknames $link" @@ -3646,6 +3956,9 @@ # The command line is too long to execute in one step. $show "using reloadable object file for export list..." skipped_export=: + # Break out early, otherwise skipped_export may be + # set to false by a later but shorter cmd. + break fi done IFS="$save_ifs" @@ -3679,67 +3992,13 @@ eval libobjs=\"\$libobjs $whole_archive_flag_spec\" else gentop="$output_objdir/${outputname}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "$mkdir $gentop" - $run $mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi generated="$generated $gentop" - for xlib in $convenience; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "$mkdir $xdir" - $run $mkdir "$xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$xdir"; then - exit $status - fi - # We will extract separately just the conflicting names and we will no - # longer touch any unique names. It is faster to leave these extract - # automatically by $AR in one run. - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 - $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 - $AR t "$xabs" | sort | uniq -cd | while read -r count name - do - i=1 - while test "$i" -le "$count" - do - # Put our $i before any first dot (extension) - # Never overwrite any file - name_to="$name" - while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" - do - name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` - done - $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" - $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? - i=`expr $i + 1` - done - done - fi - - libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` - done + func_extract_archives $gentop $convenience + libobjs="$libobjs $func_extract_archives_result" fi fi - + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" linker_flags="$linker_flags $flag" @@ -3769,7 +4028,8 @@ fi fi - if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*"` && + if test "X$skipped_export" != "X:" && + len=`expr "X$test_cmds" : ".*" 2>/dev/null` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else @@ -3788,6 +4048,7 @@ save_libobjs=$libobjs fi save_output=$output + output_la=`$echo "X$output" | $Xsed -e "$basename"` # Clear the reloadable object creation command queue and # initialize k to one. @@ -3797,13 +4058,13 @@ delfiles= last_robj= k=1 - output=$output_objdir/$save_output-${k}.$objext + output=$output_objdir/$output_la-${k}.$objext # Loop over the list of objects to be linked. for obj in $save_libobjs do eval test_cmds=\"$reload_cmds $objlist $last_robj\" if test "X$objlist" = X || - { len=`expr "X$test_cmds" : ".*"` && + { len=`expr "X$test_cmds" : ".*" 2>/dev/null` && test "$len" -le "$max_cmd_len"; }; then objlist="$objlist $obj" else @@ -3817,9 +4078,9 @@ # the last one created. eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" fi - last_robj=$output_objdir/$save_output-${k}.$objext + last_robj=$output_objdir/$output_la-${k}.$objext k=`expr $k + 1` - output=$output_objdir/$save_output-${k}.$objext + output=$output_objdir/$output_la-${k}.$objext objlist=$obj len=1 fi @@ -3839,13 +4100,13 @@ eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" fi - # Set up a command to remove the reloadale object files + # Set up a command to remove the reloadable object files # after they are used. i=0 while test "$i" -lt "$k" do i=`expr $i + 1` - delfiles="$delfiles $output_objdir/$save_output-${i}.$objext" + delfiles="$delfiles $output_objdir/$output_la-${i}.$objext" done $echo "creating a temporary reloadable object file: $output" @@ -3893,13 +4154,30 @@ IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" - $run eval "$cmd" || exit $? + $run eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' + fi + + exit $lt_exit + } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? + + if test -n "$convenience"; then + if test -z "$whole_archive_flag_spec"; then + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + fi + fi + exit $EXIT_SUCCESS fi @@ -3977,64 +4255,10 @@ eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" else gentop="$output_objdir/${obj}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "$mkdir $gentop" - $run $mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi generated="$generated $gentop" - for xlib in $convenience; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "$mkdir $xdir" - $run $mkdir "$xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$xdir"; then - exit $status - fi - # We will extract separately just the conflicting names and we will no - # longer touch any unique names. It is faster to leave these extract - # automatically by $AR in one run. - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 - $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 - $AR t "$xabs" | sort | uniq -cd | while read -r count name - do - i=1 - while test "$i" -le "$count" - do - # Put our $i before any first dot (extension) - # Never overwrite any file - name_to="$name" - while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" - do - name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` - done - $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" - $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? - i=`expr $i + 1` - done - done - fi - - reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` - done + func_extract_archives $gentop $convenience + reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi @@ -4135,6 +4359,35 @@ ;; esac + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $compile_deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $compile_deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + compile_deplibs="$new_libs" + + compile_command="$compile_command $compile_deplibs" finalize_command="$finalize_command $finalize_deplibs" @@ -4179,10 +4432,15 @@ fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; *) dllsearchpath="$dllsearchpath:$libdir";; esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac ;; esac done @@ -4296,13 +4554,25 @@ # Prepare the list of exported symbols if test -z "$export_symbols"; then - export_symbols="$output_objdir/$output.exp" + export_symbols="$output_objdir/$outputname.exp" $run $rm $export_symbols - $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in + *cygwin* | *mingw* ) + $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; + esac else - $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' - $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' + $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' + $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' $run eval 'mv "$nlist"T "$nlist"' + case $host in + *cygwin* | *mingw* ) + $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; + esac fi fi @@ -4353,7 +4623,26 @@ #endif /* The mapping between symbol names and symbols. */ +" + + case $host in + *cygwin* | *mingw* ) + $echo >> "$output_objdir/$dlsyms" "\ +/* DATA imports from DLLs on WIN32 can't be const, because + runtime relocations are performed -- see ld's documentation + on pseudo-relocs */ +struct { +" + ;; + * ) + $echo >> "$output_objdir/$dlsyms" "\ const struct { +" + ;; + esac + + + $echo >> "$output_objdir/$dlsyms" "\ const char *name; lt_ptr address; } @@ -4400,16 +4689,29 @@ esac # Now compile the dynamic symbol file. - $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" - $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + $show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? # Clean up the generated files. $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" # Transform the symbol file into the correct name. - compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + case $host in + *cygwin* | *mingw* ) + if test -f "$output_objdir/${outputname}.def" ; then + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"` + else + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + fi + ;; + * ) + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + ;; + esac ;; *) $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 @@ -4434,7 +4736,7 @@ # We have no uninstalled library dependencies, so finalize right now. $show "$link_command" $run eval "$link_command" - status=$? + exit_status=$? # Delete the generated files. if test -n "$dlsyms"; then @@ -4442,7 +4744,7 @@ $run $rm "$output_objdir/${outputname}S.${objext}" fi - exit $status + exit $exit_status fi if test -n "$shlibpath_var"; then @@ -4582,10 +4884,12 @@ esac case $host in *cygwin* | *mingw* ) - cwrappersource=`$echo ${objdir}/lt-${output}.c` - cwrapper=`$echo ${output}.exe` - $rm $cwrappersource $cwrapper - trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + output_name=`basename $output` + output_path=`dirname $output` + cwrappersource="$output_path/$objdir/lt-$output_name.c" + cwrapper="$output_path/$output_name.exe" + $rm $cwrappersource $cwrapper + trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 cat > $cwrappersource < #include #include +#include +#include +#include #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX @@ -4620,16 +4927,20 @@ #endif #ifndef DIR_SEPARATOR -#define DIR_SEPARATOR '/' +# define DIR_SEPARATOR '/' +# define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) -#define HAVE_DOS_BASED_FILE_SYSTEM -#ifndef DIR_SEPARATOR_2 -#define DIR_SEPARATOR_2 '\\' +# define HAVE_DOS_BASED_FILE_SYSTEM +# ifndef DIR_SEPARATOR_2 +# define DIR_SEPARATOR_2 '\\' +# endif +# ifndef PATH_SEPARATOR_2 +# define PATH_SEPARATOR_2 ';' +# endif #endif -#endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) @@ -4638,17 +4949,32 @@ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ +#ifndef PATH_SEPARATOR_2 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) +#else /* PATH_SEPARATOR_2 */ +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) +#endif /* PATH_SEPARATOR_2 */ + #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) +/* -DDEBUG is fairly common in CFLAGS. */ +#undef DEBUG +#if defined DEBUGWRAPPER +# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__) +#else +# define DEBUG(format, ...) +#endif + const char *program_name = NULL; void * xmalloc (size_t num); char * xstrdup (const char *string); -char * basename (const char *name); -char * fnqualify(const char *path); +const char * base_name (const char *name); +char * find_executable(const char *wrapper); +int check_executable(const char *path); char * strendzap(char *str, const char *pat); void lt_fatal (const char *message, ...); @@ -4658,29 +4984,51 @@ char **newargz; int i; - program_name = (char *) xstrdup ((char *) basename (argv[0])); + program_name = (char *) xstrdup (base_name (argv[0])); + DEBUG("(main) argv[0] : %s\n",argv[0]); + DEBUG("(main) program_name : %s\n",program_name); newargz = XMALLOC(char *, argc+2); EOF - cat >> $cwrappersource <> $cwrappersource <> $cwrappersource <<"EOF" - newargz[1] = fnqualify(argv[0]); + cat >> $cwrappersource <<"EOF" + newargz[1] = find_executable(argv[0]); + if (newargz[1] == NULL) + lt_fatal("Couldn't find %s", argv[0]); + DEBUG("(main) found exe at : %s\n",newargz[1]); /* we know the script has the same name, without the .exe */ /* so make sure newargz[1] doesn't end in .exe */ strendzap(newargz[1],".exe"); for (i = 1; i < argc; i++) newargz[i+1] = xstrdup(argv[i]); newargz[argc+1] = NULL; + + for (i=0; i> $cwrappersource <> $cwrappersource <> $cwrappersource <> $cwrappersource <<"EOF" + cat >> $cwrappersource <<"EOF" + return 127; } void * @@ -4700,48 +5048,148 @@ ; } -char * -basename (const char *name) +const char * +base_name (const char *name) { const char *base; #if defined (HAVE_DOS_BASED_FILE_SYSTEM) /* Skip over the disk name in MSDOS pathnames. */ - if (isalpha (name[0]) && name[1] == ':') + if (isalpha ((unsigned char)name[0]) && name[1] == ':') name += 2; #endif for (base = name; *name; name++) if (IS_DIR_SEPARATOR (*name)) base = name + 1; - return (char *) base; + return base; } +int +check_executable(const char * path) +{ + struct stat st; + + DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!"); + if ((!path) || (!*path)) + return 0; + + if ((stat (path, &st) >= 0) && + ( + /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */ +#if defined (S_IXOTH) + ((st.st_mode & S_IXOTH) == S_IXOTH) || +#endif +#if defined (S_IXGRP) + ((st.st_mode & S_IXGRP) == S_IXGRP) || +#endif + ((st.st_mode & S_IXUSR) == S_IXUSR)) + ) + return 1; + else + return 0; +} + +/* Searches for the full path of the wrapper. Returns + newly allocated full path name if found, NULL otherwise */ char * -fnqualify(const char *path) +find_executable (const char* wrapper) { - size_t size; - char *p; + int has_slash = 0; + const char* p; + const char* p_next; + /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; + int tmp_len; + char* concat_name; - assert(path != NULL); + DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"); - /* Is it qualified already? */ + if ((wrapper == NULL) || (*wrapper == '\0')) + return NULL; + + /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) - if (isalpha (path[0]) && path[1] == ':') - return xstrdup (path); + if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':') + { + concat_name = xstrdup (wrapper); + if (check_executable(concat_name)) + return concat_name; + XFREE(concat_name); + } + else + { #endif - if (IS_DIR_SEPARATOR (path[0])) - return xstrdup (path); + if (IS_DIR_SEPARATOR (wrapper[0])) + { + concat_name = xstrdup (wrapper); + if (check_executable(concat_name)) + return concat_name; + XFREE(concat_name); + } +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + } +#endif - /* prepend the current directory */ - /* doesn't handle '~' */ + for (p = wrapper; *p; p++) + if (*p == '/') + { + has_slash = 1; + break; + } + if (!has_slash) + { + /* no slashes; search PATH */ + const char* path = getenv ("PATH"); + if (path != NULL) + { + for (p = path; *p; p = p_next) + { + const char* q; + size_t p_len; + for (q = p; *q; q++) + if (IS_PATH_SEPARATOR(*q)) + break; + p_len = q - p; + p_next = (*q == '\0' ? q : q + 1); + if (p_len == 0) + { + /* empty path: current directory */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen(tmp); + concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + } + else + { + concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1); + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, wrapper); + } + if (check_executable(concat_name)) + return concat_name; + XFREE(concat_name); + } + } + /* not found in PATH; assume curdir */ + } + /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal ("getcwd failed"); - size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */ - p = XMALLOC(char, size); - sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path); - return p; + tmp_len = strlen(tmp); + concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + + if (check_executable(concat_name)) + return concat_name; + XFREE(concat_name); + return NULL; } char * @@ -4785,16 +5233,16 @@ va_end (ap); } EOF - # we should really use a build-platform specific compiler - # here, but OTOH, the wrappers (shell script and this C one) - # are only useful if you want to execute the "real" binary. - # Since the "real" binary is built for $host, then this - # wrapper might as well be built for $host, too. - $run $LTCC -s -o $cwrapper $cwrappersource - ;; - esac - $rm $output - trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 + # we should really use a build-platform specific compiler + # here, but OTOH, the wrappers (shell script and this C one) + # are only useful if you want to execute the "real" binary. + # Since the "real" binary is built for $host, then this + # wrapper might as well be built for $host, too. + $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource + ;; + esac + $rm $output + trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 $echo > $output "\ #! $SHELL @@ -4815,7 +5263,7 @@ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. -if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" @@ -4944,13 +5392,13 @@ # Backslashes separate directories on plain windows *-*-mingw | *-*-os2*) $echo >> $output "\ - exec \$progdir\\\\\$program \${1+\"\$@\"} + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $echo >> $output "\ - exec \$progdir/\$program \${1+\"\$@\"} + exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac @@ -4960,7 +5408,7 @@ fi else # The program doesn't exist. - \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 + \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$echo \"This script is just a wrapper for \$program.\" 1>&2 $echo \"See the $PACKAGE documentation for more information.\" 1>&2 exit $EXIT_FAILURE @@ -4992,71 +5440,73 @@ if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "$mkdir $gentop" - $run $mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi generated="$generated $gentop" - # Add in members from convenience archives. - for xlib in $addlibs; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "$mkdir $xdir" - $run $mkdir "$xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$xdir"; then - exit $status - fi - # We will extract separately just the conflicting names and we will no - # longer touch any unique names. It is faster to leave these extract - # automatically by $AR in one run. - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 - $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 - $AR t "$xabs" | sort | uniq -cd | while read -r count name - do - i=1 - while test "$i" -le "$count" - do - # Put our $i before any first dot (extension) - # Never overwrite any file - name_to="$name" - while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" - do - name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` - done - $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" - $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? - i=`expr $i + 1` - done - done - fi - - oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` - done + func_extract_archives $gentop $addlibs + oldobjs="$oldobjs $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else + # POSIX demands no paths to be encoded in archives. We have + # to avoid creating archives with duplicate basenames if we + # might have to extract them afterwards, e.g., when creating a + # static archive out of a convenience library, or when linking + # the entirety of a libtool archive into another (currently + # not supported by libtool). + if (for obj in $oldobjs + do + $echo "X$obj" | $Xsed -e 's%^.*/%%' + done | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "copying selected object files to avoid basename conflicts..." + + if test -z "$gentop"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "$gentop"; then + exit $exit_status + fi + fi + + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + counter=`expr $counter + 1` + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + $run ln "$obj" "$gentop/$newobj" || + $run cp "$obj" "$gentop/$newobj" + oldobjs="$oldobjs $gentop/$newobj" + ;; + *) oldobjs="$oldobjs $obj" ;; + esac + done + fi + eval cmds=\"$old_archive_cmds\" if len=`expr "X$cmds" : ".*"` && @@ -5070,20 +5520,7 @@ objlist= concat_cmds= save_oldobjs=$oldobjs - # GNU ar 2.10+ was changed to match POSIX; thus no paths are - # encoded into archives. This makes 'ar r' malfunction in - # this piecewise linking case whenever conflicting object - # names appear in distinct ar calls; check, warn and compensate. - if (for obj in $save_oldobjs - do - $echo "X$obj" | $Xsed -e 's%^.*/%%' - done | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2 - $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2 - AR_FLAGS=cq - fi + # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do @@ -5094,7 +5531,7 @@ oldobjs="$objlist $obj" objlist="$objlist $obj" eval test_cmds=\"$old_archive_cmds\" - if len=`expr "X$test_cmds" : ".*"` && + if len=`expr "X$test_cmds" : ".*" 2>/dev/null` && test "$len" -le "$max_cmd_len"; then : else @@ -5291,11 +5728,11 @@ # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. - $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then + $echo "X$nonopt" | grep shtool > /dev/null; then # Aesthetically quote it. arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac @@ -5304,14 +5741,14 @@ shift else install_prog= - arg="$nonopt" + arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac @@ -5329,28 +5766,31 @@ do if test -n "$dest"; then files="$files $dest" - dest="$arg" + dest=$arg continue fi case $arg in -d) isdir=yes ;; - -f) prev="-f" ;; - -g) prev="-g" ;; - -m) prev="-m" ;; - -o) prev="-o" ;; + -f) + case " $install_prog " in + *[\\\ /]cp\ *) ;; + *) prev=$arg ;; + esac + ;; + -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; - -*) ;; - + -*) + ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then prev= else - dest="$arg" + dest=$arg continue fi ;; @@ -5359,7 +5799,7 @@ # Aesthetically quote the argument. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac @@ -5528,11 +5968,14 @@ if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. + # Try `ln -sf' first, because the `ln' binary might depend on + # the symlink we replace! Solaris /bin/ln does not understand -f, + # so we also need to try rm && ln -s. for linkname do if test "$linkname" != "$realname"; then - $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" - $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" + $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" fi done fi @@ -5545,7 +5988,16 @@ IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" - $run eval "$cmd" || exit $? + $run eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' + fi + + exit $lt_exit + } done IFS="$save_ifs" fi @@ -5639,17 +6091,15 @@ notinst_deplibs= relink_command= - # To insure that "foo" is sourced, and not "foo.exe", - # finese the cygwin/MSYS system by explicitly sourcing "foo." - # which disallows the automatic-append-.exe behavior. - case $build in - *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; - *) wrapperdot=${wrapper} ;; - esac + # Note that it is not necessary on cygwin/mingw to append a dot to + # foo even if both foo and FILE.exe exist: automatic-append-.exe + # behavior happens only for exec(3), not for open(2)! Also, sourcing + # `FILE.' does not work on cygwin managed mounts. + # # If there is no directory component, then add one. - case $file in - */* | *\\*) . ${wrapperdot} ;; - *) . ./${wrapperdot} ;; + case $wrapper in + */* | *\\*) . ${wrapper} ;; + *) . ./${wrapper} ;; esac # Check the variables that should have been set. @@ -5677,34 +6127,21 @@ done relink_command= - # To insure that "foo" is sourced, and not "foo.exe", - # finese the cygwin/MSYS system by explicitly sourcing "foo." - # which disallows the automatic-append-.exe behavior. - case $build in - *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; - *) wrapperdot=${wrapper} ;; - esac + # Note that it is not necessary on cygwin/mingw to append a dot to + # foo even if both foo and FILE.exe exist: automatic-append-.exe + # behavior happens only for exec(3), not for open(2)! Also, sourcing + # `FILE.' does not work on cygwin managed mounts. + # # If there is no directory component, then add one. - case $file in - */* | *\\*) . ${wrapperdot} ;; - *) . ./${wrapperdot} ;; + case $wrapper in + */* | *\\*) . ${wrapper} ;; + *) . ./${wrapper} ;; esac outputname= if test "$fast_install" = no && test -n "$relink_command"; then if test "$finalize" = yes && test -z "$run"; then - tmpdir="/tmp" - test -n "$TMPDIR" && tmpdir="$TMPDIR" - tmpdir="$tmpdir/libtool-$$" - save_umask=`umask` - umask 0077 - if $mkdir "$tmpdir"; then - umask $save_umask - else - umask $save_umask - $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 - continue - fi + tmpdir=`func_mktempdir` file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` outputname="$tmpdir/$file" # Replace the output file specification. @@ -5728,7 +6165,7 @@ fi # remove .exe since cygwin /usr/bin/install will append another - # one anyways + # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in @@ -5828,7 +6265,7 @@ # Exit here if they wanted silent mode. test "$show" = : && exit $EXIT_SUCCESS - $echo "----------------------------------------------------------------------" + $echo "X----------------------------------------------------------------------" | $Xsed $echo "Libraries have been installed in:" for libdir in $libdirs; do $echo " $libdir" @@ -5861,7 +6298,7 @@ $echo $echo "See any operating system documentation about shared libraries for" $echo "more information, such as the ld(1) and ld.so(8) manual pages." - $echo "----------------------------------------------------------------------" + $echo "X----------------------------------------------------------------------" | $Xsed exit $EXIT_SUCCESS ;; @@ -6078,9 +6515,17 @@ rmfiles="$rmfiles $objdir/$n" done test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" - test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" - if test "$mode" = uninstall; then + case "$mode" in + clean) + case " $library_names " in + # " " in the beginning catches empty $dlname + *" $dlname "*) ;; + *) rmfiles="$rmfiles $objdir/$dlname" ;; + esac + test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + ;; + uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. cmds=$postuninstall_cmds @@ -6113,7 +6558,8 @@ IFS="$save_ifs" fi # FIXME: should reinstall the best remaining shared library. - fi + ;; + esac fi ;; @@ -6398,7 +6844,7 @@ $echo $echo "Try \`$modename --help' for more information about other modes." -exit $EXIT_SUCCESS +exit $? # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting @@ -6412,12 +6858,11 @@ # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared -build_libtool_libs=no -build_old_libs=yes +disable_libs=shared # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static -build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` +disable_libs=static # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: Modified: trunk/missing =================================================================== --- trunk/missing 2006-03-03 15:17:43 UTC (rev 158) +++ trunk/missing 2006-03-06 10:09:15 UTC (rev 159) @@ -1,9 +1,9 @@ #! /bin/sh # Common stub for a few missing GNU programs while installing. -scriptversion=2004-09-07.08 +scriptversion=2005-06-08.21 -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004 +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. @@ -19,8 +19,8 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -87,12 +87,12 @@ yacc create \`y.tab.[ch]', if possible, from existing .[ch] Send bug reports to ." - exit 0 + exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" - exit 0 + exit $? ;; -*) @@ -288,11 +288,18 @@ call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then - file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 touch $file ;; Modified: trunk/mkinstalldirs =================================================================== --- trunk/mkinstalldirs 2006-03-03 15:17:43 UTC (rev 158) +++ trunk/mkinstalldirs 2006-03-06 10:09:15 UTC (rev 159) @@ -1,7 +1,7 @@ #! /bin/sh # mkinstalldirs --- make directory hierarchy -scriptversion=2004-02-15.20 +scriptversion=2005-06-29.22 # Original author: Noah Friedman # Created: 1993-05-16 @@ -12,7 +12,7 @@ # . errstatus=0 -dirmode="" +dirmode= usage="\ Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... @@ -27,7 +27,7 @@ case $1 in -h | --help | --h*) # -h for help echo "$usage" - exit 0 + exit $? ;; -m) # -m PERM arg shift @@ -37,7 +37,7 @@ ;; --version) echo "$0 $scriptversion" - exit 0 + exit $? ;; --) # stop option processing shift @@ -103,13 +103,21 @@ for file do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + case $file in + /*) pathcomp=/ ;; + *) pathcomp= ;; + esac + oIFS=$IFS + IFS=/ + set fnord $file shift + IFS=$oIFS - pathcomp= for d do - pathcomp="$pathcomp$d" + test "x$d" = x && continue + + pathcomp=$pathcomp$d case $pathcomp in -*) pathcomp=./$pathcomp ;; esac @@ -124,7 +132,7 @@ else if test ! -z "$dirmode"; then echo "chmod $dirmode $pathcomp" - lasterr="" + lasterr= chmod "$dirmode" "$pathcomp" || lasterr=$? if test ! -z "$lasterr"; then @@ -134,7 +142,7 @@ fi fi - pathcomp="$pathcomp/" + pathcomp=$pathcomp/ done done From cvs at cvs.gnupg.org Mon Mar 6 11:33:58 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon Mar 6 11:08:22 2006 Subject: [svn] gpgme - r1170 - trunk/gpgme Message-ID: Author: marcus Date: 2006-03-06 11:33:57 +0100 (Mon, 06 Mar 2006) New Revision: 1170 Modified: trunk/gpgme/ChangeLog trunk/gpgme/gpgme-config.in Log: 2006-03-06 Marcus Brinkmann * gpgme-config.in (cflags_pth): Revert accidential removal of pthread support with last change. Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2006-03-03 10:13:49 UTC (rev 1169) +++ trunk/gpgme/ChangeLog 2006-03-06 10:33:57 UTC (rev 1170) @@ -1,3 +1,8 @@ +2006-03-06 Marcus Brinkmann + + * gpgme-config.in (cflags_pth): Revert accidential removal of + pthread support with last change. + 2006-02-28 Marcus Brinkmann * w32-glib-io.c (O_BINARY) [!O_BINARY]: New macro. Modified: trunk/gpgme/gpgme-config.in =================================================================== --- trunk/gpgme/gpgme-config.in 2006-03-03 10:13:49 UTC (rev 1169) +++ trunk/gpgme/gpgme-config.in 2006-03-06 10:33:57 UTC (rev 1170) @@ -25,6 +25,10 @@ libs_pth="@PTH_LDFLAGS@ @PTH_LIBS@" cflags_pth="@PTH_CFLAGS@" +@HAVE_PTHREAD_TRUE@thread_modules="$thread_modules pthread" +libs_pthread="-lpthread" +cflags_pthread="" + # Configure glib. libs_glib="@GLIB_LIBS@" cflags_glib="@GLIB_CFLAGS@" From cvs at cvs.gnupg.org Mon Mar 6 13:28:48 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Mar 6 13:03:11 2006 Subject: [svn] GnuPG - r4035 - in trunk: . g10 scripts Message-ID: Author: wk Date: 2006-03-06 13:28:46 +0100 (Mon, 06 Mar 2006) New Revision: 4035 Modified: trunk/configure.ac trunk/g10/ChangeLog trunk/g10/mainproc.c trunk/scripts/ChangeLog trunk/scripts/w32installer.nsi Log: Fixed problem with PGP2 style signatures and mutilple plaintext data Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-05 15:13:18 UTC (rev 4034) +++ trunk/configure.ac 2006-03-06 12:28:46 UTC (rev 4035) @@ -26,7 +26,7 @@ # Remember to change the version number immediately *after* a release # and remove the "-cvs" or "rc" suffix immediately *before* a release. -AC_INIT(gnupg, 1.4.3rc1, bug-gnupg@gnu.org) +AC_INIT(gnupg, 1.4.3-cvs, bug-gnupg@gnu.org) # Set development_version to yes if the minor number is odd or you # feel that the default check for a development version is not # sufficient. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-05 15:13:18 UTC (rev 4034) +++ trunk/g10/ChangeLog 2006-03-06 12:28:46 UTC (rev 4035) @@ -1,3 +1,8 @@ +2006-03-06 Werner Koch + + * mainproc.c (check_sig_and_print): Check for multiple plaintexts + before a signature. Reported by Tavis Ormandy. + 2006-03-05 Werner Koch * plaintext.c (handle_plaintext): Replace assert by explict error Modified: trunk/g10/mainproc.c =================================================================== --- trunk/g10/mainproc.c 2006-03-05 15:13:18 UTC (rev 4034) +++ trunk/g10/mainproc.c 2006-03-06 12:28:46 UTC (rev 4035) @@ -680,7 +680,8 @@ for( data++, datalen--; datalen; datalen--, data++ ) md_enable( c->mfx.md, *data ); any = 1; - break; /* no pass signature packets are expected */ + break; /* Stop here as one-pass signature packets are not + expected. */ } else if(n->pkt->pkttype==PKT_SIGNATURE) { @@ -1164,7 +1165,7 @@ /* If we have not encountered any signature we print an error messages, send a NODATA status back and return an error code. - Using log_error is required becuase verify_files does not check + Using log_error is required because verify_files does not check error codes for each file but we want to terminate the process with an error. */ if (!rc && !c->any_sig_seen) @@ -1444,39 +1445,62 @@ */ { KBNODE n; - int n_sig=0; + int n_sig = 0; + int n_plaintext = 0; + int sig_seen, onepass_seen; - for (n=c->list; n; n=n->next ) { + for (n=c->list; n; n=n->next ) + { if ( n->pkt->pkttype == PKT_SIGNATURE ) - n_sig++; - } - if (n_sig > 1) { /* more than one signature - check sequence */ - int tmp, onepass; - - for (tmp=onepass=0,n=c->list; n; n=n->next ) { - if (n->pkt->pkttype == PKT_ONEPASS_SIG) - onepass++; - else if (n->pkt->pkttype == PKT_GPG_CONTROL - && n->pkt->pkt.gpg_control->control - == CTRLPKT_CLEARSIGN_START ) { - onepass++; /* handle the same way as a onepass */ - } - else if ( (tmp && n->pkt->pkttype != PKT_SIGNATURE) ) { - log_error(_("can't handle these multiple signatures\n")); - return 0; - } - else if ( n->pkt->pkttype == PKT_SIGNATURE ) - tmp = 1; - else if (!tmp && !onepass - && n->pkt->pkttype == PKT_GPG_CONTROL - && n->pkt->pkt.gpg_control->control - == CTRLPKT_PLAINTEXT_MARK ) { - /* plaintext before signatures but no one-pass packets*/ - log_error(_("can't handle these multiple signatures\n")); - return 0; - } - } - } + n_sig++; + else if (n->pkt->pkttype == PKT_GPG_CONTROL + && (n->pkt->pkt.gpg_control->control + == CTRLPKT_PLAINTEXT_MARK) ) + n_plaintext++; + } + + for (sig_seen=onepass_seen=0,n=c->list; n; n=n->next ) + { + if (n->pkt->pkttype == PKT_ONEPASS_SIG) + { + onepass_seen++; + } + else if (n->pkt->pkttype == PKT_GPG_CONTROL + && (n->pkt->pkt.gpg_control->control + == CTRLPKT_CLEARSIGN_START) ) + { + onepass_seen++; /* Handle the same way as a onepass. */ + } + else if ( (sig_seen && n->pkt->pkttype != PKT_SIGNATURE) ) + { + log_error(_("can't handle these multiple signatures\n")); + return 0; + } + else if ( n->pkt->pkttype == PKT_SIGNATURE ) + { + sig_seen = 1; + } + else if (n_sig > 1 && !sig_seen && !onepass_seen + && n->pkt->pkttype == PKT_GPG_CONTROL + && (n->pkt->pkt.gpg_control->control + == CTRLPKT_PLAINTEXT_MARK) ) + { + /* Plaintext before signatures but no onepass + signature packets. */ + log_error(_("can't handle these multiple signatures\n")); + return 0; + } + else if (n_plaintext > 1 && !sig_seen && !onepass_seen + && n->pkt->pkttype == PKT_GPG_CONTROL + && (n->pkt->pkt.gpg_control->control + == CTRLPKT_PLAINTEXT_MARK) ) + { + /* More than one plaintext before a signature but no + onepass packets. */ + log_error(_("can't handle this ambiguous signed data\n")); + return 0; + } + } } astr = pubkey_algo_to_string( sig->pubkey_algo ); Modified: trunk/scripts/ChangeLog =================================================================== --- trunk/scripts/ChangeLog 2006-03-05 15:13:18 UTC (rev 4034) +++ trunk/scripts/ChangeLog 2006-03-06 12:28:46 UTC (rev 4035) @@ -1,5 +1,7 @@ 2006-02-14 Werner Koch + * w32installer.nsi: Don't use System.dll. + * autogen.sh (DIE): Add lost exit for --build-w32. 2005-10-02 Marcus Brinkmann Modified: trunk/scripts/w32installer.nsi =================================================================== --- trunk/scripts/w32installer.nsi 2006-03-05 15:13:18 UTC (rev 4034) +++ trunk/scripts/w32installer.nsi 2006-03-06 12:28:46 UTC (rev 4035) @@ -132,7 +132,7 @@ ReserveFile "opt.ini" ReserveFile "COPYING.txt" ReserveFile "README-W32.txt" -ReserveFile "${NSISDIR}/Plugins/System.dll" +#ReserveFile "${NSISDIR}/Plugins/System.dll" ReserveFile "${NSISDIR}/Plugins/UserInfo.dll" @@ -444,11 +444,14 @@ ; --------- Function .onInit - System::Call 'kernel32::CreateMutexA(i 0, i 0, t "GnuPGInst") i .r1 ?e' - Pop $R0 - StrCmp $R0 0 +3 - MessageBox MB_OK "An instance of the installer is already running." - Abort + # We can't use System.dll anymore becuase it has bee removed from + # Debian due to an inability to build using FS. We should use the + # use our own DLL as we do with gpg4win. + #System::Call 'kernel32::CreateMutexA(i 0, i 0, t "GnuPGInst") i .r1 ?e' + #Pop $R0 + #StrCmp $R0 0 +3 + # MessageBox MB_OK "An instance of the installer is already running." + # Abort ;;!define MUI_LANGDLL_ALWAYSSHOW !insertmacro MUI_LANGDLL_DISPLAY From cvs at cvs.gnupg.org Mon Mar 6 22:28:31 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Mar 6 22:02:55 2006 Subject: [svn] GnuPG - r4036 - in trunk: . checks g10 Message-ID: Author: wk Date: 2006-03-06 22:28:25 +0100 (Mon, 06 Mar 2006) New Revision: 4036 Modified: trunk/NEWS trunk/checks/ChangeLog trunk/checks/defs.inc trunk/checks/multisig.test trunk/checks/verify.test trunk/g10/ChangeLog trunk/g10/mainproc.c Log: Stricter test of allowed signature packet compositions. There is still one problem to solve. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-06 12:28:46 UTC (rev 4035) +++ trunk/NEWS 2006-03-06 21:28:25 UTC (rev 4036) @@ -51,7 +51,11 @@ are HTTP and finger, plus anything that cURL supplies, if built with cURL support. + * Files containing several signed messages are not anymore allowed + because there is no clean way to report the status of such files + back to the caller. + Noteworthy changes in version 1.4.2 (2005-07-26) ------------------------------------------------ Modified: trunk/checks/ChangeLog =================================================================== --- trunk/checks/ChangeLog 2006-03-06 12:28:46 UTC (rev 4035) +++ trunk/checks/ChangeLog 2006-03-06 21:28:25 UTC (rev 4036) @@ -1,3 +1,13 @@ +2006-03-06 Werner Koch + + * defs.inc: Print error messages also to stderr. Allow for + verbose environment variable. + (linefeed): New. + (suspend_error, resume_error): New. + * verify.test: More tests. + * multisig.test: Better error printing. + (sig_1ls1ls_valid, sig_ls_valid): Moved to the non-valid group. + 2006-02-14 Werner Koch * verify.test: New. Modified: trunk/checks/defs.inc =================================================================== --- trunk/checks/defs.inc 2006-03-06 12:28:46 UTC (rev 4035) +++ trunk/checks/defs.inc 2006-03-06 21:28:25 UTC (rev 4036) @@ -31,25 +31,55 @@ LC_ALL= LC_MESSAGES= +# Internal use. +defs_stop_on_error=no +defs_error_seen=no + #-------------------------------- #------ utility functions ------- #-------------------------------- fatal () { echo "$pgmname: fatal:" $* >&2 + [ -n "${BASH_VERSION+set}" ] && echo "$pgmname: fatal:" $* >&5 exit 1; } error () { echo "$pgmname:" $* >&2 - exit 1 + defs_error_seen=yes + [ -n "${BASH_VERSION+set}" ] && echo "$pgmname:" $* >&5 + if [ x$defs_stop_on_error != xyes ]; then + exit 1 + fi } +# Call this at the start of a test and resume_error at the end to keep +# on running all subtests without immediately exiting on error. +suspend_error () { + defs_stop_on_error=yes +} + +resume_error () { + if [ x$defs_error_seen = xyes ]; then + exit 1 + fi + defs_stop_on_error=no + defs_error_seen=no +} + info () { echo "$pgmname:" $* >&2 + if [ -n "${verbose+set}" ]; then + [ -n "${BASH_VERSION+set}" ] && echo "$pgmname:" $* >&5 + fi } +linefeed () { + echo >&2 +} + echo_n_init=no echo_n () { if test "$echo_n_init" = "no"; then @@ -126,6 +156,8 @@ GPG="../g10/gpg --no-permission-warning --homedir . " +[ -n "${BASH_VERSION+set}" ] && exec 5>/dev/stderr + exec 2> ${pgmname}.log : Modified: trunk/checks/multisig.test =================================================================== --- trunk/checks/multisig.test 2006-03-06 12:28:46 UTC (rev 4035) +++ trunk/checks/multisig.test 2006-03-06 21:28:25 UTC (rev 4036) @@ -2,13 +2,15 @@ # Check that gpg verifies only signatures where there is no ambiguity # in the order of packets. Needs the Demo Keys Lima and Mike. +# Note: We do son't support multiple signaturess anymore thus thsi test is +# not really needed becuase verify could do the same. We keep it anyway. + . $srcdir/defs.inc || exit 3 -# (variable intialization was created using: -# for i in files; do echo "`echo $i | sed 's,[.-],_,g'`='"; \ -# gpg --no-version --enarmor <$i | grep -v ^Comment:; echo "'" ; done -# ) +suspend_error + + sig_1ls1ls_valid=' -----BEGIN PGP ARMORED FILE----- @@ -119,13 +121,11 @@ -----END PGP ARMORED FILE----- ' -save_IFS="${IFS}" -IFS="" -for i in "$sig_1ls1ls_valid" "$sig_ls_valid" "$sig_sl_valid"; do - echo "$i" | ./gpg_dearmor >x - IFS="${save_IFS}" - $GPG --verify x 2>/dev/null || error "valid is invalid" - IFS="" + +for i in sig_sl_valid ; do + eval "(IFS=; echo \"\$$i\")" | ./gpg_dearmor >x + $GPG --verify x 2>/dev/null || error "valid is invalid ($i)" + linefeed done #for i in "$sig_11lss_valid_but_is_not" "$sig_11lss11lss_valid_but_is_not" \ # "$sig_ssl_valid_but_is_not"; do @@ -133,13 +133,13 @@ # $GPG --verify /dev/null || error "valid is invalid" #done -# without the +e ksh seems to terminate the for loop -set +e -for i in "$sig_1lsls_invalid" "$sig_lsls_invalid" \ - "$sig_lss_invalid" "$sig_slsl_invalid" ; do - echo "$i" | ./gpg_dearmor >x - IFS="${save_IFS}" - $GPG --verify /dev/null && error "invalid is valid" - IFS="" +for i in sig_1ls1ls_valid sig_ls_valid \ + sig_1lsls_invalid sig_lsls_invalid \ + sig_lss_invalid sig_slsl_invalid ; do + eval "(IFS=; echo \"\$$i\")" | ./gpg_dearmor >x + $GPG --verify /dev/null && error "invalid is valid ($i)" + linefeed done -IFS="${save_IFS}" + + +resume_error \ No newline at end of file Modified: trunk/checks/verify.test =================================================================== --- trunk/checks/verify.test 2006-03-06 12:28:46 UTC (rev 4035) +++ trunk/checks/verify.test 2006-03-06 21:28:25 UTC (rev 4036) @@ -2,10 +2,126 @@ . $srcdir/defs.inc || exit 3 -#info check that verify fails for bad input data +suspend_error + +# +# Two simple tests to check that verify fails for bad input data +# +info "checking bogus signature 1" ../tools/mk-tdata --char 0x2d 64 >x $GPG --verify x data-500 && error "no error code from verify" +info "checking bogus signature 2" ../tools/mk-tdata --char 0xca 64 >x $GPG --verify x data-500 && error "no error code from verify" -exit 0 +linefeed + +# A variable to collect the test names +tests="" + +# A plain signed message created using +# echo abc | gpg --homedir . --passphrase-fd 0 -u Alpha -z0 -sa msg +tests="$tests msg_ols_asc" +msg_ols_asc='-----BEGIN PGP MESSAGE----- + +kA0DAAIRLXJ8x2hpdzQBrQEHYgNtc2dEDFJaSSB0aGluayB0aGF0IGFsbCByaWdo +dC10aGlua2luZyBwZW9wbGUgaW4gdGhpcyBjb3VudHJ5IGFyZSBzaWNrIGFuZAp0 +aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgb3JkaW5hcnkgZGVjZW50IHBlb3BsZSBh +cmUgZmVkIHVwIGluIHRoaXMKY291bnRyeSB3aXRoIGJlaW5nIHNpY2sgYW5kIHRp +cmVkLiAgSSdtIGNlcnRhaW5seSBub3QuICBCdXQgSSdtCnNpY2sgYW5kIHRpcmVk +IG9mIGJlaW5nIHRvbGQgdGhhdCBJIGFtLgotIE1vbnR5IFB5dGhvbgqIPwMFAEQM +UlotcnzHaGl3NBECR4IAoJlEGTY+bHjD2HYuCixLQCmk01pbAKCIjkzLOAmkZNm0 +D8luT78c/1x45Q== +=a29i +-----END PGP MESSAGE-----' + +# A plain signed message created using +# echo abc | gpg --homedir . --passphrase-fd 0 -u Alpha -sa msg +tests="$tests msg_cols_asc" +msg_cols_asc='-----BEGIN PGP MESSAGE----- + +owGbwMvMwCSoW1RzPCOz3IRxLSN7EnNucboLT6Cgp0JJRmZeNpBMLFFIzMlRKMpM +zyjRBQtm5qUrFKTmF+SkKmTmgdQVKyTnl+aVFFUqJBalKhRnJmcrJOalcJVkFqWm +KOSnKSSlgrSU5OekQMzLL0rJzEsEKk9JTU7NK4EZBtKcBtRRWgAzlwtmbnlmSQbU +GJjxCmDj9RQUPNVzFZJTi0oSM/NyKhXy8kuAYk6lJSBxLlTF2NziqZCYq8elq+Cb +n1dSqRBQWZKRn8fVYc/MygAKBljYCDIFiTDMT+9seu836Q+bevyHTJ0dzPNuvCjn +ZpgrwX38z58rJsfYDhwOSS4SkN/d6vUAAA== +=s6sY +-----END PGP MESSAGE-----' + +# A PGP 2 style message. +tests="$tests msg_sl_asc" +msg_sl_asc='-----BEGIN PGP MESSAGE----- + +iD8DBQBEDFJaLXJ8x2hpdzQRAkeCAKCZRBk2Pmx4w9h2LgosS0AppNNaWwCgiI5M +yzgJpGTZtA/Jbk+/HP9ceOWtAQdiA21zZ0QMUlpJIHRoaW5rIHRoYXQgYWxsIHJp +Z2h0LXRoaW5raW5nIHBlb3BsZSBpbiB0aGlzIGNvdW50cnkgYXJlIHNpY2sgYW5k +CnRpcmVkIG9mIGJlaW5nIHRvbGQgdGhhdCBvcmRpbmFyeSBkZWNlbnQgcGVvcGxl +IGFyZSBmZWQgdXAgaW4gdGhpcwpjb3VudHJ5IHdpdGggYmVpbmcgc2ljayBhbmQg +dGlyZWQuICBJJ20gY2VydGFpbmx5IG5vdC4gIEJ1dCBJJ20Kc2ljayBhbmQgdGly +ZWQgb2YgYmVpbmcgdG9sZCB0aGF0IEkgYW0uCi0gTW9udHkgUHl0aG9uCg== +=0ukK +-----END PGP MESSAGE-----' + +# An OpenPGP message lacking the onepass packet. We used to accept +# such messages but now consider them invalid. +tests="$tests bad_ls_asc" +bad_ls_asc='-----BEGIN PGP MESSAGE----- + +rQEHYgNtc2dEDFJaSSB0aGluayB0aGF0IGFsbCByaWdodC10aGlua2luZyBwZW9w +bGUgaW4gdGhpcyBjb3VudHJ5IGFyZSBzaWNrIGFuZAp0aXJlZCBvZiBiZWluZyB0 +b2xkIHRoYXQgb3JkaW5hcnkgZGVjZW50IHBlb3BsZSBhcmUgZmVkIHVwIGluIHRo +aXMKY291bnRyeSB3aXRoIGJlaW5nIHNpY2sgYW5kIHRpcmVkLiAgSSdtIGNlcnRh +aW5seSBub3QuICBCdXQgSSdtCnNpY2sgYW5kIHRpcmVkIG9mIGJlaW5nIHRvbGQg +dGhhdCBJIGFtLgotIE1vbnR5IFB5dGhvbgqIPwMFAEQMUlotcnzHaGl3NBECR4IA +oJlEGTY+bHjD2HYuCixLQCmk01pbAKCIjkzLOAmkZNm0D8luT78c/1x45Q== +=Mpiu +-----END PGP MESSAGE-----' + + +# A signed message prefixed with an unsigned literal packet. +# (fols = faked-literal-data, one-pass, literal-data, signature) +# This should throw an error because running gpg to extract the +# signed data will return both literal data packets +tests="$tests bad_fols_asc" +bad_fols_asc='-----BEGIN PGP MESSAGE----- + +rF1iDG1zZy51bnNpZ25lZEQMY0x0aW1lc2hhcmluZywgbjoKCUFuIGFjY2VzcyBt +ZXRob2Qgd2hlcmVieSBvbmUgY29tcHV0ZXIgYWJ1c2VzIG1hbnkgcGVvcGxlLgqQ +DQMAAhEtcnzHaGl3NAGtAQdiA21zZ0QMUlpJIHRoaW5rIHRoYXQgYWxsIHJpZ2h0 +LXRoaW5raW5nIHBlb3BsZSBpbiB0aGlzIGNvdW50cnkgYXJlIHNpY2sgYW5kCnRp +cmVkIG9mIGJlaW5nIHRvbGQgdGhhdCBvcmRpbmFyeSBkZWNlbnQgcGVvcGxlIGFy +ZSBmZWQgdXAgaW4gdGhpcwpjb3VudHJ5IHdpdGggYmVpbmcgc2ljayBhbmQgdGly +ZWQuICBJJ20gY2VydGFpbmx5IG5vdC4gIEJ1dCBJJ20Kc2ljayBhbmQgdGlyZWQg +b2YgYmVpbmcgdG9sZCB0aGF0IEkgYW0uCi0gTW9udHkgUHl0aG9uCog/AwUARAxS +Wi1yfMdoaXc0EQJHggCgmUQZNj5seMPYdi4KLEtAKaTTWlsAoIiOTMs4CaRk2bQP +yW5Pvxz/XHjl +=UNM4 +-----END PGP MESSAGE-----' + + + + +# +# Now run the tests. +# +for i in $tests ; do + info "checking: $i" + case "$i" in + msg_*_asc) + eval "(IFS=; echo \"\$$i\")" >x + $GPG --verify x || error "verify of $i failed" + ;; + bad_*_asc) + eval "(IFS=; echo \"\$$i\")" >x + $GPG --verify x && error "verify of $i succeeded but should not" + ;; + *) + error "No handler for test case $i" + ;; + esac + linefeed +done + + +resume_error Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-06 12:28:46 UTC (rev 4035) +++ trunk/g10/ChangeLog 2006-03-06 21:28:25 UTC (rev 4036) @@ -1,7 +1,8 @@ 2006-03-06 Werner Koch - * mainproc.c (check_sig_and_print): Check for multiple plaintexts - before a signature. Reported by Tavis Ormandy. + * mainproc.c (check_sig_and_print): Made the composition test more + tight. This is due to another bug report by Tavis Ormandy. + (add_onepass_sig): Simplified. 2006-03-05 Werner Koch Modified: trunk/g10/mainproc.c =================================================================== --- trunk/g10/mainproc.c 2006-03-06 12:28:46 UTC (rev 4035) +++ trunk/g10/mainproc.c 2006-03-06 21:28:25 UTC (rev 4036) @@ -114,27 +114,14 @@ static int add_onepass_sig( CTX c, PACKET *pkt ) { - KBNODE node; + KBNODE node; - if( c->list ) { /* add another packet */ - /* We can only append another onepass packet if the list - * does contain only onepass packets */ - for( node=c->list; node && node->pkt->pkttype == PKT_ONEPASS_SIG; - node = node->next ) - ; - if( node ) { - /* this is not the case, so we flush the current thing and - * allow this packet to start a new verification thing */ - release_list( c ); - c->list = new_kbnode( pkt ); - } - else - add_kbnode( c->list, new_kbnode( pkt )); - } - else /* insert the first one */ - c->list = node = new_kbnode( pkt ); + if ( c->list ) /* add another packet */ + add_kbnode( c->list, new_kbnode( pkt )); + else /* insert the first one */ + c->list = node = new_kbnode( pkt ); - return 1; + return 1; } @@ -1416,93 +1403,118 @@ static int check_sig_and_print( CTX c, KBNODE node ) { - PKT_signature *sig = node->pkt->pkt.signature; - const char *astr; - int rc, is_expkey=0, is_revkey=0; + PKT_signature *sig = node->pkt->pkt.signature; + const char *astr; + int rc, is_expkey=0, is_revkey=0; - if( opt.skip_verify ) { - log_info(_("signature verification suppressed\n")); - return 0; + if (opt.skip_verify) + { + log_info(_("signature verification suppressed\n")); + return 0; } - /* It is not in all cases possible to check multiple signatures: - * PGP 2 (which is also allowed by OpenPGP), does use the packet - * sequence: sig+data, OpenPGP does use onepas+data=sig and GnuPG - * sometimes uses (because I did'nt read the specs right) data+sig. - * Because it is possible to create multiple signatures with - * different packet sequence (e.g. data+sig and sig+data) it might - * not be possible to get it right: let's say we have: - * data+sig, sig+data,sig+data and we have not yet encountered the last - * data, we could also see this a one data with 2 signatures and then - * data+sig. - * To protect against this we check that all signatures follow - * without any intermediate packets. Note, that we won't get this - * error when we use onepass packets or cleartext signatures because - * we reset the list every time - * - * FIXME: Now that we have these marker packets, we should create a - * real grammar and check against this. - */ - { - KBNODE n; - int n_sig = 0; - int n_plaintext = 0; - int sig_seen, onepass_seen; + /* Check that the message composition is valid. - for (n=c->list; n; n=n->next ) + Per RFC-2440bis (-15) allowed: + + S{1,n} -- detached signature. + S{1,n} P -- old style PGP2 signature + O{1,n} P S{1,n} -- standard OpenPGP signature. + C P S{1,n} -- cleartext signature. + + + O = One-Pass Signature packet. + S = Signature packet. + P = OpenPGP Message packet (Encrypted | Compressed | Literal) + (Note that the current rfc2440bis draft also allows + for a signed message but that does not work as it + introduces ambiguities.) + We keep track of these packages using the marker packet + CTRLPKT_PLAINTEXT_MARK. + C = Marker packet for cleartext signatures. + + We reject all other messages. + + Actually we are calling this too often, i.e. for verification of + each message but better have some duplicate work than to silently + introduce a bug here. + */ + { + KBNODE n; + int n_onepass, n_sig; + + log_debug ("checking signature packet composition\n"); + dump_kbnode (c->list); + + n = c->list; + assert (n); + if ( n->pkt->pkttype == PKT_SIGNATURE ) + { + /* This is either "S{1,n}" case (detached signature) or + "S{1,n} P" (old style PGP2 signature). */ + for (n = n->next; n; n = n->next) + if (n->pkt->pkttype != PKT_SIGNATURE) + break; + if (!n) + ; /* Okay, this is a detached signature. */ + else if (n->pkt->pkttype == PKT_GPG_CONTROL + && (n->pkt->pkt.gpg_control->control + == CTRLPKT_PLAINTEXT_MARK) ) { - if ( n->pkt->pkttype == PKT_SIGNATURE ) - n_sig++; - else if (n->pkt->pkttype == PKT_GPG_CONTROL - && (n->pkt->pkt.gpg_control->control - == CTRLPKT_PLAINTEXT_MARK) ) - n_plaintext++; + if (n->next) + goto ambiguous; /* We only allow one P packet. */ } - - for (sig_seen=onepass_seen=0,n=c->list; n; n=n->next ) + else + goto ambiguous; + } + else if (n->pkt->pkttype == PKT_ONEPASS_SIG) + { + /* This is the "O{1,n} P S{1,n}" case (standard signature). */ + for (n_onepass=1, n = n->next; + n && n->pkt->pkttype == PKT_ONEPASS_SIG; n = n->next) + n_onepass++; + if (!n || !(n->pkt->pkttype == PKT_GPG_CONTROL + && (n->pkt->pkt.gpg_control->control + == CTRLPKT_PLAINTEXT_MARK))) + goto ambiguous; + for (n_sig=0, n = n->next; + n && n->pkt->pkttype == PKT_SIGNATURE; n = n->next) + n_sig++; + if (n || !n_sig) + goto ambiguous; + if (n_onepass != n_sig) { - if (n->pkt->pkttype == PKT_ONEPASS_SIG) - { - onepass_seen++; - } - else if (n->pkt->pkttype == PKT_GPG_CONTROL - && (n->pkt->pkt.gpg_control->control - == CTRLPKT_CLEARSIGN_START) ) - { - onepass_seen++; /* Handle the same way as a onepass. */ - } - else if ( (sig_seen && n->pkt->pkttype != PKT_SIGNATURE) ) - { - log_error(_("can't handle these multiple signatures\n")); - return 0; - } - else if ( n->pkt->pkttype == PKT_SIGNATURE ) - { - sig_seen = 1; - } - else if (n_sig > 1 && !sig_seen && !onepass_seen - && n->pkt->pkttype == PKT_GPG_CONTROL - && (n->pkt->pkt.gpg_control->control - == CTRLPKT_PLAINTEXT_MARK) ) - { - /* Plaintext before signatures but no onepass - signature packets. */ - log_error(_("can't handle these multiple signatures\n")); - return 0; - } - else if (n_plaintext > 1 && !sig_seen && !onepass_seen - && n->pkt->pkttype == PKT_GPG_CONTROL - && (n->pkt->pkt.gpg_control->control - == CTRLPKT_PLAINTEXT_MARK) ) - { - /* More than one plaintext before a signature but no - onepass packets. */ - log_error(_("can't handle this ambiguous signed data\n")); - return 0; - } + log_info ("number of one-pass packets does not match " + "number of signature packets\n"); + goto ambiguous; } - } + } + else if (n->pkt->pkttype == PKT_GPG_CONTROL + && n->pkt->pkt.gpg_control->control == CTRLPKT_CLEARSIGN_START ) + { + /* This is the "C P S{1,n}" case (clear text signature). */ + n = n->next; + if (!n || !(n->pkt->pkttype == PKT_GPG_CONTROL + && (n->pkt->pkt.gpg_control->control + == CTRLPKT_PLAINTEXT_MARK))) + goto ambiguous; + for (n_sig=0, n = n->next; + n && n->pkt->pkttype == PKT_SIGNATURE; n = n->next) + n_sig++; + if (n || !n_sig) + goto ambiguous; + } + else + { + ambiguous: + log_error(_("can't handle this ambiguous signature data\n")); + return 0; + } + } + + /* (Indendation below not yet changed to GNU style.) */ + astr = pubkey_algo_to_string( sig->pubkey_algo ); if(keystrlen()>8) { @@ -1926,7 +1938,8 @@ /* prepare to create all requested message digests */ c->mfx.md = md_open(0, 0); - /* fixme: why looking for the signature packet and not 1passpacket*/ + /* fixme: why looking for the signature packet and not the + one-pass packet? */ for( n1 = node; (n1 = find_next_kbnode(n1, PKT_SIGNATURE )); ) { md_enable( c->mfx.md, n1->pkt->pkt.signature->digest_algo); } From cvs at cvs.gnupg.org Tue Mar 7 00:14:15 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Mon Mar 6 23:48:36 2006 Subject: [svn] GnuPG - r4037 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-07 00:14:13 +0100 (Tue, 07 Mar 2006) New Revision: 4037 Modified: trunk/g10/ChangeLog trunk/g10/mainproc.c Log: * mainproc.c (proc_compressed): "Uncompressed" is not a valid compression algorithm. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-06 21:28:25 UTC (rev 4036) +++ trunk/g10/ChangeLog 2006-03-06 23:14:13 UTC (rev 4037) @@ -1,3 +1,8 @@ +2006-03-06 David Shaw + + * mainproc.c (proc_compressed): "Uncompressed" is not a valid + compression algorithm. + 2006-03-06 Werner Koch * mainproc.c (check_sig_and_print): Made the composition test more Modified: trunk/g10/mainproc.c =================================================================== --- trunk/g10/mainproc.c 2006-03-06 21:28:25 UTC (rev 4036) +++ trunk/g10/mainproc.c 2006-03-06 23:14:13 UTC (rev 4037) @@ -748,7 +748,9 @@ int rc; /*printf("zip: compressed data packet\n");*/ - if( c->sigs_only ) + if( !zd->algorithm ) + rc=G10ERR_COMPR_ALGO; + else if( c->sigs_only ) rc = handle_compressed( c, zd, proc_compressed_cb, c ); else if( c->encrypt_only ) rc = handle_compressed( c, zd, proc_encrypt_cb, c ); From cvs at cvs.gnupg.org Tue Mar 7 02:16:32 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Tue Mar 7 01:50:53 2006 Subject: [svn] GnuPG - r4038 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-07 02:16:31 +0100 (Tue, 07 Mar 2006) New Revision: 4038 Modified: trunk/g10/ChangeLog trunk/g10/sign.c Log: * sign.c (make_keysig_packet): Don't use MD5 for a RSA_S key as that is not a PGP 2.x algorithm. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-06 23:14:13 UTC (rev 4037) +++ trunk/g10/ChangeLog 2006-03-07 01:16:31 UTC (rev 4038) @@ -1,5 +1,8 @@ 2006-03-06 David Shaw + * sign.c (make_keysig_packet): Don't use MD5 for a RSA_S key as + that is not a PGP 2.x algorithm. + * mainproc.c (proc_compressed): "Uncompressed" is not a valid compression algorithm. Modified: trunk/g10/sign.c =================================================================== --- trunk/g10/sign.c 2006-03-06 23:14:13 UTC (rev 4037) +++ trunk/g10/sign.c 2006-03-07 01:16:31 UTC (rev 4038) @@ -1374,9 +1374,8 @@ if(opt.cert_digest_algo) digest_algo=opt.cert_digest_algo; - else if((sk->pubkey_algo==PUBKEY_ALGO_RSA || - sk->pubkey_algo==PUBKEY_ALGO_RSA_S) && - pk->version<4 && sigversion < 4) + else if(sk->pubkey_algo==PUBKEY_ALGO_RSA + && pk->version<4 && sigversion<4) digest_algo = DIGEST_ALGO_MD5; else digest_algo = DIGEST_ALGO_SHA1; From cvs at cvs.gnupg.org Tue Mar 7 06:06:31 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Tue Mar 7 05:40:51 2006 Subject: [svn] GnuPG - r4039 - trunk/doc Message-ID: Author: dshaw Date: 2006-03-07 06:06:31 +0100 (Tue, 07 Mar 2006) New Revision: 4039 Modified: trunk/doc/ChangeLog trunk/doc/gpg.sgml Log: * gpg.sgml: Document --auto-key-locate. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-03-07 01:16:31 UTC (rev 4038) +++ trunk/doc/ChangeLog 2006-03-07 05:06:31 UTC (rev 4039) @@ -1,3 +1,7 @@ +2006-03-06 David Shaw + + * gpg.sgml: Document --auto-key-locate. + 2006-02-24 David Shaw * gpg.sgml: Document new --keyserver syntax. Modified: trunk/doc/gpg.sgml =================================================================== --- trunk/doc/gpg.sgml 2006-03-07 01:16:31 UTC (rev 4038) +++ trunk/doc/gpg.sgml 2006-03-07 05:06:31 UTC (rev 4039) @@ -35,10 +35,10 @@ &ParmFile;"> files"> &ParmFiles;"> +name"> +&ParmName;"> names"> &ParmNames;"> -name"> -&ParmName;"> key IDs"> &ParmKeyIDs"> n"> @@ -1238,7 +1238,6 @@ database says and enable the PKA sub model. - @@ -1248,6 +1247,47 @@ +--auto-key-locate parameters + + + +GnuPG can automatically locate and retrieve keys as needed using this +option. This happens when encrypting to an email address (in the +"user@example.com" form), and there are no user@example.com keys on +the local keyring. This option takes any number of the following +arguments, in the order they are to be tried: + + + +cert +locate a key using DNS CERT, as specified in 2538bis (currently in +draft): http://www.josefsson.org/rfc2538bis/ + + +pka +locate a key using DNS PKA. + + +ldap +locate a key using the PGP Universal method of checking +"ldap://keys.(thedomain)". + + +keyserver +locate a key using whatever keyserver is defined using the --keyserver +option. + + +(keyserver URL) +In addition, a keyserver URL as used in the --keyserver option may be +used here to query that particular keyserver. + + + + + + + --allow-pka-lookup This option enables PKA lookups. PKA is based on DNS; thus enabling @@ -1979,7 +2019,6 @@ --cert-notation &ParmNameValue; -N, --set-notation &ParmNameValue; - Put the name value pair into the signature as notation data. &ParmName; must consist only of printable characters or spaces, and must contain a '@' character in the form keyname@domain.example.com @@ -1992,7 +2031,6 @@ flagged as critical (rfc2440:5.2.3.15). --sig-notation sets a notation for data signatures. --cert-notation sets a notation for key signatures (certifications). --set-notation sets both. - From cvs at cvs.gnupg.org Tue Mar 7 17:20:04 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Tue Mar 7 16:54:23 2006 Subject: [svn] GnuPG - r4041 - trunk Message-ID: Author: dshaw Date: 2006-03-07 17:20:03 +0100 (Tue, 07 Mar 2006) New Revision: 4041 Modified: trunk/ChangeLog trunk/NEWS Log: * NEWS: Note --auto-key-locate and that keyservers can handle binary data now. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-07 11:05:41 UTC (rev 4040) +++ trunk/ChangeLog 2006-03-07 16:20:03 UTC (rev 4041) @@ -1,3 +1,8 @@ +2006-03-07 David Shaw + + * NEWS: Note --auto-key-locate and that keyservers can handle + binary data now. + 2006-03-01 David Shaw * configure.ac: Fix accidental enabling of SHA-384/512. Noted by Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-07 11:05:41 UTC (rev 4040) +++ trunk/NEWS 2006-03-07 16:20:03 UTC (rev 4041) @@ -51,13 +51,23 @@ are HTTP and finger, plus anything that cURL supplies, if built with cURL support. - * Files containing several signed messages are not anymore allowed - because there is no clean way to report the status of such files - back to the caller. To partly revert to the old behaviour the - new option --allow-multisig-verification may be used. + * Files containing several signed messages are not allowed any + longer as there is no clean way to report the status of such + files back to the caller. To partly revert to the old behaviour + the new option --allow-multisig-verification may be used. + * The keyserver helpers can now handle keys in either ASCII armor + or binary format. + * New auto-key-locate option that takes an ordered list of methods + to locate a key if it is not available at encryption time (-r or + --recipient). Possible methods include "cert" (use DNS CERT as + per RFC2538bis, "pka" (use DNS PKA), "ldap" (consult the LDAP + server for the domain in question), "keyserver" (use the + currently defined keyserver), as well as arbitrary keyserver + URIs that will be contacted for the key. + Noteworthy changes in version 1.4.2 (2005-07-26) ------------------------------------------------ From cvs at cvs.gnupg.org Tue Mar 7 20:26:23 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Mar 7 20:00:39 2006 Subject: [svn] gcry - r1144 - in trunk: . cipher doc tests Message-ID: Author: wk Date: 2006-03-07 20:26:21 +0100 (Tue, 07 Mar 2006) New Revision: 1144 Modified: trunk/AUTHORS trunk/TODO trunk/cipher/ChangeLog trunk/cipher/cipher.c trunk/doc/ChangeLog trunk/doc/gcrypt.texi trunk/tests/ChangeLog trunk/tests/basic.c trunk/tests/benchmark.c Log: Applied OFB mode patch by Brad Harris Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2006-01-08 02:10:46 UTC (rev 1143) +++ trunk/AUTHORS 2006-03-07 19:26:21 UTC (rev 1144) @@ -23,20 +23,17 @@ GNUPG Natural Resources Canada 1998-08-11 Disclaims changes by Matthew Skala. - GNUPG Michael Roth Germany 1998-09-17 Assigns changes. mroth@nessie.de Wrote cipher/des.c. Changes and bug fixes all over the place. - GNUPG Niklas Hernaeus 1998-09-18 Disclaims changes. nh@df.lth.se Weak key patches. - GNUPG Rémi Guyomarch 1999-05-25 Assigns past and future changes. (g10/compress.c, g10/encr-data.c, g10/free-packet.c, g10/mdfilter.c, g10/plaintext.c, util/iobuf.c) @@ -70,7 +67,14 @@ tests/register.c, tests/ac.c, tests/basic.c, tests/tsexp.c, tests/keygen.c, tests/pubkey.c, configure.ac, acinclude.m4) +LIBGCRYPT Brad Hards 2006-02-09 +Assigns Past and Future Changes +bradh@frogmouth.net +(Added OFB mode. Changed cipher/cipher.c, test/basic.c doc/gcrypt.tex) + + + More credits ============ The ATH implementation (src/ath*) has been taken from GPGME and @@ -85,7 +89,8 @@ Wedgwood 1996-1999. - Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright 1998, 1999, 2000, 2001, 2002, 2003, + 2006 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-01-08 02:10:46 UTC (rev 1143) +++ trunk/TODO 2006-03-07 19:26:21 UTC (rev 1144) @@ -36,3 +36,6 @@ * update/improve documentation - it's outdated for e.g. gcry_pk_algo_info. - document algorithm capabilities + +* Use builtin bit functions of gcc 3.4 + Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2006-01-08 02:10:46 UTC (rev 1143) +++ trunk/cipher/ChangeLog 2006-03-07 19:26:21 UTC (rev 1144) @@ -1,3 +1,8 @@ +2006-01-18 Brad Hards (wk 2006-03-07) + + * cipher.c (cipher_encrypt, cipher_decrypt, do_ofb_encrypt) + (do_ofb_decrypt, gcry_cipher_open): Implement Output Feedback Mode. + 2005-11-02 Moritz Schulte * pubkey.c (gcry_pk_algo_name): Return "?" instead of NULL for Modified: trunk/cipher/cipher.c =================================================================== --- trunk/cipher/cipher.c 2006-01-08 02:10:46 UTC (rev 1143) +++ trunk/cipher/cipher.c 2006-03-07 19:26:21 UTC (rev 1144) @@ -590,6 +590,7 @@ case GCRY_CIPHER_MODE_ECB: case GCRY_CIPHER_MODE_CBC: case GCRY_CIPHER_MODE_CFB: + case GCRY_CIPHER_MODE_OFB: case GCRY_CIPHER_MODE_CTR: if ((cipher->encrypt == dummy_encrypt_block) || (cipher->decrypt == dummy_decrypt_block)) @@ -983,6 +984,100 @@ static void +do_ofb_encrypt( gcry_cipher_hd_t c, + byte *outbuf, const byte *inbuf, unsigned nbytes ) +{ + byte *ivp; + size_t blocksize = c->cipher->blocksize; + + if ( nbytes <= c->unused ) + { + /* Short enough to be encoded by the remaining XOR mask. */ + /* XOR the input with the IV */ + for (ivp=c->iv+c->cipher->blocksize - c->unused; + nbytes; + nbytes--, c->unused-- ) + *outbuf++ = (*ivp++ ^ *inbuf++); + return; + } + + if( c->unused ) + { + nbytes -= c->unused; + for(ivp=c->iv+blocksize - c->unused; c->unused; c->unused-- ) + *outbuf++ = (*ivp++ ^ *inbuf++); + } + + /* Now we can process complete blocks. */ + while ( nbytes >= blocksize ) + { + int i; + /* Encrypt the IV (and save the current one). */ + memcpy( c->lastiv, c->iv, blocksize ); + c->cipher->encrypt ( &c->context.c, c->iv, c->iv ); + + for (ivp=c->iv,i=0; i < blocksize; i++ ) + *outbuf++ = (*ivp++ ^ *inbuf++); + nbytes -= blocksize; + } + if ( nbytes ) + { /* process the remaining bytes */ + memcpy( c->lastiv, c->iv, blocksize ); + c->cipher->encrypt ( &c->context.c, c->iv, c->iv ); + c->unused = blocksize; + c->unused -= nbytes; + for(ivp=c->iv; nbytes; nbytes-- ) + *outbuf++ = (*ivp++ ^ *inbuf++); + } +} + +static void +do_ofb_decrypt( gcry_cipher_hd_t c, + byte *outbuf, const byte *inbuf, unsigned int nbytes ) +{ + byte *ivp; + size_t blocksize = c->cipher->blocksize; + + if( nbytes <= c->unused ) + { + /* Short enough to be encoded by the remaining XOR mask. */ + for (ivp=c->iv+blocksize - c->unused; nbytes; nbytes--,c->unused--) + *outbuf++ = *ivp++ ^ *inbuf++; + return; + } + + if ( c->unused ) + { + nbytes -= c->unused; + for (ivp=c->iv+blocksize - c->unused; c->unused; c->unused-- ) + *outbuf++ = *ivp++ ^ *inbuf++; + } + + /* Now we can process complete blocks. */ + while ( nbytes >= blocksize ) + { + int i; + /* Encrypt the IV (and save the current one). */ + memcpy( c->lastiv, c->iv, blocksize ); + c->cipher->encrypt ( &c->context.c, c->iv, c->iv ); + for (ivp=c->iv,i=0; i < blocksize; i++ ) + *outbuf++ = *ivp++ ^ *inbuf++; + nbytes -= blocksize; + } + if ( nbytes ) + { /* Process the remaining bytes. */ + /* Encrypt the IV (and save the current one). */ + memcpy( c->lastiv, c->iv, blocksize ); + c->cipher->encrypt ( &c->context.c, c->iv, c->iv ); + c->unused = blocksize; + c->unused -= nbytes; + for (ivp=c->iv; nbytes; nbytes-- ) + *outbuf++ = *ivp++ ^ *inbuf++; + } +} + + +static void do_ctr_encrypt( gcry_cipher_hd_t c, byte *outbuf, const byte *inbuf, unsigned int nbytes ) { @@ -1046,6 +1141,9 @@ case GCRY_CIPHER_MODE_CFB: do_cfb_encrypt(c, outbuf, inbuf, nbytes ); break; + case GCRY_CIPHER_MODE_OFB: + do_ofb_encrypt(c, outbuf, inbuf, nbytes ); + break; case GCRY_CIPHER_MODE_CTR: do_ctr_encrypt(c, outbuf, inbuf, nbytes ); break; @@ -1132,6 +1230,9 @@ case GCRY_CIPHER_MODE_CFB: do_cfb_decrypt(c, outbuf, inbuf, nbytes ); break; + case GCRY_CIPHER_MODE_OFB: + do_ofb_decrypt(c, outbuf, inbuf, nbytes ); + break; case GCRY_CIPHER_MODE_CTR: do_ctr_decrypt(c, outbuf, inbuf, nbytes ); break; Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-01-08 02:10:46 UTC (rev 1143) +++ trunk/doc/ChangeLog 2006-03-07 19:26:21 UTC (rev 1144) @@ -1,3 +1,8 @@ +2006-01-18 Brad Hards (wk 2006-03-07) + + * gcrypt.texi (Available cipher modes): Typo fix, add a little + more detail on cipher modes vs cipher algorithms. + 2006-01-08 Moritz Schulte * gcrypt.texi: Added documentation for more gcry_control commands. Modified: trunk/doc/gcrypt.texi =================================================================== --- trunk/doc/gcrypt.texi 2006-01-08 02:10:46 UTC (rev 1143) +++ trunk/doc/gcrypt.texi 2006-03-07 19:26:21 UTC (rev 1144) @@ -12,7 +12,7 @@ (version @value{VERSION}, @value{UPDATED}), which is GNU's library of cryptographic building blocks. -Copyright @copyright{} 2000, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright @copyright{} 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document @@ -1318,7 +1318,7 @@ Stream mode, only to be used with stream cipher algorithms. @item GCRY_CIPHER_MODE_OFB -Outer Feedback mode. +Output Feedback mode. @item GCRY_CIPHER_MODE_CTR Counter mode. @@ -1347,8 +1347,12 @@ The cipher mode to use must be specified via @var{mode}. See @xref{Available cipher modes}, for a list of supported cipher modes -and the according constants. Note, that some modes do not work -together with all algorithms. +and the according constants. Note that some modes are incompatible +with some algorithms - in particular, stream mode +(GCRY_CIPHER_MODE_STREAM) only works with stream ciphers. Any block +cipher mode (GCRY_CIPHER_MODE_ECB, GCRY_CIPHER_MODE_CBC, +GCRY_CIPHER_MODE_CFB, GCRY_CIPHER_MODE_OFB or GCRY_CIPHER_MODE_CTR) +will work with any block cipher algorithm. The third argument @var{flags} can either be passed as @code{0} or as the bit-wise OR of the following constants. Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2006-01-08 02:10:46 UTC (rev 1143) +++ trunk/tests/ChangeLog 2006-03-07 19:26:21 UTC (rev 1144) @@ -1,3 +1,12 @@ +2006-03-07 Werner Koch + + * benchmark.c (cipher_bench): Add OFB mode. + +2006-01-18 Brad Hards (wk 2006-03-07) + + * basic.c: Added test cases for OFB and CFB modes. Fixed some + compiler warnings for signedness. + 2005-11-12 Moritz Schulte * ac-data.c: Added way more test cases. Modified: trunk/tests/basic.c =================================================================== --- trunk/tests/basic.c 2006-01-08 02:10:46 UTC (rev 1143) +++ trunk/tests/basic.c 2006-03-07 19:26:21 UTC (rev 1144) @@ -89,7 +89,7 @@ { int algo; char key[MAX_DATA_LEN]; - char plaintext[MAX_DATA_LEN]; + unsigned char plaintext[MAX_DATA_LEN]; size_t plaintextlen; char mac[MAX_DATA_LEN]; } @@ -109,7 +109,7 @@ 0, "\xfa\x4b\xdf\x9d\xfa\xab\x01\x70" } }; gcry_cipher_hd_t hd; - char out[MAX_DATA_LEN]; + unsigned char out[MAX_DATA_LEN]; int i, blklen, keylen; gcry_error_t err = 0; @@ -165,7 +165,7 @@ tv[i].plaintext, tv[i].plaintextlen ? tv[i].plaintextlen : - strlen (tv[i].plaintext)); + strlen ((char*)tv[i].plaintext)); if (err) { fail ("cbc-mac algo %d, gcry_cipher_encrypt failed: %s\n", @@ -194,11 +194,11 @@ check_aes128_cbc_cts_cipher (void) { char key[128 / 8] = "chicken teriyaki"; - char plaintext[] = + unsigned char plaintext[] = "I would like the General Gau's Chicken, please, and wonton soup."; struct tv { - char out[MAX_DATA_LEN]; + unsigned char out[MAX_DATA_LEN]; int inlen; } tv[] = { @@ -226,7 +226,7 @@ 64 }, }; gcry_cipher_hd_t hd; - char out[MAX_DATA_LEN]; + unsigned char out[MAX_DATA_LEN]; int i; gcry_error_t err = 0; @@ -306,7 +306,7 @@ char ctr[MAX_DATA_LEN]; struct data { - char plaintext[MAX_DATA_LEN]; + unsigned char plaintext[MAX_DATA_LEN]; int inlen; char out[MAX_DATA_LEN]; } @@ -369,7 +369,7 @@ } }; gcry_cipher_hd_t hde, hdd; - char out[MAX_DATA_LEN]; + unsigned char out[MAX_DATA_LEN]; int i, j, keylen, blklen; gcry_error_t err = 0; @@ -427,7 +427,7 @@ err = gcry_cipher_encrypt (hde, out, MAX_DATA_LEN, tv[i].data[j].plaintext, tv[i].data[j].inlen == -1 ? - strlen (tv[i].data[j].plaintext) : + strlen ((char*)tv[i].data[j].plaintext) : tv[i].data[j].inlen); if (err) { @@ -461,10 +461,399 @@ } static void +check_cfb_cipher (void) +{ + struct tv + { + int algo; + char key[MAX_DATA_LEN]; + char iv[MAX_DATA_LEN]; + struct data + { + unsigned char plaintext[MAX_DATA_LEN]; + int inlen; + char out[MAX_DATA_LEN]; + } + data[MAX_DATA_LEN]; + } tv[] = + { + /* http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf */ + { GCRY_CIPHER_AES, + "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c", + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a", + 16, + "\x3b\x3f\xd9\x2e\xb7\x2d\xad\x20\x33\x34\x49\xf8\xe8\x3c\xfb\x4a" }, + { "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51", + 16, + "\xc8\xa6\x45\x37\xa0\xb3\xa9\x3f\xcd\xe3\xcd\xad\x9f\x1c\xe5\x8b"}, + { "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef", + 16, + "\x26\x75\x1f\x67\xa3\xcb\xb1\x40\xb1\x80\x8c\xf1\x87\xa4\xf4\xdf" }, + { "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + 16, + "\xc0\x4b\x05\x35\x7c\x5d\x1c\x0e\xea\xc4\xc6\x6f\x9f\xf7\xf2\xe6" }, + } + }, + { GCRY_CIPHER_AES192, + "\x8e\x73\xb0\xf7\xda\x0e\x64\x52\xc8\x10\xf3\x2b" + "\x80\x90\x79\xe5\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a", + 16, + "\xcd\xc8\x0d\x6f\xdd\xf1\x8c\xab\x34\xc2\x59\x09\xc9\x9a\x41\x74" }, + { "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51", + 16, + "\x67\xce\x7f\x7f\x81\x17\x36\x21\x96\x1a\x2b\x70\x17\x1d\x3d\x7a" }, + { "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef", + 16, + "\x2e\x1e\x8a\x1d\xd5\x9b\x88\xb1\xc8\xe6\x0f\xed\x1e\xfa\xc4\xc9" }, + { "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + 16, + "\xc0\x5f\x9f\x9c\xa9\x83\x4f\xa0\x42\xae\x8f\xba\x58\x4b\x09\xff" }, + } + }, + { GCRY_CIPHER_AES256, + "\x60\x3d\xeb\x10\x15\xca\x71\xbe\x2b\x73\xae\xf0\x85\x7d\x77\x81" + "\x1f\x35\x2c\x07\x3b\x61\x08\xd7\x2d\x98\x10\xa3\x09\x14\xdf\xf4", + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a", + 16, + "\xdc\x7e\x84\xbf\xda\x79\x16\x4b\x7e\xcd\x84\x86\x98\x5d\x38\x60" }, + { "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51", + 16, + "\x39\xff\xed\x14\x3b\x28\xb1\xc8\x32\x11\x3c\x63\x31\xe5\x40\x7b" }, + { "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef", + 16, + "\xdf\x10\x13\x24\x15\xe5\x4b\x92\xa1\x3e\xd0\xa8\x26\x7a\xe2\xf9" }, + { "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + 16, + "\x75\xa3\x85\x74\x1a\xb9\xce\xf8\x20\x31\x62\x3d\x55\xb1\xe4\x71" } + } + } + }; + gcry_cipher_hd_t hde, hdd; + unsigned char out[MAX_DATA_LEN]; + int i, j, keylen, blklen; + gcry_error_t err = 0; + + for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++) + { + err = gcry_cipher_open (&hde, tv[i].algo, GCRY_CIPHER_MODE_CFB, 0); + if (!err) + err = gcry_cipher_open (&hdd, tv[i].algo, GCRY_CIPHER_MODE_CFB, 0); + if (err) + { + fail ("aes-cfb, grcy_open_cipher failed: %s\n", gpg_strerror (err)); + return; + } + + keylen = gcry_cipher_get_algo_keylen(tv[i].algo); + if (!keylen) + { + fail ("aes-cfb, gcry_cipher_get_algo_keylen failed\n"); + return; + } + + err = gcry_cipher_setkey (hde, tv[i].key, keylen); + if (!err) + err = gcry_cipher_setkey (hdd, tv[i].key, keylen); + if (err) + { + fail ("aes-cfb, gcry_cipher_setkey failed: %s\n", + gpg_strerror (err)); + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + return; + } + + blklen = gcry_cipher_get_algo_blklen(tv[i].algo); + if (!blklen) + { + fail ("aes-cfb, gcry_cipher_get_algo_blklen failed\n"); + return; + } + + err = gcry_cipher_setiv (hde, tv[i].iv, blklen); + if (!err) + err = gcry_cipher_setiv (hdd, tv[i].iv, blklen); + if (err) + { + fail ("aes-cfb, gcry_cipher_setiv failed: %s\n", + gpg_strerror (err)); + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + return; + } + + for (j = 0; tv[i].data[j].inlen; j++) + { + err = gcry_cipher_encrypt (hde, out, MAX_DATA_LEN, + tv[i].data[j].plaintext, + tv[i].data[j].inlen); + if (err) + { + fail ("aes-cfb, gcry_cipher_encrypt (%d, %d) failed: %s\n", + i, j, gpg_strerror (err)); + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + return; + } + + if (memcmp (tv[i].data[j].out, out, tv[i].data[j].inlen)) { + fail ("aes-cfb, encrypt mismatch entry %d:%d\n", i, j); + } + err = gcry_cipher_decrypt (hdd, out, tv[i].data[j].inlen, NULL, 0); + if (err) + { + fail ("aes-cfb, gcry_cipher_decrypt (%d, %d) failed: %s\n", + i, j, gpg_strerror (err)); + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + return; + } + + if (memcmp (tv[i].data[j].plaintext, out, tv[i].data[j].inlen)) + fail ("aes-cfb, decrypt mismatch entry %d:%d\n", i, j); + } + + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + } +} + +static void +check_ofb_cipher (void) +{ + struct tv + { + int algo; + char key[MAX_DATA_LEN]; + char iv[MAX_DATA_LEN]; + struct data + { + unsigned char plaintext[MAX_DATA_LEN]; + int inlen; + char out[MAX_DATA_LEN]; + } + data[MAX_DATA_LEN]; + } tv[] = + { + /* http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf */ + { GCRY_CIPHER_AES, + "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c", + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a", + 16, + "\x3b\x3f\xd9\x2e\xb7\x2d\xad\x20\x33\x34\x49\xf8\xe8\x3c\xfb\x4a" }, + { "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51", + 16, + "\x77\x89\x50\x8d\x16\x91\x8f\x03\xf5\x3c\x52\xda\xc5\x4e\xd8\x25"}, + { "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef", + 16, + "\x97\x40\x05\x1e\x9c\x5f\xec\xf6\x43\x44\xf7\xa8\x22\x60\xed\xcc" }, + { "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + 16, + "\x30\x4c\x65\x28\xf6\x59\xc7\x78\x66\xa5\x10\xd9\xc1\xd6\xae\x5e" }, + } + }, + { GCRY_CIPHER_AES192, + "\x8e\x73\xb0\xf7\xda\x0e\x64\x52\xc8\x10\xf3\x2b" + "\x80\x90\x79\xe5\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a", + 16, + "\xcd\xc8\x0d\x6f\xdd\xf1\x8c\xab\x34\xc2\x59\x09\xc9\x9a\x41\x74" }, + { "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51", + 16, + "\xfc\xc2\x8b\x8d\x4c\x63\x83\x7c\x09\xe8\x17\x00\xc1\x10\x04\x01" }, + { "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef", + 16, + "\x8d\x9a\x9a\xea\xc0\xf6\x59\x6f\x55\x9c\x6d\x4d\xaf\x59\xa5\xf2" }, + { "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + 16, + "\x6d\x9f\x20\x08\x57\xca\x6c\x3e\x9c\xac\x52\x4b\xd9\xac\xc9\x2a" }, + } + }, + { GCRY_CIPHER_AES256, + "\x60\x3d\xeb\x10\x15\xca\x71\xbe\x2b\x73\xae\xf0\x85\x7d\x77\x81" + "\x1f\x35\x2c\x07\x3b\x61\x08\xd7\x2d\x98\x10\xa3\x09\x14\xdf\xf4", + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + { { "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a", + 16, + "\xdc\x7e\x84\xbf\xda\x79\x16\x4b\x7e\xcd\x84\x86\x98\x5d\x38\x60" }, + { "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51", + 16, + "\x4f\xeb\xdc\x67\x40\xd2\x0b\x3a\xc8\x8f\x6a\xd8\x2a\x4f\xb0\x8d" }, + { "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef", + 16, + "\x71\xab\x47\xa0\x86\xe8\x6e\xed\xf3\x9d\x1c\x5b\xba\x97\xc4\x08" }, + { "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + 16, + "\x01\x26\x14\x1d\x67\xf3\x7b\xe8\x53\x8f\x5a\x8b\xe7\x40\xe4\x84" } + } + } + }; + gcry_cipher_hd_t hde, hdd; + unsigned char out[MAX_DATA_LEN]; + int i, j, keylen, blklen; + gcry_error_t err = 0; + + for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++) + { + err = gcry_cipher_open (&hde, tv[i].algo, GCRY_CIPHER_MODE_OFB, 0); + if (!err) + err = gcry_cipher_open (&hdd, tv[i].algo, GCRY_CIPHER_MODE_OFB, 0); + if (err) + { + fail ("aes-ofb, grcy_open_cipher failed: %s\n", gpg_strerror (err)); + return; + } + + keylen = gcry_cipher_get_algo_keylen(tv[i].algo); + if (!keylen) + { + fail ("aes-ofb, gcry_cipher_get_algo_keylen failed\n"); + return; + } + + err = gcry_cipher_setkey (hde, tv[i].key, keylen); + if (!err) + err = gcry_cipher_setkey (hdd, tv[i].key, keylen); + if (err) + { + fail ("aes-ofb, gcry_cipher_setkey failed: %s\n", + gpg_strerror (err)); + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + return; + } + + blklen = gcry_cipher_get_algo_blklen(tv[i].algo); + if (!blklen) + { + fail ("aes-ofb, gcry_cipher_get_algo_blklen failed\n"); + return; + } + + err = gcry_cipher_setiv (hde, tv[i].iv, blklen); + if (!err) + err = gcry_cipher_setiv (hdd, tv[i].iv, blklen); + if (err) + { + fail ("aes-ofb, gcry_cipher_setiv failed: %s\n", + gpg_strerror (err)); + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + return; + } + + for (j = 0; tv[i].data[j].inlen; j++) + { + err = gcry_cipher_encrypt (hde, out, MAX_DATA_LEN, + tv[i].data[j].plaintext, + tv[i].data[j].inlen); + if (err) + { + fail ("aes-ofb, gcry_cipher_encrypt (%d, %d) failed: %s\n", + i, j, gpg_strerror (err)); + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + return; + } + + if (memcmp (tv[i].data[j].out, out, tv[i].data[j].inlen)) + fail ("aes-ofb, encrypt mismatch entry %d:%d\n", i, j); + + err = gcry_cipher_decrypt (hdd, out, tv[i].data[j].inlen, NULL, 0); + if (err) + { + fail ("aes-ofb, gcry_cipher_decrypt (%d, %d) failed: %s\n", + i, j, gpg_strerror (err)); + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + return; + } + + if (memcmp (tv[i].data[j].plaintext, out, tv[i].data[j].inlen)) + fail ("aes-ofb, decrypt mismatch entry %d:%d\n", i, j); + } + + err = gcry_cipher_reset(hde); + if (!err) + err = gcry_cipher_reset(hdd); + if (err) + { + fail ("aes-ofb, gcry_cipher_reset (%d, %d) failed: %s\n", + i, j, gpg_strerror (err)); + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + return; + } + + /* gcry_cipher_reset clears the IV */ + err = gcry_cipher_setiv (hde, tv[i].iv, blklen); + if (!err) + err = gcry_cipher_setiv (hdd, tv[i].iv, blklen); + if (err) + { + fail ("aes-ofb, gcry_cipher_setiv failed: %s\n", + gpg_strerror (err)); + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + return; + } + + /* this time we encrypt and decrypt one byte at a time */ + for (j = 0; tv[i].data[j].inlen; j++) + { + int byteNum; + for (byteNum = 0; byteNum < tv[i].data[j].inlen; ++byteNum) + { + err = gcry_cipher_encrypt (hde, out+byteNum, 1, + (tv[i].data[j].plaintext) + byteNum, + 1); + if (err) + { + fail ("aes-ofb, gcry_cipher_encrypt (%d, %d) failed: %s\n", + i, j, gpg_strerror (err)); + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + return; + } + } + + if (memcmp (tv[i].data[j].out, out, tv[i].data[j].inlen)) + fail ("aes-ofb, encrypt mismatch entry %d:%d\n", i, j); + + for (byteNum = 0; byteNum < tv[i].data[j].inlen; ++byteNum) + { + err = gcry_cipher_decrypt (hdd, out+byteNum, 1, NULL, 0); + if (err) + { + fail ("aes-ofb, gcry_cipher_decrypt (%d, %d) failed: %s\n", + i, j, gpg_strerror (err)); + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + return; + } + } + + if (memcmp (tv[i].data[j].plaintext, out, tv[i].data[j].inlen)) + fail ("aes-ofb, decrypt mismatch entry %d:%d\n", i, j); + } + + gcry_cipher_close (hde); + gcry_cipher_close (hdd); + } +} + +static void check_one_cipher (int algo, int mode, int flags) { gcry_cipher_hd_t hd; - char key[32], plain[16], in[16], out[16]; + char key[32]; + unsigned char plain[16], in[16], out[16]; int keylen; gcry_error_t err = 0; @@ -562,6 +951,7 @@ check_one_cipher (algos[i], GCRY_CIPHER_MODE_ECB, 0); check_one_cipher (algos[i], GCRY_CIPHER_MODE_CFB, 0); + check_one_cipher (algos[i], GCRY_CIPHER_MODE_OFB, 0); check_one_cipher (algos[i], GCRY_CIPHER_MODE_CBC, 0); check_one_cipher (algos[i], GCRY_CIPHER_MODE_CBC, GCRY_CIPHER_CBC_CTS); check_one_cipher (algos[i], GCRY_CIPHER_MODE_CTR, 0); @@ -586,7 +976,7 @@ check_one_md (int algo, char *data, int len, char *expect) { gcry_md_hd_t hd, hd2; - char *p; + unsigned char *p; int mdlen; int i; gcry_error_t err = 0; @@ -1117,6 +1507,8 @@ check_aes128_cbc_cts_cipher (); check_cbc_mac_cipher (); check_ctr_cipher (); + check_cfb_cipher (); + check_ofb_cipher (); check_digests (); check_pubkey (); Modified: trunk/tests/benchmark.c =================================================================== --- trunk/tests/benchmark.c 2006-01-08 02:10:46 UTC (rev 1143) +++ trunk/tests/benchmark.c 2006-03-07 19:26:21 UTC (rev 1144) @@ -358,6 +358,7 @@ { GCRY_CIPHER_MODE_ECB, "ECB", 1 }, { GCRY_CIPHER_MODE_CBC, "CBC", 1 }, { GCRY_CIPHER_MODE_CFB, "CFB", 0 }, + { GCRY_CIPHER_MODE_OFB, "OFB", 0 }, { GCRY_CIPHER_MODE_CTR, "CTR", 0 }, { GCRY_CIPHER_MODE_STREAM, "STREAM", 0 }, {0} From cvs at cvs.gnupg.org Tue Mar 7 21:14:23 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Tue Mar 7 20:48:42 2006 Subject: [svn] GnuPG - r4042 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-07 21:14:20 +0100 (Tue, 07 Mar 2006) New Revision: 4042 Modified: trunk/g10/ChangeLog trunk/g10/gpg.c trunk/g10/mainproc.c trunk/g10/options.h trunk/g10/pkclist.c trunk/g10/trustdb.c Log: * options.h, gpg.c (main, parse_trust_model), pkclist.c (check_signatures_trust), mainproc.c (check_sig_and_print, pka_uri_from_sig), trustdb.c (init_trustdb): Some tweaks to PKA so that it is a verify-option now. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-07 16:20:03 UTC (rev 4041) +++ trunk/g10/ChangeLog 2006-03-07 20:14:20 UTC (rev 4042) @@ -1,3 +1,10 @@ +2006-03-07 David Shaw + + * options.h, gpg.c (main, parse_trust_model), pkclist.c + (check_signatures_trust), mainproc.c (check_sig_and_print, + pka_uri_from_sig), trustdb.c (init_trustdb): Some tweaks to PKA so + that it is a verify-option now. + 2006-03-07 Werner Koch * mainproc.c (proc_signature_packets): Return any_sig_seen to caller. Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2006-03-07 16:20:03 UTC (rev 4041) +++ trunk/g10/gpg.c 2006-03-07 20:14:20 UTC (rev 4042) @@ -243,7 +243,6 @@ oAlwaysTrust, oTrustModel, oForceOwnertrust, - oAllowPkaLookup, oRunAsShmCP, oSetFilename, oForYourEyesOnly, @@ -601,7 +600,6 @@ { oAlwaysTrust, "always-trust", 0, "@"}, { oTrustModel, "trust-model", 2, "@"}, { oForceOwnertrust, "force-ownertrust", 2, "@"}, - { oAllowPkaLookup, "allow-pka-lookup", 0, "@" }, { oRunAsShmCP, "run-as-shm-coprocess", 4, "@" }, { oSetFilename, "set-filename", 2, "@" }, { oForYourEyesOnly, "for-your-eyes-only", 0, "@" }, @@ -1452,7 +1450,6 @@ printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE); printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE); printf ("reader-port:%lu:\n", GC_OPT_FLAG_NONE); - printf ("allow-pka-lookup:%lu:\n", GC_OPT_FLAG_NONE); } @@ -1608,47 +1605,20 @@ static void parse_trust_model(const char *model) { - opt.pka_trust_increase = 0; if(ascii_strcasecmp(model,"pgp")==0) - { - opt.trust_model=TM_PGP; - } - else if(ascii_strcasecmp(model,"pgp+pka")==0) - { - opt.trust_model=TM_PGP; - opt.pka_trust_increase = 1; - } + opt.trust_model=TM_PGP; else if(ascii_strcasecmp(model,"classic")==0) - { - opt.trust_model=TM_CLASSIC; - } + opt.trust_model=TM_CLASSIC; else if(ascii_strcasecmp(model,"always")==0) - { - opt.trust_model=TM_ALWAYS; - } + opt.trust_model=TM_ALWAYS; else if(ascii_strcasecmp(model,"direct")==0) - { - opt.trust_model=TM_DIRECT; - } - else if(ascii_strcasecmp(model,"direct+pka")==0) - { - opt.trust_model=TM_DIRECT; - opt.pka_trust_increase = 1; - } + opt.trust_model=TM_DIRECT; else if(ascii_strcasecmp(model,"auto")==0) - { - opt.trust_model=TM_AUTO; - } - else if(ascii_strcasecmp(model,"auto+pka")==0) - { - opt.trust_model=TM_AUTO; - opt.pka_trust_increase = 1; - } + opt.trust_model=TM_AUTO; else log_error("unknown trust model `%s'\n",model); } - int main (int argc, char **argv ) { @@ -1740,7 +1710,6 @@ opt.verify_options= VERIFY_SHOW_POLICY_URLS|VERIFY_SHOW_STD_NOTATIONS|VERIFY_SHOW_KEYSERVER_URLS; opt.trust_model=TM_AUTO; - opt.pka_trust_increase=0; opt.mangle_dos_filenames=0; opt.min_cert_level=2; set_screen_dimensions(); @@ -2153,9 +2122,6 @@ opt.force_ownertrust=0; } break; - case oAllowPkaLookup: - opt.allow_pka_lookup = 1; - break; case oLoadExtension: #ifndef __riscos__ #if defined(USE_DYNAMIC_LINKING) || defined(_WIN32) @@ -2496,6 +2462,10 @@ N_("show user ID validity during signature verification")}, {"show-unusable-uids",VERIFY_SHOW_UNUSABLE_UIDS,NULL, N_("show revoked and expired user IDs in signature verification")}, + {"pka-lookup",VERIFY_PKA_LOOKUP,NULL, + N_("validate signatures with PKA data")}, + {"pka-trust-increase",VERIFY_PKA_TRUST_INCREASE,NULL, + N_("elevate the trust of signatures with valid PKA data")}, {NULL,0,NULL,NULL} }; Modified: trunk/g10/mainproc.c =================================================================== --- trunk/g10/mainproc.c 2006-03-07 16:20:03 UTC (rev 4041) +++ trunk/g10/mainproc.c 2006-03-07 20:14:20 UTC (rev 4042) @@ -1390,7 +1390,7 @@ assert (!sig->pka_info); sig->flags.pka_tried = 1; sig->pka_info = get_pka_address (sig); - if (sig->pka_info && opt.allow_pka_lookup) + if (sig->pka_info) { char *uri; @@ -1866,7 +1866,8 @@ if (!rc) { - pka_uri_from_sig (sig); /* Make sure PKA info is available. */ + if(opt.verify_options&VERIFY_PKA_LOOKUP) + pka_uri_from_sig (sig); /* Make sure PKA info is available. */ rc = check_signatures_trust( sig ); } Modified: trunk/g10/options.h =================================================================== --- trunk/g10/options.h 2006-03-07 16:20:03 UTC (rev 4041) +++ trunk/g10/options.h 2006-03-07 20:14:20 UTC (rev 4042) @@ -103,8 +103,6 @@ TM_CLASSIC=0, TM_PGP=1, TM_EXTERNAL=2, TM_ALWAYS, TM_DIRECT, TM_AUTO } trust_model; int force_ownertrust; - int pka_trust_increase; /* Valid PKA information increases the trust. */ - int allow_pka_lookup; /* PKA lookups are only done if this is set. */ enum { CO_GNUPG=0, CO_RFC2440, CO_RFC1991, CO_PGP2, CO_PGP6, CO_PGP7, CO_PGP8 @@ -316,6 +314,8 @@ #define VERIFY_SHOW_KEYSERVER_URLS (1<<4) #define VERIFY_SHOW_UID_VALIDITY (1<<5) #define VERIFY_SHOW_UNUSABLE_UIDS (1<<6) +#define VERIFY_PKA_LOOKUP (1<<7) +#define VERIFY_PKA_TRUST_INCREASE (1<<8) #define KEYSERVER_USE_TEMP_FILES (1<<0) #define KEYSERVER_KEEP_TEMP_FILES (1<<1) Modified: trunk/g10/pkclist.c =================================================================== --- trunk/g10/pkclist.c 2006-03-07 16:20:03 UTC (rev 4041) +++ trunk/g10/pkclist.c 2006-03-07 20:14:20 UTC (rev 4042) @@ -566,7 +566,7 @@ case TRUST_UNKNOWN: case TRUST_UNDEFINED: case TRUST_MARGINAL: - if (okay && opt.pka_trust_increase) + if (okay && opt.verify_options&VERIFY_PKA_TRUST_INCREASE) { trustlevel = ((trustlevel & ~TRUST_MASK) | TRUST_FULLY); log_info (_("trustlevel adjusted to FULL" Modified: trunk/g10/trustdb.c =================================================================== --- trunk/g10/trustdb.c 2006-03-07 16:20:03 UTC (rev 4041) +++ trunk/g10/trustdb.c 2006-03-07 20:14:20 UTC (rev 4042) @@ -450,12 +450,7 @@ } if(opt.verbose) - { - log_info(_("using %s trust model\n"),trust_model_string()); - if (opt.pka_trust_increase) - log_info(_("PKA verification is allowed to" - " leverage trust to full\n")); - } + log_info(_("using %s trust model\n"),trust_model_string()); } if(opt.trust_model==TM_PGP || opt.trust_model==TM_CLASSIC) From cvs at cvs.gnupg.org Tue Mar 7 22:47:37 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Tue Mar 7 22:21:54 2006 Subject: [svn] GnuPG - r4043 - trunk/doc Message-ID: Author: dshaw Date: 2006-03-07 22:47:36 +0100 (Tue, 07 Mar 2006) New Revision: 4043 Modified: trunk/doc/ChangeLog trunk/doc/gpg.sgml Log: * gpg.sgml: Document new way of enabling the PKA functions. Some minor other cleanups. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-03-07 20:14:20 UTC (rev 4042) +++ trunk/doc/ChangeLog 2006-03-07 21:47:36 UTC (rev 4043) @@ -1,3 +1,8 @@ +2006-03-07 David Shaw + + * gpg.sgml: Document new way of enabling the PKA functions. Some + minor other cleanups. + 2006-03-06 David Shaw * gpg.sgml: Document --auto-key-locate. Modified: trunk/doc/gpg.sgml =================================================================== --- trunk/doc/gpg.sgml 2006-03-07 20:14:20 UTC (rev 4042) +++ trunk/doc/gpg.sgml 2006-03-07 21:47:36 UTC (rev 4043) @@ -1200,12 +1200,6 @@ trust database. -pgp+pka -Same as pka but a valid PKA will increase the trust to full. -Note, that the option --allow-pka-lookup needs to be -enabled to actually make this work. - - classic This is the standard Web of Trust as used in PGP 2.x and earlier. @@ -1215,29 +1209,20 @@ Web of Trust. -direct+pka -Same as direct but a valid PKA will increase the trust to full. - - always Skip key validation and assume that used keys are always fully -trusted. You won't use this unless you have installed some external -validation scheme. This option also suppresses the "[uncertain]" tag -printed with signature checks when there is no evidence that the user -ID is bound to the key. +trusted. You generally won't use this unless you are using some +external validation scheme. This option also suppresses the +"[uncertain]" tag printed with signature checks when there is no +evidence that the user ID is bound to the key. auto Select the trust model depending on whatever the internal trust database says. This is the default model if such a database already -exists. Note, this won't enable the PKA sub model. +exists. -auto+pka -Select the trust model depending on whatever the internal trust -database says and enable the PKA sub model. - - @@ -1248,9 +1233,8 @@ --auto-key-locate parameters - +--no-auto-key-locate - GnuPG can automatically locate and retrieve keys as needed using this option. This happens when encrypting to an email address (in the "user@example.com" form), and there are no user@example.com keys on @@ -1288,16 +1272,6 @@ ---allow-pka-lookup - -This option enables PKA lookups. PKA is based on DNS; thus enabling -this option may disclose information on when and what signatures are verified -or to whom data is encrypted. This is similar to the "web bug" -described for the auto-key-retrieve feature. - - - - --keyid-format short|0xshort|long|0xlong Select how to display key IDs. "short" is the traditional 8-character @@ -1349,7 +1323,7 @@ keyservers this option is meaningless. Note also that most keyservers do not have cryptographic verification of key revocations, and so turning this option off may result in skipping keys that are -incorrectly marked as revoked. Defaults to on. +incorrectly marked as revoked. @@ -1361,14 +1335,38 @@ +auto-key-retrieve + +This option enables the automatic retrieving of keys from a keyserver +when verifying signatures made by keys that are not on the local +keyring. + +Note that this option makes a "web bug" like behavior possible. +Keyserver operators can see which keys you request, so by sending you +a message signed by a brand new key (which you naturally will not have +on your local keyring), the operator can tell both your IP address and +the time when you verified the signature. + + + honor-keyserver-url When using --refresh-keys, if the key in question has a preferred -keyserver set, then use that preferred keyserver to refresh the key -from. Defaults to yes. +keyserver URL, then use that preferred keyserver to refresh the key +from. In addition, if auto-key-retrieve is set, and the signature +being verified has a preferred keyserver URL, then use that preferred +keyserver to fetch the key from. Defaults to yes. +honor-pka-record + +If auto-key-retrieve is set, and the signature being verified has a +PKA record, then use the PKA information to fetch the key. Defaults +to yes. + + + include-subkeys When receiving a key, include subkeys as potential targets. Note that @@ -1421,32 +1419,6 @@ "http_proxy". - -auto-key-retrieve - -This option enables the automatic retrieving of keys from a keyserver -when verifying signatures made by keys that are not on the local -keyring. - -Note that this option makes a "web bug" like behavior possible. -Keyserver operators can see which keys you request, so by sending you -a message signed by a brand new key (which you naturally will not have -on your local keyring), the operator can tell both your IP address and -the time when you verified the signature. - - - -auto-pka-retrieve - -This option enables the automatic retrieving of missing keys through -information taken from PKA records in the DNS. Defaults to yes. -Note, that the option --allow-pka-lookup needs to be -enabled to actually make this work. - -By using this option, one may unintentionally disclose information -similar to the one described for auto-key-retrieve. - - @@ -1499,7 +1471,9 @@ import-minimal Import the smallest key possible. This removes all signatures except -the most recent self-signature on each user ID. Defaults to no. +the most recent self-signature on each user ID. This option is the +same as running the --edit-key command "minimize" after import. +Defaults to no. @@ -1552,15 +1526,18 @@ exported if the user IDs are not usable. Also, do not export any signatures that are not usable. This includes signatures that were issued by keys that are not present on the keyring. This option is -the same as running the --edit-key command "clean" before export. -Defaults to no. +the same as running the --edit-key command "clean" before export +except that the local copy of the key is not modified. Defaults to +no. export-minimal Export the smallest key possible. This removes all signatures except -the most recent self-signature on each user ID. Defaults to no. +the most recent self-signature on each user ID. This option is the +same as running the --edit-key command "minimize" before export except +that the local copy of the key is not modified. Defaults to no. @@ -1704,6 +1681,23 @@ Defaults to no. + +pka-lookups + +Enable PKA lookups to verify sender addresses. Note that PKA is based +on DNS, and so enabling this option may disclose information on when +and what signatures are verified or to whom data is encrypted. This +is similar to the "web bug" described for the auto-key-retrieve +feature. + + + +pka-trust-increase + +Raise the trust in a signature to full if the signature passes PKA +validation. This option is only meaningful if pka-lookups is set. + + @@ -2329,11 +2323,9 @@ --passphrase-fd &ParmN; -Read the passphrase from file descriptor &ParmN;. If you use -0 for &ParmN;, the passphrase will be read from stdin. This -can only be used if only one passphrase is supplied. - -Don't use this option if you can avoid it. +Read the passphrase from file descriptor &ParmN;. If you use 0 for +&ParmN;, the passphrase will be read from stdin. This can only be +used if only one passphrase is supplied. @@ -2341,8 +2333,8 @@ Read the passphrase from file &ParmFile;. This can only be used if only one passphrase is supplied. Obviously, a passphrase stored in a -file is of questionable security. Don't use this option if you can -avoid it. +file is of questionable security if other users can read this file. +Don't use this option if you can avoid it. @@ -2350,7 +2342,8 @@ Use &ParmString; as the passphrase. This can only be used if only one passphrase is supplied. Obviously, this is of very questionable -security. Don't use this option if you can avoid it. +security on a multi-user system. Don't use this option if you can +avoid it. @@ -3172,12 +3165,6 @@ be used to override it. -http_proxy -Only honored when the keyserver-option -honor-http-proxy is set. - - - COLUMNS LINES From cvs at cvs.gnupg.org Tue Mar 7 23:44:24 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Tue Mar 7 23:18:39 2006 Subject: [svn] GnuPG - r4044 - trunk/doc Message-ID: Author: dshaw Date: 2006-03-07 23:44:23 +0100 (Tue, 07 Mar 2006) New Revision: 4044 Modified: trunk/doc/ChangeLog trunk/doc/gpg.sgml Log: * gpg.sgml: Rename backsigs to cross-certification (backsigs is just shorthand). Document max-cert-size. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-03-07 21:47:36 UTC (rev 4043) +++ trunk/doc/ChangeLog 2006-03-07 22:44:23 UTC (rev 4044) @@ -1,5 +1,8 @@ 2006-03-07 David Shaw + * gpg.sgml: Rename backsigs to cross-certification (backsigs is + just shorthand). Document max-cert-size. + * gpg.sgml: Document new way of enabling the PKA functions. Some minor other cleanups. Modified: trunk/doc/gpg.sgml =================================================================== --- trunk/doc/gpg.sgml 2006-03-07 21:47:36 UTC (rev 4043) +++ trunk/doc/gpg.sgml 2006-03-07 22:44:23 UTC (rev 4044) @@ -528,7 +528,7 @@ Set a preferred keyserver for the specified user ID(s). This allows other users to know where you prefer they get your key from. See ---keyserver-option honor-keyserver-url for more on how this works. +--keyserver-options honor-keyserver-url for more on how this works. Note that some versions of PGP interpret the presence of a keyserver URL as an instruction to enable PGP/MIME mail encoding. Setting a value of "none" removes a existing preferred keyserver. @@ -557,11 +557,12 @@ -backsign +cross-certify -Add back signatures to signing subkeys that may not currently have -back signatures. Back signatures protect against a subtle attack -against signing subkeys. See --require-backsigs. +Add cross-certification signatures to signing subkeys that may not +currently have them. Cross-certification signatures protect against a +subtle attack against signing subkeys. See +--require-cross-certification. @@ -718,7 +719,7 @@ There are a few other options which control how this command works. -Most notable here is the --keyserver-option merge-only option which +Most notable here is the --keyserver-options merge-only option which does not insert new keys but does only the merging of new signatures, user-IDs and subkeys. @@ -739,7 +740,7 @@ signatures, user IDs, etc. Calling this with no arguments will refresh the entire keyring. Option --keyserver must be used to give the name of the keyserver for all keys that do not have preferred -keyservers set (see --keyserver-option honor-keyserver-url). +keyservers set (see --keyserver-options honor-keyserver-url). @@ -1399,7 +1400,7 @@ -timeout +timeout&OptEqualsValue; Tell the keyserver helper program how long (in seconds) to try and perform a keyserver action before giving up. Note that performing @@ -1415,10 +1416,17 @@ For HTTP-like keyserver schemes that (such as HKP and HTTP itself), try to access the keyserver over a proxy. If a &ParmValue; is specified, use this as the HTTP proxy. If no &ParmValue; is -specified, try to use the value of the environment variable -"http_proxy". +specified, the value of the environment variable "http_proxy", if any, +will be used. + +max-cert-size&OptEqualsValue; + +When retrieving a key via DNS CERT, only accept keys up to this size. +Defaults to 16384 bytes. + + @@ -2789,14 +2797,14 @@ ---require-backsigs ---no-require-backsigs +--require-cross-certification +--no-require-certification -When verifying a signature made from a subkey, ensure that the "back -signature" on the subkey is present and valid. This protects against -a subtle attack against subkeys that can sign. Currently defaults to ---no-require-backsigs, but will be changed to --require-backsigs in -the future. +When verifying a signature made from a subkey, ensure that the cross +certification "back signature" on the subkey is present and valid. +This protects against a subtle attack against subkeys that can sign. +Currently defaults to --no-require-cross-certification, but will be +changed to --require-cross-certification in the future. From cvs at cvs.gnupg.org Wed Mar 8 03:36:37 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed Mar 8 03:10:50 2006 Subject: [svn] GnuPG - r4045 - trunk Message-ID: Author: dshaw Date: 2006-03-08 03:36:37 +0100 (Wed, 08 Mar 2006) New Revision: 4045 Modified: trunk/ChangeLog trunk/NEWS Log: * NEWS: Note CERT retrieval. Tweak PKA and backsig language to match current code. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-07 22:44:23 UTC (rev 4044) +++ trunk/ChangeLog 2006-03-08 02:36:37 UTC (rev 4045) @@ -1,5 +1,8 @@ 2006-03-07 David Shaw + * NEWS: Note CERT retrieval. Tweak PKA and backsig language to + match current code. + * NEWS: Note --auto-key-locate and that keyservers can handle binary data now. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-07 22:44:23 UTC (rev 4044) +++ trunk/NEWS 2006-03-08 02:36:37 UTC (rev 4045) @@ -11,14 +11,11 @@ Note also that a future version of GnuPG will remove the old keyserver helpers altogether. - * Implemented Public Key Association (PKA) trust sub model. This - is an optional trust model on top of the standard ones. It make - use of special DNS records and notation data to associate a mail - address with an OpenPGP key. It is by default not used. To use - it you need to set the new option --allow-pka-lookup and an - appropriate trust-model. Also added new keyserver option - auto-pka-retrieve which is enabled by default but only working - if --allow-pka-lookup is also used. + * Implemented Public Key Association (PKA) signature verification. + This uses special DNS records and notation data to associate a + mail address with an OpenPGP key to prove that mail coming from + that address is legitimate without the need for a full trust + path to the signing key. * When exporting subkeys, those specified with a key ID or fingerpint and the '!' suffix are now merged into one keyblock. @@ -26,12 +23,12 @@ * Added "gpg-zip", a program to create encrypted archives that can interoperate with PGP Zip. - * Added support for signing subkey "back signatures". Requiring - back signatures to be present is currently off by default, but - will be changed to on by default in the future, once more keys - contain the back signature. A new "backsign" command in the - --edit-key menu can be used to update signing subkeys with back - signatures. + * Added support for signing subkey cross-certification "back + signatures". Requiring cross-certification to be present is + currently off by default, but will be changed to on by default + in the future, once more keys use it. A new "cross-certify" + command in the --edit-key menu can be used to update signing + subkeys to have cross-certification. * The key cleaning options for --import-options and --export-options have been further polished. "import-clean" and @@ -67,7 +64,10 @@ currently defined keyserver), as well as arbitrary keyserver URIs that will be contacted for the key. + * Able to retrieve keys using DNS CERT records as per RFC-2538bis + (currently in draft): http://www.josefsson.org/rfc2538bis + Noteworthy changes in version 1.4.2 (2005-07-26) ------------------------------------------------ From cvs at cvs.gnupg.org Wed Mar 8 03:40:44 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed Mar 8 03:14:57 2006 Subject: [svn] GnuPG - r4046 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-08 03:40:42 +0100 (Wed, 08 Mar 2006) New Revision: 4046 Modified: trunk/g10/ChangeLog trunk/g10/gpg.c trunk/g10/keyedit.c trunk/g10/mainproc.c trunk/g10/options.h trunk/g10/sig-check.c Log: * options.h, mainproc.c (check_sig_and_print), gpg.c (main): pka-lookups, not pka-lookup. * options.h, gpg.c (main), keyedit.c [cmds], sig-check.c (signature_check2): Rename "backsign" to "cross-certify" as a more accurate name. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-08 02:36:37 UTC (rev 4045) +++ trunk/g10/ChangeLog 2006-03-08 02:40:42 UTC (rev 4046) @@ -1,5 +1,12 @@ 2006-03-07 David Shaw + * options.h, mainproc.c (check_sig_and_print), gpg.c (main): + pka-lookups, not pka-lookup. + + * options.h, gpg.c (main), keyedit.c [cmds], sig-check.c + (signature_check2): Rename "backsign" to "cross-certify" as a more + accurate name. + * options.h, gpg.c (main, parse_trust_model), pkclist.c (check_signatures_trust), mainproc.c (check_sig_and_print, pka_uri_from_sig), trustdb.c (init_trustdb): Some tweaks to PKA so Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2006-03-08 02:36:37 UTC (rev 4045) +++ trunk/g10/gpg.c 2006-03-08 02:40:42 UTC (rev 4046) @@ -357,8 +357,8 @@ octapiDriver, opcscDriver, oDisableCCID, - oRequireBacksigs, - oNoRequireBacksigs, + oRequireCrossCert, + oNoRequireCrossCert, oAutoKeyLocate, oNoAutoKeyLocate, oAllowMultisigVerification, @@ -706,8 +706,10 @@ I'm returning the favor. */ { oLocalUser, "sign-with", 2, "@" }, { oRecipient, "user", 2, "@" }, - { oRequireBacksigs, "require-backsigs", 0, "@"}, - { oNoRequireBacksigs, "no-require-backsigs", 0, "@"}, + { oRequireCrossCert, "require-backsigs", 0, "@"}, + { oRequireCrossCert, "require-cross-certification", 0, "@"}, + { oNoRequireCrossCert, "no-require-backsigs", 0, "@"}, + { oNoRequireCrossCert, "no-require-cross-certification", 0, "@"}, { oAutoKeyLocate, "auto-key-locate", 2, "@"}, { oNoAutoKeyLocate, "no-auto-key-locate", 0, "@"}, {0,NULL,0,NULL} @@ -2462,7 +2464,7 @@ N_("show user ID validity during signature verification")}, {"show-unusable-uids",VERIFY_SHOW_UNUSABLE_UIDS,NULL, N_("show revoked and expired user IDs in signature verification")}, - {"pka-lookup",VERIFY_PKA_LOOKUP,NULL, + {"pka-lookups",VERIFY_PKA_LOOKUPS,NULL, N_("validate signatures with PKA data")}, {"pka-trust-increase",VERIFY_PKA_TRUST_INCREASE,NULL, N_("elevate the trust of signatures with valid PKA data")}, @@ -2625,8 +2627,8 @@ opt.limit_card_insert_tries = pargs.r.ret_int; break; - case oRequireBacksigs: opt.require_backsigs=1; break; - case oNoRequireBacksigs: opt.require_backsigs=0; break; + case oRequireCrossCert: opt.flags.require_cross_cert=1; break; + case oNoRequireCrossCert: opt.flags.require_cross_cert=0; break; case oAutoKeyLocate: if(!parse_auto_key_locate(pargs.r.ret_str)) Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2006-03-08 02:36:37 UTC (rev 4045) +++ trunk/g10/keyedit.c 2006-03-08 02:40:42 UTC (rev 4046) @@ -1363,6 +1363,7 @@ { "key" , cmdSELKEY , 0, N_("select subkey N") }, { "check" , cmdCHECK , 0, N_("check signatures") }, { "c" , cmdCHECK , 0, NULL }, + { "cross-certify", cmdBACKSIGN , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, NULL }, { "backsign", cmdBACKSIGN , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, NULL }, { "sign" , cmdSIGN , KEYEDIT_NOT_SK|KEYEDIT_TAIL_MATCH, N_("sign selected user IDs [* see below for related commands]") }, Modified: trunk/g10/mainproc.c =================================================================== --- trunk/g10/mainproc.c 2006-03-08 02:36:37 UTC (rev 4045) +++ trunk/g10/mainproc.c 2006-03-08 02:40:42 UTC (rev 4046) @@ -1866,7 +1866,7 @@ if (!rc) { - if(opt.verify_options&VERIFY_PKA_LOOKUP) + if(opt.verify_options&VERIFY_PKA_LOOKUPS) pka_uri_from_sig (sig); /* Make sure PKA info is available. */ rc = check_signatures_trust( sig ); } Modified: trunk/g10/options.h =================================================================== --- trunk/g10/options.h 2006-03-08 02:36:37 UTC (rev 4045) +++ trunk/g10/options.h 2006-03-08 02:40:42 UTC (rev 4046) @@ -215,10 +215,13 @@ int disable_ccid; /* Disable the use of the internal CCID driver. */ #endif /*ENABLE_CARD_SUPPORT*/ - /* If set, require an 0x19 backsig to be present on signatures made - by signing subkeys. If not set, a missing backsig is not an - error (but an invalid backsig still is). */ - int require_backsigs; + struct + { + /* If set, require an 0x19 backsig to be present on signatures + made by signing subkeys. If not set, a missing backsig is not + an error (but an invalid backsig still is). */ + unsigned int require_cross_cert:1; + } flags; /* Linked list of ways to find a key if the key isn't on the local keyring. */ @@ -314,7 +317,7 @@ #define VERIFY_SHOW_KEYSERVER_URLS (1<<4) #define VERIFY_SHOW_UID_VALIDITY (1<<5) #define VERIFY_SHOW_UNUSABLE_UIDS (1<<6) -#define VERIFY_PKA_LOOKUP (1<<7) +#define VERIFY_PKA_LOOKUPS (1<<7) #define VERIFY_PKA_TRUST_INCREASE (1<<8) #define KEYSERVER_USE_TEMP_FILES (1<<0) Modified: trunk/g10/sig-check.c =================================================================== --- trunk/g10/sig-check.c 2006-03-08 02:36:37 UTC (rev 4045) +++ trunk/g10/sig-check.c 2006-03-08 02:40:42 UTC (rev 4046) @@ -100,7 +100,7 @@ have backsigs, change this to always give the warning, and have --require-backsigs enable or disable the G10ERR_GENERAL. */ - if(pk->backsig==0 && opt.require_backsigs) + if(pk->backsig==0 && opt.flags.require_cross_cert) { log_info(_("WARNING: signing subkey %s is not" " cross-certified\n"),keystr_from_pk(pk)); From cvs at cvs.gnupg.org Wed Mar 8 10:11:36 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed Mar 8 09:45:51 2006 Subject: [svn] GnuPG - r4047 - in tags/V1-4-2: . checks g10 Message-ID: Author: wk Date: 2006-03-08 10:11:34 +0100 (Wed, 08 Mar 2006) New Revision: 4047 Modified: tags/V1-4-2/ChangeLog tags/V1-4-2/NEWS tags/V1-4-2/checks/ChangeLog tags/V1-4-2/checks/defs.inc tags/V1-4-2/checks/multisig.test tags/V1-4-2/checks/verify.test tags/V1-4-2/configure.ac tags/V1-4-2/g10/ChangeLog tags/V1-4-2/g10/g10.c tags/V1-4-2/g10/mainproc.c tags/V1-4-2/g10/options.h Log: Backported verification fixes from 1.4.3-cvs Modified: tags/V1-4-2/ChangeLog =================================================================== --- tags/V1-4-2/ChangeLog 2006-03-08 02:40:42 UTC (rev 4046) +++ tags/V1-4-2/ChangeLog 2006-03-08 09:11:34 UTC (rev 4047) @@ -1,3 +1,7 @@ +2006-03-08 Werner Koch + + Released 1.4.2.2. + 2006-02-14 Werner Koch Released 1.4.2.1. Modified: tags/V1-4-2/NEWS =================================================================== --- tags/V1-4-2/NEWS 2006-03-08 02:40:42 UTC (rev 4046) +++ tags/V1-4-2/NEWS 2006-03-08 09:11:34 UTC (rev 4047) @@ -1,3 +1,12 @@ +Noteworthy changes in version 1.4.2.2 (2006-03-08) +-------------------------------------------------- + + * Files containing several signed messages are not allowed any + longer as there is no clean way to report the status of such + files back to the caller. To partly revert to the old behaviour + the new option --allow-multisig-verification may be used. + + Noteworthy changes in version 1.4.2.1 (2006-02-14) -------------------------------------------------- Modified: tags/V1-4-2/checks/ChangeLog =================================================================== --- tags/V1-4-2/checks/ChangeLog 2006-03-08 02:40:42 UTC (rev 4046) +++ tags/V1-4-2/checks/ChangeLog 2006-03-08 09:11:34 UTC (rev 4047) @@ -1,3 +1,9 @@ +2006-03-08 Werner Koch + + * verify.test: More tests + * multisig.test: Adjusted. + * defs.inc: A few more support functions. + 2005-06-21 Werner Koch * conventional.test (algos): Uhh ohh, cut+paste error and not Modified: tags/V1-4-2/checks/defs.inc =================================================================== --- tags/V1-4-2/checks/defs.inc 2006-03-08 02:40:42 UTC (rev 4046) +++ tags/V1-4-2/checks/defs.inc 2006-03-08 09:11:34 UTC (rev 4047) @@ -31,25 +31,55 @@ LC_ALL= LC_MESSAGES= +# Internal use. +defs_stop_on_error=no +defs_error_seen=no + #-------------------------------- #------ utility functions ------- #-------------------------------- fatal () { echo "$pgmname: fatal:" $* >&2 + [ -n "${BASH_VERSION+set}" ] && echo "$pgmname: fatal:" $* >&5 exit 1; } error () { echo "$pgmname:" $* >&2 - exit 1 + defs_error_seen=yes + [ -n "${BASH_VERSION+set}" ] && echo "$pgmname:" $* >&5 + if [ x$defs_stop_on_error != xyes ]; then + exit 1 + fi } +# Call this at the start of a test and resume_error at the end to keep +# on running all subtests without immediately exiting on error. +suspend_error () { + defs_stop_on_error=yes +} + +resume_error () { + if [ x$defs_error_seen = xyes ]; then + exit 1 + fi + defs_stop_on_error=no + defs_error_seen=no +} + info () { echo "$pgmname:" $* >&2 + if [ -n "${verbose+set}" ]; then + [ -n "${BASH_VERSION+set}" ] && echo "$pgmname:" $* >&5 + fi } +linefeed () { + echo >&2 +} + echo_n_init=no echo_n () { if test "$echo_n_init" = "no"; then @@ -126,6 +156,8 @@ GPG="../g10/gpg --no-permission-warning --homedir . " +[ -n "${BASH_VERSION+set}" ] && exec 5>/dev/stderr + exec 2> ${pgmname}.log : Modified: tags/V1-4-2/checks/multisig.test =================================================================== --- tags/V1-4-2/checks/multisig.test 2006-03-08 02:40:42 UTC (rev 4046) +++ tags/V1-4-2/checks/multisig.test 2006-03-08 09:11:34 UTC (rev 4047) @@ -2,13 +2,15 @@ # Check that gpg verifies only signatures where there is no ambiguity # in the order of packets. Needs the Demo Keys Lima and Mike. +# Note: We do son't support multiple signaturess anymore thus thsi test is +# not really needed becuase verify could do the same. We keep it anyway. + . $srcdir/defs.inc || exit 3 -# (variable intialization was created using: -# for i in files; do echo "`echo $i | sed 's,[.-],_,g'`='"; \ -# gpg --no-version --enarmor <$i | grep -v ^Comment:; echo "'" ; done -# ) +suspend_error + + sig_1ls1ls_valid=' -----BEGIN PGP ARMORED FILE----- @@ -119,13 +121,11 @@ -----END PGP ARMORED FILE----- ' -save_IFS="${IFS}" -IFS="" -for i in "$sig_1ls1ls_valid" "$sig_ls_valid" "$sig_sl_valid"; do - echo "$i" | ./gpg_dearmor >x - IFS="${save_IFS}" - $GPG --verify x 2>/dev/null || error "valid is invalid" - IFS="" + +for i in sig_sl_valid ; do + eval "(IFS=; echo \"\$$i\")" | ./gpg_dearmor >x + $GPG --verify x 2>/dev/null || error "valid is invalid ($i)" + linefeed done #for i in "$sig_11lss_valid_but_is_not" "$sig_11lss11lss_valid_but_is_not" \ # "$sig_ssl_valid_but_is_not"; do @@ -133,13 +133,13 @@ # $GPG --verify /dev/null || error "valid is invalid" #done -# without the +e ksh seems to terminate the for loop -set +e -for i in "$sig_1lsls_invalid" "$sig_lsls_invalid" \ - "$sig_lss_invalid" "$sig_slsl_invalid" ; do - echo "$i" | ./gpg_dearmor >x - IFS="${save_IFS}" - $GPG --verify /dev/null && error "invalid is valid" - IFS="" +for i in sig_1ls1ls_valid sig_ls_valid \ + sig_1lsls_invalid sig_lsls_invalid \ + sig_lss_invalid sig_slsl_invalid ; do + eval "(IFS=; echo \"\$$i\")" | ./gpg_dearmor >x + $GPG --verify /dev/null && error "invalid is valid ($i)" + linefeed done -IFS="${save_IFS}" + + +resume_error \ No newline at end of file Modified: tags/V1-4-2/checks/verify.test =================================================================== --- tags/V1-4-2/checks/verify.test 2006-03-08 02:40:42 UTC (rev 4046) +++ tags/V1-4-2/checks/verify.test 2006-03-08 09:11:34 UTC (rev 4047) @@ -2,10 +2,251 @@ . $srcdir/defs.inc || exit 3 -#info check that verify fails for bad input data +suspend_error + +# +# Two simple tests to check that verify fails for bad input data +# +info "checking bogus signature 1" ../tools/mk-tdata --char 0x2d 64 >x $GPG --verify x data-500 && error "no error code from verify" +info "checking bogus signature 2" ../tools/mk-tdata --char 0xca 64 >x $GPG --verify x data-500 && error "no error code from verify" -exit 0 +linefeed + +# A variable to collect the test names +tests="" + +# A plain signed message created using +# echo abc | gpg --homedir . --passphrase-fd 0 -u Alpha -z0 -sa msg +tests="$tests msg_ols_asc" +msg_ols_asc='-----BEGIN PGP MESSAGE----- + +kA0DAAIRLXJ8x2hpdzQBrQEHYgNtc2dEDFJaSSB0aGluayB0aGF0IGFsbCByaWdo +dC10aGlua2luZyBwZW9wbGUgaW4gdGhpcyBjb3VudHJ5IGFyZSBzaWNrIGFuZAp0 +aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgb3JkaW5hcnkgZGVjZW50IHBlb3BsZSBh +cmUgZmVkIHVwIGluIHRoaXMKY291bnRyeSB3aXRoIGJlaW5nIHNpY2sgYW5kIHRp +cmVkLiAgSSdtIGNlcnRhaW5seSBub3QuICBCdXQgSSdtCnNpY2sgYW5kIHRpcmVk +IG9mIGJlaW5nIHRvbGQgdGhhdCBJIGFtLgotIE1vbnR5IFB5dGhvbgqIPwMFAEQM +UlotcnzHaGl3NBECR4IAoJlEGTY+bHjD2HYuCixLQCmk01pbAKCIjkzLOAmkZNm0 +D8luT78c/1x45Q== +=a29i +-----END PGP MESSAGE-----' + +# A plain signed message created using +# echo abc | gpg --homedir . --passphrase-fd 0 -u Alpha -sa msg +tests="$tests msg_cols_asc" +msg_cols_asc='-----BEGIN PGP MESSAGE----- + +owGbwMvMwCSoW1RzPCOz3IRxLSN7EnNucboLT6Cgp0JJRmZeNpBMLFFIzMlRKMpM +zyjRBQtm5qUrFKTmF+SkKmTmgdQVKyTnl+aVFFUqJBalKhRnJmcrJOalcJVkFqWm +KOSnKSSlgrSU5OekQMzLL0rJzEsEKk9JTU7NK4EZBtKcBtRRWgAzlwtmbnlmSQbU +GJjxCmDj9RQUPNVzFZJTi0oSM/NyKhXy8kuAYk6lJSBxLlTF2NziqZCYq8elq+Cb +n1dSqRBQWZKRn8fVYc/MygAKBljYCDIFiTDMT+9seu836Q+bevyHTJ0dzPNuvCjn +ZpgrwX38z58rJsfYDhwOSS4SkN/d6vUAAA== +=s6sY +-----END PGP MESSAGE-----' + +# A PGP 2 style message. +tests="$tests msg_sl_asc" +msg_sl_asc='-----BEGIN PGP MESSAGE----- + +iD8DBQBEDFJaLXJ8x2hpdzQRAkeCAKCZRBk2Pmx4w9h2LgosS0AppNNaWwCgiI5M +yzgJpGTZtA/Jbk+/HP9ceOWtAQdiA21zZ0QMUlpJIHRoaW5rIHRoYXQgYWxsIHJp +Z2h0LXRoaW5raW5nIHBlb3BsZSBpbiB0aGlzIGNvdW50cnkgYXJlIHNpY2sgYW5k +CnRpcmVkIG9mIGJlaW5nIHRvbGQgdGhhdCBvcmRpbmFyeSBkZWNlbnQgcGVvcGxl +IGFyZSBmZWQgdXAgaW4gdGhpcwpjb3VudHJ5IHdpdGggYmVpbmcgc2ljayBhbmQg +dGlyZWQuICBJJ20gY2VydGFpbmx5IG5vdC4gIEJ1dCBJJ20Kc2ljayBhbmQgdGly +ZWQgb2YgYmVpbmcgdG9sZCB0aGF0IEkgYW0uCi0gTW9udHkgUHl0aG9uCg== +=0ukK +-----END PGP MESSAGE-----' + +# An OpenPGP message lacking the onepass packet. We used to accept +# such messages but now consider them invalid. +tests="$tests bad_ls_asc" +bad_ls_asc='-----BEGIN PGP MESSAGE----- + +rQEHYgNtc2dEDFJaSSB0aGluayB0aGF0IGFsbCByaWdodC10aGlua2luZyBwZW9w +bGUgaW4gdGhpcyBjb3VudHJ5IGFyZSBzaWNrIGFuZAp0aXJlZCBvZiBiZWluZyB0 +b2xkIHRoYXQgb3JkaW5hcnkgZGVjZW50IHBlb3BsZSBhcmUgZmVkIHVwIGluIHRo +aXMKY291bnRyeSB3aXRoIGJlaW5nIHNpY2sgYW5kIHRpcmVkLiAgSSdtIGNlcnRh +aW5seSBub3QuICBCdXQgSSdtCnNpY2sgYW5kIHRpcmVkIG9mIGJlaW5nIHRvbGQg +dGhhdCBJIGFtLgotIE1vbnR5IFB5dGhvbgqIPwMFAEQMUlotcnzHaGl3NBECR4IA +oJlEGTY+bHjD2HYuCixLQCmk01pbAKCIjkzLOAmkZNm0D8luT78c/1x45Q== +=Mpiu +-----END PGP MESSAGE-----' + + +# A signed message prefixed with an unsigned literal packet. +# (fols = faked-literal-data, one-pass, literal-data, signature) +# This should throw an error because running gpg to extract the +# signed data will return both literal data packets +tests="$tests bad_fols_asc" +bad_fols_asc='-----BEGIN PGP MESSAGE----- + +rF1iDG1zZy51bnNpZ25lZEQMY0x0aW1lc2hhcmluZywgbjoKCUFuIGFjY2VzcyBt +ZXRob2Qgd2hlcmVieSBvbmUgY29tcHV0ZXIgYWJ1c2VzIG1hbnkgcGVvcGxlLgqQ +DQMAAhEtcnzHaGl3NAGtAQdiA21zZ0QMUlpJIHRoaW5rIHRoYXQgYWxsIHJpZ2h0 +LXRoaW5raW5nIHBlb3BsZSBpbiB0aGlzIGNvdW50cnkgYXJlIHNpY2sgYW5kCnRp +cmVkIG9mIGJlaW5nIHRvbGQgdGhhdCBvcmRpbmFyeSBkZWNlbnQgcGVvcGxlIGFy +ZSBmZWQgdXAgaW4gdGhpcwpjb3VudHJ5IHdpdGggYmVpbmcgc2ljayBhbmQgdGly +ZWQuICBJJ20gY2VydGFpbmx5IG5vdC4gIEJ1dCBJJ20Kc2ljayBhbmQgdGlyZWQg +b2YgYmVpbmcgdG9sZCB0aGF0IEkgYW0uCi0gTW9udHkgUHl0aG9uCog/AwUARAxS +Wi1yfMdoaXc0EQJHggCgmUQZNj5seMPYdi4KLEtAKaTTWlsAoIiOTMs4CaRk2bQP +yW5Pvxz/XHjl +=UNM4 +-----END PGP MESSAGE-----' + +# A signed message suffixed with an unsigned literal packet. +# (fols = faked-literal-data, one-pass, literal-data, signature) +# This should throw an error because running gpg to extract the +# signed data will return both literal data packets +tests="$tests bad_olsf_asc" +bad_olsf_asc='-----BEGIN PGP MESSAGE----- + +kA0DAAIRLXJ8x2hpdzQBrQEHYgNtc2dEDFJaSSB0aGluayB0aGF0IGFsbCByaWdo +dC10aGlua2luZyBwZW9wbGUgaW4gdGhpcyBjb3VudHJ5IGFyZSBzaWNrIGFuZAp0 +aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgb3JkaW5hcnkgZGVjZW50IHBlb3BsZSBh +cmUgZmVkIHVwIGluIHRoaXMKY291bnRyeSB3aXRoIGJlaW5nIHNpY2sgYW5kIHRp +cmVkLiAgSSdtIGNlcnRhaW5seSBub3QuICBCdXQgSSdtCnNpY2sgYW5kIHRpcmVk +IG9mIGJlaW5nIHRvbGQgdGhhdCBJIGFtLgotIE1vbnR5IFB5dGhvbgqIPwMFAEQM +UlotcnzHaGl3NBECR4IAoJlEGTY+bHjD2HYuCixLQCmk01pbAKCIjkzLOAmkZNm0 +D8luT78c/1x45axdYgxtc2cudW5zaWduZWREDGNMdGltZXNoYXJpbmcsIG46CglB +biBhY2Nlc3MgbWV0aG9kIHdoZXJlYnkgb25lIGNvbXB1dGVyIGFidXNlcyBtYW55 +IHBlb3BsZS4K +=3gnG +-----END PGP MESSAGE-----' + + +# Two standard signed messages in a row +tests="$tests msg_olsols_asc_multisig" +msg_olsols_asc_multisig='-----BEGIN PGP MESSAGE----- + +kA0DAAIRLXJ8x2hpdzQBrQEHYgNtc2dEDFJaSSB0aGluayB0aGF0IGFsbCByaWdo +dC10aGlua2luZyBwZW9wbGUgaW4gdGhpcyBjb3VudHJ5IGFyZSBzaWNrIGFuZAp0 +aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgb3JkaW5hcnkgZGVjZW50IHBlb3BsZSBh +cmUgZmVkIHVwIGluIHRoaXMKY291bnRyeSB3aXRoIGJlaW5nIHNpY2sgYW5kIHRp +cmVkLiAgSSdtIGNlcnRhaW5seSBub3QuICBCdXQgSSdtCnNpY2sgYW5kIHRpcmVk +IG9mIGJlaW5nIHRvbGQgdGhhdCBJIGFtLgotIE1vbnR5IFB5dGhvbgqIPwMFAEQM +UlotcnzHaGl3NBECR4IAoJlEGTY+bHjD2HYuCixLQCmk01pbAKCIjkzLOAmkZNm0 +D8luT78c/1x45ZANAwACES1yfMdoaXc0Aa0BB2IDbXNnRAxSWkkgdGhpbmsgdGhh +dCBhbGwgcmlnaHQtdGhpbmtpbmcgcGVvcGxlIGluIHRoaXMgY291bnRyeSBhcmUg +c2ljayBhbmQKdGlyZWQgb2YgYmVpbmcgdG9sZCB0aGF0IG9yZGluYXJ5IGRlY2Vu +dCBwZW9wbGUgYXJlIGZlZCB1cCBpbiB0aGlzCmNvdW50cnkgd2l0aCBiZWluZyBz +aWNrIGFuZCB0aXJlZC4gIEknbSBjZXJ0YWlubHkgbm90LiAgQnV0IEknbQpzaWNr +IGFuZCB0aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgSSBhbS4KLSBNb250eSBQeXRo +b24KiD8DBQBEDFJaLXJ8x2hpdzQRAkeCAKCZRBk2Pmx4w9h2LgosS0AppNNaWwCg +iI5MyzgJpGTZtA/Jbk+/HP9ceOU= +=8nLN +-----END PGP MESSAGE-----' + +# A standard message with two signatures (actually the same signature +# duplicated). +tests="$tests msg_oolss_asc" +msg_oolss_asc='-----BEGIN PGP MESSAGE----- + +kA0DAAIRLXJ8x2hpdzQBkA0DAAIRLXJ8x2hpdzQBrQEHYgNtc2dEDFJaSSB0aGlu +ayB0aGF0IGFsbCByaWdodC10aGlua2luZyBwZW9wbGUgaW4gdGhpcyBjb3VudHJ5 +IGFyZSBzaWNrIGFuZAp0aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgb3JkaW5hcnkg +ZGVjZW50IHBlb3BsZSBhcmUgZmVkIHVwIGluIHRoaXMKY291bnRyeSB3aXRoIGJl +aW5nIHNpY2sgYW5kIHRpcmVkLiAgSSdtIGNlcnRhaW5seSBub3QuICBCdXQgSSdt +CnNpY2sgYW5kIHRpcmVkIG9mIGJlaW5nIHRvbGQgdGhhdCBJIGFtLgotIE1vbnR5 +IFB5dGhvbgqIPwMFAEQMUlotcnzHaGl3NBECR4IAoJlEGTY+bHjD2HYuCixLQCmk +01pbAKCIjkzLOAmkZNm0D8luT78c/1x45Yg/AwUARAxSWi1yfMdoaXc0EQJHggCg +mUQZNj5seMPYdi4KLEtAKaTTWlsAoIiOTMs4CaRk2bQPyW5Pvxz/XHjl +=KVw5 +-----END PGP MESSAGE-----' + +# A standard message with two one-pass packet but only one signature +# packet +tests="$tests bad_ools_asc" +bad_ools_asc='-----BEGIN PGP MESSAGE----- + +kA0DAAIRLXJ8x2hpdzQBkA0DAAIRLXJ8x2hpdzQBrQEHYgNtc2dEDFJaSSB0aGlu +ayB0aGF0IGFsbCByaWdodC10aGlua2luZyBwZW9wbGUgaW4gdGhpcyBjb3VudHJ5 +IGFyZSBzaWNrIGFuZAp0aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgb3JkaW5hcnkg +ZGVjZW50IHBlb3BsZSBhcmUgZmVkIHVwIGluIHRoaXMKY291bnRyeSB3aXRoIGJl +aW5nIHNpY2sgYW5kIHRpcmVkLiAgSSdtIGNlcnRhaW5seSBub3QuICBCdXQgSSdt +CnNpY2sgYW5kIHRpcmVkIG9mIGJlaW5nIHRvbGQgdGhhdCBJIGFtLgotIE1vbnR5 +IFB5dGhvbgqIPwMFAEQMUlotcnzHaGl3NBECR4IAoJlEGTY+bHjD2HYuCixLQCmk +01pbAKCIjkzLOAmkZNm0D8luT78c/1x45Q== +=1/ix +-----END PGP MESSAGE-----' + +# Standard cleartext signature +tests="$tests msg_cls_asc" +msg_cls_asc=`cat <x + case "$i" in + msg_*_asc) + $GPG --verify x || error "verify of $i failed" + ;; + msg_*_asc_multisig) + $GPG --verify --allow-multisig-verification x \ + || error "verify of $i failed" + $GPG --verify x && error "verify of $i succeeded but should not" + ;; + bad_*_asc) + $GPG --verify x && error "verify of $i succeeded but should not" + ;; + *) + error "No handler for test case $i" + ;; + esac + linefeed +done + + +resume_error Modified: tags/V1-4-2/configure.ac =================================================================== --- tags/V1-4-2/configure.ac 2006-03-08 02:40:42 UTC (rev 4046) +++ tags/V1-4-2/configure.ac 2006-03-08 09:11:34 UTC (rev 4047) @@ -26,7 +26,7 @@ # Remember to change the version number immediately *after* a release # and remove the "-cvs" or "rc" suffix immediately *before* a release. -AC_INIT(gnupg, 1.4.2.1, bug-gnupg@gnu.org) +AC_INIT(gnupg, 1.4.2.2, bug-gnupg@gnu.org) # Set development_version to yes if the minor number is odd or you # feel that the default check for a development version is not # sufficient. Modified: tags/V1-4-2/g10/ChangeLog =================================================================== --- tags/V1-4-2/g10/ChangeLog 2006-03-08 02:40:42 UTC (rev 4046) +++ tags/V1-4-2/g10/ChangeLog 2006-03-08 09:11:34 UTC (rev 4047) @@ -1,3 +1,14 @@ +2006-03-08 Werner Koch + + * mainproc.c (proc_signature_packets): Return any_sig_seen to + caller. + (check_sig_and_print): Made the composition test more tight. This + is due to another bug report by Tavis Ormandy. + (add_onepass_sig): Simplified. + (do_check_sig): Use log_error for standalone revocations. + * g10.c: New option --allow-multisig-verification. + * options.h (struct): Add allow_multisig_verification. + 2005-07-26 Werner Koch * passphrase.c (agent_get_passphrase): Make sure to release the Modified: tags/V1-4-2/g10/g10.c =================================================================== --- tags/V1-4-2/g10/g10.c 2006-03-08 02:40:42 UTC (rev 4046) +++ tags/V1-4-2/g10/g10.c 2006-03-08 09:11:34 UTC (rev 4047) @@ -354,6 +354,8 @@ opcscDriver, oDisableCCID, + oAllowMultisigVerification, + oNoop }; @@ -679,6 +681,7 @@ { oKeyidFormat, "keyid-format", 2, "@" }, { oExitOnStatusWriteError, "exit-on-status-write-error", 0, "@" }, { oLimitCardInsertTries, "limit-card-insert-tries", 1, "@"}, + { oAllowMultisigVerification, "allow-multisig-verification", 0, "@"}, { oReaderPort, "reader-port", 2, "@"}, { octapiDriver, "ctapi-driver", 2, "@"}, @@ -2554,6 +2557,9 @@ opt.limit_card_insert_tries = pargs.r.ret_int; break; + case oAllowMultisigVerification: + opt.allow_multisig_verification = 1; + break; case oNoop: break; Modified: tags/V1-4-2/g10/mainproc.c =================================================================== --- tags/V1-4-2/g10/mainproc.c 2006-03-08 02:40:42 UTC (rev 4046) +++ tags/V1-4-2/g10/mainproc.c 2006-03-08 09:11:34 UTC (rev 4047) @@ -112,27 +112,14 @@ static int add_onepass_sig( CTX c, PACKET *pkt ) { - KBNODE node; + KBNODE node; - if( c->list ) { /* add another packet */ - /* We can only append another onepass packet if the list - * does contain only onepass packets */ - for( node=c->list; node && node->pkt->pkttype == PKT_ONEPASS_SIG; - node = node->next ) - ; - if( node ) { - /* this is not the case, so we flush the current thing and - * allow this packet to start a new verification thing */ - release_list( c ); - c->list = new_kbnode( pkt ); - } - else - add_kbnode( c->list, new_kbnode( pkt )); - } - else /* insert the first one */ - c->list = node = new_kbnode( pkt ); + if ( c->list ) /* add another packet */ + add_kbnode( c->list, new_kbnode( pkt )); + else /* insert the first one */ + c->list = node = new_kbnode( pkt ); - return 1; + return 1; } @@ -802,8 +789,8 @@ return check_key_signature( c->list, node, is_selfsig ); } else if( sig->sig_class == 0x20 ) { - log_info(_("standalone revocation - " - "use \"gpg --import\" to apply\n")); + log_error (_("standalone revocation - " + "use \"gpg --import\" to apply\n")); return G10ERR_NOT_PROCESSED; } else { @@ -1151,6 +1138,13 @@ log_error (_("no signature found\n")); rc = G10ERR_NO_DATA; } + + /* Propagate the signature seen flag upward. Do this only on + success so that we won't issue the nodata status several + times. */ + if (!rc && c->anchor && c->any_sig_seen) + c->anchor->any_sig_seen = 1; + m_free( c ); return rc; } @@ -1313,70 +1307,120 @@ static int check_sig_and_print( CTX c, KBNODE node ) { - PKT_signature *sig = node->pkt->pkt.signature; - const char *astr; - int rc, is_expkey=0, is_revkey=0; + PKT_signature *sig = node->pkt->pkt.signature; + const char *astr; + int rc, is_expkey=0, is_revkey=0; - if( opt.skip_verify ) { - log_info(_("signature verification suppressed\n")); - return 0; + if (opt.skip_verify) + { + log_info(_("signature verification suppressed\n")); + return 0; } - /* It is not in all cases possible to check multiple signatures: - * PGP 2 (which is also allowed by OpenPGP), does use the packet - * sequence: sig+data, OpenPGP does use onepas+data=sig and GnuPG - * sometimes uses (because I did'nt read the specs right) data+sig. - * Because it is possible to create multiple signatures with - * different packet sequence (e.g. data+sig and sig+data) it might - * not be possible to get it right: let's say we have: - * data+sig, sig+data,sig+data and we have not yet encountered the last - * data, we could also see this a one data with 2 signatures and then - * data+sig. - * To protect against this we check that all signatures follow - * without any intermediate packets. Note, that we won't get this - * error when we use onepass packets or cleartext signatures because - * we reset the list every time - * - * FIXME: Now that we have these marker packets, we should create a - * real grammar and check against this. - */ - { - KBNODE n; - int n_sig=0; + /* Check that the message composition is valid. - for (n=c->list; n; n=n->next ) { - if ( n->pkt->pkttype == PKT_SIGNATURE ) - n_sig++; - } - if (n_sig > 1) { /* more than one signature - check sequence */ - int tmp, onepass; + Per RFC-2440bis (-15) allowed: - for (tmp=onepass=0,n=c->list; n; n=n->next ) { - if (n->pkt->pkttype == PKT_ONEPASS_SIG) - onepass++; - else if (n->pkt->pkttype == PKT_GPG_CONTROL - && n->pkt->pkt.gpg_control->control - == CTRLPKT_CLEARSIGN_START ) { - onepass++; /* handle the same way as a onepass */ - } - else if ( (tmp && n->pkt->pkttype != PKT_SIGNATURE) ) { - log_error(_("can't handle these multiple signatures\n")); - return 0; - } - else if ( n->pkt->pkttype == PKT_SIGNATURE ) - tmp = 1; - else if (!tmp && !onepass - && n->pkt->pkttype == PKT_GPG_CONTROL - && n->pkt->pkt.gpg_control->control - == CTRLPKT_PLAINTEXT_MARK ) { - /* plaintext before signatures but no one-pass packets*/ - log_error(_("can't handle these multiple signatures\n")); - return 0; - } - } - } - } + S{1,n} -- detached signature. + S{1,n} P -- old style PGP2 signature + O{1,n} P S{1,n} -- standard OpenPGP signature. + C P S{1,n} -- cleartext signature. + + O = One-Pass Signature packet. + S = Signature packet. + P = OpenPGP Message packet (Encrypted | Compressed | Literal) + (Note that the current rfc2440bis draft also allows + for a signed message but that does not work as it + introduces ambiguities.) + We keep track of these packages using the marker packet + CTRLPKT_PLAINTEXT_MARK. + C = Marker packet for cleartext signatures. + + We reject all other messages. + + Actually we are calling this too often, i.e. for verification of + each message but better have some duplicate work than to silently + introduce a bug here. + */ + { + KBNODE n; + int n_onepass, n_sig; + +/* log_debug ("checking signature packet composition\n"); */ +/* dump_kbnode (c->list); */ + + n = c->list; + assert (n); + if ( n->pkt->pkttype == PKT_SIGNATURE ) + { + /* This is either "S{1,n}" case (detached signature) or + "S{1,n} P" (old style PGP2 signature). */ + for (n = n->next; n; n = n->next) + if (n->pkt->pkttype != PKT_SIGNATURE) + break; + if (!n) + ; /* Okay, this is a detached signature. */ + else if (n->pkt->pkttype == PKT_GPG_CONTROL + && (n->pkt->pkt.gpg_control->control + == CTRLPKT_PLAINTEXT_MARK) ) + { + if (n->next) + goto ambiguous; /* We only allow one P packet. */ + } + else + goto ambiguous; + } + else if (n->pkt->pkttype == PKT_ONEPASS_SIG) + { + /* This is the "O{1,n} P S{1,n}" case (standard signature). */ + for (n_onepass=1, n = n->next; + n && n->pkt->pkttype == PKT_ONEPASS_SIG; n = n->next) + n_onepass++; + if (!n || !(n->pkt->pkttype == PKT_GPG_CONTROL + && (n->pkt->pkt.gpg_control->control + == CTRLPKT_PLAINTEXT_MARK))) + goto ambiguous; + for (n_sig=0, n = n->next; + n && n->pkt->pkttype == PKT_SIGNATURE; n = n->next) + n_sig++; + if (!n_sig) + goto ambiguous; + if (n && !opt.allow_multisig_verification) + goto ambiguous; + if (n_onepass != n_sig) + { + log_info ("number of one-pass packets does not match " + "number of signature packets\n"); + goto ambiguous; + } + } + else if (n->pkt->pkttype == PKT_GPG_CONTROL + && n->pkt->pkt.gpg_control->control == CTRLPKT_CLEARSIGN_START ) + { + /* This is the "C P S{1,n}" case (clear text signature). */ + n = n->next; + if (!n || !(n->pkt->pkttype == PKT_GPG_CONTROL + && (n->pkt->pkt.gpg_control->control + == CTRLPKT_PLAINTEXT_MARK))) + goto ambiguous; + for (n_sig=0, n = n->next; + n && n->pkt->pkttype == PKT_SIGNATURE; n = n->next) + n_sig++; + if (n || !n_sig) + goto ambiguous; + } + else + { + ambiguous: + log_error(_("can't handle this ambiguous signature data\n")); + return 0; + } + + } + + /* (Indendation below not yet changed to GNU style.) */ + astr = pubkey_algo_to_string( sig->pubkey_algo ); if(keystrlen()>8) { Modified: tags/V1-4-2/g10/options.h =================================================================== --- tags/V1-4-2/g10/options.h 2006-03-08 02:40:42 UTC (rev 4046) +++ tags/V1-4-2/g10/options.h 2006-03-08 09:11:34 UTC (rev 4047) @@ -207,6 +207,9 @@ int disable_ccid; /* Disable the use of the internal CCID driver. */ #endif /*ENABLE_CARD_SUPPORT*/ + /* True if multiple concatenated signatures may be verified. */ + int allow_multisig_verification; + } opt; /* CTRL is used to keep some global variables we currently can't From cvs at cvs.gnupg.org Wed Mar 8 10:58:07 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed Mar 8 10:32:18 2006 Subject: [svn] GnuPG - r4048 - tags Message-ID: Author: wk Date: 2006-03-08 10:58:07 +0100 (Wed, 08 Mar 2006) New Revision: 4048 Added: tags/gnupg-1.4.2.2/ Log: From cvs at cvs.gnupg.org Thu Mar 9 00:30:16 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Mar 9 00:04:24 2006 Subject: [svn] GnuPG - r4049 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-09 00:30:12 +0100 (Thu, 09 Mar 2006) New Revision: 4049 Modified: trunk/g10/ChangeLog trunk/g10/build-packet.c trunk/g10/gpg.c trunk/g10/keyedit.c trunk/g10/keygen.c trunk/g10/main.h trunk/g10/options.h trunk/g10/packet.h trunk/g10/sign.c Log: * options.h, sign.c (mk_notation_policy_etc), gpg.c (add_notation_data): Use it here for the various notation commands. * packet.h, main.h, keygen.c (keygen_add_notations), build-packet.c (string_to_notation, sig_to_notation) (free_notation): New "one stop shopping" functions to handle notations and start removing some code duplication. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-08 09:58:07 UTC (rev 4048) +++ trunk/g10/ChangeLog 2006-03-08 23:30:12 UTC (rev 4049) @@ -1,3 +1,14 @@ +2006-03-08 David Shaw + + * options.h, sign.c (mk_notation_policy_etc), gpg.c + (add_notation_data): Use it here for the various notation + commands. + + * packet.h, main.h, keygen.c (keygen_add_notations), + build-packet.c (string_to_notation, sig_to_notation) + (free_notation): New "one stop shopping" functions to handle + notations and start removing some code duplication. + 2006-03-07 David Shaw * options.h, mainproc.c (check_sig_and_print), gpg.c (main): Modified: trunk/g10/build-packet.c =================================================================== --- trunk/g10/build-packet.c 2006-03-08 09:58:07 UTC (rev 4048) +++ trunk/g10/build-packet.c 2006-03-08 23:30:12 UTC (rev 4049) @@ -1,6 +1,6 @@ /* build-packet.c - assemble packets and write them - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, - * 2005 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + * 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -25,6 +25,7 @@ #include #include #include +#include #include "packet.h" #include "errors.h" @@ -33,6 +34,7 @@ #include "util.h" #include "cipher.h" #include "memory.h" +#include "i18n.h" #include "options.h" static int do_user_id( IOBUF out, int ctb, PKT_user_id *uid ); @@ -886,6 +888,153 @@ uid->attrib_len+=idx+headerlen+buflen; } +struct notation * +string_to_notation(const char *string,int is_utf8) +{ + const char *s,*i; + int saw_at=0,highbit=0; + struct notation *notation; + + notation=xmalloc_clear(sizeof(*notation)); + + if(*string=='!') + { + notation->flags.critical=1; + string++; + } + + /* If and when the IETF assigns some official name tags, we'll have + to add them here. */ + + for( s=string ; *s != '='; s++ ) + { + if( *s=='@') + saw_at++; + + if( !*s || !isascii (*s) || (!isgraph(*s) && !isspace(*s)) ) + { + log_error(_("a notation name must have only printable characters" + " or spaces, and end with an '='\n") ); + goto fail; + } + } + + notation->name=xmalloc((s-string)+1); + strncpy(notation->name,string,s-string); + notation->name[s-string]='\0'; + + if(!saw_at && !opt.expert) + { + log_error(_("a user notation name must contain the '@' character\n")); + goto fail; + } + + if (saw_at > 1) + { + log_error(_("a notation name must not contain more than" + " one '@' character\n")); + goto fail; + } + + i=s+1; + + /* we only support printable text - therefore we enforce the use of + only printable characters (an empty value is valid) */ + for(s++; *s ; s++ ) + { + if ( !isascii (*s) ) + highbit=1; + else if (iscntrl(*s)) + { + log_error(_("a notation value must not use any" + " control characters\n")); + goto fail; + } + } + + if(!highbit || is_utf8) + notation->value=xstrdup(i); + else + notation->value=native_to_utf8(i); + + return notation; + + fail: + free_notation(notation); + return NULL; +} + +struct notation * +sig_to_notation(PKT_signature *sig) +{ + const byte *p; + size_t len; + int seq=0,crit; + struct notation *list=NULL; + + while((p=enum_sig_subpkt(sig->hashed,SIGSUBPKT_NOTATION,&len,&seq,&crit))) + { + int n1,n2; + struct notation *n=NULL; + + if(len<8) + { + log_info(_("WARNING: invalid notation data found\n")); + continue; + } + + n1=(p[4]<<8)|p[5]; + n2=(p[6]<<8)|p[7]; + + if(8+n1+n2!=len) + { + log_info(_("WARNING: invalid notation data found\n")); + continue; + } + + n=xmalloc_clear(sizeof(*n)); + n->name=xmalloc(n1+1); + + memcpy(n->name,&p[8],n1); + n->name[n1]='\0'; + + if(p[0]&0x80) + { + n->value=xmalloc(n2+1); + memcpy(n->value,&p[8+n1],n2); + n->value[n2]='\0'; + } + else + { + n->value=xmalloc(2+strlen(_("not human readable"))+2+1); + strcpy(n->value,"[ "); + strcat(n->value,_("not human readable")); + strcat(n->value," ]"); + } + + n->flags.critical=crit; + + n->next=list; + list=n; + } + + return list; +} + +void +free_notation(struct notation *notation) +{ + while(notation) + { + struct notation *n=notation; + + xfree(n->name); + xfree(n->value); + notation=n->next; + xfree(n); + } +} + static int do_signature( IOBUF out, int ctb, PKT_signature *sig ) { Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2006-03-08 09:58:07 UTC (rev 4048) +++ trunk/g10/gpg.c 2006-03-08 23:30:12 UTC (rev 4049) @@ -3974,69 +3974,22 @@ static void add_notation_data( const char *string, int which ) { - const char *s; - STRLIST sl,*notation_data; - int critical=0; - int highbit=0; - int saw_at=0; + struct notation *notation; - if(which) - notation_data=&opt.cert_notation_data; - else - notation_data=&opt.sig_notation_data; - - if( *string == '!' ) { - critical = 1; - string++; - } - - /* If and when the IETF assigns some official name tags, we'll - have to add them here. */ - - for( s=string ; *s != '='; s++ ) - { - if( *s=='@') - saw_at++; - - if( !*s || !isascii (*s) || (!isgraph(*s) && !isspace(*s)) ) - { - log_error(_("a notation name must have only printable characters " - "or spaces, and end with an '='\n") ); - return; - } - } - - if(!saw_at && !opt.expert) - { - log_error(_("a user notation name must contain the '@' character\n")); - return; - } - if (saw_at > 1) - { - log_error(_("a notation name must not contain more than " - "one '@' character\n")); - return; - } - - /* we only support printable text - therefore we enforce the use - * of only printable characters (an empty value is valid) */ - for( s++; *s ; s++ ) { - if ( !isascii (*s) ) - highbit = 1; - else if (iscntrl(*s)) { - log_error(_("a notation value must not use" - " any control characters\n") ); - return; + notation=string_to_notation(string,utf8_strings); + if(notation) + { + if(which) + { + notation->next=opt.cert_notations; + opt.cert_notations=notation; } + else + { + notation->next=opt.sig_notations; + opt.sig_notations=notation; + } } - - if( highbit ) /* must use UTF8 encoding */ - sl = add_to_strlist2( notation_data, string, utf8_strings ); - else - sl = add_to_strlist( notation_data, string ); - - if( critical ) - sl->flags |= 1; } static void Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2006-03-08 09:58:07 UTC (rev 4048) +++ trunk/g10/keyedit.c 2006-03-08 23:30:12 UTC (rev 4049) @@ -1,6 +1,6 @@ /* keyedit.c - keyedit stuff - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, - * 2005 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + * 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -546,7 +546,7 @@ byte trust_depth=0,trust_value=0; if(local || nonrevocable || trust || - opt.cert_policy_url || opt.cert_notation_data) + opt.cert_policy_url || opt.cert_notations) force_v4=1; /* we have to use a copy of the sk, because make_keysig_packet Modified: trunk/g10/keygen.c =================================================================== --- trunk/g10/keygen.c 2006-03-08 09:58:07 UTC (rev 4048) +++ trunk/g10/keygen.c 2006-03-08 23:30:12 UTC (rev 4049) @@ -1,6 +1,6 @@ /* keygen.c - generate a key pair - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, - * 2005 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + * 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -690,6 +690,50 @@ } int +keygen_add_notations(PKT_signature *sig,void *opaque) +{ + struct notation *notation; + + /* We always start clean */ + delete_sig_subpkt(sig->hashed,SIGSUBPKT_NOTATION); + delete_sig_subpkt(sig->unhashed,SIGSUBPKT_NOTATION); + sig->flags.notation=0; + + for(notation=opaque;notation;notation=notation->next) + if(!notation->flags.ignore) + { + unsigned char *buf; + unsigned int n1,n2; + + n1=strlen(notation->name); + if(notation->altvalue) + n2=strlen(notation->altvalue); + else + n2=strlen(notation->value); + + buf = xmalloc( 8 + n1 + n2 ); + + buf[0] = 0x80; /* human readable */ + buf[1] = buf[2] = buf[3] = 0; + buf[4] = n1 >> 8; + buf[5] = n1; + buf[6] = n2 >> 8; + buf[7] = n2; + memcpy(buf+8, notation->name, n1 ); + if(notation->altvalue) + memcpy(buf+8+n1, notation->altvalue, n2 ); + else + memcpy(buf+8+n1, notation->value, n2 ); + build_sig_subpkt( sig, SIGSUBPKT_NOTATION | + (notation->flags.critical?SIGSUBPKT_FLAG_CRITICAL:0), + buf, 8+n1+n2 ); + xfree(buf); + } + + return 0; +} + +int keygen_add_revkey(PKT_signature *sig, void *opaque) { struct revocation_key *revkey=opaque; Modified: trunk/g10/main.h =================================================================== --- trunk/g10/main.h 2006-03-08 09:58:07 UTC (rev 4048) +++ trunk/g10/main.h 2006-03-08 23:30:12 UTC (rev 4049) @@ -1,6 +1,6 @@ /* main.h - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, - * 2005 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + * 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -55,7 +55,7 @@ struct groupitem *next; }; -/*-- g10.c --*/ +/*-- gpg.c --*/ extern int g10_errors_seen; #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) @@ -181,6 +181,7 @@ int keygen_add_std_prefs( PKT_signature *sig, void *opaque ); int keygen_upd_std_prefs( PKT_signature *sig, void *opaque ); int keygen_add_keyserver_url(PKT_signature *sig, void *opaque); +int keygen_add_notations(PKT_signature *sig,void *opaque); int keygen_add_revkey(PKT_signature *sig, void *opaque); int make_backsig(PKT_signature *sig,PKT_public_key *pk, PKT_public_key *sub_pk,PKT_secret_key *sub_sk); Modified: trunk/g10/options.h =================================================================== --- trunk/g10/options.h 2006-03-08 09:58:07 UTC (rev 4048) +++ trunk/g10/options.h 2006-03-08 23:30:12 UTC (rev 4049) @@ -163,8 +163,8 @@ char *temp_dir; int no_encrypt_to; int interactive; - STRLIST sig_notation_data; - STRLIST cert_notation_data; + struct notation *sig_notations; + struct notation *cert_notations; STRLIST sig_policy_url; STRLIST cert_policy_url; STRLIST sig_keyserver_url; Modified: trunk/g10/packet.h =================================================================== --- trunk/g10/packet.h 2006-03-08 09:58:07 UTC (rev 4048) +++ trunk/g10/packet.h 2006-03-08 23:30:12 UTC (rev 4049) @@ -1,6 +1,6 @@ /* packet.h - packet definitions - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, - * 2004 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + * 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -407,6 +407,18 @@ SIGSUBPKT_FLAG_CRITICAL=128 } sigsubpkttype_t; +struct notation +{ + char *name; + char *value; + char *altvalue; + struct + { + unsigned int critical:1; + unsigned int ignore:1; + } flags; + struct notation *next; +}; /*-- mainproc.c --*/ int proc_packets( void *ctx, IOBUF a ); @@ -476,6 +488,9 @@ void build_attribute_subpkt(PKT_user_id *uid,byte type, const void *buf,u32 buflen, const void *header,u32 headerlen); +struct notation *string_to_notation(const char *string,int is_utf8); +struct notation *sig_to_notation(PKT_signature *sig); +void free_notation(struct notation *notation); /*-- free-packet.c --*/ void free_symkey_enc( PKT_symkey_enc *enc ); Modified: trunk/g10/sign.c =================================================================== --- trunk/g10/sign.c 2006-03-08 09:58:07 UTC (rev 4048) +++ trunk/g10/sign.c 2006-03-08 23:30:12 UTC (rev 4049) @@ -1,6 +1,6 @@ /* sign.c - sign data - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, - * 2005 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + * 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -55,9 +55,9 @@ static int recipient_digest_algo=0; /**************** - * Create a notation. It is assumed that the stings in STRLIST - * are already checked to contain only printable data and have a valid - * NAME=VALUE format. + * Create notations and other stuff. It is assumed that the stings in + * STRLIST are already checked to contain only printable data and have + * a valid NAME=VALUE format. */ static void mk_notation_policy_etc( PKT_signature *sig, @@ -65,9 +65,8 @@ { const char *string; char *s=NULL; - byte *buf; - unsigned n1, n2; - STRLIST nd=NULL,pu=NULL; + STRLIST pu=NULL; + struct notation *nd=NULL; struct expando_args args; memset(&args,0,sizeof(args)); @@ -80,58 +79,44 @@ good to do these checks anyway. */ /* notation data */ - if(IS_SIG(sig) && opt.sig_notation_data) + if(IS_SIG(sig) && opt.sig_notations) { if(sig->version<4) log_error(_("can't put notation data into v3 (PGP 2.x style) " "signatures\n")); else - nd=opt.sig_notation_data; + nd=opt.sig_notations; } - else if( IS_CERT(sig) && opt.cert_notation_data ) + else if( IS_CERT(sig) && opt.cert_notations ) { if(sig->version<4) log_error(_("can't put notation data into v3 (PGP 2.x style) " "key signatures\n")); else - nd=opt.cert_notation_data; + nd=opt.cert_notations; } - for( ; nd; nd = nd->next ) { - char *expanded; + if(nd) + { + struct notation *i; - string = nd->d; - s = strchr( string, '=' ); - if( !s ) - BUG(); /* we have already parsed this */ - n1 = s - string; - s++; - - expanded=pct_expando(s,&args); - if(!expanded) + for(i=nd;i;i=i->next) { - log_error(_("WARNING: unable to %%-expand notation " - "(too large). Using unexpanded.\n")); - expanded=xstrdup(s); + i->altvalue=pct_expando(i->value,&args); + if(!i->altvalue) + log_error(_("WARNING: unable to %%-expand notation " + "(too large). Using unexpanded.\n")); } - n2 = strlen(expanded); - buf = xmalloc( 8 + n1 + n2 ); - buf[0] = 0x80; /* human readable */ - buf[1] = buf[2] = buf[3] = 0; - buf[4] = n1 >> 8; - buf[5] = n1; - buf[6] = n2 >> 8; - buf[7] = n2; - memcpy(buf+8, string, n1 ); - memcpy(buf+8+n1, expanded, n2 ); - build_sig_subpkt( sig, SIGSUBPKT_NOTATION - | ((nd->flags & 1)? SIGSUBPKT_FLAG_CRITICAL:0), - buf, 8+n1+n2 ); - xfree(expanded); - xfree(buf); - } + keygen_add_notations(sig,nd); + for(i=nd;i;i=i->next) + { + xfree(i->altvalue); + i->altvalue=NULL; + } + } + /* set policy URL */ if( IS_SIG(sig) && opt.sig_policy_url ) { @@ -650,7 +635,7 @@ if(opt.force_v3_sigs || RFC1991) sig->version=3; else if(duration || opt.sig_policy_url - || opt.sig_notation_data || opt.sig_keyserver_url) + || opt.sig_notations || opt.sig_keyserver_url) sig->version=4; else sig->version=sk->version; From cvs at cvs.gnupg.org Thu Mar 9 00:42:48 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Mar 9 00:16:56 2006 Subject: [svn] GnuPG - r4050 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-09 00:42:45 +0100 (Thu, 09 Mar 2006) New Revision: 4050 Modified: trunk/g10/ChangeLog trunk/g10/build-packet.c trunk/g10/keygen.c trunk/g10/packet.h Log: * packet.h, build-packet.c (sig_to_notation), keygen.c (keygen_add_notations): Tweak to handle non-human-readable notation values. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-08 23:30:12 UTC (rev 4049) +++ trunk/g10/ChangeLog 2006-03-08 23:42:45 UTC (rev 4050) @@ -1,5 +1,9 @@ 2006-03-08 David Shaw + * packet.h, build-packet.c (sig_to_notation), keygen.c + (keygen_add_notations): Tweak to handle non-human-readable + notation values. + * options.h, sign.c (mk_notation_policy_etc), gpg.c (add_notation_data): Use it here for the various notation commands. Modified: trunk/g10/build-packet.c =================================================================== --- trunk/g10/build-packet.c 2006-03-08 23:30:12 UTC (rev 4049) +++ trunk/g10/build-packet.c 2006-03-08 23:42:45 UTC (rev 4050) @@ -1000,18 +1000,18 @@ if(p[0]&0x80) { + n->flags.human=1; n->value=xmalloc(n2+1); - memcpy(n->value,&p[8+n1],n2); n->value[n2]='\0'; } else { - n->value=xmalloc(2+strlen(_("not human readable"))+2+1); - strcpy(n->value,"[ "); - strcat(n->value,_("not human readable")); - strcat(n->value," ]"); + n->value=xmalloc(n2); + n->blen=n2; } + memcpy(n->value,&p[8+n1],n2); + n->flags.critical=crit; n->next=list; Modified: trunk/g10/keygen.c =================================================================== --- trunk/g10/keygen.c 2006-03-08 23:30:12 UTC (rev 4049) +++ trunk/g10/keygen.c 2006-03-08 23:42:45 UTC (rev 4050) @@ -708,12 +708,15 @@ n1=strlen(notation->name); if(notation->altvalue) n2=strlen(notation->altvalue); + else if(!notation->flags.human) + n2=notation->blen; else n2=strlen(notation->value); buf = xmalloc( 8 + n1 + n2 ); - buf[0] = 0x80; /* human readable */ + /* human readable or not */ + buf[0] = notation->flags.human?0x80:0; buf[1] = buf[2] = buf[3] = 0; buf[4] = n1 >> 8; buf[5] = n1; Modified: trunk/g10/packet.h =================================================================== --- trunk/g10/packet.h 2006-03-08 23:30:12 UTC (rev 4049) +++ trunk/g10/packet.h 2006-03-08 23:42:45 UTC (rev 4050) @@ -411,10 +411,12 @@ { char *name; char *value; + size_t blen; char *altvalue; struct { unsigned int critical:1; + unsigned int human:1; unsigned int ignore:1; } flags; struct notation *next; From cvs at cvs.gnupg.org Thu Mar 9 02:15:20 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Mar 9 01:49:29 2006 Subject: [svn] GnuPG - r4051 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-09 02:15:18 +0100 (Thu, 09 Mar 2006) New Revision: 4051 Modified: trunk/g10/ChangeLog trunk/g10/build-packet.c trunk/g10/keygen.c trunk/g10/packet.h Log: * packet.h, build-packet.c (sig_to_notation), keygen.c (keygen_add_notations): Provide printable text for non-human-readable notation values. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-08 23:42:45 UTC (rev 4050) +++ trunk/g10/ChangeLog 2006-03-09 01:15:18 UTC (rev 4051) @@ -1,6 +1,10 @@ 2006-03-08 David Shaw * packet.h, build-packet.c (sig_to_notation), keygen.c + (keygen_add_notations): Provide printable text for + non-human-readable notation values. + + * packet.h, build-packet.c (sig_to_notation), keygen.c (keygen_add_notations): Tweak to handle non-human-readable notation values. Modified: trunk/g10/build-packet.c =================================================================== --- trunk/g10/build-packet.c 2006-03-08 23:42:45 UTC (rev 4050) +++ trunk/g10/build-packet.c 2006-03-09 01:15:18 UTC (rev 4051) @@ -1000,18 +1000,22 @@ if(p[0]&0x80) { - n->flags.human=1; n->value=xmalloc(n2+1); + memcpy(n->value,&p[8+n1],n2); n->value[n2]='\0'; } else { - n->value=xmalloc(n2); + n->bdat=xmalloc(n2); n->blen=n2; + memcpy(n->bdat,&p[8+n1],n2); + + n->value=xmalloc(2+strlen(_("not human readable"))+2+1); + strcpy(n->value,"[ "); + strcat(n->value,_("not human readable")); + strcat(n->value," ]"); } - memcpy(n->value,&p[8+n1],n2); - n->flags.critical=crit; n->next=list; @@ -1030,6 +1034,8 @@ xfree(n->name); xfree(n->value); + xfree(n->altvalue); + xfree(n->bdat); notation=n->next; xfree(n); } Modified: trunk/g10/keygen.c =================================================================== --- trunk/g10/keygen.c 2006-03-08 23:42:45 UTC (rev 4050) +++ trunk/g10/keygen.c 2006-03-09 01:15:18 UTC (rev 4051) @@ -708,7 +708,7 @@ n1=strlen(notation->name); if(notation->altvalue) n2=strlen(notation->altvalue); - else if(!notation->flags.human) + else if(notation->bdat) n2=notation->blen; else n2=strlen(notation->value); @@ -716,7 +716,7 @@ buf = xmalloc( 8 + n1 + n2 ); /* human readable or not */ - buf[0] = notation->flags.human?0x80:0; + buf[0] = notation->bdat?0:0x80; buf[1] = buf[2] = buf[3] = 0; buf[4] = n1 >> 8; buf[5] = n1; @@ -725,6 +725,8 @@ memcpy(buf+8, notation->name, n1 ); if(notation->altvalue) memcpy(buf+8+n1, notation->altvalue, n2 ); + else if(notation->bdat) + memcpy(buf+8+n1, notation->bdat, n2 ); else memcpy(buf+8+n1, notation->value, n2 ); build_sig_subpkt( sig, SIGSUBPKT_NOTATION | Modified: trunk/g10/packet.h =================================================================== --- trunk/g10/packet.h 2006-03-08 23:42:45 UTC (rev 4050) +++ trunk/g10/packet.h 2006-03-09 01:15:18 UTC (rev 4051) @@ -411,12 +411,12 @@ { char *name; char *value; + char *altvalue; + unsigned char *bdat; size_t blen; - char *altvalue; struct { unsigned int critical:1; - unsigned int human:1; unsigned int ignore:1; } flags; struct notation *next; From cvs at cvs.gnupg.org Thu Mar 9 04:31:29 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Mar 9 04:05:38 2006 Subject: [svn] GnuPG - r4052 - trunk/util Message-ID: Author: dshaw Date: 2006-03-09 04:31:28 +0100 (Thu, 09 Mar 2006) New Revision: 4052 Modified: trunk/util/ChangeLog trunk/util/argparse.c Log: * argparse.c (default_strusage): Update copyright year to 2006. Modified: trunk/util/ChangeLog =================================================================== --- trunk/util/ChangeLog 2006-03-09 01:15:18 UTC (rev 4051) +++ trunk/util/ChangeLog 2006-03-09 03:31:28 UTC (rev 4052) @@ -1,3 +1,7 @@ +2006-03-08 David Shaw + + * argparse.c (default_strusage): Update copyright year to 2006. + 2006-02-19 David Shaw * http.c (send_request): A zero length proxy is the same as no Modified: trunk/util/argparse.c =================================================================== --- trunk/util/argparse.c 2006-03-09 01:15:18 UTC (rev 4051) +++ trunk/util/argparse.c 2006-03-09 03:31:28 UTC (rev 4052) @@ -1,5 +1,5 @@ /* [argparse.c wk 17.06.97] Argument Parser for option handling - * Copyright (C) 1998, 1999, 2000, 2001, 2003 + * Copyright (C) 1998, 1999, 2000, 2001, 2003, * 2004 Free Software Foundation, Inc. * * This file is part of GnuPG. @@ -914,7 +914,7 @@ switch( level ) { case 11: p = "foo"; break; case 13: p = "0.0"; break; - case 14: p = "Copyright (C) 2005 Free Software Foundation, Inc."; break; + case 14: p = "Copyright (C) 2006 Free Software Foundation, Inc."; break; case 15: p = "This program comes with ABSOLUTELY NO WARRANTY.\n" "This is free software, and you are welcome to redistribute it\n" From cvs at cvs.gnupg.org Thu Mar 9 04:35:27 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Mar 9 04:09:35 2006 Subject: [svn] GnuPG - r4053 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-09 04:35:26 +0100 (Thu, 09 Mar 2006) New Revision: 4053 Modified: trunk/g10/ChangeLog trunk/g10/keylist.c trunk/g10/mainproc.c Log: * mainproc.c (get_pka_address), keylist.c (show_notation): Remove duplicate code by using notation functions. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-09 03:31:28 UTC (rev 4052) +++ trunk/g10/ChangeLog 2006-03-09 03:35:26 UTC (rev 4053) @@ -1,5 +1,8 @@ 2006-03-08 David Shaw + * mainproc.c (get_pka_address), keylist.c (show_notation): Remove + duplicate code by using notation functions. + * packet.h, build-packet.c (sig_to_notation), keygen.c (keygen_add_notations): Provide printable text for non-human-readable notation values. Modified: trunk/g10/keylist.c =================================================================== --- trunk/g10/keylist.c 2006-03-09 03:31:28 UTC (rev 4052) +++ trunk/g10/keylist.c 2006-03-09 03:35:26 UTC (rev 4053) @@ -332,71 +332,55 @@ void show_notation(PKT_signature *sig,int indent,int mode,int which) { - const byte *p; - size_t len; - int seq=0,crit; FILE *fp=mode?log_stream():stdout; + struct notation *nd,*notations; if(which==0) which=3; + notations=sig_to_notation(sig); + /* There may be multiple notations in the same sig. */ + for(nd=notations;nd;nd=nd->next) + { + if(mode!=2) + { + int has_at=!!strchr(nd->name,'@'); - while((p=enum_sig_subpkt(sig->hashed,SIGSUBPKT_NOTATION,&len,&seq,&crit))) - if(len>=8) - { - int n1,n2; + if((which&1 && !has_at) || (which&2 && has_at)) + { + int i; + const char *str; - n1=(p[4]<<8)|p[5]; - n2=(p[6]<<8)|p[7]; + for(i=0;iflags.critical) + str=_("Critical signature notation: "); + else + str=_("Signature notation: "); + if(mode) + log_info("%s",str); + else + printf("%s",str); + /* This is all UTF8 */ + print_utf8_string(fp,nd->name,strlen(nd->name)); + fprintf(fp,"="); + print_utf8_string(fp,nd->value,strlen(nd->value)); + fprintf(fp,"\n"); + } + } - if(mode!=2) - { - int has_at=!!memchr(p+8,'@',n1); + if(mode) + { + write_status_buffer(STATUS_NOTATION_NAME, + nd->name,strlen(nd->name),0); + write_status_buffer(STATUS_NOTATION_DATA, + nd->value,strlen(nd->value),50); + } + } - if((which&1 && !has_at) || (which&2 && has_at)) - { - int i; - const char *str; - - for(i=0;ihashed, SIGSUBPKT_NOTATION, - &len, &seq, NULL))) + notation=sig_to_notation(sig); + + for(nd=notation;nd;nd=nd->next) { - if (len < 8) - continue; /* Notation packet is too short. */ - n1 = (p[4]<<8)|p[5]; - n2 = (p[6]<<8)|p[7]; - if (8 + n1 + n2 != len) - continue; /* Length fields of notation packet are inconsistent. */ - p += 8; - if (n1 != 21 || memcmp (p, "pka-address@gnupg.org", 21)) + if(strcmp(nd->name,"pka-address@gnupg.org")!=0) continue; /* Not the notation we want. */ - p += n1; - if (n2 < 3) - continue; /* Impossible email address. */ - if (pka) - break; /* For now we only use the first valid PKA notation. In - future we might want to keep additional PKA - notations in a linked list. */ - - pka = xmalloc (sizeof *pka + n2); - pka->valid = 0; - pka->checked = 0; - pka->uri = NULL; - memcpy (pka->email, p, n2); - pka->email[n2] = 0; - - if (!is_valid_mailbox (pka->email)) - { - /* We don't accept invalid mail addresses. */ - xfree (pka); - pka = NULL; - } + /* For now we only use the first valid PKA notation. In future + we might want to keep additional PKA notations in a linked + list. */ + if (is_valid_mailbox (pka->email)) + { + pka = xmalloc (sizeof *pka + strlen(nd->value)); + pka->valid = 0; + pka->checked = 0; + pka->uri = NULL; + strcpy (pka->email, nd->value); + break; + } } + free_notation(notation); + return pka; } From cvs at cvs.gnupg.org Thu Mar 9 04:49:40 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Mar 9 04:23:47 2006 Subject: [svn] GnuPG - r4054 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-09 04:49:39 +0100 (Thu, 09 Mar 2006) New Revision: 4054 Modified: trunk/g10/ChangeLog trunk/g10/keyedit.c Log: * keyedit.c (menu_set_notation): New function to set notations on self-signatures. (keyedit_menu): Call it here. (tty_print_notations): Helper. (show_prefs): Show notations in "showpref". Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-09 03:35:26 UTC (rev 4053) +++ trunk/g10/ChangeLog 2006-03-09 03:49:39 UTC (rev 4054) @@ -1,5 +1,11 @@ 2006-03-08 David Shaw + * keyedit.c (menu_set_notation): New function to set notations on + self-signatures. + (keyedit_menu): Call it here. + (tty_print_notations): Helper. + (show_prefs): Show notations in "showpref". + * mainproc.c (get_pka_address), keylist.c (show_notation): Remove duplicate code by using notation functions. Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2006-03-09 03:35:26 UTC (rev 4053) +++ trunk/g10/keyedit.c 2006-03-09 03:49:39 UTC (rev 4054) @@ -67,6 +67,8 @@ static int menu_set_preferences( KBNODE pub_keyblock, KBNODE sec_keyblock ); static int menu_set_keyserver_url (const char *url, KBNODE pub_keyblock, KBNODE sec_keyblock ); +static int menu_set_notation(const char *string, + KBNODE pub_keyblock,KBNODE sec_keyblock); static int menu_select_uid( KBNODE keyblock, int idx ); static int menu_select_uid_namehash( KBNODE keyblock, const char *namehash ); static int menu_select_key( KBNODE keyblock, int idx ); @@ -1339,8 +1341,9 @@ cmdSAVE, cmdADDUID, cmdADDPHOTO, cmdDELUID, cmdADDKEY, cmdDELKEY, cmdADDREVOKER, cmdTOGGLE, cmdSELKEY, cmdPASSWD, cmdTRUST, cmdPREF, cmdEXPIRE, cmdBACKSIGN, cmdENABLEKEY, cmdDISABLEKEY, cmdSHOWPREF, - cmdSETPREF, cmdPREFKS, cmdINVCMD, cmdSHOWPHOTO, cmdUPDTRUST, cmdCHKTRUST, - cmdADDCARDKEY, cmdKEYTOCARD, cmdBKUPTOCARD, cmdCLEAN, cmdMINIMIZE, cmdNOP + cmdSETPREF, cmdPREFKS, cmdNOTATION, cmdINVCMD, cmdSHOWPHOTO, cmdUPDTRUST, + cmdCHKTRUST, cmdADDCARDKEY, cmdKEYTOCARD, cmdBKUPTOCARD, cmdCLEAN, + cmdMINIMIZE, cmdNOP }; static struct @@ -1422,7 +1425,9 @@ { "updpref" , cmdSETPREF , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, NULL }, { "keyserver",cmdPREFKS , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, - N_("set preferred keyserver URL for the selected user IDs")}, + N_("set the preferred keyserver URL for the selected user IDs")}, + { "notation", cmdNOTATION , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, + N_("set a notation for the selected user IDs")}, { "passwd" , cmdPASSWD , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("change the passphrase") }, /* Alias */ @@ -2151,6 +2156,16 @@ } break; + case cmdNOTATION: + if( menu_set_notation ( *arg_string?arg_string:NULL, + keyblock, sec_keyblock ) ) + { + merge_keys_and_selfsig( keyblock ); + modified = 1; + redisplay = 1; + } + break; + case cmdNOP: break; @@ -2238,8 +2253,36 @@ xfree(answer); } +static void +tty_print_notations(int indent,PKT_signature *sig) +{ + int first=1; + struct notation *notation,*nd; - + if(indent<0) + { + first=0; + indent=-indent; + } + + notation=sig_to_notation(sig); + + for(nd=notation;nd;nd=nd->next) + { + if(!first) + tty_printf("%*s",indent,""); + else + first=0; + + tty_print_utf8_string(nd->name,strlen(nd->name)); + tty_printf("="); + tty_print_utf8_string(nd->value,strlen(nd->value)); + tty_printf("\n"); + } + + free_notation(notation); +} + /**************** * show preferences of a public keyblock. */ @@ -2369,6 +2412,13 @@ tty_print_utf8_string(pref_ks,pref_ks_len); tty_printf("\n"); } + + if(selfsig->flags.notation) + { + tty_printf (" "); + tty_printf(_("Notations: ")); + tty_print_notations(5+strlen(_("Notations: ")),selfsig); + } } } else { @@ -4100,7 +4150,197 @@ return modified; } +static int +menu_set_notation(const char *string,KBNODE pub_keyblock,KBNODE sec_keyblock) +{ + PKT_secret_key *sk; /* copy of the main sk */ + PKT_public_key *main_pk; + PKT_user_id *uid; + KBNODE node; + u32 keyid[2]; + int selected, select_all; + int modified = 0; + char *answer; + struct notation *notation; + no_primary_warning(pub_keyblock); + + if(string) + answer=xstrdup(string); + else + { + answer=cpr_get_utf8("keyedit.add_notation", + _("Enter the notation: ")); + if(answer[0]=='\0' || answer[0]=='\004') + { + xfree(answer); + return 0; + } + } + + if(ascii_strcasecmp(answer,"none")==0) + notation=NULL; /* delete them all */ + else + { + notation=string_to_notation(answer,0); + if(!notation) + { + xfree(answer); + return 0; + } + } + + xfree(answer); + + select_all = !count_selected_uids (pub_keyblock); + + node = find_kbnode( sec_keyblock, PKT_SECRET_KEY ); + sk = copy_secret_key( NULL, node->pkt->pkt.secret_key); + + /* Now we can actually change the self signature(s) */ + main_pk = NULL; + uid = NULL; + selected = 0; + for ( node=pub_keyblock; node; node = node->next ) + { + if ( node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) + break; /* ready */ + + if ( node->pkt->pkttype == PKT_PUBLIC_KEY ) + { + main_pk = node->pkt->pkt.public_key; + keyid_from_pk( main_pk, keyid ); + } + else if ( node->pkt->pkttype == PKT_USER_ID ) + { + uid = node->pkt->pkt.user_id; + selected = select_all || (node->flag & NODFLG_SELUID); + } + else if ( main_pk && uid && selected + && node->pkt->pkttype == PKT_SIGNATURE ) + { + PKT_signature *sig = node->pkt->pkt.signature; + if ( keyid[0] == sig->keyid[0] && keyid[1] == sig->keyid[1] + && (uid && (sig->sig_class&~3) == 0x10) + && sig->flags.chosen_selfsig) + { + char *user=utf8_to_native(uid->name,strlen(uid->name),0); + if( sig->version < 4 ) + log_info(_("skipping v3 self-signature on user ID \"%s\"\n"), + user); + else + { + PKT_signature *newsig; + PACKET *newpkt; + int rc,skip=0,addonly=1; + + if(sig->flags.notation) + { + tty_printf("Current notations for user ID \"%s\":\n", + user); + tty_print_notations(-10,sig); + } + else + { + tty_printf("No notations on user ID \"%s\"\n",user); + if(notation==NULL) + { + /* There are no current notations, so there + is no point in trying to un-set them. */ + continue; + } + } + + if(notation) + { + struct notation *n,*list=sig_to_notation(sig); + notation->next=list; + + for(n=list;n;n=n->next) + if(strcmp(n->name,notation->name)==0) + { + if(strcmp(n->value,notation->value)==0) + { + /* Adding the same notation twice, so + don't add it at all. */ + skip=1; + tty_printf("Skipping notation: %s=%s\n", + notation->name,notation->value); + notation->flags.ignore=1; + break; + } + else if(notation->value[0]=='\0') + { + /* No value, so we don't replace this + notation with anything. */ + n->flags.ignore=1; + notation->flags.ignore=1; + addonly=0; + } + + if(n->flags.ignore) + tty_printf("Removing notation: %s=%s\n", + n->name,n->value); + } + + if(!notation->flags.ignore) + tty_printf("Adding notation: %s=%s\n", + notation->name,notation->value); + } + else + { + tty_printf("Removing all notations\n"); + addonly=0; + } + + if(skip + || (!addonly + && !cpr_get_answer_is_yes("keyedit.confirm_notation", + _("Proceed? (y/N) ")))) + continue; + + rc = update_keysig_packet (&newsig, sig, + main_pk, uid, NULL, + sk, + keygen_add_notations, notation ); + if( rc ) + { + log_error ("update_keysig_packet failed: %s\n", + g10_errstr(rc)); + free_secret_key( sk ); + free_notation(notation); + xfree(user); + return 0; + } + + /* replace the packet */ + newpkt = xmalloc_clear( sizeof *newpkt ); + newpkt->pkttype = PKT_SIGNATURE; + newpkt->pkt.signature = newsig; + free_packet( node->pkt ); + xfree( node->pkt ); + node->pkt = newpkt; + modified = 1; + + if(notation) + { + /* Snip off the notation list from the sig */ + free_notation(notation->next); + notation->next=NULL; + } + + xfree(user); + } + } + } + } + + free_notation(notation); + free_secret_key( sk ); + return modified; +} + + /**************** * Select one user id or remove all selection if index is 0. * Returns: True if the selection changed; From cvs at cvs.gnupg.org Thu Mar 9 05:00:19 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Mar 9 04:34:25 2006 Subject: [svn] GnuPG - r4055 - trunk/doc Message-ID: Author: dshaw Date: 2006-03-09 05:00:18 +0100 (Thu, 09 Mar 2006) New Revision: 4055 Modified: trunk/doc/ChangeLog trunk/doc/gpg.sgml Log: * gpg.sgml: Document "notation". Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-03-09 03:49:39 UTC (rev 4054) +++ trunk/doc/ChangeLog 2006-03-09 04:00:18 UTC (rev 4055) @@ -1,3 +1,7 @@ +2006-03-08 David Shaw + + * gpg.sgml: Document "notation". + 2006-03-07 David Shaw * gpg.sgml: Rename backsigs to cross-certification (backsigs is Modified: trunk/doc/gpg.sgml =================================================================== --- trunk/doc/gpg.sgml 2006-03-09 03:49:39 UTC (rev 4054) +++ trunk/doc/gpg.sgml 2006-03-09 04:00:18 UTC (rev 4055) @@ -506,9 +506,10 @@ showpref More verbose preferences listing for the selected user ID. This shows -the preferences in effect by including the implied preferences of -3DES (cipher), SHA-1 (digest), and Uncompressed (compression) if they -are not already included in the preference list. +the preferences in effect by including the implied preferences of 3DES +(cipher), SHA-1 (digest), and Uncompressed (compression) if they are +not already included in the preference list. In addition, the +preferred keyserver and signature notations (if any) are shown. setpref &ParmString; @@ -529,11 +530,17 @@ Set a preferred keyserver for the specified user ID(s). This allows other users to know where you prefer they get your key from. See --keyserver-options honor-keyserver-url for more on how this works. -Note that some versions of PGP interpret the presence of a keyserver -URL as an instruction to enable PGP/MIME mail encoding. Setting a -value of "none" removes a existing preferred keyserver. +Setting a value of "none" removes an existing preferred keyserver. + notation + +Set a name=value notation for the specified user ID(s). See +--cert-notation for more on how this works. Setting a value of "none" +removes all notations, and setting a name with no value removes that +notation alone. + + toggle Toggle between public and secret key listing. From cvs at cvs.gnupg.org Thu Mar 9 13:45:03 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Mar 9 13:19:08 2006 Subject: [svn] GnuPG - r4056 - in trunk: . checks g10 Message-ID: Author: wk Date: 2006-03-09 13:45:02 +0100 (Thu, 09 Mar 2006) New Revision: 4056 Modified: trunk/ChangeLog trunk/checks/ChangeLog trunk/checks/defs.inc trunk/configure.ac trunk/g10/ChangeLog trunk/g10/mainproc.c Log: Preparing for an RC23 Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-09 04:00:18 UTC (rev 4055) +++ trunk/ChangeLog 2006-03-09 12:45:02 UTC (rev 4056) @@ -1,3 +1,7 @@ +2006-03-09 Werner Koch + + Released 1.4.3rc2. + 2006-03-07 David Shaw * NEWS: Note CERT retrieval. Tweak PKA and backsig language to Modified: trunk/checks/ChangeLog =================================================================== --- trunk/checks/ChangeLog 2006-03-09 04:00:18 UTC (rev 4055) +++ trunk/checks/ChangeLog 2006-03-09 12:45:02 UTC (rev 4056) @@ -1,3 +1,7 @@ +2006-03-09 Werner Koch + + * defs.inc: Removed Basishm by proper redirection. + 2006-03-06 Werner Koch * defs.inc: Print error messages also to stderr. Allow for Modified: trunk/checks/defs.inc =================================================================== --- trunk/checks/defs.inc 2006-03-09 04:00:18 UTC (rev 4055) +++ trunk/checks/defs.inc 2006-03-09 12:45:02 UTC (rev 4056) @@ -41,14 +41,14 @@ fatal () { echo "$pgmname: fatal:" $* >&2 - [ -n "${BASH_VERSION+set}" ] && echo "$pgmname: fatal:" $* >&5 + echo "$pgmname: fatal:" $* >&5 exit 1; } error () { echo "$pgmname:" $* >&2 defs_error_seen=yes - [ -n "${BASH_VERSION+set}" ] && echo "$pgmname:" $* >&5 + echo "$pgmname:" $* >&5 if [ x$defs_stop_on_error != xyes ]; then exit 1 fi @@ -71,7 +71,7 @@ info () { echo "$pgmname:" $* >&2 if [ -n "${verbose+set}" ]; then - [ -n "${BASH_VERSION+set}" ] && echo "$pgmname:" $* >&5 + echo "$pgmname:" $* >&5 fi } @@ -156,9 +156,7 @@ GPG="../g10/gpg --no-permission-warning --homedir . " -[ -n "${BASH_VERSION+set}" ] && exec 5>/dev/stderr +exec 5>&2 2>${pgmname}.log -exec 2> ${pgmname}.log - : # end Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-09 04:00:18 UTC (rev 4055) +++ trunk/configure.ac 2006-03-09 12:45:02 UTC (rev 4056) @@ -26,7 +26,7 @@ # Remember to change the version number immediately *after* a release # and remove the "-cvs" or "rc" suffix immediately *before* a release. -AC_INIT(gnupg, 1.4.3-cvs, bug-gnupg@gnu.org) +AC_INIT(gnupg, 1.4.3rc2, bug-gnupg@gnu.org) # Set development_version to yes if the minor number is odd or you # feel that the default check for a development version is not # sufficient. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-09 04:00:18 UTC (rev 4055) +++ trunk/g10/ChangeLog 2006-03-09 12:45:02 UTC (rev 4056) @@ -6,26 +6,31 @@ (tty_print_notations): Helper. (show_prefs): Show notations in "showpref". - * mainproc.c (get_pka_address), keylist.c (show_notation): Remove + * mainproc.c (get_pka_address) + * keylist.c (show_notation): Remove duplicate code by using notation functions. - * packet.h, build-packet.c (sig_to_notation), keygen.c - (keygen_add_notations): Provide printable text for + * packet.h, build-packet.c (sig_to_notation) + * keygen.c (keygen_add_notations): Provide printable text for non-human-readable notation values. - * packet.h, build-packet.c (sig_to_notation), keygen.c - (keygen_add_notations): Tweak to handle non-human-readable + * packet.h, build-packet.c (sig_to_notation) + * keygen.c (keygen_add_notations): Tweak to handle non-human-readable notation values. - * options.h, sign.c (mk_notation_policy_etc), gpg.c - (add_notation_data): Use it here for the various notation + * options.h, sign.c (mk_notation_policy_etc) + * gpg.c (add_notation_data): Use it here for the various notation commands. - * packet.h, main.h, keygen.c (keygen_add_notations), - build-packet.c (string_to_notation, sig_to_notation) + * packet.h, main.h, keygen.c (keygen_add_notations) + * build-packet.c (string_to_notation, sig_to_notation) (free_notation): New "one stop shopping" functions to handle notations and start removing some code duplication. +2006-03-08 Werner Koch + + * mainproc.c (do_check_sig): Use log_error for standalone revocations. + 2006-03-07 David Shaw * options.h, mainproc.c (check_sig_and_print), gpg.c (main): Modified: trunk/g10/mainproc.c =================================================================== --- trunk/g10/mainproc.c 2006-03-09 04:00:18 UTC (rev 4055) +++ trunk/g10/mainproc.c 2006-03-09 12:45:02 UTC (rev 4056) @@ -814,8 +814,8 @@ return check_key_signature( c->list, node, is_selfsig ); } else if( sig->sig_class == 0x20 ) { - log_info(_("standalone revocation - " - "use \"gpg --import\" to apply\n")); + log_error (_("standalone revocation - " + "use \"gpg --import\" to apply\n")); return G10ERR_NOT_PROCESSED; } else { From cvs at cvs.gnupg.org Thu Mar 9 13:58:26 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Mar 9 13:32:31 2006 Subject: [svn] GnuPG - r4057 - trunk/scripts Message-ID: Author: wk Date: 2006-03-09 13:58:26 +0100 (Thu, 09 Mar 2006) New Revision: 4057 Modified: trunk/scripts/ChangeLog trunk/scripts/config.guess trunk/scripts/config.sub Log: Updated Modified: trunk/scripts/ChangeLog =================================================================== --- trunk/scripts/ChangeLog 2006-03-09 12:45:02 UTC (rev 4056) +++ trunk/scripts/ChangeLog 2006-03-09 12:58:26 UTC (rev 4057) @@ -1,3 +1,7 @@ +2006-03-09 Werner Koch + + * config.sub, config.guess: Updated. + 2006-02-14 Werner Koch * w32installer.nsi: Don't use System.dll. Modified: trunk/scripts/config.guess =================================================================== --- trunk/scripts/config.guess 2006-03-09 12:45:02 UTC (rev 4056) +++ trunk/scripts/config.guess 2006-03-09 12:58:26 UTC (rev 4057) @@ -3,7 +3,7 @@ # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. -timestamp='2005-05-27' +timestamp='2006-02-23' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -106,7 +106,7 @@ trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; @@ -125,7 +125,7 @@ ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ;' +esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) @@ -199,48 +199,16 @@ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; - amd64:OpenBSD:*:*) - echo x86_64-unknown-openbsd${UNAME_RELEASE} - exit ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit ;; - cats:OpenBSD:*:*) - echo arm-unknown-openbsd${UNAME_RELEASE} - exit ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit ;; - luna88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit ;; - macppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit ;; - mvmeppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit ;; - sgi:OpenBSD:*:*) - echo mips64-unknown-openbsd${UNAME_RELEASE} - exit ;; - sun3:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit ;; *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; macppc:MirBSD:*:*) echo powerppc-unknown-mirbsd${UNAME_RELEASE} exit ;; @@ -658,8 +626,7 @@ esac if [ ${HP_ARCH} = "hppa2.0w" ] then - # avoid double evaluation of $set_cc_for_build - test -n "$CC_FOR_BUILD" || eval $set_cc_for_build + eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -800,7 +767,12 @@ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin @@ -808,6 +780,9 @@ i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; + i*:MSYS_NT-*:*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 @@ -815,9 +790,12 @@ i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; - x86:Interix*:[34]*) - echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + x86:Interix*:[345]*) + echo i586-pc-interix${UNAME_RELEASE} exit ;; + EM64T:Interix*:[345]*) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; @@ -830,7 +808,7 @@ i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; - amd64:CYGWIN*:*:*) + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) @@ -887,7 +865,11 @@ #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; mips64:Linux:*:*) @@ -906,9 +888,16 @@ #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; @@ -952,6 +941,9 @@ sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; @@ -997,7 +989,7 @@ LIBC=gnulibc1 # endif #else - #ifdef __INTEL_COMPILER + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun) LIBC=gnu #else LIBC=gnuaout @@ -1007,7 +999,11 @@ LIBC=dietlibc #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^LIBC/{ + s: ::g + p + }'`" test x"${LIBC}" != x && { echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit @@ -1218,7 +1214,6 @@ *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in - *86) UNAME_PROCESSOR=i686 ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} @@ -1297,6 +1292,9 @@ i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 Modified: trunk/scripts/config.sub =================================================================== --- trunk/scripts/config.sub 2006-03-09 12:45:02 UTC (rev 4056) +++ trunk/scripts/config.sub 2006-03-09 12:58:26 UTC (rev 4057) @@ -3,7 +3,7 @@ # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. -timestamp='2005-05-12' +timestamp='2006-02-23' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -119,8 +119,9 @@ # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ - kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; @@ -171,6 +172,10 @@ -hiux*) os=-hiuxwe2 ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -187,6 +192,10 @@ # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -239,7 +248,7 @@ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ - | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ + | m32r | m32rle | m68000 | m68k | m88k | maxq | mb | microblaze | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -248,6 +257,7 @@ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ @@ -256,13 +266,15 @@ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | mt \ | msp430 \ + | nios | nios2 \ | ns16k | ns32k \ - | openrisc | or32 \ + | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ - | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b \ @@ -274,6 +286,9 @@ | z8k) basic_machine=$basic_machine-unknown ;; + m32c) + basic_machine=$basic_machine-unknown + ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown @@ -281,6 +296,9 @@ ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; + ms1) + basic_machine=mt-unknown + ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and @@ -322,6 +340,7 @@ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ @@ -330,14 +349,16 @@ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ + | mt-* \ | msp430-* \ + | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ | sparclite-* \ @@ -352,6 +373,8 @@ | ymp-* \ | z8k-*) ;; + m32c-*) + ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) @@ -687,6 +710,9 @@ basic_machine=i386-pc os=-msdos ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; mvs) basic_machine=i370-ibm os=-mvs @@ -762,9 +788,8 @@ basic_machine=hppa1.1-oki os=-proelf ;; - or32 | or32-*) + openrisc | openrisc-*) basic_machine=or32-unknown - os=-coff ;; os400) basic_machine=powerpc-ibm @@ -795,6 +820,12 @@ pc532 | pc532-*) basic_machine=ns32k-pc532 ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; @@ -851,6 +882,10 @@ basic_machine=i586-unknown os=-pw32 ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; rom68k) basic_machine=m68k-rom68k os=-coff @@ -1090,12 +1125,9 @@ we32k) basic_machine=we32k-att ;; - sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sh64) - basic_machine=sh64-unknown - ;; sparc | sparcv8 | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; @@ -1169,20 +1201,23 @@ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* | -skyos*) + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1200,7 +1235,7 @@ os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) @@ -1389,6 +1424,9 @@ *-be) os=-beos ;; + *-haiku) + os=-haiku + ;; *-ibm) os=-aix ;; From cvs at cvs.gnupg.org Thu Mar 9 14:20:50 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Mar 9 13:54:53 2006 Subject: [svn] GnuPG - r4058 - tags Message-ID: Author: wk Date: 2006-03-09 14:20:49 +0100 (Thu, 09 Mar 2006) New Revision: 4058 Added: tags/gnupg-1.4.3rc2/ Log: 1.4.3rc2 has been released Copied: tags/gnupg-1.4.3rc2 (from rev 4057, trunk) From cvs at cvs.gnupg.org Thu Mar 9 16:36:33 2006 From: cvs at cvs.gnupg.org (cvs user werner) Date: Thu Mar 9 17:47:50 2006 Subject: oftpd/src (6 files) Message-ID: Date: Thursday, March 9, 2006 @ 16:36:33 Author: werner Path: /cvs/wk/oftpd/src Modified: config.h.in error.h ftp_listener.c ftp_session.c oftpd.c oftpd.h A couple of changes collected over the last year ----------------+ config.h.in | 8 ++++++ error.h | 7 +++++ ftp_listener.c | 42 +++++++++++++++++++++++------------ ftp_session.c | 66 +++++++++++++++++++++++++++++++++++++------------------ oftpd.c | 43 ++++++++++++++++++++++++----------- oftpd.h | 3 -- 6 files changed, 117 insertions(+), 52 deletions(-) From cvs at cvs.gnupg.org Thu Mar 9 16:36:32 2006 From: cvs at cvs.gnupg.org (cvs user werner) Date: Thu Mar 9 17:47:57 2006 Subject: oftpd (BUGS ChangeLog NEWS configure.in) Message-ID: Date: Thursday, March 9, 2006 @ 16:36:32 Author: werner Path: /cvs/wk/oftpd Modified: BUGS ChangeLog NEWS configure.in A couple of changes collected over the last year --------------+ BUGS | 5 +---- ChangeLog | 6 ++++++ NEWS | 7 +++++++ configure.in | 11 ++++++++++- 4 files changed, 24 insertions(+), 5 deletions(-) From cvs at cvs.gnupg.org Thu Mar 9 20:43:32 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Mar 9 20:17:35 2006 Subject: [svn] GnuPG - r4060 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-09 20:43:29 +0100 (Thu, 09 Mar 2006) New Revision: 4060 Modified: trunk/g10/ChangeLog trunk/g10/build-packet.c trunk/g10/keyedit.c Log: * build-packet.c (string_to_notation): Add ability to indicate a notation to be deleted with a '-' prefix. * keyedit.c (menu_set_notation): Use it here to allow deleting a notation marked with '-'. This works with either "-notation" or "-notation=value". Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-09 19:24:59 UTC (rev 4059) +++ trunk/g10/ChangeLog 2006-03-09 19:43:29 UTC (rev 4060) @@ -1,3 +1,12 @@ +2006-03-09 David Shaw + + * build-packet.c (string_to_notation): Add ability to indicate a + notation to be deleted with a '-' prefix. + + * keyedit.c (menu_set_notation): Use it here to allow deleting a + notation marked with '-'. This works with either "-notation" or + "-notation=value". + 2006-03-08 David Shaw * keyedit.c (menu_set_notation): New function to set notations on Modified: trunk/g10/build-packet.c =================================================================== --- trunk/g10/build-packet.c 2006-03-09 19:24:59 UTC (rev 4059) +++ trunk/g10/build-packet.c 2006-03-09 19:43:29 UTC (rev 4060) @@ -891,12 +891,18 @@ struct notation * string_to_notation(const char *string,int is_utf8) { - const char *s,*i; - int saw_at=0,highbit=0; + const char *s; + int saw_at=0; struct notation *notation; notation=xmalloc_clear(sizeof(*notation)); + if(*string=='-') + { + notation->flags.ignore=1; + string++; + } + if(*string=='!') { notation->flags.critical=1; @@ -911,6 +917,10 @@ if( *s=='@') saw_at++; + /* -notationname is legal without an = sign */ + if(!*s && notation->flags.ignore) + break; + if( !*s || !isascii (*s) || (!isgraph(*s) && !isspace(*s)) ) { log_error(_("a notation name must have only printable characters" @@ -936,27 +946,31 @@ goto fail; } - i=s+1; + if(*s) + { + const char *i=s+1; + int highbit=0; - /* we only support printable text - therefore we enforce the use of - only printable characters (an empty value is valid) */ - for(s++; *s ; s++ ) - { - if ( !isascii (*s) ) - highbit=1; - else if (iscntrl(*s)) + /* we only support printable text - therefore we enforce the use + of only printable characters (an empty value is valid) */ + for(s++; *s ; s++ ) { - log_error(_("a notation value must not use any" - " control characters\n")); - goto fail; + if ( !isascii (*s) ) + highbit=1; + else if (iscntrl(*s)) + { + log_error(_("a notation value must not use any" + " control characters\n")); + goto fail; + } } + + if(!highbit || is_utf8) + notation->value=xstrdup(i); + else + notation->value=native_to_utf8(i); } - if(!highbit || is_utf8) - notation->value=xstrdup(i); - else - notation->value=native_to_utf8(i); - return notation; fail: Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2006-03-09 19:24:59 UTC (rev 4059) +++ trunk/g10/keyedit.c 2006-03-09 19:43:29 UTC (rev 4060) @@ -4178,7 +4178,8 @@ } } - if(ascii_strcasecmp(answer,"none")==0) + if(ascii_strcasecmp(answer,"none")==0 + || ascii_strcasecmp(answer,"-")==0) notation=NULL; /* delete them all */ else { @@ -4238,7 +4239,7 @@ { tty_printf("Current notations for user ID \"%s\":\n", user); - tty_print_notations(-10,sig); + tty_print_notations(-9,sig); } else { @@ -4253,39 +4254,61 @@ if(notation) { - struct notation *n,*list=sig_to_notation(sig); - notation->next=list; + struct notation *n; + int deleting=0; - for(n=list;n;n=n->next) + notation->next=sig_to_notation(sig); + + for(n=notation->next;n;n=n->next) if(strcmp(n->name,notation->name)==0) { - if(strcmp(n->value,notation->value)==0) + if(notation->value) { - /* Adding the same notation twice, so - don't add it at all. */ - skip=1; - tty_printf("Skipping notation: %s=%s\n", - notation->name,notation->value); - notation->flags.ignore=1; - break; + if(strcmp(n->value,notation->value)==0) + { + if(notation->flags.ignore) + { + /* Value match with a delete + flag. */ + n->flags.ignore=1; + deleting=1; + } + else + { + /* Adding the same notation + twice, so don't add it at + all. */ + skip=1; + tty_printf("Skipping notation:" + " %s=%s\n", + notation->name, + notation->value); + break; + } + } } - else if(notation->value[0]=='\0') + else { - /* No value, so we don't replace this - notation with anything. */ + /* No value, so it means delete. */ n->flags.ignore=1; - notation->flags.ignore=1; - addonly=0; + deleting=1; } if(n->flags.ignore) - tty_printf("Removing notation: %s=%s\n", - n->name,n->value); + { + tty_printf("Removing notation: %s=%s\n", + n->name,n->value); + addonly=0; + } } - if(!notation->flags.ignore) + if(!notation->flags.ignore && !skip) tty_printf("Adding notation: %s=%s\n", notation->name,notation->value); + + /* We tried to delete, but had no matches */ + if(notation->flags.ignore && !deleting) + continue; } else { From cvs at cvs.gnupg.org Thu Mar 9 20:47:37 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Mar 9 20:21:40 2006 Subject: [svn] GnuPG - r4061 - trunk/doc Message-ID: Author: dshaw Date: 2006-03-09 20:47:35 +0100 (Thu, 09 Mar 2006) New Revision: 4061 Modified: trunk/doc/ChangeLog trunk/doc/gpg.sgml Log: * gpg.sgml: Clarify new notation delete feature. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-03-09 19:43:29 UTC (rev 4060) +++ trunk/doc/ChangeLog 2006-03-09 19:47:35 UTC (rev 4061) @@ -1,3 +1,7 @@ +2006-03-09 David Shaw + + * gpg.sgml: Clarify new notation delete feature. + 2006-03-08 David Shaw * gpg.sgml: Document "notation". Modified: trunk/doc/gpg.sgml =================================================================== --- trunk/doc/gpg.sgml 2006-03-09 19:43:29 UTC (rev 4060) +++ trunk/doc/gpg.sgml 2006-03-09 19:47:35 UTC (rev 4061) @@ -537,8 +537,10 @@ Set a name=value notation for the specified user ID(s). See --cert-notation for more on how this works. Setting a value of "none" -removes all notations, and setting a name with no value removes that -notation alone. +removes all notations, setting a notation prefixed with a minus sign +(-) removes that notation, and setting a notation name (without the +=value) prefixed with a minus sign removes all notations with that +name. toggle From cvs at cvs.gnupg.org Fri Mar 10 11:23:54 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri Mar 10 10:58:05 2006 Subject: [svn] gcry - r1145 - in trunk: . cipher doc src tests Message-ID: Author: wk Date: 2006-03-10 11:23:52 +0100 (Fri, 10 Mar 2006) New Revision: 1145 Modified: trunk/AUTHORS trunk/NEWS trunk/cipher/ChangeLog trunk/cipher/md.c trunk/cipher/sha256.c trunk/doc/ChangeLog trunk/doc/gcrypt.texi trunk/src/ChangeLog trunk/src/cipher.h trunk/src/gcrypt.h trunk/tests/ChangeLog trunk/tests/basic.c Log: Applied pacthes from Brad Hards. Note, that the HMAC tests for SHA-384 and SHA-512 are failing. Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2006-03-07 19:26:21 UTC (rev 1144) +++ trunk/AUTHORS 2006-03-10 10:23:52 UTC (rev 1145) @@ -70,7 +70,8 @@ LIBGCRYPT Brad Hards 2006-02-09 Assigns Past and Future Changes bradh@frogmouth.net -(Added OFB mode. Changed cipher/cipher.c, test/basic.c doc/gcrypt.tex) +(Added OFB mode. Changed cipher/cipher.c, test/basic.c doc/gcrypt.tex. + added SHA-224, changed cipher/sha256.c, added HMAC tests.) Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-07 19:26:21 UTC (rev 1144) +++ trunk/NEWS 2006-03-10 10:23:52 UTC (rev 1145) @@ -12,6 +12,7 @@ gcry_fast_random_poll NEW gcry_pk_algo_name CHANGED (minor change in respect to return value) gcry_cipher_algo_name CHANGED (minor change in respect to return value) +GCRY_MD_SHA224 NEW FIXME: Please add API changes immediatley so that we don't forget about them. Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2006-03-07 19:26:21 UTC (rev 1144) +++ trunk/cipher/ChangeLog 2006-03-10 10:23:52 UTC (rev 1145) @@ -1,3 +1,8 @@ +2006-03-10 Brad Hards (wk, patch 2005-04-22) + + * md.c, sha256.c: Add support for SHA-224. + (sha224_init): New. + 2006-01-18 Brad Hards (wk 2006-03-07) * cipher.c (cipher_encrypt, cipher_decrypt, do_ofb_encrypt) Modified: trunk/cipher/md.c =================================================================== --- trunk/cipher/md.c 2006-03-07 19:26:21 UTC (rev 1144) +++ trunk/cipher/md.c 2006-03-10 10:23:52 UTC (rev 1145) @@ -56,6 +56,7 @@ #endif #if USE_SHA256 { &_gcry_digest_spec_sha256, GCRY_MD_SHA256 }, + { &_gcry_digest_spec_sha224, GCRY_MD_SHA224 }, #endif #if USE_SHA512 { &_gcry_digest_spec_sha512, GCRY_MD_SHA512 }, Modified: trunk/cipher/sha256.c =================================================================== --- trunk/cipher/sha256.c 2006-03-07 19:26:21 UTC (rev 1144) +++ trunk/cipher/sha256.c 2006-03-10 10:23:52 UTC (rev 1145) @@ -1,5 +1,5 @@ /* sha256.c - SHA256 hash function - * Copyright (C) 2003 Free Software Foundation, Inc. + * Copyright (C) 2003, 2006 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -22,13 +22,16 @@ /* Test vectors: "abc" - ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad + SHA224: 23097d22 3405d822 8642a477 bda255b3 2aadbce4 bda0b3f7 e36c9da7 + SHA256: ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" - 248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1 + SHA224: 75388b16 512776cc 5dba5da1 fd890150 b0c6455c b4f58b19 52522525 + SHA256: 248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1 "a" one million times - cdc76e5c 9914fb92 81a1c7e2 84d73e67 f1809a48 a497200e 046d39cc c7112cd0 + SHA224: 20794655 980c91d8 bbb4c1ea 97618a4b f03f4258 1948b2ee 4ee7ad67 + SHA256: cdc76e5c 9914fb92 81a1c7e2 84d73e67 f1809a48 a497200e 046d39cc c7112cd0 */ @@ -70,6 +73,25 @@ } +static void +sha224_init (void *context) +{ + SHA256_CONTEXT *hd = context; + + hd->h0 = 0xc1059ed8; + hd->h1 = 0x367cd507; + hd->h2 = 0x3070dd17; + hd->h3 = 0xf70e5939; + hd->h4 = 0xffc00b31; + hd->h5 = 0x68581511; + hd->h6 = 0x64f98fa7; + hd->h7 = 0xbefa4fa4; + + hd->nblocks = 0; + hd->count = 0; +} + + /* Transform the message X which consists of 16 32-bit-words. See FIPS 180-2 for details. */ @@ -290,7 +312,20 @@ return hd->buf; } -static byte asn[19] = /* Object ID is 2.16.840.1.101.3.4.2.1 */ +static byte asn224[19] = /* Object ID is 2.16.840.1.101.3.4.2.4 */ + { 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, + 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, + 0x20 + }; + +static gcry_md_oid_spec_t oid_spec_sha224[] = + { + /* From RFC3874, Section 4 */ + { "2.16.840.1.101.3.4.2.4" }, + { NULL }, + }; + +static byte asn256[19] = /* Object ID is 2.16.840.1.101.3.4.2.1 */ { 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 }; @@ -302,9 +337,16 @@ { NULL }, }; +gcry_md_spec_t _gcry_digest_spec_sha224 = + { + "SHA224", asn224, DIM (asn224), oid_spec_sha224, 28, + sha224_init, sha256_write, sha256_final, sha256_read, + sizeof (SHA256_CONTEXT) + }; + gcry_md_spec_t _gcry_digest_spec_sha256 = { - "SHA256", asn, DIM (asn), oid_spec_sha256, 32, + "SHA256", asn256, DIM (asn256), oid_spec_sha256, 32, sha256_init, sha256_write, sha256_final, sha256_read, sizeof (SHA256_CONTEXT) }; Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-03-07 19:26:21 UTC (rev 1144) +++ trunk/doc/ChangeLog 2006-03-10 10:23:52 UTC (rev 1145) @@ -1,3 +1,7 @@ +2006-03-10 Brad Hards (wk, patch 2005-04-25) + + * gcrypt.texi: Document SHA-224 and typo fixes. + 2006-01-18 Brad Hards (wk 2006-03-07) * gcrypt.texi (Available cipher modes): Typo fix, add a little Modified: trunk/doc/gcrypt.texi =================================================================== --- trunk/doc/gcrypt.texi 2006-03-07 19:26:21 UTC (rev 1144) +++ trunk/doc/gcrypt.texi 2006-03-10 10:23:52 UTC (rev 1145) @@ -845,7 +845,7 @@ @code{0}. Also, it is guaranteed that an error value made from the error code @code{0} will be @code{0} itself (as a whole). This means that the error source information is lost for this error code, -however, as this error code indicates that no error occured, this is +however, as this error code indicates that no error occurred, this is generally not a problem. @item GPG_ERR_GENERAL @@ -1630,17 +1630,21 @@ bit. It yields a message digest of 20 bytes. Note that there is no implementation yet available. +@item GCRY_MD_SHA224 +This is the SHA-224 algorithm which yields a message digest of 28 bytes. +See Change Notice 1 for FIPS 180-2 for the specification. + @item GCRY_MD_SHA256 This is the SHA-256 algorithm which yields a message digest of 32 bytes. See FIPS 180-2 for the specification. @item GCRY_MD_SHA384 -This is reserved for SHA-2 with 384 bits. It yields a message digest of -48 bytes. Note that there is no implementation yet available. +This is the SHA-384 algorithm which yields a message digest of 48 bytes. +See FIPS 180-2 for the specification. @item GCRY_MD_SHA512 -This is reserved for SHA-2 with 512 bits. It yields a message digest of -64 bytes. Note that there is no implementation yet available. +This is the SHA-384 algorithm which yields a message digest of 64 bytes. +See FIPS 180-2 for the specification. @item GCRY_MD_CRC32 This is the ISO 3309 and ITU-T V.42 cyclic redundancy check. It @@ -1665,7 +1669,7 @@ @section Hash algorithm modules @acronym{Libgcrypt} makes it possible to load additional `message -digest modules'; these cipher can be used just like the message digest +digest modules'; these digests can be used just like the message digest algorithms that are built into the library directly. For an introduction into extension modules, see @xref{Modules}. @@ -1788,8 +1792,7 @@ @item GCRY_MD_FLAG_HMAC Turn the algorithm into a HMAC message authentication algorithm. This -does only work if just one algorithm is enabled for the handle and -SHA-384 and SHA512 is not used. Note that the function +only works if just one algorithm is enabled for the handle. Note that the function @code{gcry_md_setkey} must be used to set the MAC key. If you want CBC message authentication codes based on a cipher, see @xref{Working with cipher handles}. @@ -1846,7 +1849,7 @@ @end deftypefun -Often it is necessary to start hashing some data and than continue to +Often it is necessary to start hashing some data and then continue to hash different data. To avoid hashing the same data several times (which might not even be possible if the data is received from a pipe), a snapshot of the current hash context can be taken and turned into a new @@ -1861,10 +1864,10 @@ @end deftypefun -Now that we have prepared everything to calculate hashes, its time to -see how it is actually done. There are 2 ways for this, one to +Now that we have prepared everything to calculate hashes, it is time to +see how it is actually done. There are two ways for this, one to update the hash with a block of memory and one macro to update the hash -by just one character. Both may be used intermixed. +by just one character. Both methods can be used on the same hash context. @deftypefun void gcry_md_write (gcry_md_hd_t @var{h}, const void *@var{buffer}, size_t @var{length}) @@ -1880,10 +1883,10 @@ a macro to buffer the data before an actual update. @end deftypefun -The semantics of the hash functions don't allow to read out intermediate -message digests because the calculation must be finalized fist. This +The semantics of the hash functions do not provide for reading out intermediate +message digests because the calculation must be finalized first. This finalization may for example include the number of bytes hashed in the -message digest. +message digest or some padding. @deftypefun void gcry_md_final (gcry_md_hd_t @var{h}) @@ -1913,7 +1916,7 @@ Because it is often necessary to get the message digest of one block of memory, a fast convenience function is available for this task: -@deftypefun void gcry_md_hash_buffer (int @var{algo}, void *@var{digest}, const cvoid *@var{buffer}, size_t @var{length}); +@deftypefun void gcry_md_hash_buffer (int @var{algo}, void *@var{digest}, const void *@var{buffer}, size_t @var{length}); @code{gcry_md_hash_buffer} is a shortcut function to calculate a message digest of a buffer. This function does not require a context and @@ -1932,14 +1935,14 @@ @c *********************************** Hash algorithms are identified by internal algorithm numbers (see -@code{gcry_md_open} for a list. However, in most applications they are -used by names, so 2 functions are available to map between string +@code{gcry_md_open} for a list). However, in most applications they are +used by names, so two functions are available to map between string representations and hash algorithm identifiers. @deftypefun const char *gcry_md_algo_name (int @var{algo}) Map the digest algorithm id @var{algo} to a string representation of the -algorithm name. For unknown algorithms this functions returns an +algorithm name. For unknown algorithms this function returns an empty string. This function should not be used to test for the availability of an algorithm. @end deftypefun @@ -2571,7 +2574,7 @@ @deftypefun gcry_error_t gcry_pk_testkey (gcry_sexp_t @var{key}) Return zero if the private key @var{key} is `sane', an error code otherwise. -Note, that it is not possible to chek the `saneness' of a public key. +Note, that it is not possible to check the `saneness' of a public key. @end deftypefun @@ -3545,7 +3548,7 @@ actual data with index @var{number} is returned and the length of this data will be stored to @var{datalen}. If there is no data at the given index or the index represents another list, @code{NULL} is returned. -@strong{Note:} The returned pointer is valid as long as @var{list} is +@strong{Caution:} The returned pointer is valid as long as @var{list} is not modified or released. @noindent @@ -3897,7 +3900,7 @@ @end deftypefun @node Miscellaneous -@section Miscellanous +@section Miscellaneous @deftypefun gcry_mpi_t gcry_mpi_set_opaque (@w{gcry_mpi_t @var{a}}, @w{void *@var{p}}, @w{unsigned int @var{nbits}}) @@ -4093,7 +4096,7 @@ /* ... */ - /* Allocate a pool of 16k secure memory. This also drops priviliges + /* Allocate a pool of 16k secure memory. This also drops privileges on some systems. */ gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-03-07 19:26:21 UTC (rev 1144) +++ trunk/src/ChangeLog 2006-03-10 10:23:52 UTC (rev 1145) @@ -1,3 +1,7 @@ +2006-03-10 Werner Koch + + * gcrypt.h: Add GCRY_MD_SHA224. + 2005-11-02 Moritz Schulte * gcrypt.h: Update comments for functions: gcry_cipher_algo_name, Modified: trunk/src/cipher.h =================================================================== --- trunk/src/cipher.h 2006-03-07 19:26:21 UTC (rev 1144) +++ trunk/src/cipher.h 2006-03-10 10:23:52 UTC (rev 1145) @@ -67,6 +67,7 @@ extern gcry_md_spec_t _gcry_digest_spec_md5; extern gcry_md_spec_t _gcry_digest_spec_rmd160; extern gcry_md_spec_t _gcry_digest_spec_sha1; +extern gcry_md_spec_t _gcry_digest_spec_sha224; extern gcry_md_spec_t _gcry_digest_spec_sha256; extern gcry_md_spec_t _gcry_digest_spec_sha512; extern gcry_md_spec_t _gcry_digest_spec_sha384; Modified: trunk/src/gcrypt.h =================================================================== --- trunk/src/gcrypt.h 2006-03-07 19:26:21 UTC (rev 1144) +++ trunk/src/gcrypt.h 2006-03-10 10:23:52 UTC (rev 1145) @@ -1,6 +1,6 @@ /* gcrypt.h - GNU cryptographic library interface * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, - * 2004 Free Software Foundation, Inc. + * 2004, 2006 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -963,7 +963,8 @@ GCRY_MD_CRC32 = 302, GCRY_MD_CRC32_RFC1510 = 303, GCRY_MD_CRC24_RFC2440 = 304, - GCRY_MD_WHIRLPOOL = 305 + GCRY_MD_WHIRLPOOL = 305, + GCRY_MD_SHA224 = 306 }; /* Flags used with the open function. */ Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2006-03-07 19:26:21 UTC (rev 1144) +++ trunk/tests/ChangeLog 2006-03-10 10:23:52 UTC (rev 1145) @@ -1,3 +1,7 @@ +2006-03-10 Brad Hards (wk, patch 2006-02-18) + + * basic.c (check_one_hmac, check_hmac): New. + 2006-03-07 Werner Koch * benchmark.c (cipher_bench): Add OFB mode. Modified: trunk/tests/basic.c =================================================================== --- trunk/tests/basic.c 2006-03-07 19:26:21 UTC (rev 1144) +++ trunk/tests/basic.c 2006-03-10 10:23:52 UTC (rev 1145) @@ -113,6 +113,9 @@ int i, blklen, keylen; gcry_error_t err = 0; + if (verbose) + fprintf (stderr, "Starting CBC MAC checks.\n"); + for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++) { err = gcry_cipher_open (&hd, @@ -160,6 +163,10 @@ return; } + if (verbose) + fprintf (stderr, " checking CBC MAC for %s [%i]\n", + gcry_cipher_algo_name (tv[i].algo), + tv[i].algo); err = gcry_cipher_encrypt (hd, out, blklen, tv[i].plaintext, @@ -188,6 +195,8 @@ gcry_cipher_close (hd); } + if (verbose) + fprintf (stderr, "Completed CBC MAC checks.\n"); } static void @@ -230,6 +239,8 @@ int i; gcry_error_t err = 0; + if (verbose) + fprintf (stderr, "Starting AES128 CBC CTS checks.\n"); err = gcry_cipher_open (&hd, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_CBC, GCRY_CIPHER_CBC_CTS); @@ -259,6 +270,8 @@ return; } + if (verbose) + fprintf (stderr, " checking encryption for length %i\n", tv[i].inlen); err = gcry_cipher_encrypt (hd, out, MAX_DATA_LEN, plaintext, tv[i].inlen); if (err) @@ -280,6 +293,8 @@ gcry_cipher_close (hd); return; } + if (verbose) + fprintf (stderr, " checking decryption for length %i\n", tv[i].inlen); err = gcry_cipher_decrypt (hd, out, tv[i].inlen, NULL, 0); if (err) { @@ -294,6 +309,8 @@ } gcry_cipher_close (hd); + if (verbose) + fprintf (stderr, "Completed AES128 CBC CTS checks.\n"); } static void @@ -373,6 +390,8 @@ int i, j, keylen, blklen; gcry_error_t err = 0; + if (verbose) + fprintf (stderr, "Starting CTR cipher checks.\n"); for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++) { err = gcry_cipher_open (&hde, tv[i].algo, GCRY_CIPHER_MODE_CTR, 0); @@ -422,6 +441,10 @@ return; } + if (verbose) + fprintf (stderr, " checking CTR mode for for %s [%i]\n", + gcry_cipher_algo_name (tv[i].algo), + tv[i].algo); for (j = 0; tv[i].data[j].inlen; j++) { err = gcry_cipher_encrypt (hde, out, MAX_DATA_LEN, @@ -458,6 +481,8 @@ gcry_cipher_close (hde); gcry_cipher_close (hdd); } + if (verbose) + fprintf (stderr, "Completed CTR cipher checks.\n"); } static void @@ -942,10 +967,12 @@ }; int i; + if (verbose) + fprintf (stderr, "Starting Cipher checks.\n"); for (i = 0; algos[i]; i++) { if (verbose) - fprintf (stderr, "checking `%s' [%i]\n", + fprintf (stderr, " checking %s [%i]\n", gcry_cipher_algo_name (algos[i]), gcry_cipher_map_name (gcry_cipher_algo_name (algos[i]))); @@ -960,13 +987,16 @@ for (i = 0; algos2[i]; i++) { if (verbose) - fprintf (stderr, "checking `%s'\n", + fprintf (stderr, " checking `%s'\n", gcry_cipher_algo_name (algos2[i])); check_one_cipher (algos2[i], GCRY_CIPHER_MODE_STREAM, 0); } /* we have now run all cipher's selftests */ + if (verbose) + fprintf (stderr, "Completed Cipher checks.\n"); + /* TODO: add some extra encryption to test the higher level functions */ } @@ -1066,6 +1096,17 @@ { GCRY_MD_SHA1, "!" /* kludge for "a"*1000000 */ , "\x34\xAA\x97\x3C\xD4\xC4\xDA\xA4\xF6\x1E" "\xEB\x2B\xDB\xAD\x27\x31\x65\x34\x01\x6F" }, + // From RFC3874 + { GCRY_MD_SHA224, "abc", + "\x23\x09\x7d\x22\x34\x05\xd8\x22\x86\x42\xa4\x77\xbd\xa2\x55\xb3" + "\x2a\xad\xbc\xe4\xbd\xa0\xb3\xf7\xe3\x6c\x9d\xa7" }, + { GCRY_MD_SHA224, + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "\x75\x38\x8b\x16\x51\x27\x76\xcc\x5d\xba\x5d\xa1\xfd\x89\x01\x50" + "\xb0\xc6\x45\x5c\xb4\xf5\x8b\x19\x52\x52\x25\x25" }, + { GCRY_MD_SHA224, "!", + "\x20\x79\x46\x55\x98\x0c\x91\xd8\xbb\xb4\xc1\xea\x97\x61\x8a\x4b" + "\xf0\x3f\x42\x58\x19\x48\xb2\xee\x4e\xe7\xad\x67" }, { GCRY_MD_SHA256, "abc", "\xba\x78\x16\xbf\x8f\x01\xcf\xea\x41\x41\x40\xde\x5d\xae\x22\x23" "\xb0\x03\x61\xa3\x96\x17\x7a\x9c\xb4\x10\xff\x61\xf2\x00\x15\xad" }, @@ -1133,23 +1174,25 @@ "ghijklmnopqrstuvwxyz+0123456789", "\x46\x7D\xB8\x08\x63\xEB\xCE\x48\x8D\xF1\xCD\x12" "\x61\x65\x5D\xE9\x57\x89\x65\x65\x97\x5F\x91\x97" }, -#if 0 { GCRY_MD_TIGER, "Tiger - A Fast New Hash Function, " "by Ross Anderson and Eli Biham", - "0C410A042968868A1671DA5A3FD29A725EC1E457D3CDB303" }, + "\x0C\x41\x0A\x04\x29\x68\x86\x8A\x16\x71\xDA\x5A" + "\x3F\xD2\x9A\x72\x5E\xC1\xE4\x57\xD3\xCD\xB3\x03" }, { GCRY_MD_TIGER, "Tiger - A Fast New Hash Function, " "by Ross Anderson and Eli Biham, proceedings of Fa" "st Software Encryption 3, Cambridge.", - "EBF591D5AFA655CE7F22894FF87F54AC89C811B6B0DA3193" }, + "\xEB\xF5\x91\xD5\xAF\xA6\x55\xCE\x7F\x22\x89\x4F" + "\xF8\x7F\x54\xAC\x89\xC8\x11\xB6\xB0\xDA\x31\x93" }, { GCRY_MD_TIGER, "Tiger - A Fast New Hash Function, " "by Ross Anderson and Eli Biham, proceedings of Fa" "st Software Encryption 3, Cambridge, 1996.", - "3D9AEB03D1BD1A6357B2774DFD6D5B24DD68151D503974FC" }, + "\x3D\x9A\xEB\x03\xD1\xBD\x1A\x63\x57\xB2\x77\x4D" + "\xFD\x6D\x5B\x24\xDD\x68\x15\x1D\x50\x39\x74\xFC" }, { GCRY_MD_TIGER, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh" "ijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRS" "TUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", - "00B83EB4E53440C5 76AC6AAEE0A74858 25FD15E70A59FFE4" }, -#endif + "\x00\xB8\x3E\xB4\xE5\x34\x40\xC5\x76\xAC\x6A\xAE" + "\xE0\xA7\x48\x58\x25\xFD\x15\xE7\x0A\x59\xFF\xE4" }, { GCRY_MD_WHIRLPOOL, "", "\x19\xFA\x61\xD7\x55\x22\xA4\x66\x9B\x44\xE3\x9C\x1D\x2E\x17\x26" "\xC5\x30\x23\x21\x30\xD4\x07\xF8\x9A\xFE\xE0\x96\x49\x97\xF7\xA7" @@ -1181,18 +1224,387 @@ }; int i; + if (verbose) + fprintf (stderr, "Starting hash checks.\n"); + for (i = 0; algos[i].md; i++) { if (verbose) - fprintf (stderr, "checking `%s'\n", gcry_md_algo_name (algos[i].md)); + fprintf (stderr, " checking %s [%i] for length %zi\n", + gcry_md_algo_name (algos[i].md), + algos[i].md, + strlen(algos[i].data)); check_one_md (algos[i].md, algos[i].data, strlen (algos[i].data), algos[i].expect); } - /* TODO: test HMAC mode */ + if (verbose) + fprintf (stderr, "Completed hash checks.\n"); } +static void +check_one_hmac (int algo, char *data, int datalen, + char *key, int keylen, char *expect) +{ + gcry_md_hd_t hd, hd2; + unsigned char *p; + int mdlen; + int i; + gcry_error_t err = 0; + + err = gcry_md_open (&hd, algo, GCRY_MD_FLAG_HMAC); + if (err) + { + fail ("algo %d, grcy_md_open failed: %s\n", algo, gpg_strerror (err)); + return; + } + + mdlen = gcry_md_get_algo_dlen (algo); + if (mdlen < 1 || mdlen > 500) + { + fail ("algo %d, grcy_md_get_algo_dlen failed: %d\n", algo, mdlen); + return; + } + + gcry_md_setkey( hd, key, keylen ); + + gcry_md_write (hd, data, datalen); + + err = gcry_md_copy (&hd2, hd); + if (err) + { + fail ("algo %d, gcry_md_copy failed: %s\n", algo, gpg_strerror (err)); + } + + gcry_md_close (hd); + + p = gcry_md_read (hd2, algo); + if (0 == p) + fail("algo %d, hmac gcry_md_read failed\n", algo); + + if (memcmp (p, expect, mdlen)) + { + printf ("computed: "); + for (i = 0; i < mdlen; i++) + printf ("%02x ", p[i] & 0xFF); + printf ("\nexpected: "); + for (i = 0; i < mdlen; i++) + printf ("%02x ", expect[i] & 0xFF); + printf ("\n"); + + fail ("algo %d, digest mismatch\n", algo); + } + + gcry_md_close (hd2); +} + +static void +check_hmac (void) +{ + static struct algos + { + int md; + char *data; + char *key; + char *expect; + } algos[] = + { + { GCRY_MD_MD5, "what do ya want for nothing?", "Jefe", + "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38" }, + { GCRY_MD_MD5, + "Hi There", + "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", + "\x92\x94\x72\x7a\x36\x38\xbb\x1c\x13\xf4\x8e\xf8\x15\x8b\xfc\x9d" }, + { GCRY_MD_MD5, + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd", + "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA", + "\x56\xbe\x34\x52\x1d\x14\x4c\x88\xdb\xb8\xc7\x33\xf0\xe8\xb3\xf6" }, + { GCRY_MD_MD5, + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd", + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", + "\x69\x7e\xaf\x0a\xca\x3a\x3a\xea\x3a\x75\x16\x47\x46\xff\xaa\x79" }, + { GCRY_MD_MD5, "Test With Truncation", + "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c", + "\x56\x46\x1e\xf2\x34\x2e\xdc\x00\xf9\xba\xb9\x95\x69\x0e\xfd\x4c" }, + { GCRY_MD_MD5, "Test Using Larger Than Block-Size Key - Hash Key First", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa", + "\x6b\x1a\xb7\xfe\x4b\xd7\xbf\x8f\x0b\x62\xe6\xce\x61\xb9\xd0\xcd" }, + { GCRY_MD_MD5, + "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa", + "\x6f\x63\x0f\xad\x67\xcd\xa0\xee\x1f\xb1\xf5\x62\xdb\x3a\xa5\x3e", }, + { GCRY_MD_SHA256, "what do ya want for nothing?", "Jefe", + "\x5b\xdc\xc1\x46\xbf\x60\x75\x4e\x6a\x04\x24\x26\x08\x95\x75\xc7\x5a" + "\x00\x3f\x08\x9d\x27\x39\x83\x9d\xec\x58\xb9\x64\xec\x38\x43" }, + { GCRY_MD_SHA256, + "Hi There", + "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" + "\x0b\x0b\x0b", + "\xb0\x34\x4c\x61\xd8\xdb\x38\x53\x5c\xa8\xaf\xce\xaf\x0b\xf1\x2b\x88" + "\x1d\xc2\x00\xc9\x83\x3d\xa7\x26\xe9\x37\x6c\x2e\x32\xcf\xf7" }, + { GCRY_MD_SHA256, + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd", + "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" + "\xAA\xAA\xAA\xAA", + "\x77\x3e\xa9\x1e\x36\x80\x0e\x46\x85\x4d\xb8\xeb\xd0\x91\x81\xa7" + "\x29\x59\x09\x8b\x3e\xf8\xc1\x22\xd9\x63\x55\x14\xce\xd5\x65\xfe" }, + { GCRY_MD_SHA256, + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd", + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", + "\x82\x55\x8a\x38\x9a\x44\x3c\x0e\xa4\xcc\x81\x98\x99\xf2\x08" + "\x3a\x85\xf0\xfa\xa3\xe5\x78\xf8\x07\x7a\x2e\x3f\xf4\x67\x29\x66\x5b" }, + { GCRY_MD_SHA256, + "Test Using Larger Than Block-Size Key - Hash Key First", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa", + "\x60\xe4\x31\x59\x1e\xe0\xb6\x7f\x0d\x8a\x26\xaa\xcb\xf5\xb7\x7f" + "\x8e\x0b\xc6\x21\x37\x28\xc5\x14\x05\x46\x04\x0f\x0e\xe3\x7f\x54" }, + { GCRY_MD_SHA256, + "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa", + "\x9b\x09\xff\xa7\x1b\x94\x2f\xcb\x27\x63\x5f\xbc\xd5\xb0\xe9\x44" + "\xbf\xdc\x63\x64\x4f\x07\x13\x93\x8a\x7f\x51\x53\x5c\x3a\x35\xe2" }, + { GCRY_MD_SHA224, "what do ya want for nothing?", "Jefe", + "\xa3\x0e\x01\x09\x8b\xc6\xdb\xbf\x45\x69\x0f\x3a\x7e\x9e\x6d\x0f" + "\x8b\xbe\xa2\xa3\x9e\x61\x48\x00\x8f\xd0\x5e\x44" }, + { GCRY_MD_SHA224, + "Hi There", + "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" + "\x0b\x0b\x0b", + "\x89\x6f\xb1\x12\x8a\xbb\xdf\x19\x68\x32\x10\x7c\xd4\x9d\xf3\x3f\x47" + "\xb4\xb1\x16\x99\x12\xba\x4f\x53\x68\x4b\x22" }, + { GCRY_MD_SHA224, + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd", + "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" + "\xAA\xAA\xAA\xAA", + "\x7f\xb3\xcb\x35\x88\xc6\xc1\xf6\xff\xa9\x69\x4d\x7d\x6a\xd2\x64" + "\x93\x65\xb0\xc1\xf6\x5d\x69\xd1\xec\x83\x33\xea" }, + { GCRY_MD_SHA224, + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd", + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", + "\x6c\x11\x50\x68\x74\x01\x3c\xac\x6a\x2a\xbc\x1b\xb3\x82\x62" + "\x7c\xec\x6a\x90\xd8\x6e\xfc\x01\x2d\xe7\xaf\xec\x5a" }, + { GCRY_MD_SHA224, + "Test Using Larger Than Block-Size Key - Hash Key First", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa", + "\x95\xe9\xa0\xdb\x96\x20\x95\xad\xae\xbe\x9b\x2d\x6f\x0d\xbc\xe2" + "\xd4\x99\xf1\x12\xf2\xd2\xb7\x27\x3f\xa6\x87\x0e" }, + { GCRY_MD_SHA224, + "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa", + "\x3a\x85\x41\x66\xac\x5d\x9f\x02\x3f\x54\xd5\x17\xd0\xb3\x9d\xbd" + "\x94\x67\x70\xdb\x9c\x2b\x95\xc9\xf6\xf5\x65\xd1" }, + { GCRY_MD_SHA384, "what do ya want for nothing?", "Jefe", + "\xaf\x45\xd2\xe3\x76\x48\x40\x31\x61\x7f\x78\xd2\xb5\x8a\x6b\x1b" + "\x9c\x7e\xf4\x64\xf5\xa0\x1b\x47\xe4\x2e\xc3\x73\x63\x22\x44\x5e" + "\x8e\x22\x40\xca\x5e\x69\xe2\xc7\x8b\x32\x39\xec\xfa\xb2\x16\x49" }, + { GCRY_MD_SHA384, + "Hi There", + "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" + "\x0b\x0b\x0b", + "\xaf\xd0\x39\x44\xd8\x48\x95\x62\x6b\x08\x25\xf4\xab\x46\x90\x7f\x15" + "\xf9\xda\xdb\xe4\x10\x1e\xc6\x82\xaa\x03\x4c\x7c\xeb\xc5\x9c\xfa\xea" + "\x9e\xa9\x07\x6e\xde\x7f\x4a\xf1\x52\xe8\xb2\xfa\x9c\xb6" }, + { GCRY_MD_SHA384, + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd", + "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" + "\xAA\xAA\xAA\xAA", + "\x88\x06\x26\x08\xd3\xe6\xad\x8a\x0a\xa2\xac\xe0\x14\xc8\xa8\x6f" + "\x0a\xa6\x35\xd9\x47\xac\x9f\xeb\xe8\x3e\xf4\xe5\x59\x66\x14\x4b" + "\x2a\x5a\xb3\x9d\xc1\x38\x14\xb9\x4e\x3a\xb6\xe1\x01\xa3\x4f\x27" }, + { GCRY_MD_SHA384, + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd", + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", + "\x3e\x8a\x69\xb7\x78\x3c\x25\x85\x19\x33\xab\x62\x90\xaf\x6c\xa7" + "\x7a\x99\x81\x48\x08\x50\x00\x9c\xc5\x57\x7c\x6e\x1f\x57\x3b\x4e" + "\x68\x01\xdd\x23\xc4\xa7\xd6\x79\xcc\xf8\xa3\x86\xc6\x74\xcf\xfb" }, + { GCRY_MD_SHA384, + "Test Using Larger Than Block-Size Key - Hash Key First", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa", + "\x4e\xce\x08\x44\x85\x81\x3e\x90\x88\xd2\xc6\x3a\x04\x1b\xc5\xb4" + "\x4f\x9e\xf1\x01\x2a\x2b\x58\x8f\x3c\xd1\x1f\x05\x03\x3a\xc4\xc6" + "\x0c\x2e\xf6\xab\x40\x30\xfe\x82\x96\x24\x8d\xf1\x63\xf4\x49\x52" }, + { GCRY_MD_SHA384, + "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa", + "\x66\x17\x17\x8e\x94\x1f\x02\x0d\x35\x1e\x2f\x25\x4e\x8f\xd3\x2c" + "\x60\x24\x20\xfe\xb0\xb8\xfb\x9a\xdc\xce\xbb\x82\x46\x1e\x99\xc5" + "\xa6\x78\xcc\x31\xe7\x99\x17\x6d\x38\x60\xe6\x11\x0c\x46\x52\x3e" }, + { GCRY_MD_SHA512, "what do ya want for nothing?", "Jefe", + "\x16\x4b\x7a\x7b\xfc\xf8\x19\xe2\xe3\x95\xfb\xe7\x3b\x56\xe0\xa3" + "\x87\xbd\x64\x22\x2e\x83\x1f\xd6\x10\x27\x0c\xd7\xea\x25\x05\x54" + "\x97\x58\xbf\x75\xc0\x5a\x99\x4a\x6d\x03\x4f\x65\xf8\xf0\xe6\xfd" + "\xca\xea\xb1\xa3\x4d\x4a\x6b\x4b\x63\x6e\x07\x0a\x38\xbc\xe7\x37" }, + { GCRY_MD_SHA512, + "Hi There", + "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" + "\x0b\x0b\x0b", + "\x87\xaa\x7c\xde\xa5\xef\x61\x9d\x4f\xf0\xb4\x24\x1a\x1d\x6c\xb0" + "\x23\x79\xf4\xe2\xce\x4e\xc2\x78\x7a\xd0\xb3\x05\x45\xe1\x7c\xde" + "\xda\xa8\x33\xb7\xd6\xb8\xa7\x02\x03\x8b\x27\x4e\xae\xa3\xf4\xe4" + "\xbe\x9d\x91\x4e\xeb\x61\xf1\x70\x2e\x69\x6c\x20\x3a\x12\x68\x54" }, + { GCRY_MD_SHA512, + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" + "\xdd\xdd\xdd\xdd\xdd", + "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" + "\xAA\xAA\xAA\xAA", + "\xfa\x73\xb0\x08\x9d\x56\xa2\x84\xef\xb0\xf0\x75\x6c\x89\x0b\xe9" + "\xb1\xb5\xdb\xdd\x8e\xe8\x1a\x36\x55\xf8\x3e\x33\xb2\x27\x9d\x39" + "\xbf\x3e\x84\x82\x79\xa7\x22\xc8\x06\xb4\x85\xa4\x7e\x67\xc8\x07" + "\xb9\x46\xa3\x37\xbe\xe8\x94\x26\x74\x27\x88\x59\xe1\x32\x92\xfb" }, + { GCRY_MD_SHA512, + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" + "\xcd\xcd\xcd\xcd\xcd", + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", + "\xb0\xba\x46\x56\x37\x45\x8c\x69\x90\xe5\xa8\xc5\xf6\x1d\x4a\xf7" + "\xe5\x76\xd9\x7f\xf9\x4b\x87\x2d\xe7\x6f\x80\x50\x36\x1e\xe3\xdb" + "\xa9\x1c\xa5\xc1\x1a\xa2\x5e\xb4\xd6\x79\x27\x5c\xc5\x78\x80\x63" + "\xa5\xf1\x97\x41\x12\x0c\x4f\x2d\xe2\xad\xeb\xeb\x10\xa2\x98\xdd" }, + { GCRY_MD_SHA512, + "Test Using Larger Than Block-Size Key - Hash Key First", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa", + "\x80\xb2\x42\x63\xc7\xc1\xa3\xeb\xb7\x14\x93\xc1\xdd\x7b\xe8\xb4" + "\x9b\x46\xd1\xf4\x1b\x4a\xee\xc1\x12\x1b\x01\x37\x83\xf8\xf3\x52" + "\x6b\x56\xd0\x37\xe0\x5f\x25\x98\xbd\x0f\xd2\x21\x5d\x6a\x1e\x52" + "\x95\xe6\x4f\x73\xf6\x3f\x0a\xec\x8b\x91\x5a\x98\x5d\x78\x65\x98" }, + { GCRY_MD_SHA512, + "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + "\xaa\xaa\xaa", + "\xe3\x7b\x6a\x77\x5d\xc8\x7d\xba\xa4\xdf\xa9\xf9\x6e\x5e\x3f\xfd" + "\xde\xbd\x71\xf8\x86\x72\x89\x86\x5d\xf5\xa3\x2d\x20\xcd\xc9\x44" + "\xb6\x02\x2c\xac\x3c\x49\x82\xb1\x0d\x5e\xeb\x55\xc3\xe4\xde\x15" + "\x13\x46\x76\xfb\x6d\xe0\x44\x60\x65\xc9\x74\x40\xfa\x8c\x6a\x58" }, + { 0 }, + }; + int i; + + if (verbose) + fprintf (stderr, "Starting hashed MAC checks.\n"); + + for (i = 0; algos[i].md; i++) + { + if (verbose) + fprintf (stderr, " checking %s [%i] for length %zi\n", + gcry_md_algo_name (algos[i].md), + algos[i].md, + strlen(algos[i].data)); + + check_one_hmac (algos[i].md, algos[i].data, strlen (algos[i].data), + algos[i].key, strlen(algos[i].key), + algos[i].expect); + } + + if (verbose) + fprintf (stderr, "Completed hashed MAC checks.\n"); + } + /* Check that the signature SIG matches the hash HASH. PKEY is the public key used for the verification. BADHASH is a hasvalue which should; result in a bad signature status. */ @@ -1260,7 +1672,7 @@ for (dataidx = 0; datas[dataidx].data; dataidx++) { if (verbose) - fprintf (stderr, "signature test %d\n", dataidx); + fprintf (stderr, " signature test %d\n", dataidx); rc = gcry_sexp_sscan (&hash, NULL, datas[dataidx].data, strlen (datas[dataidx].data)); @@ -1334,7 +1746,8 @@ { gcry_sexp_t key_spec, key, pub_key, sec_key; int rc; - + if (verbose) + fprintf (stderr, " generating RSA key:"); rc = gcry_sexp_new (&key_spec, "(genkey (rsa (nbits 4:1024)))", 0, 1); if (rc) @@ -1366,7 +1779,7 @@ do_check_one_pubkey (n, skey, pkey, NULL, FLAG_SIGN | FLAG_CRYPT); } -/* Run all tests for the public key fucntions. */ +/* Run all tests for the public key functions. */ static void check_pubkey (void) { @@ -1476,12 +1889,22 @@ }, }; int i; - + if (verbose) + fprintf (stderr, "Starting public key checks.\n"); for (i = 0; i < sizeof (pubkeys) / sizeof (*pubkeys); i++) if (pubkeys[i].id) check_one_pubkey (i, pubkeys[i]); + if (verbose) + fprintf (stderr, "Completed public key checks.\n"); - check_one_pubkey_new (i); + if (verbose) + fprintf (stderr, "Starting additional public key checks.\n"); + for (i = 0; i < sizeof (pubkeys) / sizeof (*pubkeys); i++) + if (pubkeys[i].id) + check_one_pubkey_new (i); + if (verbose) + fprintf (stderr, "Completed additional public key checks.\n"); + } int @@ -1510,7 +1933,10 @@ check_cfb_cipher (); check_ofb_cipher (); check_digests (); + check_hmac (); check_pubkey (); + if (verbose) + fprintf (stderr, "\nAll tests completed. Errors: %i\n", error_count); return error_count ? 1 : 0; } From cvs at cvs.gnupg.org Sun Mar 12 16:33:58 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Sun Mar 12 16:07:57 2006 Subject: [svn] GnuPG - r4063 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-12 16:33:57 +0100 (Sun, 12 Mar 2006) New Revision: 4063 Modified: trunk/g10/ChangeLog trunk/g10/keyedit.c trunk/g10/sig-check.c Log: * sig-check.c (signature_check2): Print the backsig warning when there is no backsig present. Give a URL for more information. * keyedit.c (menu_backsign): Small tweak to work properly with keys originally generated with older GnuPGs that included comments in the secret keys. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-11 15:29:57 UTC (rev 4062) +++ trunk/g10/ChangeLog 2006-03-12 15:33:57 UTC (rev 4063) @@ -1,3 +1,12 @@ +2006-03-12 David Shaw + + * sig-check.c (signature_check2): Print the backsig warning when + there is no backsig present. Give a URL for more information. + + * keyedit.c (menu_backsign): Small tweak to work properly with + keys originally generated with older GnuPGs that included comments + in the secret keys. + 2006-03-09 David Shaw * build-packet.c (string_to_notation): Add ability to indicate a Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2006-03-11 15:29:57 UTC (rev 4062) +++ trunk/g10/keyedit.c 2006-03-12 15:33:57 UTC (rev 4063) @@ -3699,9 +3699,10 @@ keys), so we just pick the selfsig with the right class. This is what menu_expire does as well. */ for(node2=node2->next; - node2 && node2->pkt->pkttype==PKT_SIGNATURE; + node2 && node2->pkt->pkttype!=PKT_SECRET_SUBKEY; node2=node2->next) - if(node2->pkt->pkt.signature->version>=4 + if(node2->pkt->pkttype==PKT_SIGNATURE + && node2->pkt->pkt.signature->version>=4 && node2->pkt->pkt.signature->keyid[0]==sig_pk->pkt->pkt.signature->keyid[0] && node2->pkt->pkt.signature->keyid[1]==sig_pk->pkt->pkt.signature->keyid[1] && node2->pkt->pkt.signature->sig_class==sig_pk->pkt->pkt.signature->sig_class) Modified: trunk/g10/sig-check.c =================================================================== --- trunk/g10/sig-check.c 2006-03-11 15:29:57 UTC (rev 4062) +++ trunk/g10/sig-check.c 2006-03-12 15:33:57 UTC (rev 4063) @@ -96,15 +96,17 @@ signaures issued by it. */ if(rc==0 && !pk->is_primary && pk->backsig<2) { - /* TODO: In a future version, once enough signing subkeys - have backsigs, change this to always give the warning, - and have --require-backsigs enable or disable the - G10ERR_GENERAL. */ - if(pk->backsig==0 && opt.flags.require_cross_cert) + if(pk->backsig==0) { log_info(_("WARNING: signing subkey %s is not" " cross-certified\n"),keystr_from_pk(pk)); - rc=G10ERR_GENERAL; + log_info(_("please see %s for more information\n"), + "http://www.gnupg.org/subkey-cross-certify.html"); + /* --require-cross-certification makes this warning an + error. TODO: change the default to require this + after more keys have backsigs. */ + if(opt.flags.require_cross_cert) + rc=G10ERR_GENERAL; } else if(pk->backsig==1) { From cvs at cvs.gnupg.org Mon Mar 13 09:57:48 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Mar 13 09:31:29 2006 Subject: [svn] gcry - r1146 - trunk/cipher Message-ID: Author: wk Date: 2006-03-13 09:57:47 +0100 (Mon, 13 Mar 2006) New Revision: 1146 Modified: trunk/cipher/ChangeLog trunk/cipher/md.c Log: Fixed hmac for larger blocksizes algorithms Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2006-03-10 10:23:52 UTC (rev 1145) +++ trunk/cipher/ChangeLog 2006-03-13 08:57:47 UTC (rev 1146) @@ -1,3 +1,8 @@ +2006-03-12 Brad Hards (wk) + + * md.c (md_open): Use new variable macpads_Bsize instead of + hardwiring the block size. Changed at all places. + 2006-03-10 Brad Hards (wk, patch 2005-04-22) * md.c, sha256.c: Add support for SHA-224. Modified: trunk/cipher/md.c =================================================================== --- trunk/cipher/md.c 2006-03-10 10:23:52 UTC (rev 1145) +++ trunk/cipher/md.c 2006-03-13 08:57:47 UTC (rev 1146) @@ -1,5 +1,5 @@ /* md.c - message digest dispatcher - * Copyright (C) 1998, 1999, 2002, 2003 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2002, 2003, 2006 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -101,6 +101,7 @@ int finalized; GcryDigestEntry *list; byte *macpads; + int macpads_Bsize; /* Blocksize as used for the HMAC pads. */ }; @@ -430,7 +431,13 @@ if (hmac) { - ctx->macpads = gcry_malloc_secure (128); + if ( (GCRY_MD_SHA384 == algo) || (GCRY_MD_SHA512 == algo) ) { + ctx->macpads_Bsize = 128; + ctx->macpads = gcry_malloc_secure (2*(ctx->macpads_Bsize)); + } else { + ctx->macpads_Bsize = 64; + ctx->macpads = gcry_malloc_secure (2*(ctx->macpads_Bsize)); + } if (! ctx->macpads) { md_close (hd); @@ -592,14 +599,14 @@ b->debug = NULL; if (a->macpads) { - b->macpads = gcry_malloc_secure (128); + b->macpads = gcry_malloc_secure (2*(a->macpads_Bsize)); if (! b->macpads) { md_close (bhd); err = gpg_err_code_from_errno (errno); } else - memcpy (b->macpads, a->macpads, 128); + memcpy (b->macpads, a->macpads, (2*(a->macpads_Bsize))); } } @@ -662,7 +669,7 @@ (*r->digest->init) (&r->context.c); } if (a->ctx->macpads) - md_write (a, a->ctx->macpads, 64); /* inner pad */ + md_write (a, a->ctx->macpads, a->ctx->macpads_Bsize); /* inner pad */ } static void @@ -686,7 +693,7 @@ if (a->ctx->macpads) { - wipememory (a->ctx->macpads, 128); + wipememory (a->ctx->macpads, 2*(a->ctx->macpads_Bsize)); gcry_free(a->ctx->macpads); } @@ -755,7 +762,7 @@ if (err) _gcry_fatal_error (err, NULL); - md_write (om, a->ctx->macpads+64, 64); + md_write (om, (a->ctx->macpads)+(a->ctx->macpads_Bsize), a->ctx->macpads_Bsize); md_write (om, p, dlen); md_final (om); /* Replace our digest with the mac (they have the same size). */ @@ -786,12 +793,12 @@ assert ( keylen <= 64 ); } - memset ( hd->ctx->macpads, 0, 128 ); + memset ( hd->ctx->macpads, 0, 2*(hd->ctx->macpads_Bsize) ); ipad = hd->ctx->macpads; - opad = hd->ctx->macpads+64; + opad = (hd->ctx->macpads)+(hd->ctx->macpads_Bsize); memcpy ( ipad, key, keylen ); memcpy ( opad, key, keylen ); - for (i=0; i < 64; i++ ) + for (i=0; i < (hd->ctx->macpads_Bsize); i++ ) { ipad[i] ^= 0x36; opad[i] ^= 0x5c; From cvs at cvs.gnupg.org Tue Mar 14 03:23:02 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Tue Mar 14 02:56:40 2006 Subject: [svn] GnuPG - r4064 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-14 03:23:00 +0100 (Tue, 14 Mar 2006) New Revision: 4064 Modified: trunk/g10/ChangeLog trunk/g10/import.c trunk/g10/keyserver.c trunk/g10/main.h Log: * main.h, import.c (import_one): Optionally return the fingerprint of the key being imported. (import_keys_internal, import_keys_stream, import): Change all callers. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-12 15:33:57 UTC (rev 4063) +++ trunk/g10/ChangeLog 2006-03-14 02:23:00 UTC (rev 4064) @@ -1,3 +1,10 @@ +2006-03-13 David Shaw + + * main.h, import.c (import_one): Optionally return the fingerprint + of the key being imported. + (import_keys_internal, import_keys_stream, import): Change all + callers. + 2006-03-12 David Shaw * sig-check.c (signature_check2): Print the backsig warning when Modified: trunk/g10/import.c =================================================================== --- trunk/g10/import.c 2006-03-12 15:33:57 UTC (rev 4063) +++ trunk/g10/import.c 2006-03-14 02:23:00 UTC (rev 4064) @@ -1,6 +1,6 @@ /* import.c - import a key into our key storage. - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, - * 2005 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + * 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -60,12 +60,13 @@ }; -static int import( IOBUF inp, const char* fname, - struct stats_s *stats, unsigned int options ); +static int import( IOBUF inp, const char* fname,struct stats_s *stats, + unsigned char **fpr,size_t *fpr_len,unsigned int options ); static int read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root ); static void revocation_present(KBNODE keyblock); -static int import_one( const char *fname, KBNODE keyblock, - struct stats_s *stats, unsigned int options); +static int import_one(const char *fname, KBNODE keyblock,struct stats_s *stats, + unsigned char **fpr,size_t *fpr_len, + unsigned int options); static int import_secret_one( const char *fname, KBNODE keyblock, struct stats_s *stats, unsigned int options); static int import_revoke_cert( const char *fname, KBNODE node, @@ -163,7 +164,8 @@ */ static int import_keys_internal( IOBUF inp, char **fnames, int nnames, - void *stats_handle, unsigned int options ) + void *stats_handle, unsigned char **fpr, size_t *fpr_len, + unsigned int options ) { int i, rc = 0; struct stats_s *stats = stats_handle; @@ -172,7 +174,7 @@ stats = import_new_stats_handle (); if (inp) { - rc = import( inp, "[stream]", stats, options); + rc = import( inp, "[stream]", stats, fpr, fpr_len, options); } else { if( !fnames && !nnames ) @@ -191,15 +193,16 @@ } if( !inp2 ) log_error(_("can't open `%s': %s\n"), fname, strerror(errno) ); - else { - rc = import( inp2, fname, stats, options ); + else + { + rc = import( inp2, fname, stats, fpr, fpr_len, options ); iobuf_close(inp2); /* Must invalidate that ugly cache to actually close it. */ iobuf_ioctl (NULL, 2, 0, (char*)fname); if( rc ) - log_error("import from `%s' failed: %s\n", fname, - g10_errstr(rc) ); - } + log_error("import from `%s' failed: %s\n", fname, + g10_errstr(rc) ); + } if( !fname ) break; } @@ -225,18 +228,19 @@ import_keys( char **fnames, int nnames, void *stats_handle, unsigned int options ) { - import_keys_internal( NULL, fnames, nnames, stats_handle, options); + import_keys_internal(NULL,fnames,nnames,stats_handle,NULL,NULL,options); } int -import_keys_stream( IOBUF inp, void *stats_handle, unsigned int options ) +import_keys_stream( IOBUF inp, void *stats_handle, + unsigned char **fpr, size_t *fpr_len,unsigned int options ) { - return import_keys_internal( inp, NULL, 0, stats_handle, options); + return import_keys_internal(inp,NULL,0,stats_handle,fpr,fpr_len,options); } static int -import( IOBUF inp, const char* fname, - struct stats_s *stats, unsigned int options ) +import( IOBUF inp, const char* fname,struct stats_s *stats, + unsigned char **fpr,size_t *fpr_len,unsigned int options ) { PACKET *pending_pkt = NULL; KBNODE keyblock; @@ -252,7 +256,7 @@ while( !(rc = read_block( inp, &pending_pkt, &keyblock) )) { if( keyblock->pkt->pkttype == PKT_PUBLIC_KEY ) - rc = import_one( fname, keyblock, stats, options ); + rc = import_one( fname, keyblock, stats, fpr, fpr_len, options ); else if( keyblock->pkt->pkttype == PKT_SECRET_KEY ) rc = import_secret_one( fname, keyblock, stats, options ); else if( keyblock->pkt->pkttype == PKT_SIGNATURE @@ -673,8 +677,8 @@ * which called g10. */ static int -import_one( const char *fname, KBNODE keyblock, - struct stats_s *stats, unsigned int options ) +import_one( const char *fname, KBNODE keyblock, struct stats_s *stats, + unsigned char **fpr,size_t *fpr_len,unsigned int options ) { PKT_public_key *pk; PKT_public_key *pk_orig; @@ -692,6 +696,10 @@ BUG(); pk = node->pkt->pkt.public_key; + + if(fpr) + *fpr=fingerprint_from_pk(pk,NULL,fpr_len); + keyid_from_pk( pk, keyid ); uidnode = find_next_kbnode( keyblock, PKT_USER_ID ); @@ -1146,7 +1154,8 @@ KBNODE pub_keyblock=sec_to_pub_keyblock(keyblock); if(pub_keyblock) { - import_one(fname,pub_keyblock,stats,opt.import_options); + import_one(fname,pub_keyblock,stats, + NULL,NULL,opt.import_options); release_kbnode(pub_keyblock); } } Modified: trunk/g10/keyserver.c =================================================================== --- trunk/g10/keyserver.c 2006-03-12 15:33:57 UTC (rev 4063) +++ trunk/g10/keyserver.c 2006-03-14 02:23:00 UTC (rev 4064) @@ -1457,7 +1457,7 @@ way to do this could be to continue parsing this line-by-line and make a temp iobuf for each key. */ - import_keys_stream(spawn->fromchild,stats_handle, + import_keys_stream(spawn->fromchild,stats_handle,NULL,NULL, opt.keyserver_options.import_options); import_print_stats(stats_handle); @@ -1995,7 +1995,8 @@ /* CERTs are always in binary format */ opt.no_armor=1; - rc=import_keys_stream(key,NULL,opt.keyserver_options.import_options); + rc=import_keys_stream(key,NULL,NULL,NULL, + opt.keyserver_options.import_options); opt.no_armor=armor_status; Modified: trunk/g10/main.h =================================================================== --- trunk/g10/main.h 2006-03-12 15:33:57 UTC (rev 4063) +++ trunk/g10/main.h 2006-03-14 02:23:00 UTC (rev 4064) @@ -210,8 +210,8 @@ int parse_import_options(char *str,unsigned int *options,int noisy); void import_keys( char **fnames, int nnames, void *stats_hd, unsigned int options ); -int import_keys_stream( IOBUF inp, - void *stats_hd, unsigned int options ); +int import_keys_stream( IOBUF inp,void *stats_hd,unsigned char **fpr, + size_t *fpr_len,unsigned int options ); void *import_new_stats_handle (void); void import_release_stats_handle (void *p); void import_print_stats (void *hd); From cvs at cvs.gnupg.org Tue Mar 14 03:42:03 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Tue Mar 14 03:15:40 2006 Subject: [svn] GnuPG - r4065 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-14 03:42:02 +0100 (Tue, 14 Mar 2006) New Revision: 4065 Modified: trunk/g10/ChangeLog trunk/g10/getkey.c trunk/g10/keyserver-internal.h trunk/g10/keyserver.c Log: * keyserver-internal.h, keyserver.c (keyserver_spawn, keyserver_work, keyserver_import_cert, keyserver_import_name, keyserver_import_ldap): Pass fingerprint info through. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-14 02:23:00 UTC (rev 4064) +++ trunk/g10/ChangeLog 2006-03-14 02:42:02 UTC (rev 4065) @@ -1,5 +1,9 @@ 2006-03-13 David Shaw + * keyserver-internal.h, keyserver.c (keyserver_spawn, + keyserver_work, keyserver_import_cert, keyserver_import_name, + keyserver_import_ldap): Pass fingerprint info through. + * main.h, import.c (import_one): Optionally return the fingerprint of the key being imported. (import_keys_internal, import_keys_stream, import): Change all Modified: trunk/g10/getkey.c =================================================================== --- trunk/g10/getkey.c 2006-03-14 02:23:00 UTC (rev 4064) +++ trunk/g10/getkey.c 2006-03-14 02:42:02 UTC (rev 4065) @@ -926,7 +926,7 @@ { case AKL_CERT: glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_cert(name); + res=keyserver_import_cert(name,NULL,NULL); glo_ctrl.in_auto_key_retrieve--; if(res==0) @@ -963,7 +963,7 @@ case AKL_LDAP: glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_ldap(name); + res=keyserver_import_ldap(name,NULL,NULL); glo_ctrl.in_auto_key_retrieve--; if(res==0) @@ -979,7 +979,7 @@ if(opt.keyserver) { glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_name(name,opt.keyserver); + res=keyserver_import_name(name,NULL,NULL,opt.keyserver); glo_ctrl.in_auto_key_retrieve--; if(res==0) @@ -994,7 +994,7 @@ keyserver=keyserver_match(akl->spec); glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_name(name,keyserver); + res=keyserver_import_name(name,NULL,NULL,keyserver); glo_ctrl.in_auto_key_retrieve--; if(res==0) Modified: trunk/g10/keyserver-internal.h =================================================================== --- trunk/g10/keyserver-internal.h 2006-03-14 02:23:00 UTC (rev 4064) +++ trunk/g10/keyserver-internal.h 2006-03-14 02:42:02 UTC (rev 4065) @@ -43,9 +43,12 @@ int keyserver_refresh(STRLIST users); int keyserver_search(STRLIST tokens); int keyserver_fetch(STRLIST urilist); -int keyserver_import_cert(const char *name); +int keyserver_import_cert(const char *name, + unsigned char **fpr,size_t *fpr_len); int keyserver_import_pka(const char *name,unsigned char *fpr); -int keyserver_import_name(const char *name,struct keyserver_spec *keyserver); -int keyserver_import_ldap(const char *name); +int keyserver_import_name(const char *name,unsigned char **fpr,size_t *fpr_len, + struct keyserver_spec *keyserver); +int keyserver_import_ldap(const char *name, + unsigned char **fpr,size_t *fpr_len); #endif /* !_KEYSERVER_INTERNAL_H_ */ Modified: trunk/g10/keyserver.c =================================================================== --- trunk/g10/keyserver.c 2006-03-14 02:23:00 UTC (rev 4064) +++ trunk/g10/keyserver.c 2006-03-14 02:42:02 UTC (rev 4065) @@ -92,6 +92,7 @@ static int keyserver_work(enum ks_action action,STRLIST list, KEYDB_SEARCH_DESC *desc,int count, + unsigned char **fpr,size_t *fpr_len, struct keyserver_spec *keyserver); /* Reasonable guess */ @@ -754,7 +755,8 @@ while((num=strsep(&split," ,"))!=NULL) if(atoi(num)>=1 && atoi(num)<=numdesc) - keyserver_work(KS_GET,NULL,&desc[atoi(num)-1],1,opt.keyserver); + keyserver_work(KS_GET,NULL,&desc[atoi(num)-1],1, + NULL,NULL,opt.keyserver); xfree(answer); return 1; @@ -956,7 +958,8 @@ static int keyserver_spawn(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc, - int count,int *prog,struct keyserver_spec *keyserver) + int count,int *prog,unsigned char **fpr,size_t *fpr_len, + struct keyserver_spec *keyserver) { int ret=0,i,gotversion=0,outofband=0; STRLIST temp; @@ -1457,7 +1460,7 @@ way to do this could be to continue parsing this line-by-line and make a temp iobuf for each key. */ - import_keys_stream(spawn->fromchild,stats_handle,NULL,NULL, + import_keys_stream(spawn->fromchild,stats_handle,fpr,fpr_len, opt.keyserver_options.import_options); import_print_stats(stats_handle); @@ -1491,7 +1494,8 @@ static int keyserver_work(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc, - int count,struct keyserver_spec *keyserver) + int count,unsigned char **fpr,size_t *fpr_len, + struct keyserver_spec *keyserver) { int rc=0,ret=0; @@ -1509,7 +1513,7 @@ #else /* Spawn a handler */ - rc=keyserver_spawn(action,list,desc,count,&ret,keyserver); + rc=keyserver_spawn(action,list,desc,count,&ret,fpr,fpr_len,keyserver); if(ret) { switch(ret) @@ -1583,7 +1587,7 @@ if(sl) { - rc=keyserver_work(KS_SEND,sl,NULL,0,opt.keyserver); + rc=keyserver_work(KS_SEND,sl,NULL,0,NULL,NULL,opt.keyserver); free_strlist(sl); } @@ -1621,7 +1625,7 @@ } if(count>0) - rc=keyserver_work(KS_GET,NULL,desc,count,opt.keyserver); + rc=keyserver_work(KS_GET,NULL,desc,count,NULL,NULL,opt.keyserver); xfree(desc); @@ -1645,7 +1649,9 @@ memcpy(desc.u.fpr,fprint,fprint_len); - return keyserver_work(KS_GET,NULL,&desc,1,keyserver); + /* TODO: Warn here if the fingerprint we got doesn't match the one + we asked for? */ + return keyserver_work(KS_GET,NULL,&desc,1,NULL,NULL,keyserver); } int @@ -1659,7 +1665,7 @@ desc.u.kid[0]=keyid[0]; desc.u.kid[1]=keyid[1]; - return keyserver_work(KS_GET,NULL,&desc,1,keyserver); + return keyserver_work(KS_GET,NULL,&desc,1,NULL,NULL,keyserver); } /* code mostly stolen from do_export_stream */ @@ -1863,7 +1869,7 @@ Note that a preferred keyserver without a scheme:// will be interpreted as hkp:// */ - rc=keyserver_work(KS_GET,NULL,&desc[i],1,keyserver); + rc=keyserver_work(KS_GET,NULL,&desc[i],1,NULL,NULL,keyserver); if(rc) log_info(_("WARNING: unable to refresh key %s" " via %s: %s\n"),keystr_from_desc(&desc[i]), @@ -1893,7 +1899,7 @@ count,opt.keyserver->uri); } - rc=keyserver_work(KS_GET,NULL,desc,numdesc,opt.keyserver); + rc=keyserver_work(KS_GET,NULL,desc,numdesc,NULL,NULL,opt.keyserver); } xfree(desc); @@ -1912,7 +1918,7 @@ keyserver_search(STRLIST tokens) { if(tokens) - return keyserver_work(KS_SEARCH,tokens,NULL,0,opt.keyserver); + return keyserver_work(KS_SEARCH,tokens,NULL,0,NULL,NULL,opt.keyserver); else return 0; } @@ -1952,7 +1958,7 @@ */ spec->flags.direct_uri=1; - rc=keyserver_work(KS_GET,NULL,&desc,1,spec); + rc=keyserver_work(KS_GET,NULL,&desc,1,NULL,NULL,spec); if(rc) log_info (_("WARNING: unable to fetch URI %s: %s\n"), sl->d,g10_errstr(rc)); @@ -1975,7 +1981,7 @@ /* Import key in a CERT or pointed to by a CERT */ int -keyserver_import_cert(const char *name) +keyserver_import_cert(const char *name,unsigned char **fpr,size_t *fpr_len) { char *domain,*look,*url; IOBUF key; @@ -1995,7 +2001,7 @@ /* CERTs are always in binary format */ opt.no_armor=1; - rc=import_keys_stream(key,NULL,NULL,NULL, + rc=import_keys_stream(key,NULL,fpr,fpr_len, opt.keyserver_options.import_options); opt.no_armor=armor_status; @@ -2053,14 +2059,15 @@ /* Import all keys that match name */ int -keyserver_import_name(const char *name,struct keyserver_spec *keyserver) +keyserver_import_name(const char *name,unsigned char **fpr,size_t *fpr_len, + struct keyserver_spec *keyserver) { STRLIST list=NULL; int rc; append_to_strlist(&list,name); - rc=keyserver_work(KS_GETNAME,list,NULL,0,keyserver); + rc=keyserver_work(KS_GETNAME,list,NULL,0,fpr,fpr_len,keyserver); free_strlist(list); @@ -2070,7 +2077,7 @@ /* Use the PGP Universal trick of asking ldap://keys.(maildomain) for the key. */ int -keyserver_import_ldap(const char *name) +keyserver_import_ldap(const char *name,unsigned char **fpr,size_t *fpr_len) { char *domain; struct keyserver_spec *keyserver; @@ -2098,7 +2105,7 @@ strcat(keyserver->uri,"://"); strcat(keyserver->uri,keyserver->host); - rc=keyserver_work(KS_GETNAME,list,NULL,0,keyserver); + rc=keyserver_work(KS_GETNAME,list,NULL,0,fpr,fpr_len,keyserver); free_strlist(list); From cvs at cvs.gnupg.org Tue Mar 14 04:16:23 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Tue Mar 14 03:50:00 2006 Subject: [svn] GnuPG - r4066 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-14 04:16:21 +0100 (Tue, 14 Mar 2006) New Revision: 4066 Modified: trunk/g10/ChangeLog trunk/g10/getkey.c trunk/g10/keyserver-internal.h trunk/g10/keyserver.c Log: * keyserver-internal.h, keyserver.c (keyserver_import_pka): Use the same API as the other auto-key-locate fetchers. * getkey.c (get_pubkey_byname): Use the fingerprint of the key that we actually fetched. This helps prevent problems where the key that we fetched doesn't have the same name that we used to fetch it. In the case of CERT and PKA, this is an actual security requirement as the URL might point to a key put in by an attacker. By forcing the use of the fingerprint, we won't use the attacker's key here. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-14 02:42:02 UTC (rev 4065) +++ trunk/g10/ChangeLog 2006-03-14 03:16:21 UTC (rev 4066) @@ -1,5 +1,16 @@ 2006-03-13 David Shaw + * keyserver-internal.h, keyserver.c (keyserver_import_pka): Use + the same API as the other auto-key-locate fetchers. + + * getkey.c (get_pubkey_byname): Use the fingerprint of the key + that we actually fetched. This helps prevent problems where the + key that we fetched doesn't have the same name that we used to + fetch it. In the case of CERT and PKA, this is an actual security + requirement as the URL might point to a key put in by an attacker. + By forcing the use of the fingerprint, we won't use the attacker's + key here. + * keyserver-internal.h, keyserver.c (keyserver_spawn, keyserver_work, keyserver_import_cert, keyserver_import_name, keyserver_import_ldap): Pass fingerprint info through. Modified: trunk/g10/getkey.c =================================================================== --- trunk/g10/getkey.c 2006-03-14 02:42:02 UTC (rev 4065) +++ trunk/g10/getkey.c 2006-03-14 03:16:21 UTC (rev 4066) @@ -922,11 +922,14 @@ for(akl=opt.auto_key_locate;akl;akl=akl->next) { + unsigned char *fpr; + size_t fpr_len; + switch(akl->type) { case AKL_CERT: glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_cert(name,NULL,NULL); + res=keyserver_import_cert(name,&fpr,&fpr_len); glo_ctrl.in_auto_key_retrieve--; if(res==0) @@ -935,35 +938,17 @@ break; case AKL_PKA: - { - unsigned char fpr[MAX_FINGERPRINT_LEN]; + glo_ctrl.in_auto_key_retrieve++; + res=keyserver_import_pka(name,&fpr,&fpr_len); - glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_pka(name,fpr); - glo_ctrl.in_auto_key_retrieve--; - - if(res==0) - { - int i; - char fpr_string[MAX_FINGERPRINT_LEN*2+1]; - - log_info(_("Automatically retrieved `%s' via %s\n"), - name,"PKA"); - - free_strlist(namelist); - namelist=NULL; - - for(i=0;ispec); glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_name(name,NULL,NULL,keyserver); + res=keyserver_import_name(name,&fpr,&fpr_len,keyserver); glo_ctrl.in_auto_key_retrieve--; if(res==0) @@ -1004,6 +989,34 @@ break; } + /* Use the fingerprint of the key that we actually fetched. + This helps prevent problems where the key that we fetched + doesn't have the same name that we used to fetch it. In + the case of CERT and PKA, this is an actual security + requirement as the URL might point to a key put in by an + attacker. By forcing the use of the fingerprint, we + won't use the attacker's key here. */ + if(res==0 && fpr) + { + int i; + char fpr_string[MAX_FINGERPRINT_LEN*2+1]; + + assert(fpr_len<=MAX_FINGERPRINT_LEN); + + free_strlist(namelist); + namelist=NULL; + + for(i=0;i Author: twoaday Date: 2006-03-14 13:13:21 +0100 (Tue, 14 Mar 2006) New Revision: 139 Modified: trunk/src/ChangeLog trunk/src/gpgol-rsrcs.rc trunk/src/passphrase-dialog.c trunk/src/recipient-dialog.c Log: 2006-03-14 Timo Schulz * passphrase-dialog.c (decrypt_dlg_proc): When used as a signing key selection dialog, use a different title. * gpgol-rsrcs.rc: Use German titles for German dialog versions. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-01-26 11:15:11 UTC (rev 138) +++ trunk/src/ChangeLog 2006-03-14 12:13:21 UTC (rev 139) @@ -1,3 +1,9 @@ +2006-03-14 Timo Schulz + + * passphrase-dialog.c (decrypt_dlg_proc): When used + as a signing key selection dialog, use a different title. + * gpgol-rsrcs.rc: Use German titles for German dialog versions. + 2006-01-16 Werner Koch * verify-dialog.c (load_sigbox): Give a hint in case of a bad Modified: trunk/src/gpgol-rsrcs.rc =================================================================== --- trunk/src/gpgol-rsrcs.rc 2006-01-26 11:15:11 UTC (rev 138) +++ trunk/src/gpgol-rsrcs.rc 2006-03-14 12:13:21 UTC (rev 139) @@ -42,7 +42,7 @@ IDD_ENC_DE DIALOG DISCARDABLE 0, 0, 332, 215 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Recipient Dialog" +CAPTION "Auswahl des Empfängerschlüssels" FONT 8, "MS Sans Serif" BEGIN CONTROL "List1",IDC_ENC_RSET1,"SysListView32",LVS_REPORT | @@ -61,7 +61,7 @@ IDD_DEC_EXT_DE DIALOG DISCARDABLE 0, 0, 207, 143 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Secret Key Dialog" +CAPTION "Auswahl des geheimen Schlüssels" FONT 8, "MS Sans Serif" BEGIN LTEXT "Verschlüsselt mit folgenden Public-Keys:",IDC_STATIC,7, @@ -99,7 +99,7 @@ IDD_VRY_DE DIALOG DISCARDABLE 0, 0, 253, 116 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION -CAPTION "Verifictation Result" +CAPTION "Prüfungsresultat" FONT 8, "MS Sans Serif" BEGIN LTEXT "Signatur erstellt",IDC_STATIC,3,6,49,8 @@ -121,7 +121,7 @@ IDD_DEC_DE DIALOG DISCARDABLE 0, 0, 225, 101 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Secret Key Dialog" +CAPTION "Auswahl des geheimen Schlüssels" FONT 8, "MS Sans Serif" BEGIN COMBOBOX IDC_DEC_KEYLIST,9,7,209,58,CBS_DROPDOWNLIST | WS_VSCROLL | Modified: trunk/src/passphrase-dialog.c =================================================================== --- trunk/src/passphrase-dialog.c 2006-01-26 11:15:11 UTC (rev 138) +++ trunk/src/passphrase-dialog.c 2006-03-14 12:13:21 UTC (rev 139) @@ -322,7 +322,10 @@ _("Invalid passphrase; please try again..."):""); if (dec && !context->use_as_cb) - context->keyarray = load_secbox (dlg, IDC_DEC_KEYLIST); + { + context->keyarray = load_secbox (dlg, IDC_DEC_KEYLIST); + SetWindowText (dlg, _("Select Signing Key")); + } CheckDlgButton (dlg, IDC_DEC_HIDE, BST_CHECKED); center_window (dlg, NULL); Modified: trunk/src/recipient-dialog.c =================================================================== --- trunk/src/recipient-dialog.c 2006-01-26 11:15:11 UTC (rev 138) +++ trunk/src/recipient-dialog.c 2006-03-14 12:13:21 UTC (rev 139) @@ -415,8 +415,8 @@ hrset = GetDlgItem (dlg, IDC_ENC_RSET2); if (ListView_GetItemCount (hrset) == 0) { - MessageBox (dlg, "Please select at least one recipient key.", - "Recipient Dialog", MB_ICONINFORMATION|MB_OK); + MessageBox (dlg, _("Please select at least one recipient key."), + _("Recipient Dialog"), MB_ICONINFORMATION|MB_OK); return FALSE; } From cvs at cvs.gnupg.org Tue Mar 14 13:45:25 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue Mar 14 13:18:59 2006 Subject: [svn] gpg-error - r161 - trunk Message-ID: Author: marcus Date: 2006-03-14 13:45:25 +0100 (Tue, 14 Mar 2006) New Revision: 161 Modified: trunk/NEWS Log: GNU gettext is included for systems that do not provide it. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-14 12:44:14 UTC (rev 160) +++ trunk/NEWS 2006-03-14 12:45:25 UTC (rev 161) @@ -1,6 +1,8 @@ Noteworthy changes in version 1.3 (unreleased) ---------------------------------------------- + * GNU gettext is included for systems that do not provide it. + * Interface changes relative to the 1.2 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From cvs at cvs.gnupg.org Tue Mar 14 13:45:59 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue Mar 14 13:19:33 2006 Subject: [svn] gpg-error - r162 - trunk/src Message-ID: Author: marcus Date: 2006-03-14 13:45:58 +0100 (Tue, 14 Mar 2006) New Revision: 162 Modified: trunk/src/Makefile.am Log: Fix last change. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2006-03-14 12:45:25 UTC (rev 161) +++ trunk/src/Makefile.am 2006-03-14 12:45:58 UTC (rev 162) @@ -92,7 +92,7 @@ libgpg_error_la_SOURCES = gpg-error.h gettext.h $(arch_sources) \ init.c strsource.c strerror.c code-to-errno.c code-from-errno.c -libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" +libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -I../intl libgpg_error_la_LIBADD = $(intllibs) gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c $(arch_sources) From cvs at cvs.gnupg.org Tue Mar 14 14:13:13 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Mar 14 13:46:53 2006 Subject: [svn] gcry - r1147 - in trunk: . cipher tests Message-ID: Author: wk Date: 2006-03-14 14:13:11 +0100 (Tue, 14 Mar 2006) New Revision: 1147 Modified: trunk/ChangeLog trunk/NEWS trunk/TODO trunk/cipher/ChangeLog trunk/cipher/random.c trunk/configure.ac trunk/tests/ChangeLog trunk/tests/ac-data.c trunk/tests/ac.c trunk/tests/basic.c trunk/tests/keygen.c trunk/tests/pkbench.c trunk/tests/pubkey.c Log: Use quick key generation. Cleaned up output; i.e. take care of --verbose. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/ChangeLog 2006-03-14 13:13:11 UTC (rev 1147) @@ -1,3 +1,7 @@ +2006-03-14 Werner Koch + + * configure.ac: Check for fctnl and ftruncate. + 2005-12-08 Werner Koch * configure.ac: Changed the random device names for netbsd. From @@ -1032,7 +1036,7 @@ Copyright 1998, 1999, 2000, 2001, 2002, 2003, - 2004 Free Software Foundation, Inc. + 2004, 2006 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/NEWS 2006-03-14 13:13:11 UTC (rev 1147) @@ -7,6 +7,11 @@ general a good idea to spread this macro into the application code to make sure that these polls happen often enough. + * Reading and writing the random seed file is now protected by a + fcntl style file lock on systems that provide this function. + + * Support for SHA-224 and HMAC using SHA-384 and SHA-512. + * Interface changes relative to the 1.2.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gcry_fast_random_poll NEW Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/TODO 2006-03-14 13:13:11 UTC (rev 1147) @@ -1,6 +1,6 @@ What's left to do -*- outline -*- -* Add more tests. Even basic is very minimal. +* Add more tests. * udiv-qrnbd.o should get build as *.lo [HPUX] @@ -26,9 +26,6 @@ with the ac interface (i.e. by using ac's `data sets') and the pk interface could be changed to be a wrapper for the ac interface. -* HMAC won't work with sha-512 due to the different block size. OTOH, - I can imagine no cryptographic reason to use it. - * cipher/pubkey.c and pubkey implementaions. Don't rely on the secure memory based wiping function but add an extra wiping. @@ -39,3 +36,15 @@ * Use builtin bit functions of gcc 3.4 +* Consider using a daemon to maintain he random pool + + The down side of this is that we can't assume that the random das + has always been stored in "secure memory". And we rely on that + sniffing of Unix domain sockets is not possible. We can implement + this simply by detecting a special prefixed random seed name and + divert in this case to the daemon. There are several benefits with + such an approach: We keep the state of the RNG over invocations of + libgcrypt based applications, don't need time consuming + initialization of the pool and in case the entropy collectros need + to run that bunch of Unix utilities we don't waste their precious + results. Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/cipher/ChangeLog 2006-03-14 13:13:11 UTC (rev 1147) @@ -1,3 +1,12 @@ +2006-03-14 Werner Koch + + * random.c (lock_seed_file): New. + (read_seed_file, _gcry_update_random_seed_file): Use it. + + * random.c (gcry_create_nonce): Detect a fork and re-seed. + (read_pool): Fixed the fork detection; it used to work only for + multi-threaded processes. + 2006-03-12 Brad Hards (wk) * md.c (md_open): Use new variable macpads_Bsize instead of Modified: trunk/cipher/random.c =================================================================== --- trunk/cipher/random.c 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/cipher/random.c 2006-03-14 13:13:11 UTC (rev 1147) @@ -1,6 +1,6 @@ /* random.c - random number generator * Copyright (C) 1998, 2000, 2001, 2002, 2003, - * 2004 Free Software Foundation, Inc. + * 2004, 2005, 2006 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -62,7 +62,14 @@ #define RAND_MAX 32767 #endif +/* Check whether we can lock the seed file read write. */ +#if defined(HAVE_FCNTL) && defined(HAVE_FTRUNCATE) && !defined(HAVE_W32_SYSTEM) +#define LOCK_SEED_FILE 1 +#else +#define LOCK_SEED_FILE 0 +#endif + #if SIZEOF_UNSIGNED_LONG == 8 #define ADD_VALUE 0xa5a5a5a5a5a5a5a5 #elif SIZEOF_UNSIGNED_LONG == 4 @@ -259,7 +266,8 @@ byte *buf, *p; int err; - /* First a hack toavoid the strong random using our regression test suite. */ + /* First a hack to avoid the strong random using our regression test + suite. */ if (quick_test && level > 1) level = 1; @@ -531,6 +539,45 @@ } +/* Lock an open file identified by file descriptor FD and wait a + reasonable time to succeed. With FOR_WRITE set to true a write + lock will be taken. FNAME is used only for diagnostics. Returns 0 + on success or -1 on error. */ +static int +lock_seed_file (int fd, const char *fname, int for_write) +{ +#if LOCK_SEED_FILE + struct flock lck; + struct timeval tv; + int backoff=0; + + /* We take a lock on the entire file. */ + memset (&lck, 0, sizeof lck); + lck.l_type = for_write? F_WRLCK : F_RDLCK; + lck.l_whence = SEEK_SET; + + while (fcntl (fd, F_SETLK, &lck) == -1) + { + if (errno != EAGAIN && errno != EACCES) + { + log_info (_("can't lock `%s': %s\n"), fname, strerror (errno)); + return -1; + } + + if (backoff > 2) /* Show the first message after ~2.25 seconds. */ + log_info( _("waiting for lock on `%s'...\n"), fname); + + tv.tv_sec = backoff; + tv.tv_usec = 250000; + select (0, NULL, NULL, NULL, &tv); + if (backoff < 10) + backoff++ ; + } +#endif /*LOCK_SEED_FILE*/ + return 0; +} + + /* Read in a seed form the random_seed file and return true if this was successful. @@ -564,6 +611,11 @@ log_info(_("can't open `%s': %s\n"), seed_file_name, strerror(errno) ); return 0; } + if (lock_seed_file (fd, seed_file_name, 0)) + { + close (fd); + return 0; + } if (fstat( fd, &sb ) ) { log_info(_("can't stat `%s': %s\n"), seed_file_name, strerror(errno) ); @@ -652,7 +704,7 @@ log_fatal ("failed to acquire the pool lock: %s\n", strerror (err)); pool_is_locked = 1; - /* copy the entropy pool to a scratch pool and mix both of them */ + /* Copy the entropy pool to a scratch pool and mix both of them. */ for (i=0,dp=(ulong*)keypool, sp=(ulong*)rndpool; i < POOLWORDS; i++, dp++, sp++ ) { @@ -661,28 +713,41 @@ mix_pool(rndpool); rndstats.mixrnd++; mix_pool(keypool); rndstats.mixkey++; -#ifdef HAVE_DOSISH_SYSTEM +#if defined(HAVE_DOSISH_SYSTEM) || defined(__CYGWIN__) fd = open (seed_file_name, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IRUSR|S_IWUSR ); #else - fd = open (seed_file_name, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR ); +# if LOCK_SEED_FILE + fd = open (seed_file_name, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR ); +# else + fd = open (seed_file_name, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR ); +# endif #endif if (fd == -1 ) log_info (_("can't create `%s': %s\n"), seed_file_name, strerror(errno) ); + else if (lock_seed_file (fd, seed_file_name, 1)) + { + close (fd); + } +#if LOCK_SEED_FILE + else if (ftruncate (fd, 0)) + { + log_info(_("can't write `%s': %s\n"), seed_file_name, strerror(errno)); + close (fd); + } +#endif /*LOCK_SEED_FILE*/ else { do { i = write (fd, keypool, POOLSIZE ); } - while( i == -1 && errno == EINTR ); + while (i == -1 && errno == EINTR); if (i != POOLSIZE) - log_info (_("can't write `%s': %s\n"), - seed_file_name, strerror(errno) ); + log_info (_("can't write `%s': %s\n"),seed_file_name, strerror(errno)); if (close(fd)) - log_info(_("can't close `%s': %s\n"), - seed_file_name, strerror(errno) ); + log_info (_("can't close `%s': %s\n"),seed_file_name, strerror(errno)); } pool_is_locked = 0; @@ -694,22 +759,40 @@ /* Read random out of the pool. This function is the core of the - public random fucntions. Note that Level 0 is not anymore handeld - special and in fact an alias for level 1. */ + public random functions. Note that Level 0 is not anymore handeld + special and in fact an alias for level 1. Must be called with the + pool already locked. */ static void read_pool (byte *buffer, size_t length, int level) { int i; unsigned long *sp, *dp; - volatile pid_t my_pid; /* The volatile is there to make sure the - compiler does not optimize the code away - in case the getpid function is badly - attributed. */ + /* The volatile is there to make sure the compiler does not optimize + the code away in case the getpid function is badly attributed. + Note that we keep a pid in a static variable as well as in a + stack based one; the latter is to detect ill behaving thread + libraries, ignoring the pool mutexes. */ + static volatile pid_t my_pid = (pid_t)(-1); + volatile pid_t my_pid2; + retry: /* Get our own pid, so that we can detect a fork. */ - my_pid = getpid (); + my_pid2 = getpid (); + if (my_pid == (pid_t)(-1)) + my_pid = my_pid2; + if ( my_pid != my_pid2 ) + { + /* We detected a plain fork; i.e. we are now the child. Update + the static pid and add some randomness. */ + pid_t x; + my_pid = my_pid2; + x = my_pid; + add_randomness (&x, sizeof(x), 0); + just_mixed = 0; /* Make sure it will get mixed. */ + } + assert (pool_is_locked); /* Our code does not allow to extract more than POOLSIZE. Better @@ -756,7 +839,7 @@ pool_balance += needed; } - /* make sure the pool is filled */ + /* Make sure the pool is filled. */ while (!pool_filled) random_poll(); @@ -765,7 +848,10 @@ /* Mix the pid in so that we for sure won't deliver the same random after a fork. */ - add_randomness (&my_pid, sizeof (my_pid), 0); + { + pid_t apid = my_pid; + add_randomness (&apid, sizeof (apid), 0); + } /* Mix the pool (if add_randomness() didn't it). */ if (!just_mixed) @@ -783,8 +869,8 @@ mix_pool(rndpool); rndstats.mixrnd++; mix_pool(keypool); rndstats.mixkey++; - /* Read the required data. We use a readpointer to read from a - different position each time */ + /* Read the requested data. We use a read pointer to read from a + different position each time. */ while (length--) { *buffer++ = keypool[pool_readpos++]; @@ -801,17 +887,14 @@ /* We need to detect whether a fork has happened. A fork might have an identical pool and thus the child and the parent could emit - the very same random number. Obviously this can only happen when - running multi-threaded and the pool lock should even catch this. - However things do get wrong and thus we better check and retry it - here. We assume that the thread library has no other fatal - faults, though. - */ - if ( getpid () != my_pid ) + the very same random number. This test here is to detect forks + in a multi-threaded process. */ + if ( getpid () != my_pid2 ) { pid_t x = getpid(); add_randomness (&x, sizeof(x), 0); just_mixed = 0; /* Make sure it will get mixed. */ + my_pid = x; /* Also update the static pid. */ goto retry; } } @@ -1101,6 +1184,10 @@ { static unsigned char nonce_buffer[20+8]; static int nonce_buffer_initialized = 0; + static volatile pid_t my_pid; /* The volatile is there to make sure the + compiler does not optimize the code away + in case the getpid function is badly + attributed. */ unsigned char *p; size_t n; int err; @@ -1121,6 +1208,8 @@ pid_t apid = getpid (); time_t atime = time (NULL); + my_pid = apid; + if ((sizeof apid + sizeof atime) > sizeof nonce_buffer) BUG (); @@ -1137,6 +1226,12 @@ nonce_buffer_initialized = 1; } + else if ( my_pid != getpid () ) + { + /* We forked. Need to reseed the buffer - doing this for the + private part should be sufficient. */ + gcry_randomize (nonce_buffer+20, 8, GCRY_WEAK_RANDOM); + } /* Create the nonce by hashing the entire buffer, returning the hash and updating the first 20 bytes of the buffer with this hash. */ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/configure.ac 2006-03-14 13:13:11 UTC (rev 1147) @@ -1,6 +1,6 @@ # Configure.ac script for Libgcrypt # Copyright (C) 1998, 1999, 2000, 2001, 2002 -# 2003, 2004 Free Software Foundation, Inc. +# 2003, 2004, 2006 Free Software Foundation, Inc. # # This file is part of Libgcrypt. # @@ -484,6 +484,7 @@ # Other checks AC_CHECK_FUNCS(strerror rand mmap getpagesize waitpid wait4) AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime) +AC_CHECK_FUNCS(fcntl ftruncate) GNUPG_CHECK_MLOCK Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/tests/ChangeLog 2006-03-14 13:13:11 UTC (rev 1147) @@ -1,3 +1,15 @@ +2006-03-14 Werner Koch + + * ac-data.c (check_sexp_conversion, check_run): Take care of VERBOSE. + * basic.c (main): Speed up test key generation. + (main): use progress handler only in verbose mode. + * ac.c (main): Ditto. + * pubkey.c (main): Ditto. + * keygen.c (main): Ditto. + (check_rsa_keys): Print key only in verbose mode. + + * pkbench.c (main): Ditto. + 2006-03-10 Brad Hards (wk, patch 2006-02-18) * basic.c (check_one_hmac, check_hmac): New. Modified: trunk/tests/ac-data.c =================================================================== --- trunk/tests/ac-data.c 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/tests/ac-data.c 2006-03-14 13:13:11 UTC (rev 1147) @@ -63,7 +63,8 @@ err = gcry_ac_data_to_sexp (data, &sexp, identifiers); assert_err (err); - gcry_sexp_dump (sexp); + if (verbose) + gcry_sexp_dump (sexp); err = gcry_ac_data_from_sexp (&data2, sexp, identifiers); assert_err (err); @@ -128,7 +129,8 @@ check_sexp_conversion (data, identifiers_null); check_sexp_conversion (data, NULL); - printf ("data-set-test-0 succeeded\n"); + if (verbose) + printf ("data-set-test-0 succeeded\n"); gcry_ac_data_clear (data); @@ -161,16 +163,18 @@ assert_err (err); gcry_free ((void *) label1); /* FIXME!! */ gcry_mpi_release (mpi1); - - printf ("data-set-test-1 succeeded\n"); + if (verbose) + printf ("data-set-test-1 succeeded\n"); + gcry_ac_data_clear (data); assert (! gcry_ac_data_length (data)); check_sexp_conversion (data, identifiers); check_sexp_conversion (data, identifiers_null); check_sexp_conversion (data, NULL); - printf ("data-set-test-2 succeeded\n"); + if (verbose) + printf ("data-set-test-2 succeeded\n"); gcry_ac_data_destroy (data); Modified: trunk/tests/ac.c =================================================================== --- trunk/tests/ac.c 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/tests/ac.c 2006-03-14 13:13:11 UTC (rev 1147) @@ -152,6 +152,8 @@ gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); if (debug) gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0); + /* No valuable keys are create, so we can speed up our RNG. */ + gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); for (; i > 0; i--) check_run (); Modified: trunk/tests/basic.c =================================================================== --- trunk/tests/basic.c 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/tests/basic.c 2006-03-14 13:13:11 UTC (rev 1147) @@ -1096,7 +1096,7 @@ { GCRY_MD_SHA1, "!" /* kludge for "a"*1000000 */ , "\x34\xAA\x97\x3C\xD4\xC4\xDA\xA4\xF6\x1E" "\xEB\x2B\xDB\xAD\x27\x31\x65\x34\x01\x6F" }, - // From RFC3874 + /* From RFC3874 */ { GCRY_MD_SHA224, "abc", "\x23\x09\x7d\x22\x34\x05\xd8\x22\x86\x42\xa4\x77\xbd\xa2\x55\xb3" "\x2a\xad\xbc\xe4\xbd\xa0\xb3\xf7\xe3\x6c\x9d\xa7" }, @@ -1920,12 +1920,16 @@ if (!gcry_check_version (GCRYPT_VERSION)) die ("version mismatch\n"); - gcry_set_progress_handler (progress_handler, NULL); + if (verbose) + gcry_set_progress_handler (progress_handler, NULL); gcry_control (GCRYCTL_DISABLE_SECMEM, 0); gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); if (debug) gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); + /* No valuable keys are create, so we can speed up our RNG. */ + gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); + check_ciphers (); check_aes128_cbc_cts_cipher (); check_cbc_mac_cipher (); Modified: trunk/tests/keygen.c =================================================================== --- trunk/tests/keygen.c 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/tests/keygen.c 2006-03-14 13:13:11 UTC (rev 1147) @@ -139,8 +139,9 @@ { char buffer[20000]; gcry_sexp_sprint (key, GCRYSEXP_FMT_ADVANCED, buffer, sizeof buffer); - printf ("=============================\n%s\n" - "=============================\n", buffer); + if (verbose) + printf ("=============================\n%s\n" + "=============================\n", buffer); } gcry_sexp_release (key); exit (0); Modified: trunk/tests/pkbench.c =================================================================== --- trunk/tests/pkbench.c 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/tests/pkbench.c 2006-03-14 13:13:11 UTC (rev 1147) @@ -335,6 +335,9 @@ char *algorithm = NULL; char *key_size = NULL; + /* No valuable keys are create, so we can speed up our RNG. */ + gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); + if (argv[2]) { algorithm = argv[2]; Modified: trunk/tests/pubkey.c =================================================================== --- trunk/tests/pubkey.c 2006-03-13 08:57:47 UTC (rev 1146) +++ trunk/tests/pubkey.c 2006-03-14 13:13:11 UTC (rev 1147) @@ -247,6 +247,8 @@ gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); if (debug) gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0); + /* No valuable keys are create, so we can speed up our RNG. */ + gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); for (; i > 0; i--) check_run (); From cvs at cvs.gnupg.org Tue Mar 14 14:15:10 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue Mar 14 13:48:44 2006 Subject: [svn] gpg-error - r163 - trunk Message-ID: Author: marcus Date: 2006-03-14 14:15:10 +0100 (Tue, 14 Mar 2006) New Revision: 163 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac Log: 2006-03-14 Marcus Brinkmann Released 1.3. * configure.ac (LIBGPG_ERROR_LT_REVISION): Bump for release. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-14 12:45:58 UTC (rev 162) +++ trunk/ChangeLog 2006-03-14 13:15:10 UTC (rev 163) @@ -1,5 +1,9 @@ 2006-03-14 Marcus Brinkmann + Released 1.3. + + * configure.ac (LIBGPG_ERROR_LT_REVISION): Bump for release. + Many files regenerated. * src/Makefile.am (gpg_error_CPPFLAGS, libgpg_error_la_CPPFLAGS): Add -I../intl. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-14 12:45:58 UTC (rev 162) +++ trunk/NEWS 2006-03-14 13:15:10 UTC (rev 163) @@ -1,13 +1,9 @@ -Noteworthy changes in version 1.3 (unreleased) +Noteworthy changes in version 1.3 (2006-03-14) ---------------------------------------------- * GNU gettext is included for systems that do not provide it. - * Interface changes relative to the 1.2 release: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Noteworthy changes in version 1.2 (2006-03-03) ---------------------------------------------- Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-14 12:45:58 UTC (rev 162) +++ trunk/configure.ac 2006-03-14 13:15:10 UTC (rev 163) @@ -23,7 +23,7 @@ min_automake_version="1.9.6" # The gettext version is set below using AM_GNU_GETTEXT_VERSION # Version number: Remember to change it immediately *after* a release. -AC_INIT([libgpg-error],[1.3-cvs],[bug-gnupg@gnupg.org]) +AC_INIT([libgpg-error],[1.3],[bug-gnupg@gnupg.org]) # LT Version numbers, remember to change them just *before* a release. # (Code changed: REVISION++) # (Interfaces added/removed/changed: CURRENT++, REVISION=0) @@ -32,7 +32,7 @@ # Note that added error codes don't constitute an interface change. LIBGPG_ERROR_LT_CURRENT=2 LIBGPG_ERROR_LT_AGE=2 -LIBGPG_ERROR_LT_REVISION=0 +LIBGPG_ERROR_LT_REVISION=1 AC_SUBST(LIBGPG_ERROR_LT_CURRENT) AC_SUBST(LIBGPG_ERROR_LT_AGE) AC_SUBST(LIBGPG_ERROR_LT_REVISION) From cvs at cvs.gnupg.org Tue Mar 14 14:26:55 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Mar 14 14:00:30 2006 Subject: [svn] gcry - r1148 - trunk/tests Message-ID: Author: wk Date: 2006-03-14 14:26:55 +0100 (Tue, 14 Mar 2006) New Revision: 1148 Modified: trunk/tests/ChangeLog trunk/tests/benchmark.c Log: Add a way to manually test the seed file locking Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2006-03-14 13:13:11 UTC (rev 1147) +++ trunk/tests/ChangeLog 2006-03-14 13:26:55 UTC (rev 1148) @@ -1,15 +1,16 @@ 2006-03-14 Werner Koch + * benchmark.c (main): Allow for seed file argument to random bench. + + * basic.c (main): Use progress handler only in verbose mode. + (main): Speed up test key generation. * ac-data.c (check_sexp_conversion, check_run): Take care of VERBOSE. - * basic.c (main): Speed up test key generation. - (main): use progress handler only in verbose mode. * ac.c (main): Ditto. * pubkey.c (main): Ditto. + * pkbench.c (main): Ditto. * keygen.c (main): Ditto. (check_rsa_keys): Print key only in verbose mode. - * pkbench.c (main): Ditto. - 2006-03-10 Brad Hards (wk, patch 2006-02-18) * basic.c (check_one_hmac, check_hmac): New. Modified: trunk/tests/benchmark.c =================================================================== --- trunk/tests/benchmark.c 2006-03-14 13:13:11 UTC (rev 1147) +++ trunk/tests/benchmark.c 2006-03-14 13:26:55 UTC (rev 1148) @@ -1,5 +1,5 @@ /* benchmark.c - for libgcrypt - * Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. + * Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -695,7 +695,16 @@ stdout); else if ( !strcmp (*argv, "random")) { - random_bench (); + if (argc == 1) + random_bench (); + else if (argc == 2) + { + gcry_control (GCRYCTL_SET_RANDOM_SEED_FILE, argv[1]); + random_bench (); + gcry_control (GCRYCTL_UPDATE_RANDOM_SEED_FILE); + } + else + fputs ("usage: benchmark random [seedfile]\n", stdout); } else if ( !strcmp (*argv, "md")) { From cvs at cvs.gnupg.org Tue Mar 14 14:29:14 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue Mar 14 14:02:48 2006 Subject: [svn] gpg-error - r164 - tags Message-ID: Author: marcus Date: 2006-03-14 14:29:14 +0100 (Tue, 14 Mar 2006) New Revision: 164 Added: tags/libgpg-error-1.3/ Log: Tag release 1.3. Copied: tags/libgpg-error-1.3 (from rev 163, trunk) From cvs at cvs.gnupg.org Wed Mar 15 12:46:50 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed Mar 15 12:20:21 2006 Subject: [svn] gcry - r1149 - trunk/src Message-ID: Author: wk Date: 2006-03-15 12:46:50 +0100 (Wed, 15 Mar 2006) New Revision: 1149 Added: trunk/src/gcryptrnd.c trunk/src/getrandom.c Modified: trunk/src/ChangeLog trunk/src/Makefile.am Log: Wrote random daemon and client. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-03-14 13:26:55 UTC (rev 1148) +++ trunk/src/ChangeLog 2006-03-15 11:46:50 UTC (rev 1149) @@ -1,3 +1,11 @@ +2006-03-15 Werner Koch + + * getrandom.c: New. + +2006-03-14 Werner Koch + + * gcryptrnd.c: New. + 2006-03-10 Werner Koch * gcrypt.h: Add GCRY_MD_SHA224. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2006-03-14 13:26:55 UTC (rev 1148) +++ trunk/src/Makefile.am 2006-03-15 11:46:50 UTC (rev 1149) @@ -25,6 +25,8 @@ include_HEADERS = gcrypt.h gcrypt-module.h lib_LTLIBRARIES = libgcrypt.la +sbin_PROGRAMS = gcryptrnd +bin_PROGRAMS = getrandom if HAVE_LD_VERSION_SCRIPT libgcrypt_version_script_cmd = -Wl,--version-script=$(srcdir)/libgcrypt.vers @@ -45,3 +47,10 @@ $(srcdir)/libgcrypt.vers libgcrypt_la_LIBADD = ../cipher/libcipher.la ../mpi/libmpi.la \ @LTLIBOBJS@ @GPG_ERROR_LIBS@ + +gcryptrnd_SOURCES = gcryptrnd.c +gcryptrnd_CFLAGS = $(GPG_ERROR_CFLAGS) $(PTH_CFLAGS) +gcryptrnd_LDADD = ../src/libgcrypt.la $(PTH_LIBS) + +getrandom_SOURCES = getrandom.c + Added: trunk/src/gcryptrnd.c =================================================================== --- trunk/src/gcryptrnd.c 2006-03-14 13:26:55 UTC (rev 1148) +++ trunk/src/gcryptrnd.c 2006-03-15 11:46:50 UTC (rev 1149) @@ -0,0 +1,678 @@ +/* gcryptrnd.c - Libgcrypt Random Number Daemon + * Copyright (C) 2006 Free Software Foundation, Inc. + * + * Gcryptend is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * Gcryptrnd is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +/* We require vsyslog pth + We need to test for: setrlimit + + We should also prioritize requests. This is best done by putting + the requests into queues and have a main thread processing these + queues. + + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PGM "gcryptrnd" +#define MYVERSION_LINE PGM " (Libgcrypt) " VERSION +#define BUGREPORT_LINE "\nReport bugs to .\n" + +/* Pth wrapper function definitions. */ +GCRY_THREAD_OPTION_PTH_IMPL; + + +/* Flag set to true if we have been daemonized. */ +static int running_detached; +/* Flag indicating that a shutdown has been requested. */ +static int shutdown_pending; +/* Counter for active connections. */ +static int active_connections; + + + +/* Local prototypes. */ +static void serve (int listen_fd); + + + + + +/* To avoid that a compiler optimizes certain memset calls away, these + macros may be used instead. */ +#define wipememory2(_ptr,_set,_len) do { \ + volatile char *_vptr=(volatile char *)(_ptr); \ + size_t _vlen=(_len); \ + while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \ + } while(0) +#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len) + + + + +/* Error printing utility. PRIORITY should be one of syslog's + priority levels. This fucntions prints to the stderro or syslog + depending on whether we are already daemonized. */ +static void +logit (int priority, const char *format, ...) +{ + va_list arg_ptr; + + va_start (arg_ptr, format) ; + if (running_detached) + { + vsyslog (priority, format, arg_ptr); + } + else + { + fputs (PGM ": ", stderr); + vfprintf (stderr, format, arg_ptr); + putc ('\n', stderr); + } + va_end (arg_ptr); +} + +/* Callback used by libgcrypt for logging. */ +static void +my_gcry_logger (void *dummy, int level, const char *format, va_list arg_ptr) +{ + /* Map the log levels. */ + switch (level) + { + case GCRY_LOG_CONT: level = LOG_INFO /* FIXME */; break; + case GCRY_LOG_INFO: level = LOG_INFO; break; + case GCRY_LOG_WARN: level = LOG_WARNING; break; + case GCRY_LOG_ERROR:level = LOG_ERR; break; + case GCRY_LOG_FATAL:level = LOG_CRIT; break; + case GCRY_LOG_BUG: level = LOG_CRIT; break; + case GCRY_LOG_DEBUG:level = LOG_DEBUG; break; + default: level = LOG_ERR; break; + } + if (running_detached) + { + vsyslog (level, format, arg_ptr); + } + else + { + fputs (PGM ": ", stderr); + vfprintf (stderr, format, arg_ptr); + if (!*format || format[strlen (format)-1] != '\n') + putc ('\n', stderr); + } +} + + +/* The cleanup handler - used to wipe out the secure memory. */ +static void +cleanup (void) +{ + gcry_control (GCRYCTL_TERM_SECMEM ); +} + + +/* Make us a daemon and open the syslog. */ +static void +daemonize (void) +{ + int i; + pid_t pid; + + fflush (NULL); + + pid = fork (); + if (pid == (pid_t)-1) + { + logit (LOG_CRIT, "fork failed: %s", strerror (errno)); + exit (1); + } + if (pid) + exit (0); + + if (setsid() == -1) + { + logit (LOG_CRIT, "setsid() failed: %s", strerror(errno)); + exit (1); + } + + signal (SIGHUP, SIG_IGN); + + pid = fork (); + if (pid == (pid_t)-1) + { + logit (LOG_CRIT, PGM ": second fork failed: %s", strerror (errno)); + exit (1); + } + if (pid) + exit (0); /* First child exits. */ + + running_detached = 1; + + if (chdir("/")) + { + logit (LOG_CRIT, "chdir(\"/\") failed: %s", strerror (errno)); + exit (1); + } + umask (0); + + for (i=0; i <= 2; i++) + close (i); + + openlog (PGM, LOG_PID, LOG_DAEMON); +} + + +static void +disable_core_dumps (void) +{ +#ifdef HAVE_SETRLIMIT + struct rlimit limit; + + if (getrlimit (RLIMIT_CORE, &limit)) + limit.rlim_max = 0; + limit.rlim_cur = 0; + if( !setrlimit (RLIMIT_CORE, &limit) ) + return 0; + if (errno != EINVAL && errno != ENOSYS) + logit (LOG_ERR, "can't disable core dumps: %s\n", strerror (errno)); +#endif /* HAVE_SETRLIMIT */ +} + + + +static void +print_version (int with_help) +{ + fputs (MYVERSION_LINE "\n" + "Copyright (C) 2006 Free Software Foundation, Inc.\n" + "This program comes with ABSOLUTELY NO WARRANTY.\n" + "This is free software, and you are welcome to redistribute it\n" + "under certain conditions. See the file COPYING for details.\n", + stdout); + + if (with_help) + fputs ("\n" + "Usage: " PGM " [OPTIONS] [SOCKETNAME]\n" + "Start Libgcrypt's random number daemon listening" + " on socket SOCKETNAME\n" + "SOCKETNAME defaults to XXX\n" + "\n" + " --no-detach do not deatach from the console\n" + " --version print version of the program and exit\n" + " --help display this help and exit\n" + BUGREPORT_LINE, stdout ); + + exit (0); +} + +static int +print_usage (void) +{ + fputs ("usage: " PGM " [OPTIONS] [SOCKETNAME]\n", stderr); + fputs (" (use --help to display options)\n", stderr); + exit (1); +} + + +int +main (int argc, char **argv) +{ + int no_detach = 0; + gpg_error_t err; + struct sockaddr_un *srvr_addr; + socklen_t addrlen; + int fd; + int rc; + const char *socketname = "/var/run/libgcrypt/S.gcryptrnd"; + + + if (argc) + { + argc--; argv++; + } + while (argc && **argv == '-' && (*argv)[1] == '-') + { + if (!(*argv)[2]) + { + argc--; argv++; + break; + } + else if (!strcmp (*argv, "--version")) + print_version (0); + else if (!strcmp (*argv, "--help")) + print_version (1); + else if (!strcmp (*argv, "--no-detach")) + { + no_detach = 1; + argc--; argv++; + } + else + print_usage (); + } + + if (argc == 1) + socketname = argv[0]; + else if (argc > 1) + print_usage (); + + if (!no_detach) + daemonize (); + + signal (SIGPIPE, SIG_IGN); + + logit (LOG_NOTICE, "started version " VERSION ); + + /* Libgcrypt requires us to register the threading model before we + do anything else with it. Note that this also calls pth_init. We + do the initialization while already running as a daemon to avoid + overhead with double initialization of Libgcrypt. */ + err = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth); + if (err) + { + logit (LOG_CRIT, "can't register GNU Pth with Libgcrypt: %s", + gpg_strerror (err)); + exit (1); + } + + /* Check that the libgcrypt version is sufficient. */ + if (!gcry_check_version (VERSION) ) + { + logit (LOG_CRIT, "libgcrypt is too old (need %s, have %s)", + VERSION, gcry_check_version (NULL) ); + exit (1); + } + + /* Register the logging callback and tell Libcgrypt to put the + random pool into secure memory. */ + gcry_set_log_handler (my_gcry_logger, NULL); + gcry_control (GCRYCTL_USE_SECURE_RNDPOOL); + + /* Obviously we don't want to allow any core dumps. */ + disable_core_dumps (); + + /* Initialize the secure memory stuff which will also drop any extra + privileges we have. */ + gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); + + /* Register a cleanup handler. */ + atexit (cleanup); + + /* Create and listen on the socket. */ + fd = socket (AF_UNIX, SOCK_STREAM, 0); + if (fd == -1) + { + logit (LOG_CRIT, "can't create socket: %s", strerror (errno)); + exit (1); + } + srvr_addr = gcry_xmalloc (sizeof *srvr_addr); + memset (srvr_addr, 0, sizeof *srvr_addr); + srvr_addr->sun_family = AF_UNIX; + if (strlen (socketname) + 1 >= sizeof (srvr_addr->sun_path)) + { + logit (LOG_CRIT, "socket name `%s' too long", socketname); + exit (1); + } + strcpy (srvr_addr->sun_path, socketname); + addrlen = (offsetof (struct sockaddr_un, sun_path) + + strlen (srvr_addr->sun_path) + 1); + rc = bind (fd, (struct sockaddr*) srvr_addr, addrlen); + if (rc == -1 && errno == EADDRINUSE) + { + remove (socketname); + rc = bind (fd, (struct sockaddr*) srvr_addr, addrlen); + } + if (rc == -1) + { + logit (LOG_CRIT, "error binding socket to `%s': %s", + srvr_addr->sun_path, strerror (errno)); + close (fd); + exit (1); + } + + if (listen (fd, 5 ) == -1) + { + logit (LOG_CRIT, "listen() failed: %s", strerror (errno)); + close (fd); + exit (1); + } + + logit (LOG_INFO, "listening on socket `%s', fd=%d", + srvr_addr->sun_path, fd); + + serve (fd); + close (fd); + + logit (LOG_NOTICE, "stopped version " VERSION ); + return 0; +} + + +/* Send LENGTH bytes of BUFFER to file descriptor FD. Returns 0 on + success or another value on write error. */ +static int +writen (int fd, const void *buffer, size_t length) +{ + while (length) + { + ssize_t n = pth_write (fd, buffer, length); + if (n < 0) + { + logit (LOG_ERR, "connection %d: write error: %s", + fd, strerror (errno)); + return -1; /* write error */ + } + length -= n; + buffer += n; + } + return 0; /* Okay */ +} + + +/* Send an error response back. Returns 0 on success. */ +static int +send_error (int fd, int errcode) +{ + unsigned char buf[2]; + + buf[0] = errcode; + buf[1] = 0; + return writen (fd, buf, 2 ); +} + +/* Send a pong response back. Returns 0 on success or another value + on write error. */ +static int +send_pong (int fd) +{ + return writen (fd, "\x00\x04pong", 6); +} + +/* Send a nonce of size LENGTH back. Return 0 on success. */ +static int +send_nonce (int fd, int length) +{ + unsigned char buf[2+255]; + int rc; + + assert (length >= 0 && length <= 255); + buf[0] = 0; + buf[1] = length; + gcry_create_nonce (buf+2, length); + rc = writen (fd, buf, 2+length ); + wipememory (buf+2, length); + return rc; +} + +/* Send a random of size LENGTH with quality LEVEL back. Return 0 on + success. */ +static int +send_random (int fd, int length, int level) +{ + unsigned char buf[2+255]; + int rc; + + assert (length >= 0 && length <= 255); + assert (level == GCRY_STRONG_RANDOM || level == GCRY_VERY_STRONG_RANDOM); + buf[0] = 0; + buf[1] = length; + /* Note that we don't bother putting the random stuff into secure + memory because this daemon is anyway intended to be run under + root and it is questionable whether the kernel buffers etc. are + equally well protected. */ + gcry_randomize (buf+2, length, level); + rc = writen (fd, buf, 2+length ); + wipememory (buf+2, length); + return rc; +} + +/* Main processing loop for a connection. + + A request is made up of: + + 1 byte Total length of request; must be 3 + 1 byte Command + 0 = Ping + 10 = GetNonce + 11 = GetStrongRandom + 12 = GetVeryStrongRandom + (all other values are reserved) + 1 byte Number of requested bytes. + This is ignored for command Ping. + + A response is made up of: + + 1 byte Error Code + 0 = Everything is fine + 1 = Bad Command + 0xff = Other error. + (For a bad request the connection will simply be closed) + 1 byte Length of data + n byte data + + The requests are read as long as the connection is open. + + + */ +static void +connection_loop (int fd) +{ + unsigned char request[3]; + unsigned char *p; + int nleft, n; + int rc; + + for (;;) + { + for (nleft=3, p=request; nleft > 0; ) + { + n = pth_read (fd, p, nleft); + if (!n && p == request) + return; /* Client terminated connection. */ + if (n <= 0) + { + logit (LOG_ERR, "connection %d: read error: %s", + fd, n? strerror (errno) : "Unexpected EOF"); + return; + } + p += n; + nleft -= n; + } + if (request[0] != 3) + { + logit (LOG_ERR, "connection %d: invalid length (%d) of request", + fd, request[0]); + return; + } + + switch (request[1]) + { + case 0: /* Ping */ + rc = send_pong (fd); + break; + case 10: /* GetNonce */ + rc = send_nonce (fd, request[2]); + break; + case 11: /* GetStrongRandom */ + rc = send_random (fd, request[2], GCRY_STRONG_RANDOM); + break; + case 12: /* GetVeryStrongRandom */ + rc = send_random (fd, request[2], GCRY_VERY_STRONG_RANDOM); + break; + + default: /* Invalid command */ + rc = send_error (fd, 1); + break; + } + if (rc) + break; /* A write error occured while sending the response. */ + } +} + + + +/* Entry point for a connection's thread. */ +static void * +connection_thread (void *arg) +{ + int fd = (int)arg; + + active_connections++; + logit (LOG_INFO, "connection handler for fd %d started", fd); + + connection_loop (fd); + + close (fd); + logit (LOG_INFO, "connection handler for fd %d terminated", fd); + active_connections--; + + return NULL; +} + + +/* This signal handler is called from the main loop between acepting + connections. It is called on the regular stack, thus no special + caution needs to be taken. It returns true to indicate that the + process should terminate. */ +static int +handle_signal (int signo) +{ + switch (signo) + { + case SIGHUP: + logit (LOG_NOTICE, "SIGHUP received - re-reading configuration"); + break; + + case SIGUSR1: + logit (LOG_NOTICE, "SIGUSR1 received - no action defined"); + break; + + case SIGUSR2: + logit (LOG_NOTICE, "SIGUSR2 received - no action defined"); + break; + + case SIGTERM: + if (!shutdown_pending) + logit (LOG_NOTICE, "SIGTERM received - shutting down ..."); + else + logit (LOG_NOTICE, "SIGTERM received - still %d active connections", + active_connections); + shutdown_pending++; + if (shutdown_pending > 2) + { + logit (LOG_NOTICE, "shutdown forced"); + return 1; + } + break; + + case SIGINT: + logit (LOG_NOTICE, "SIGINT received - immediate shutdown"); + return 1; + + default: + logit (LOG_NOTICE, "signal %d received - no action defined\n", signo); + } + return 0; +} + + + +/* Main server loop. This is called with the FD of the listening + socket. */ +static void +serve (int listen_fd) +{ + pth_attr_t tattr; + pth_event_t ev; + sigset_t sigs; + int signo; + struct sockaddr_un paddr; + socklen_t plen = sizeof (paddr); + int fd; + + tattr = pth_attr_new(); + pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0); + pth_attr_set (tattr, PTH_ATTR_STACK_SIZE, 256*1024); + pth_attr_set (tattr, PTH_ATTR_NAME, "connection"); + + sigemptyset (&sigs); + sigaddset (&sigs, SIGHUP); + sigaddset (&sigs, SIGUSR1); + sigaddset (&sigs, SIGUSR2); + sigaddset (&sigs, SIGINT); + sigaddset (&sigs, SIGTERM); + ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo); + + for (;;) + { + if (shutdown_pending) + { + if (!active_connections) + break; /* Ready. */ + + /* Do not accept anymore connections but wait for existing + connections to terminate. */ + signo = 0; + pth_wait (ev); + if (pth_event_occurred (ev) && signo) + if (handle_signal (signo)) + break; /* Stop the loop. */ + continue; + } + + gcry_fast_random_poll (); + fd = pth_accept_ev (listen_fd, (struct sockaddr *)&paddr, &plen, ev); + if (fd == -1) + { + if (pth_event_occurred (ev)) + { + if (handle_signal (signo)) + break; /* Stop the loop. */ + continue; + } + logit (LOG_WARNING, "accept failed: %s - waiting 1s\n", + strerror (errno)); + gcry_fast_random_poll (); + pth_sleep (1); + continue; + } + + if (!pth_spawn (tattr, connection_thread, (void*)fd)) + { + logit (LOG_ERR, "error spawning connection handler: %s\n", + strerror (errno) ); + close (fd); + } + } + + pth_event_free (ev, PTH_FREE_ALL); +} + Added: trunk/src/getrandom.c =================================================================== --- trunk/src/getrandom.c 2006-03-14 13:26:55 UTC (rev 1148) +++ trunk/src/getrandom.c 2006-03-15 11:46:50 UTC (rev 1149) @@ -0,0 +1,326 @@ +/* getrandom.c - Libgcrypt Random Number client + * Copyright (C) 2006 Free Software Foundation, Inc. + * + * Getrandom is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * Getrandom is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PGM "getrandom" +#define MYVERSION_LINE PGM " (Libgcrypt) " VERSION +#define BUGREPORT_LINE "\nReport bugs to .\n" + + +static void +logit (const char *format, ...) +{ + va_list arg_ptr; + + va_start (arg_ptr, format) ; + fputs (PGM ": ", stderr); + vfprintf (stderr, format, arg_ptr); + putc ('\n', stderr); + va_end (arg_ptr); +} + + +/* Send LENGTH bytes of BUFFER to file descriptor FD. Returns 0 on + success or another value on write error. */ +static int +writen (int fd, const void *buffer, size_t length) +{ + while (length) + { + ssize_t n; + + do + n = write (fd, buffer, length); + while (n < 0 && errno == EINTR); + if (n < 0) + { + logit ("write error: %s", strerror (errno)); + return -1; /* write error */ + } + length -= n; + buffer += n; + } + return 0; /* Okay */ +} + + + + +static void +print_version (int with_help) +{ + fputs (MYVERSION_LINE "\n" + "Copyright (C) 2006 Free Software Foundation, Inc.\n" + "This program comes with ABSOLUTELY NO WARRANTY.\n" + "This is free software, and you are welcome to redistribute it\n" + "under certain conditions. See the file COPYING for details.\n", + stdout); + + if (with_help) + fputs ("\n" + "Usage: " PGM " [OPTIONS] NBYTES\n" + "Connect to libgcrypt's random number daemon and " + "return random numbers" + "\n" + " --nonce Return weak random suitable for a nonce\n" + " --very-strong Return very strong random\n" + " --ping Send a ping\n" + " --socket NAME Name of sockket to connect to\n" + " --hex Return result as a hex dump\n" + " --verbose Show what we are doing\n" + " --version Print version of the program and exit\n" + " --help Display this help and exit\n" + BUGREPORT_LINE, stdout ); + + exit (0); +} + +static int +print_usage (void) +{ + fputs ("usage: " PGM " [OPTIONS] NBYTES\n", stderr); + fputs (" (use --help to display options)\n", stderr); + exit (1); +} + + +int +main (int argc, char **argv) +{ + struct sockaddr_un *srvr_addr; + socklen_t addrlen; + int fd; + int rc; + unsigned char buffer[300]; + int nleft, nread; + const char *socketname = "/var/run/libgcrypt/S.gcryptrnd"; + int do_ping = 0; + int get_nonce = 0; + int get_very_strong = 0; + int req_nbytes, nbytes, n; + int verbose = 0; + int fail = 0; + int do_hex = 0; + + if (argc) + { + argc--; argv++; + } + while (argc && **argv == '-' && (*argv)[1] == '-') + { + if (!(*argv)[2]) + { + argc--; argv++; + break; + } + else if (!strcmp (*argv, "--version")) + print_version (0); + else if (!strcmp (*argv, "--help")) + print_version (1); + else if (!strcmp (*argv, "--socket") && argc > 1 ) + { + argc--; argv++; + socketname = *argv; + argc--; argv++; + } + else if (!strcmp (*argv, "--nonce")) + { + argc--; argv++; + get_nonce = 1; + } + else if (!strcmp (*argv, "--very-strong")) + { + argc--; argv++; + get_very_strong = 1; + } + else if (!strcmp (*argv, "--ping")) + { + argc--; argv++; + do_ping = 1; + } + else if (!strcmp (*argv, "--hex")) + { + argc--; argv++; + do_hex = 1; + } + else if (!strcmp (*argv, "--verbose")) + { + argc--; argv++; + verbose = 1; + } + else + print_usage (); + } + + + if (!argc && do_ping) + ; /* This is allowed. */ + else if (argc != 1) + print_usage (); + req_nbytes = argc? atoi (*argv) : 0; + + if (req_nbytes < 0) + print_usage (); + + /* Create a socket. */ + fd = socket (AF_UNIX, SOCK_STREAM, 0); + if (fd == -1) + { + logit ("can't create socket: %s", strerror (errno)); + exit (1); + } + srvr_addr = malloc (sizeof *srvr_addr); + if (!srvr_addr) + { + logit ("malloc failed: %s", strerror (errno)); + exit (1); + } + memset (srvr_addr, 0, sizeof *srvr_addr); + srvr_addr->sun_family = AF_UNIX; + if (strlen (socketname) + 1 >= sizeof (srvr_addr->sun_path)) + { + logit ("socket name `%s' too long", socketname); + exit (1); + } + strcpy (srvr_addr->sun_path, socketname); + addrlen = (offsetof (struct sockaddr_un, sun_path) + + strlen (srvr_addr->sun_path) + 1); + rc = connect (fd, (struct sockaddr*) srvr_addr, addrlen); + if (rc == -1) + { + logit ("error connecting socket `%s': %s", + srvr_addr->sun_path, strerror (errno)); + close (fd); + exit (1); + } + + do + { + nbytes = req_nbytes > 255? 255 : req_nbytes; + req_nbytes -= nbytes; + + buffer[0] = 3; + if (do_ping) + buffer[1] = 0; + else if (get_nonce) + buffer[1] = 10; + else if (get_very_strong) + buffer[1] = 12; + else + buffer[1] = 11; + buffer[2] = nbytes; + if (writen (fd, buffer, 3)) + fail = 1; + else + { + for (nleft=2, nread=0; nleft > 0; ) + { + do + n = read (fd, buffer+nread, nleft); + while (n < 0 && errno == EINTR); + if (n < 0) + { + logit ("read error: %s", strerror (errno)); + exit (1); + } + nleft -= n; + nread += n; + if (nread && buffer[0]) + { + logit ("server returned error code %d", buffer[0]); + exit (1); + } + } + if (verbose) + logit ("received response with %d bytes of data", buffer[1]); + if (buffer[1] < nbytes) + { + logit ("warning: server returned less bytes than requested"); + fail = 1; + } + else if (buffer[1] > nbytes && !do_ping) + { + logit ("warning: server returned more bytes than requested"); + fail = 1; + } + nbytes = buffer[1]; + if (nbytes > sizeof buffer) + { + logit ("buffer too short to receive data"); + exit (1); + } + + for (nleft=nbytes, nread=0; nleft > 0; ) + { + do + n = read (fd, buffer+nread, nleft); + while (n < 0 && errno == EINTR); + if (n < 0) + { + logit ("read error: %s", strerror (errno)); + exit (1); + } + nleft -= n; + nread += n; + } + + if (do_hex) + { + for (n=0; n < nbytes; n++) + { + if (!n) + ; + else if (!(n % 16)) + putchar ('\n'); + else + putchar (' '); + printf ("%02X", buffer[n]); + } + if (nbytes) + putchar ('\n'); + } + else + { + if (fwrite (buffer, nbytes, 1, stdout) != 1) + { + logit ("error writing to stdout: %s", strerror (errno)); + fail = 1; + } + } + } + } + while (!fail && req_nbytes); + + close (fd); + free (srvr_addr); + return fail? 1 : 0; +} + From cvs at cvs.gnupg.org Thu Mar 16 23:40:06 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Mar 16 23:13:39 2006 Subject: [svn] GnuPG - r4067 - in trunk: g10 include util Message-ID: Author: dshaw Date: 2006-03-16 23:40:04 +0100 (Thu, 16 Mar 2006) New Revision: 4067 Modified: trunk/g10/keyserver.c trunk/include/ChangeLog trunk/include/util.h trunk/util/ChangeLog trunk/util/cert.c Log: * cert.c (get_cert): Handle the fixed IPGP type with fingerprint. Modified: trunk/g10/keyserver.c =================================================================== --- trunk/g10/keyserver.c 2006-03-14 03:16:21 UTC (rev 4066) +++ trunk/g10/keyserver.c 2006-03-16 22:40:04 UTC (rev 4067) @@ -1993,7 +1993,7 @@ if(domain) *domain='.'; - type=get_cert(look,max_cert_size,&key,&url); + type=get_cert(look,max_cert_size,&key,NULL,NULL,&url); if(type==1) { int armor_status=opt.no_armor; Modified: trunk/include/ChangeLog =================================================================== --- trunk/include/ChangeLog 2006-03-14 03:16:21 UTC (rev 4066) +++ trunk/include/ChangeLog 2006-03-16 22:40:04 UTC (rev 4067) @@ -1,3 +1,7 @@ +2006-03-16 David Shaw + + * util.h: Handle the fixed IPGP type with fingerprint. + 2006-02-14 Werner Koch * errors.h (G10ERR_NO_DATA): New. Modified: trunk/include/util.h =================================================================== --- trunk/include/util.h 2006-03-14 03:16:21 UTC (rev 4066) +++ trunk/include/util.h 2006-03-16 22:40:04 UTC (rev 4067) @@ -1,6 +1,6 @@ /* util.h - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 - * 2004 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + * 2006 Free Software Foundation, Inc. * * This file is part of GNUPG. * @@ -257,7 +257,8 @@ char *get_pka_info (const char *address, unsigned char *fpr); /*-- cert.c --*/ -int get_cert(const char *name,size_t max_size,IOBUF *iobuf,char **url); +int get_cert(const char *name,size_t max_size,IOBUF *iobuf, + unsigned char **fpr,size_t *fpr_len,char **url); /**** other missing stuff ****/ #ifndef HAVE_ATEXIT /* For SunOS */ Modified: trunk/util/ChangeLog =================================================================== --- trunk/util/ChangeLog 2006-03-14 03:16:21 UTC (rev 4066) +++ trunk/util/ChangeLog 2006-03-16 22:40:04 UTC (rev 4067) @@ -1,3 +1,7 @@ +2006-03-16 David Shaw + + * cert.c (get_cert): Handle the fixed IPGP type with fingerprint. + 2006-03-08 David Shaw * argparse.c (default_strusage): Update copyright year to 2006. Modified: trunk/util/cert.c =================================================================== --- trunk/util/cert.c 2006-03-14 03:16:21 UTC (rev 4066) +++ trunk/util/cert.c 2006-03-16 22:40:04 UTC (rev 4067) @@ -1,5 +1,5 @@ /* cert.c - DNS CERT code - * Copyright (C) 2005 Free Software Foundation, Inc. + * Copyright (C) 2005, 2006 Free Software Foundation, Inc. * * This file is part of GNUPG. * @@ -33,6 +33,7 @@ #include "memory.h" #endif #include "iobuf.h" +#include "util.h" /* Not every installation has gotten around to supporting CERTs yet... */ @@ -45,12 +46,19 @@ /* Returns -1 on error, 0 for no answer, 1 for PGP provided and 2 for IPGP provided. */ int -get_cert(const char *name,size_t max_size,IOBUF *iobuf,char **url) +get_cert(const char *name,size_t max_size,IOBUF *iobuf, + unsigned char **fpr,size_t *fpr_len,char **url) { unsigned char *answer; int r,ret=-1; u16 count; + if(fpr) + *fpr=NULL; + + if(url) + *url=NULL; + answer=xmalloc(max_size); r=res_query(name,C_IN,T_CERT,answer,max_size); @@ -90,7 +98,8 @@ pt+=rc; - /* Truncated message? */ + /* Truncated message? 15 bytes takes us to the point where + we start looking at the ctype. */ if((emsg-pt)<15) break; @@ -127,26 +136,41 @@ dlen-=5; - if(ctype==3 && iobuf) + /* 15 bytes takes us to here */ + + if(ctype==3 && iobuf && dlen) { /* PGP type */ *iobuf=iobuf_temp_with_content((char *)pt,dlen); ret=1; break; } -#if 0 - else if(ctype==6 && dlen<1023 && url) + else if(ctype==6 && dlen && dlen<1023 && dlen>=pt[0]+1 + && fpr && fpr_len && url) { - /* Sanity check the IPGP URL type that the URL isn't too - long */ + /* IPGP type */ + *fpr_len=pt[0]; - *url=xmalloc(dlen+1); - memcpy(*url,pt,dlen); - (*url)[dlen]='\0'; + if(*fpr_len) + { + *fpr=xmalloc(*fpr_len); + memcpy(*fpr,&pt[1],*fpr_len); + } + else + *fpr=NULL; + + if(dlen>*fpr_len+1) + { + *url=xmalloc(dlen-(*fpr_len+1)+1); + memcpy(*url,&pt[*fpr_len+1],dlen-(*fpr_len+1)); + (*url)[dlen-(*fpr_len+1)]='\0'; + } + else + *url=NULL; + ret=2; break; } -#endif /* Neither type matches, so go around to the next answer. */ pt+=dlen; @@ -162,7 +186,8 @@ #else /* !USE_DNS_CERT */ int -get_cert(const char *name,size_t max_size,IOBUF *iobuf,char **url) +get_cert(const char *name,size_t max_size,IOBUF *iobuf, + unsigned char **fpr,size_t *fpr_len,char **url) { return -1; } @@ -175,6 +200,8 @@ int main(int argc,char *argv[]) { + unsigned char *fpr; + size_t fpr_len; char *url; int rc; IOBUF iobuf; @@ -187,7 +214,7 @@ printf("CERT lookup on %s\n",argv[1]); - rc=get_cert(argv[1],16384,&iobuf,&url); + rc=get_cert(argv[1],16384,&iobuf,&fpr,&fpr_len,&url); if(rc==-1) printf("error\n"); else if(rc==0) @@ -199,7 +226,23 @@ } else if(rc==2) { - printf("URL found: %s\n",url); + if(fpr) + { + size_t i; + printf("Fingerprint found (%d bytes): ",fpr_len); + for(i=0;i Author: dshaw Date: 2006-03-17 06:20:13 +0100 (Fri, 17 Mar 2006) New Revision: 4068 Modified: trunk/g10/ChangeLog trunk/g10/getkey.c trunk/g10/keyserver.c Log: * keyserver.c (keyserver_import_cert): Handle the IPGP CERT type for both the fingerprint alone, and fingerprint+URL cases. * getkey.c (get_pubkey_byname): Minor cleanup. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-16 22:40:04 UTC (rev 4067) +++ trunk/g10/ChangeLog 2006-03-17 05:20:13 UTC (rev 4068) @@ -1,3 +1,10 @@ +2006-03-16 David Shaw + + * keyserver.c (keyserver_import_cert): Handle the IPGP CERT type + for both the fingerprint alone, and fingerprint+URL cases. + + * getkey.c (get_pubkey_byname): Minor cleanup. + 2006-03-13 David Shaw * keyserver-internal.h, keyserver.c (keyserver_import_pka): Use Modified: trunk/g10/getkey.c =================================================================== --- trunk/g10/getkey.c 2006-03-16 22:40:04 UTC (rev 4067) +++ trunk/g10/getkey.c 2006-03-17 05:20:13 UTC (rev 4068) @@ -917,7 +917,6 @@ if (rc == G10ERR_NO_PUBKEY && is_valid_mailbox(name)) { - int res; struct akl *akl; for(akl=opt.auto_key_locate;akl;akl=akl->next) @@ -929,29 +928,29 @@ { case AKL_CERT: glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_cert(name,&fpr,&fpr_len); + rc=keyserver_import_cert(name,&fpr,&fpr_len); glo_ctrl.in_auto_key_retrieve--; - if(res==0) + if(rc==0) log_info(_("Automatically retrieved `%s' via %s\n"), name,"DNS CERT"); break; case AKL_PKA: glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_pka(name,&fpr,&fpr_len); + rc=keyserver_import_pka(name,&fpr,&fpr_len); - if(res==0) + if(rc==0) log_info(_("Automatically retrieved `%s' via %s\n"), name,"PKA"); break; case AKL_LDAP: glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_ldap(name,&fpr,&fpr_len); + rc=keyserver_import_ldap(name,&fpr,&fpr_len); glo_ctrl.in_auto_key_retrieve--; - if(res==0) + if(rc==0) log_info(_("Automatically retrieved `%s' via %s\n"), name,"LDAP"); break; @@ -964,10 +963,10 @@ if(opt.keyserver) { glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_name(name,&fpr,&fpr_len,opt.keyserver); + rc=keyserver_import_name(name,&fpr,&fpr_len,opt.keyserver); glo_ctrl.in_auto_key_retrieve--; - if(res==0) + if(rc==0) log_info(_("Automatically retrieved `%s' via %s\n"), name,opt.keyserver->uri); } @@ -979,10 +978,10 @@ keyserver=keyserver_match(akl->spec); glo_ctrl.in_auto_key_retrieve++; - res=keyserver_import_name(name,&fpr,&fpr_len,keyserver); + rc=keyserver_import_name(name,&fpr,&fpr_len,keyserver); glo_ctrl.in_auto_key_retrieve--; - if(res==0) + if(rc==0) log_info(_("Automatically retrieved `%s' via %s\n"), name,akl->spec->uri); } @@ -996,7 +995,7 @@ requirement as the URL might point to a key put in by an attacker. By forcing the use of the fingerprint, we won't use the attacker's key here. */ - if(res==0 && fpr) + if(rc==0 && fpr) { int i; char fpr_string[MAX_FINGERPRINT_LEN*2+1]; Modified: trunk/g10/keyserver.c =================================================================== --- trunk/g10/keyserver.c 2006-03-16 22:40:04 UTC (rev 4067) +++ trunk/g10/keyserver.c 2006-03-17 05:20:13 UTC (rev 4068) @@ -1985,7 +1985,7 @@ { char *domain,*look,*url; IOBUF key; - int type,rc=-1; + int type,rc=G10ERR_GENERAL; look=xstrdup(name); @@ -1993,7 +1993,7 @@ if(domain) *domain='.'; - type=get_cert(look,max_cert_size,&key,NULL,NULL,&url); + type=get_cert(look,max_cert_size,&key,fpr,fpr_len,&url); if(type==1) { int armor_status=opt.no_armor; @@ -2008,23 +2008,36 @@ iobuf_close(key); } - else if(type==2) + else if(type==2 && *fpr) { - struct keyserver_spec *spec; - - spec=parse_keyserver_uri(url,1,NULL,0); - if(spec) + /* We only consider the IPGP type if a fingerprint was provided. + This lets us select the right key regardless of what a URL + points to, or get the key from a keyserver. */ + if(url) { - STRLIST list=NULL; + struct keyserver_spec *spec; - add_to_strlist(&list,url); + spec=parse_keyserver_uri(url,1,NULL,0); + if(spec) + { + STRLIST list=NULL; - rc=keyserver_fetch(list); + add_to_strlist(&list,url); - free_strlist(list); - free_keyserver_spec(spec); + rc=keyserver_fetch(list); + + free_strlist(list); + free_keyserver_spec(spec); + } } + else if(opt.keyserver) + { + /* If only a fingerprint is provided, try and fetch it from + our --keyserver */ + rc=keyserver_import_fprint(*fpr,*fpr_len,opt.keyserver); + } + xfree(url); } From cvs at cvs.gnupg.org Fri Mar 17 17:24:28 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri Mar 17 16:57:59 2006 Subject: [svn] gcry - r1150 - in trunk: . cipher src Message-ID: Author: wk Date: 2006-03-17 17:24:27 +0100 (Fri, 17 Mar 2006) New Revision: 1150 Added: trunk/cipher/random-daemon.c Modified: trunk/ChangeLog trunk/README trunk/acinclude.m4 trunk/cipher/ChangeLog trunk/cipher/Makefile.am trunk/cipher/random.c trunk/cipher/random.h trunk/configure.ac trunk/src/global.c Log: More changes. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-15 11:46:50 UTC (rev 1149) +++ trunk/ChangeLog 2006-03-17 16:24:27 UTC (rev 1150) @@ -1,6 +1,9 @@ 2006-03-14 Werner Koch * configure.ac: Check for fctnl and ftruncate. + (HAVE_PTH): Check for GNU Pth. + (HAVE_W32_SYSTEM): Define it. + * acinclude.m4 (GNUPG_PTH_VERSION_CHECK): New. Taken from GnuPG 1.4. 2005-12-08 Werner Koch Modified: trunk/README =================================================================== --- trunk/README 2006-03-15 11:46:50 UTC (rev 1149) +++ trunk/README 2006-03-17 16:24:27 UTC (rev 1150) @@ -52,8 +52,10 @@ the GPL as found in the file COPYING. The modules under the GPL are: - rndunix - Entropy gatherer for Unices without a /dev/random - rndw32 - Entropy gatherer for MS Windows + rndunix - Entropy gatherer for Unices without a /dev/random + rndw32 - Entropy gatherer for MS Windows + gcryptrnd - The random number daemon. + getrandom - A client for that daemon. The documentation is available under the terms of the GPL. Modified: trunk/acinclude.m4 =================================================================== --- trunk/acinclude.m4 2006-03-15 11:46:50 UTC (rev 1149) +++ trunk/acinclude.m4 2006-03-17 16:24:27 UTC (rev 1150) @@ -321,412 +321,7 @@ AC_SUBST(GPG_ERROR_LIBS) ]) -dnl ## -dnl ## GNU Pth - The GNU Portable Threads -dnl ## Copyright (c) 1999-2002 Ralf S. Engelschall -dnl ## -dnl ## This file is part of GNU Pth, a non-preemptive thread scheduling -dnl ## library which can be found at http://www.gnu.org/software/pth/. -dnl ## -dnl ## This library is free software; you can redistribute it and/or -dnl ## modify it under the terms of the GNU Lesser General Public -dnl ## License as published by the Free Software Foundation; either -dnl ## version 2.1 of the License, or (at your option) any later version. -dnl ## -dnl ## This library is distributed in the hope that it will be useful, -dnl ## but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl ## Lesser General Public License for more details. -dnl ## -dnl ## You should have received a copy of the GNU Lesser General Public -dnl ## License along with this library; if not, write to the Free Software -dnl ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -dnl ## USA, or contact Ralf S. Engelschall . -dnl ## -dnl ## pth.m4: Autoconf macro for locating GNU Pth from within -dnl ## configure.in of third-party software packages -dnl ## -dnl ## -dnl ## Synopsis: -dnl ## AC_CHECK_PTH([MIN-VERSION [, # minimum Pth version, e.g. 1.2.0 -dnl ## DEFAULT-WITH-PTH [, # default value for --with-pth option -dnl ## DEFAULT-WITH-PTH-TEST [,# default value for --with-pth-test option -dnl ## EXTEND-VARS [, # whether CFLAGS/LDFLAGS/etc are extended -dnl ## ACTION-IF-FOUND [, # action to perform if Pth was found -dnl ## ACTION-IF-NOT-FOUND # action to perform if Pth was not found -dnl ## ]]]]]]) -dnl ## Examples: -dnl ## AC_CHECK_PTH(1.2.0) -dnl ## AC_CHECK_PTH(1.2.0,,,no,CFLAGS="$CFLAGS -DHAVE_PTH $PTH_CFLAGS") -dnl ## AC_CHECK_PTH(1.2.0,yes,yes,yes,CFLAGS="$CFLAGS -DHAVE_PTH") -dnl ## -dnl -dnl # auxilliary macros -AC_DEFUN([_AC_PTH_ERROR], [dnl -AC_MSG_RESULT([*FAILED*]) -dnl define(_ac_pth_line,dnl -dnl "+------------------------------------------------------------------------+") -dnl echo " _ac_pth_line" 1>&2 -cat <>/ /' 1>&2 -$1 -EOT -dnl echo " _ac_pth_line" 1>&2 -dnl undefine(_ac_pth_line) -exit 1 -]) -AC_DEFUN([_AC_PTH_VERBOSE], [dnl -if test ".$verbose" = .yes; then - AC_MSG_RESULT([ $1]) -fi -]) -dnl # the user macro -AC_DEFUN([AC_CHECK_PTH], [dnl -dnl -dnl # prerequisites -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_PROG_CPP])dnl -dnl -PTH_CPPFLAGS='' -PTH_CFLAGS='' -PTH_LDFLAGS='' -PTH_LIBS='' -AC_SUBST(PTH_CPPFLAGS) -AC_SUBST(PTH_CFLAGS) -AC_SUBST(PTH_LDFLAGS) -AC_SUBST(PTH_LIBS) -dnl # command line options -AC_MSG_CHECKING(for GNU Pth) -_AC_PTH_VERBOSE([]) -AC_ARG_WITH(pth,dnl -[ --with-pth[=ARG] Build with GNU Pth Library (default=]ifelse([$2],,yes,$2)[)],dnl -,dnl -with_pth="ifelse([$2],,yes,$2)" -)dnl -AC_ARG_WITH(pth-test,dnl -[ --with-pth-test Perform GNU Pth Sanity Test (default=]ifelse([$3],,yes,$3)[)],dnl -,dnl -with_pth_test="ifelse([$3],,yes,$3)" -)dnl -_AC_PTH_VERBOSE([+ Command Line Options:]) -_AC_PTH_VERBOSE([ o --with-pth=$with_pth]) -_AC_PTH_VERBOSE([ o --with-pth-test=$with_pth_test]) -dnl -dnl # configuration -if test ".$with_pth" != .no; then - _pth_subdir=no - _pth_subdir_opts='' - case "$with_pth" in - subdir:* ) - _pth_subdir=yes - changequote(, )dnl - _pth_subdir_opts=`echo $with_pth | sed -e 's/^subdir:[^ ]*[ ]*//'` - with_pth=`echo $with_pth | sed -e 's/^subdir:\([^ ]*\).*$/\1/'` - changequote([, ])dnl - ;; - esac - _pth_version="" - _pth_location="" - _pth_type="" - _pth_cppflags="" - _pth_cflags="" - _pth_ldflags="" - _pth_libs="" - if test ".$with_pth" = .yes; then - # via config script in $PATH - changequote(, )dnl - _pth_version=`(pth-config --version) 2>/dev/null |\ - sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'` - changequote([, ])dnl - if test ".$_pth_version" != .; then - _pth_location=`pth-config --prefix` - _pth_type='installed' - _pth_cppflags=`pth-config --cflags` - _pth_cflags=`pth-config --cflags` - _pth_ldflags=`pth-config --ldflags` - _pth_libs=`pth-config --libs` - fi - elif test -d "$with_pth"; then - with_pth=`echo $with_pth | sed -e 's;/*$;;'` - _pth_found=no - # via locally included source tree - if test ".$_pth_subdir" = .yes; then - _pth_location="$with_pth" - _pth_type='local' - _pth_cppflags="-I$with_pth" - _pth_cflags="-I$with_pth" - if test -f "$with_pth/ltconfig"; then - _pth_ldflags="-L$with_pth/.libs" - else - _pth_ldflags="-L$with_pth" - fi - _pth_libs="-lpth" - changequote(, )dnl - _pth_version=`grep '^const char PTH_Hello' $with_pth/pth_vers.c |\ - sed -e 's;^.*Version[ ]*\([0-9]*\.[0-9]*[.ab][0-9]*\)[ ].*$;\1;'` - changequote([, ])dnl - _pth_found=yes - ac_configure_args="$ac_configure_args --enable-subdir $_pth_subdir_opts" - with_pth_test=no - fi - # via config script under a specified directory - # (a standard installation, but not a source tree) - if test ".$_pth_found" = .no; then - for _dir in $with_pth/bin $with_pth; do - if test -f "$_dir/pth-config"; then - test -f "$_dir/pth-config.in" && continue # pth-config in source tree! - changequote(, )dnl - _pth_version=`($_dir/pth-config --version) 2>/dev/null |\ - sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'` - changequote([, ])dnl - if test ".$_pth_version" != .; then - _pth_location=`$_dir/pth-config --prefix` - _pth_type="installed" - _pth_cppflags=`$_dir/pth-config --cflags` - _pth_cflags=`$_dir/pth-config --cflags` - _pth_ldflags=`$_dir/pth-config --ldflags` - _pth_libs=`$_dir/pth-config --libs` - _pth_found=yes - break - fi - fi - done - fi - # in any subarea under a specified directory - # (either a special installation or a Pth source tree) - if test ".$_pth_found" = .no; then - changequote(, )dnl - _pth_found=0 - for _file in x `find $with_pth -name "pth.h" -type f -print`; do - test .$_file = .x && continue - _dir=`echo $_file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'` - _pth_version=`($_dir/pth-config --version) 2>/dev/null |\ - sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'` - if test ".$_pth_version" = .; then - _pth_version=`grep '^#define PTH_VERSION_STR' $_file |\ - sed -e 's;^#define[ ]*PTH_VERSION_STR[ ]*"\([0-9]*\.[0-9]*[.ab][0-9]*\)[ ].*$;\1;'` - fi - _pth_cppflags="-I$_dir" - _pth_cflags="-I$_dir" - _pth_found=`expr $_pth_found + 1` - done - for _file in x `find $with_pth -name "libpth.[aso]" -type f -print`; do - test .$_file = .x && continue - _dir=`echo $_file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'` - _pth_ldflags="-L$_dir" - _pth_libs="-lpth" - _pth_found=`expr $_pth_found + 1` - done - changequote([, ])dnl - if test ".$_pth_found" = .2; then - _pth_location="$with_pth" - _pth_type="uninstalled" - else - _pth_version='' - fi - fi - fi - _AC_PTH_VERBOSE([+ Determined Location:]) - _AC_PTH_VERBOSE([ o path: $_pth_location]) - _AC_PTH_VERBOSE([ o type: $_pth_type]) - if test ".$_pth_version" = .; then - with_pth=no - else -dnl if test ".$with_pth" != .yes; then -dnl _AC_PTH_ERROR([dnl -dnl Unable to locate GNU Pth under $with_pth. -dnl Please specify the correct path to either a GNU Pth installation tree -dnl (use --with-pth=DIR if you used --prefix=DIR for installing GNU Pth in -dnl the past) or to a GNU Pth source tree (use --with-pth=DIR if DIR is a -dnl path to a pth-X.Y.Z/ directory; but make sure the package is already -dnl built, i.e., the "configure; make" step was already performed there).]) -dnl else -dnl _AC_PTH_ERROR([dnl -dnl Unable to locate GNU Pth in any system-wide location (see \$PATH). -dnl Please specify the correct path to either a GNU Pth installation tree -dnl (use --with-pth=DIR if you used --prefix=DIR for installing GNU Pth in -dnl the past) or to a GNU Pth source tree (use --with-pth=DIR if DIR is a -dnl path to a pth-X.Y.Z/ directory; but make sure the package is already -dnl built, i.e., the "configure; make" step was already performed there).]) -dnl fi -dnl fi - dnl # - dnl # Check whether the found version is sufficiently new - dnl # - _req_version="ifelse([$1],,1.0.0,$1)" - for _var in _pth_version _req_version; do - eval "_val=\"\$${_var}\"" - _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'` - _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'` - _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'` - _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'` - case $_rtype in - "a" ) _rtype=0 ;; - "b" ) _rtype=1 ;; - "." ) _rtype=2 ;; - esac - _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \ - "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"` - eval "${_var}_hex=\"\$_hex\"" - done - _AC_PTH_VERBOSE([+ Determined Versions:]) - _AC_PTH_VERBOSE([ o existing: $_pth_version -> 0x$_pth_version_hex]) - _AC_PTH_VERBOSE([ o required: $_req_version -> 0x$_req_version_hex]) - _ok=0 - if test ".$_pth_version_hex" != .; then - if test ".$_req_version_hex" != .; then - if test $_pth_version_hex -ge $_req_version_hex; then - _ok=1 - fi - fi - fi - if test ".$_ok" = .0; then - _AC_PTH_ERROR([dnl - Found Pth version $_pth_version, but required at least version $_req_version. - Upgrade Pth under $_pth_location to $_req_version or higher first, please.]) - fi - dnl # - dnl # Perform Pth Sanity Compile Check - dnl # - if test ".$with_pth_test" = .yes; then - _ac_save_CPPFLAGS="$CPPFLAGS" - _ac_save_CFLAGS="$CFLAGS" - _ac_save_LDFLAGS="$LDFLAGS" - _ac_save_LIBS="$LIBS" - CPPFLAGS="$CPPFLAGS $_pth_cppflags" - CFLAGS="$CFLAGS $_pth_cflags" - LDFLAGS="$LDFLAGS $_pth_ldflags" - LIBS="$LIBS $_pth_libs" - _AC_PTH_VERBOSE([+ Test Build Environment:]) - _AC_PTH_VERBOSE([ o CPPFLAGS=\"$CPPFLAGS\"]) - _AC_PTH_VERBOSE([ o CFLAGS=\"$CFLAGS\"]) - _AC_PTH_VERBOSE([ o LDFLAGS=\"$LDFLAGS\"]) - _AC_PTH_VERBOSE([ o LIBS=\"$LIBS\"]) - cross_compile=no - define(_code1, [dnl - #include - #include - ]) - define(_code2, [dnl - int main(int argc, char *argv[]) - { - FILE *fp; - if (!(fp = fopen("conftestval", "w"))) - exit(1); - fprintf(fp, "hmm"); - fclose(fp); - pth_init(); - pth_kill(); - if (!(fp = fopen("conftestval", "w"))) - exit(1); - fprintf(fp, "yes"); - fclose(fp); - exit(0); - } - ]) - _AC_PTH_VERBOSE([+ Performing Sanity Checks:]) - _AC_PTH_VERBOSE([ o pre-processor test]) - AC_TRY_CPP(_code1, _ok=yes, _ok=no) - if test ".$_ok" != .yes; then - _AC_PTH_ERROR([dnl - Found GNU Pth $_pth_version under $_pth_location, but - was unable to perform a sanity pre-processor check. This means - the GNU Pth header pth.h was not found. - We used the following build environment: - >> CPP="$CPP" - >> CPPFLAGS="$CPPFLAGS" - See config.log for possibly more details.]) - fi - _AC_PTH_VERBOSE([ o link check]) - AC_TRY_LINK(_code1, _code2, _ok=yes, _ok=no) - if test ".$_ok" != .yes; then - _AC_PTH_ERROR([dnl - Found GNU Pth $_pth_version under $_pth_location, but - was unable to perform a sanity linker check. This means - the GNU Pth library libpth.a was not found. - We used the following build environment: - >> CC="$CC" - >> CFLAGS="$CFLAGS" - >> LDFLAGS="$LDFLAGS" - >> LIBS="$LIBS" - See config.log for possibly more details.]) - fi - _AC_PTH_VERBOSE([ o run-time check]) - AC_TRY_RUN(_code1 _code2, _ok=`cat conftestval`, _ok=no, _ok=no) - if test ".$_ok" != .yes; then - if test ".$_ok" = .no; then - _AC_PTH_ERROR([dnl - Found GNU Pth $_pth_version under $_pth_location, but - was unable to perform a sanity execution check. This usually - means that the GNU Pth shared library libpth.so is present - but \$LD_LIBRARY_PATH is incomplete to execute a Pth test. - In this case either disable this test via --without-pth-test, - or extend \$LD_LIBRARY_PATH, or build GNU Pth as a static - library only via its --disable-shared Autoconf option. - We used the following build environment: - >> CC="$CC" - >> CFLAGS="$CFLAGS" - >> LDFLAGS="$LDFLAGS" - >> LIBS="$LIBS" - See config.log for possibly more details.]) - else - _AC_PTH_ERROR([dnl - Found GNU Pth $_pth_version under $_pth_location, but - was unable to perform a sanity run-time check. This usually - means that the GNU Pth library failed to work and possibly - caused a core dump in the test program. In this case it - is strongly recommended that you re-install GNU Pth and this - time make sure that it really passes its "make test" procedure. - We used the following build environment: - >> CC="$CC" - >> CFLAGS="$CFLAGS" - >> LDFLAGS="$LDFLAGS" - >> LIBS="$LIBS" - See config.log for possibly more details.]) - fi - fi - _extendvars="ifelse([$4],,yes,$4)" - if test ".$_extendvars" != .yes; then - CPPFLAGS="$_ac_save_CPPFLAGS" - CFLAGS="$_ac_save_CFLAGS" - LDFLAGS="$_ac_save_LDFLAGS" - LIBS="$_ac_save_LIBS" - fi - else - _extendvars="ifelse([$4],,yes,$4)" - if test ".$_extendvars" = .yes; then - if test ".$_pth_subdir" = .yes; then - CPPFLAGS="$CPPFLAGS $_pth_cppflags" - CFLAGS="$CFLAGS $_pth_cflags" - LDFLAGS="$LDFLAGS $_pth_ldflags" - LIBS="$LIBS $_pth_libs" - fi - fi - fi - PTH_CPPFLAGS="$_pth_cppflags" - PTH_CFLAGS="$_pth_cflags" - PTH_LDFLAGS="$_pth_ldflags" - PTH_LIBS="$_pth_libs" - AC_SUBST(PTH_CPPFLAGS) - AC_SUBST(PTH_CFLAGS) - AC_SUBST(PTH_LDFLAGS) - AC_SUBST(PTH_LIBS) - _AC_PTH_VERBOSE([+ Final Results:]) - _AC_PTH_VERBOSE([ o PTH_CPPFLAGS=\"$PTH_CPPFLAGS\"]) - _AC_PTH_VERBOSE([ o PTH_CFLAGS=\"$PTH_CFLAGS\"]) - _AC_PTH_VERBOSE([ o PTH_LDFLAGS=\"$PTH_LDFLAGS\"]) - _AC_PTH_VERBOSE([ o PTH_LIBS=\"$PTH_LIBS\"]) -fi -fi -if test ".$with_pth" != .no; then - AC_MSG_RESULT([version $_pth_version, $_pth_type under $_pth_location]) - ifelse([$5], , :, [$5]) -else - AC_MSG_RESULT([no]) - ifelse([$6], , :, [$6]) -fi -]) - dnl Check for socklen_t: historically on BSD it is an int, and in dnl POSIX 1g it is a type of its own, but some platforms use different dnl types for the argument to getsockopt, getpeername, etc. So we @@ -767,3 +362,68 @@ [#include #include ]) ]) + + +# GNUPG_PTH_VERSION_CHECK(REQUIRED) +# +# If the version is sufficient, HAVE_PTH will be set to yes. +# +# Taken form the m4 macros which come with Pth +AC_DEFUN([GNUPG_PTH_VERSION_CHECK], + [ + _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'` + _req_version="ifelse([$1],,1.2.0,$1)" + + AC_MSG_CHECKING(for PTH - version >= $_req_version) + for _var in _pth_version _req_version; do + eval "_val=\"\$${_var}\"" + _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'` + _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'` + _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'` + _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'` + case $_rtype in + "a" ) _rtype=0 ;; + "b" ) _rtype=1 ;; + "." ) _rtype=2 ;; + esac + _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \ + "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"` + eval "${_var}_hex=\"\$_hex\"" + done + have_pth=no + if test ".$_pth_version_hex" != .; then + if test ".$_req_version_hex" != .; then + if test $_pth_version_hex -ge $_req_version_hex; then + have_pth=yes + fi + fi + fi + if test $have_pth = yes; then + AC_MSG_RESULT(yes) + AC_MSG_CHECKING([whether PTH installation is sane]) + AC_CACHE_VAL(gnupg_cv_pth_is_sane,[ + _gnupg_pth_save_cflags=$CFLAGS + _gnupg_pth_save_ldflags=$LDFLAGS + _gnupg_pth_save_libs=$LIBS + CFLAGS="$CFLAGS `$PTH_CONFIG --cflags`" + LDFLAGS="$LDFLAGS `$PTH_CONFIG --ldflags`" + LIBS="$LIBS `$PTH_CONFIG --libs`" + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include + ], + [[ pth_init ();]])], + gnupg_cv_pth_is_sane=yes, + gnupg_cv_pth_is_sane=no) + CFLAGS=$_gnupg_pth_save_cflags + LDFLAGS=$_gnupg_pth_save_ldflags + LIBS=$_gnupg_pth_save_libs + ]) + if test $gnupg_cv_pth_is_sane != yes; then + have_pth=no + fi + AC_MSG_RESULT($gnupg_cv_pth_is_sane) + else + AC_MSG_RESULT(no) + fi + ]) + + Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2006-03-15 11:46:50 UTC (rev 1149) +++ trunk/cipher/ChangeLog 2006-03-17 16:24:27 UTC (rev 1150) @@ -1,3 +1,10 @@ +2006-03-15 Werner Koch + + * random-daemon.c: New. + * random.c (_gcry_use_random_daemon): New. + (get_random_bytes, gcry_randomize, gcry_create_nonce): Try + diverting to the daemon functions. + 2006-03-14 Werner Koch * random.c (lock_seed_file): New. Modified: trunk/cipher/Makefile.am =================================================================== --- trunk/cipher/Makefile.am 2006-03-15 11:46:50 UTC (rev 1149) +++ trunk/cipher/Makefile.am 2006-03-17 16:24:27 UTC (rev 1150) @@ -36,7 +36,7 @@ cipher.c pubkey.c ac.c md.c \ bithelp.h \ primegen.c \ -random.c random.h \ +random.c random-daemon.c random.h \ rand-internal.h \ rmd.h Added: trunk/cipher/random-daemon.c =================================================================== --- trunk/cipher/random-daemon.c 2006-03-15 11:46:50 UTC (rev 1149) +++ trunk/cipher/random-daemon.c 2006-03-17 16:24:27 UTC (rev 1150) @@ -0,0 +1,108 @@ +/* random-daemon.c - Access to the external random daemon + * Copyright (C) 2006 Free Software Foundation, Inc. + * + * This file is part of Libgcrypt. + * + * Libgcrypt is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * Libgcrypt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/* + The functions here are used by random.c to divert calls to an + external random number daemon. The actual daemon we use is + gcryptrnd. Such a daemon is useful to keep a persistent pool in + memory over invocations of a single application and to allow + prioritizing access to the actual entropy sources. The drawback is + that we need to use IPC (i.e. unxi domain socket) to convey + sensitive data. + */ + + +#include +#include +#include +#include + +#include "g10lib.h" +#include "random.h" +#include "ath.h" + + +/* The lock taken while talking to the daemon. */ +static ath_mutex_t daemon_lock = ATH_MUTEX_INITIALIZER; + + + +/* Initialize basics of this module. This should be viewed as a + constroctur to prepare locking. */ +void +_gcry_daemon_initialize_basics (void) +{ + static int initialized; + int err; + + if (!initialized) + { + initialized = 1; + err = ath_mutex_init (&daemon_lock); + if (err) + log_fatal ("failed to create the daemon lock: %s\n", strerror (err) ); + } +} + + + + + + + + + + + + + + + + + +/* Internal function to fill BUFFER with LENGTH bytes of random. We + support GCRY_STRONG_RANDOM and GCRY_VERY_STRONG_RANDOM here. + Return 0 on success. */ +int +_gcry_daemon_randomize (void *buffer, size_t length, + enum gcry_random_level level) +{ + return -1; +} + +/* Internal function to return a pointer to a randomized buffer of + LEVEL and NBYTES length. Caller must free the buffer. With SECURE + passed as TRUE, allocate the rwanom in secure memory - however note + that the IPC mechanism might have not stored it there. Return a + pointer to a newly alloced memory or NULL if it failed. */ +void * +_gcry_daemon_get_random_bytes (ize_t nbytes, int level, int secure) +{ + return NULL; +} + + +/* Internal function to fill BUFFER with NBYTES of data usable for a + nonce. Returns 0 on success. */ +int +_gcry_daemon_create_nonce (void *buffer, size_t length) +{ + return -1; +} Modified: trunk/cipher/random.c =================================================================== --- trunk/cipher/random.c 2006-03-15 11:46:50 UTC (rev 1149) +++ trunk/cipher/random.c 2006-03-17 16:24:27 UTC (rev 1150) @@ -94,6 +94,7 @@ static int is_initialized; +static int allow_daemon; /* If true, try to use the daemon first. */ #define MASK_LEVEL(a) do { (a) &= 3; } while(0) static char *rndpool; /* allocated size is POOLSIZE+BLOCKLEN */ static char *keypool; /* allocated size is POOLSIZE+BLOCKLEN */ @@ -159,6 +160,7 @@ if (err) log_fatal ("failed to create the nonce buffer lock: %s\n", strerror (err) ); + _gcry_daemon_initialize_basics (); } } @@ -248,7 +250,24 @@ return faked_rng? 1 : last; } + +/* With ONOFF set to 1, enable the use of the daemon. With ONOFF set + to 0, disable the use of the daemon. With ONOF set to -1, return + whether the daemon has been enabled. */ int +_gcry_use_random_daemon (int onoff) +{ + int last; + + /* FIXME: This is not really thread safe. */ + last = allow_daemon; + if (onoff != -1) + allow_daemon = onoff; + return last; +} + + +int _gcry_random_is_faked() { if( !is_initialized ) @@ -274,6 +293,9 @@ /* Make sure the requested level is in range. */ MASK_LEVEL(level); + if (allow_daemon && (p=_gcry_daemon_get_random_bytes (nbytes, level,secure))) + return p; /* The daemon succeeded. */ + /* Lock the pool. */ err = ath_mutex_lock (&pool_lock); if (err) @@ -352,7 +374,7 @@ } /* The public function to return random data of the quality LEVEL; - this version of the function retrun the random a buffer allocated + this version of the function return the random a buffer allocated in secure memory. */ void * gcry_random_bytes_secure( size_t nbytes, enum gcry_random_level level ) @@ -384,6 +406,9 @@ /* Make sure the level is okay. */ MASK_LEVEL(level); + if (allow_daemon && !_gcry_daemon_randomize (buffer, length, level)) + return; /* The daemon succeeded. */ + /* Acquire the pool lock. */ err = ath_mutex_lock (&pool_lock); if (err) @@ -1196,6 +1221,9 @@ if (!is_initialized) initialize (); + if (allow_daemon && !_gcry_daemon_create_nonce (buffer, length)) + return; /* The daemon succeeded. */ + /* Acquire the nonce buffer lock. */ err = ath_mutex_lock (&nonce_buffer_lock); if (err) Modified: trunk/cipher/random.h =================================================================== --- trunk/cipher/random.h 2006-03-15 11:46:50 UTC (rev 1149) +++ trunk/cipher/random.h 2006-03-17 16:24:27 UTC (rev 1150) @@ -29,12 +29,21 @@ void _gcry_secure_random_alloc(void); int _gcry_quick_random_gen( int onoff ); int _gcry_random_is_faked(void); +int _gcry_use_random_daemon (int onoff); void _gcry_set_random_seed_file (const char *name); void _gcry_update_random_seed_file (void); byte *_gcry_get_random_bits( size_t nbits, int level, int secure ); void _gcry_fast_random_poll( void ); +/*-- random-daemon.c (only used from random.c) --*/ +void _gcry_daemon_initialize_basics (void); +int _gcry_daemon_randomize (void *buffer, size_t length, + enum gcry_random_level level); +void *_gcry_daemon_get_random_bytes (size_t nbytes, int level, int secure); +int _gcry_daemon_create_nonce (void *buffer, size_t length); + + #endif /*G10_RANDOM_H*/ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-15 11:46:50 UTC (rev 1149) +++ trunk/configure.ac 2006-03-17 16:24:27 UTC (rev 1150) @@ -131,12 +131,14 @@ # Other definitions. print_egd_notice=no +have_w32_system=no # Setup some stuff depending on host/target. case "${target}" in *-*-mingw32*) available_random_modules="w32" ac_cv_have_dev_random=no + have_w32_system=yes AC_DEFINE(USE_ONLY_8DOT3,1, [set this to limit filenames to the 8.3 format]) AC_DEFINE(HAVE_DRIVE_LETTERS,1, @@ -185,6 +187,13 @@ ;; esac +if test "$have_w32_system" = yes; then + AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system]) +fi +AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) + + + # A printable OS Name is sometime useful. case "${target}" in *-*-mingw32*) @@ -422,6 +431,9 @@ #### Checks for libraries. #### ############################### +# +# gpg-error is required. +# AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION") if test "x$GPG_ERROR_LIBS" = "x"; then AC_MSG_ERROR([libgpg-error is needed. @@ -431,6 +443,43 @@ AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GCRYPT, [The default error source for libgcrypt.]) +# +# Check whether the GNU Pth library is available. We require this +# to build the optional gcryptrnd program. +# +AC_ARG_WITH(pth-prefix, + AC_HELP_STRING([--with-pth-prefix=PFX], + [prefix where GNU Pth is installed (optional)]), + pth_config_prefix="$withval", pth_config_prefix="") +if test x$pth_config_prefix != x ; then + PTH_CONFIG="$pth_config_prefix/bin/pth-config" +fi +AC_PATH_PROG(PTH_CONFIG, pth-config, no) +if test "$PTH_CONFIG" = "no"; then + AC_MSG_WARN([[ +*** +*** To build the Libgcrypt's random humber daemon +*** we need the support of the GNU Portable Threads Library. +*** Download it from ftp://ftp.gnu.org/gnu/pth/ +*** On a Debian GNU/Linux system you might want to try +*** apt-get install libpth-dev +***]]) + else + GNUPG_PTH_VERSION_CHECK([1.3.7]) + if test $have_pth = yes; then + PTH_CFLAGS=`$PTH_CONFIG --cflags` + PTH_LIBS=`$PTH_CONFIG --ldflags` + PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs`" + AC_DEFINE(USE_GNU_PTH, 1, + [Defined if the GNU Portable Thread Library should be used]) + AC_DEFINE(HAVE_PTH, 1, + [Defined if the GNU Pth is available]) + fi +fi +AC_SUBST(PTH_CFLAGS) +AC_SUBST(PTH_LIBS) + + # Solaris needs -lsocket and -lnsl. Unisys system includes # gethostbyname in libsocket but needs libnsl for socket. AC_SEARCH_LIBS(setsockopt, [socket], , Modified: trunk/src/global.c =================================================================== --- trunk/src/global.c 2006-03-15 11:46:50 UTC (rev 1149) +++ trunk/src/global.c 2006-03-17 16:24:27 UTC (rev 1150) @@ -314,7 +314,7 @@ if (! init_finished) { global_init (); - /* Do only a basic ranom initialization, i.e. inti the + /* Do only a basic random initialization, i.e. init the mutexes. */ _gcry_random_initialize (0); init_finished = 1; From cvs at cvs.gnupg.org Fri Mar 17 17:32:26 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri Mar 17 17:05:43 2006 Subject: [svn] gcry - r1151 - trunk/cipher Message-ID: Author: wk Date: 2006-03-17 17:32:26 +0100 (Fri, 17 Mar 2006) New Revision: 1151 Modified: trunk/cipher/random-daemon.c Log: Made ist compile - not it won't work yet. Modified: trunk/cipher/random-daemon.c =================================================================== --- trunk/cipher/random-daemon.c 2006-03-17 16:24:27 UTC (rev 1150) +++ trunk/cipher/random-daemon.c 2006-03-17 16:32:26 UTC (rev 1151) @@ -93,7 +93,7 @@ that the IPC mechanism might have not stored it there. Return a pointer to a newly alloced memory or NULL if it failed. */ void * -_gcry_daemon_get_random_bytes (ize_t nbytes, int level, int secure) +_gcry_daemon_get_random_bytes (size_t nbytes, int level, int secure) { return NULL; } From cvs at cvs.gnupg.org Sat Mar 18 06:36:32 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Sat Mar 18 06:09:44 2006 Subject: [svn] GnuPG - r4069 - trunk Message-ID: Author: dshaw Date: 2006-03-18 06:36:32 +0100 (Sat, 18 Mar 2006) New Revision: 4069 Modified: trunk/ChangeLog trunk/configure.ac Log: * configure.ac: Allow the DNS stuff to work on OSX by trying the Apple-specific BIND_8_COMPAT. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-17 05:20:13 UTC (rev 4068) +++ trunk/ChangeLog 2006-03-18 05:36:32 UTC (rev 4069) @@ -1,3 +1,8 @@ +2006-03-17 David Shaw + + * configure.ac: Allow the DNS stuff to work on OSX by trying the + Apple-specific BIND_8_COMPAT. + 2006-03-09 Werner Koch Released 1.4.3rc2. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-17 05:20:13 UTC (rev 4068) +++ trunk/configure.ac 2006-03-18 05:36:32 UTC (rev 4069) @@ -1,6 +1,6 @@ dnl configure.ac script for GnuPG -dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, -dnl 2005, 2006 Free Software Foundation, Inc. +dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +dnl 2006 Free Software Foundation, Inc. dnl dnl This file is part of GnuPG. dnl @@ -593,12 +593,28 @@ # enabling any code that calls it. At some point I'll rewrite the # code to use the BIND 8 resolver API. + AC_MSG_CHECKING([whether the resolver is usable]) AC_LINK_IFELSE([AC_LANG_PROGRAM([#include #include #include #include ], -[[unsigned char answer[PACKETSZ]; res_query("foo.bar",C_IN,T_A,answer,PACKETSZ);]])],have_resolver=yes) +[[unsigned char answer[PACKETSZ]; res_query("foo.bar",C_IN,T_A,answer,PACKETSZ);]])],have_resolver=yes,have_resolver=no) + AC_MSG_RESULT($have_resolver) +# This is Apple-specific and somewhat bizarre as they changed the +# define in bind 8 for some reason. + + if test x"$have_resolver" != xyes ; then + AC_MSG_CHECKING([whether I can make the resolver usable with BIND_8_COMPAT]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([#define BIND_8_COMPAT +#include +#include +#include +#include ], +[[unsigned char answer[PACKETSZ]; res_query("foo.bar",C_IN,T_A,answer,PACKETSZ);]])],[have_resolver=yes ; need_compat=yes]) + AC_MSG_RESULT($have_resolver) + fi + if test x"$have_resolver" = xyes ; then SRVLIBS=$LIBS @@ -613,6 +629,10 @@ if test x"$use_dns_cert" = xyes ; then AC_DEFINE(USE_DNS_CERT,1,[define to use DNS CERT]) fi + + if test x"$need_compat" = xyes ; then + AC_DEFINE(BIND_8_COMPAT,1,[an Appleism]) + fi else use_dns_srv=no use_dns_pka=no From cvs at cvs.gnupg.org Mon Mar 20 01:39:45 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Mon Mar 20 01:12:56 2006 Subject: [svn] GnuPG - r4070 - trunk/cipher Message-ID: Author: dshaw Date: 2006-03-20 01:39:44 +0100 (Mon, 20 Mar 2006) New Revision: 4070 Modified: trunk/cipher/ChangeLog trunk/cipher/blowfish.c trunk/cipher/md5.c trunk/cipher/rmd160.c trunk/cipher/sha1.c trunk/cipher/sha256.c trunk/cipher/sha512.c Log: * blowfish.c, md5.c, rmd160.c, sha1.c, sha256.c, sha512.c: Use '#if' rather than '#ifdef' BIG_ENDIAN_HOST. Harmless as we explicitly define BIG_ENDIAN_HOST to 1 when we need it, but needed for OSX fat builds when we define BIG_ENDIAN_HOST to another macro. Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2006-03-18 05:36:32 UTC (rev 4069) +++ trunk/cipher/ChangeLog 2006-03-20 00:39:44 UTC (rev 4070) @@ -1,3 +1,11 @@ +2006-03-19 David Shaw + + * blowfish.c, md5.c, rmd160.c, sha1.c, sha256.c, sha512.c: Use + '#if' rather than '#ifdef' BIG_ENDIAN_HOST. Harmless as we + explicitly define BIG_ENDIAN_HOST to 1 when we need it, but needed + for OSX fat builds when we define BIG_ENDIAN_HOST to another + macro. + 2006-02-14 Werner Koch * random.c (lock_seed_file): Build even when not used. Modified: trunk/cipher/blowfish.c =================================================================== --- trunk/cipher/blowfish.c 2006-03-18 05:36:32 UTC (rev 4069) +++ trunk/cipher/blowfish.c 2006-03-20 00:39:44 UTC (rev 4070) @@ -251,7 +251,7 @@ { u16 a, b, c, d; -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST a = ((byte*)&x)[0]; b = ((byte*)&x)[1]; c = ((byte*)&x)[2]; @@ -267,7 +267,7 @@ } #endif -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST #define F(x) ((( s0[((byte*)&x)[0]] + s1[((byte*)&x)[1]]) \ ^ s2[((byte*)&x)[2]]) + s3[((byte*)&x)[3]] ) #else @@ -528,7 +528,7 @@ } for(i=j=0; i < BLOWFISH_ROUNDS+2; i++ ) { -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST ((byte*)&data)[0] = key[j]; ((byte*)&data)[1] = key[(j+1)%keylen]; ((byte*)&data)[2] = key[(j+2)%keylen]; Modified: trunk/cipher/md5.c =================================================================== --- trunk/cipher/md5.c 2006-03-18 05:36:32 UTC (rev 4069) +++ trunk/cipher/md5.c 2006-03-20 00:39:44 UTC (rev 4070) @@ -100,7 +100,7 @@ u32 D = ctx->D; u32 *cwp = correct_words; -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST { int i; byte *p2, *p1; for(i=0, p1=data, p2=(byte*)correct_words; i < 16; i++, p2 += 4 ) { @@ -311,7 +311,7 @@ burn_stack (80+6*sizeof(void*)); p = hd->buf; -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST #define X(a) do { *p++ = hd-> a ; *p++ = hd-> a >> 8; \ *p++ = hd-> a >> 16; *p++ = hd-> a >> 24; } while(0) #else /* little endian */ Modified: trunk/cipher/rmd160.c =================================================================== --- trunk/cipher/rmd160.c 2006-03-18 05:36:32 UTC (rev 4069) +++ trunk/cipher/rmd160.c 2006-03-20 00:39:44 UTC (rev 4070) @@ -176,7 +176,7 @@ transform( RMD160_CONTEXT *hd, byte *data ) { u32 a,b,c,d,e,aa,bb,cc,dd,ee,t; -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST u32 x[16]; { int i; byte *p2, *p1; @@ -515,7 +515,7 @@ burn_stack (108+5*sizeof(void*)); p = hd->buf; -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST #define X(a) do { *p++ = hd->h##a ; *p++ = hd->h##a >> 8; \ *p++ = hd->h##a >> 16; *p++ = hd->h##a >> 24; } while(0) #else /* little endian */ Modified: trunk/cipher/sha1.c =================================================================== --- trunk/cipher/sha1.c 2006-03-18 05:36:32 UTC (rev 4069) +++ trunk/cipher/sha1.c 2006-03-20 00:39:44 UTC (rev 4070) @@ -91,7 +91,7 @@ d = hd->h3; e = hd->h4; -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST memcpy( x, data, 64 ); #else { int i; @@ -305,7 +305,7 @@ burn_stack (88+4*sizeof(void*)); p = hd->buf; -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST #define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0) #else /* little endian */ #define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \ Modified: trunk/cipher/sha256.c =================================================================== --- trunk/cipher/sha256.c 2006-03-18 05:36:32 UTC (rev 4069) +++ trunk/cipher/sha256.c 2006-03-20 00:39:44 UTC (rev 4070) @@ -111,7 +111,7 @@ g = hd->h6; h = hd->h7; -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST memcpy( w, data, 64 ); #else { @@ -257,7 +257,7 @@ burn_stack (328); p = hd->buf; -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST #define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0) #else /* little endian */ #define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \ Modified: trunk/cipher/sha512.c =================================================================== --- trunk/cipher/sha512.c 2006-03-18 05:36:32 UTC (rev 4069) +++ trunk/cipher/sha512.c 2006-03-20 00:39:44 UTC (rev 4070) @@ -171,7 +171,7 @@ g = hd->h6; h = hd->h7; -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST memcpy( w, data, 128 ); #else { @@ -332,7 +332,7 @@ burn_stack (768); p = hd->buf; -#ifdef BIG_ENDIAN_HOST +#if BIG_ENDIAN_HOST #define X(a) do { *(u64*)p = hd->h##a ; p += 8; } while(0) #else /* little endian */ #define X(a) do { *p++ = hd->h##a >> 56; *p++ = hd->h##a >> 48; \ From cvs at cvs.gnupg.org Mon Mar 20 01:57:33 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Mon Mar 20 01:30:35 2006 Subject: [svn] GnuPG - r4071 - trunk Message-ID: Author: dshaw Date: 2006-03-20 01:57:33 +0100 (Mon, 20 Mar 2006) New Revision: 4071 Modified: trunk/ChangeLog trunk/README trunk/configure.ac Log: * configure.ac: Add --disable-endian-check for building fat binaries on OSX. * README: Add note on how to build a fat binary on OSX. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-20 00:39:44 UTC (rev 4070) +++ trunk/ChangeLog 2006-03-20 00:57:33 UTC (rev 4071) @@ -1,3 +1,10 @@ +2006-03-19 David Shaw + + * configure.ac: Add --disable-endian-check for building fat + binaries on OSX. + + * README: Add note on how to build a fat binary on OSX. + 2006-03-17 David Shaw * configure.ac: Allow the DNS stuff to work on OSX by trying the Modified: trunk/README =================================================================== --- trunk/README 2006-03-20 00:39:44 UTC (rev 4070) +++ trunk/README 2006-03-20 00:57:33 UTC (rev 4071) @@ -47,6 +47,7 @@ Installation ------------ + Please read the file INSTALL and the sections in this file related to the installation. Here is a quick summary: @@ -74,6 +75,7 @@ How to Verify the Source ------------------------ + In order to check that the version of GnuPG which you are going to install is an original and unmodified one, you can do it in one of the following ways: @@ -141,6 +143,7 @@ Introduction ------------ + Here is a brief overview on how to use GnuPG - it is strongly suggested that you read the manual and other information about the use of cryptography. GnuPG is only a tool, secure usage requires that @@ -387,7 +390,8 @@ 8 Ways to Specify a User ID - -------------------------- + ---------=----------------- + There are several ways to specify a user ID, here are some examples. * Only by the short keyid (prepend a zero if it begins with A..F): @@ -439,6 +443,7 @@ Batch mode ---------- + If you use the option "--batch", GnuPG runs in non-interactive mode and never prompts for input data. This does not even allow entering the passphrase. Until we have a better solution (something like ssh-agent), @@ -451,6 +456,7 @@ Exit status ----------- + GnuPG returns with an exit status of 1 if in batch mode and a bad signature has been detected or 2 or higher for all other errors. You should parse stderr or, better, the output of the fd specified with --status-fd to get @@ -459,6 +465,7 @@ Configure options ----------------- + Here is a list of configure options which are sometime useful for installation. @@ -627,18 +634,10 @@ the use of iconv. Note, that iconv is also disabled if gettext has been disabled. - --enable-backsigs - Enables "backsigs" support. This is a currently - experimental solution to a subtle OpenPGP protocol - problem involving signing subkeys. It is - specified in the 2440bis drafts that will become - the new OpenPGP standard, but is not finalized yet - and has not had interoperability testing. Use at - your own risk. - Installation Problems --------------------- + If you get unresolved externals "gettext" you should run configure again with the option "--with-included-gettext"; this is version 0.12.1 which is available at ftp.gnu.org. @@ -706,6 +705,7 @@ ./configure ac_cv_sys_symbol_underscore=yes + The Random Device ----------------- @@ -722,6 +722,7 @@ Creating an RPM package ----------------------- + The file scripts/gnupg.spec is used to build a RPM package (both binary and src): 1. copy the spec file into /usr/src/redhat/SPECS @@ -735,9 +736,23 @@ rpm in /usr/src/redhat/SRPMS + Building Universal Binaries on Apple OS X + ----------------------------------------- + You can build a universal ("fat") binary that will work on both + PPC and Intel Macs with something like: + + ./configure CFLAGS="-arch ppc -arch i386" \ + --disable-dependency-tracking --disable-asm + + If you are doing the build on a OS X 10.4 (Tiger) PPC machine you + may need to add "-isysroot /Developer/SDKs/MacOSX10.4u.sdk" to + those CFLAGS. + + GnuPG 1.4 and GnuPG 1.9 ----------------------- + GnuPG 1.4 is the stable version of GnuPG; GnuPG 1.9 is the development branch. However, large parts of GnuPG 1.9 are also considered to be stable and useful. In particular the tools @@ -748,7 +763,6 @@ want to make use of gpg-agent. - How to Get More Information --------------------------- Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-20 00:39:44 UTC (rev 4070) +++ trunk/configure.ac 2006-03-20 00:57:33 UTC (rev 4071) @@ -823,8 +823,19 @@ AC_TYPE_SIGNAL AC_DECL_SYS_SIGLIST -GNUPG_CHECK_ENDIAN +AC_ARG_ENABLE(endian-check, + AC_HELP_STRING([--disable-endian-check],[disable the endian check and trust the OS provided macros]), + endiancheck=$enableval,endiancheck=yes) +if test x"$endiancheck" = xno ; then + # don't do an endian check so we can build universal ("fat") + # binaries on OS X. + AC_DEFINE_UNQUOTED(LITTLE_ENDIAN_HOST,__LITTLE_ENDIAN__) + AC_DEFINE_UNQUOTED(BIG_ENDIAN_HOST,__BIG_ENDIAN__) +else + GNUPG_CHECK_ENDIAN +fi + GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF) GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF) GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF) From cvs at cvs.gnupg.org Mon Mar 20 13:05:19 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Mar 20 12:38:26 2006 Subject: [svn] GPGol - r140 - in trunk: . src Message-ID: Author: wk Date: 2006-03-20 13:05:18 +0100 (Mon, 20 Mar 2006) New Revision: 140 Modified: trunk/NEWS trunk/configure.ac trunk/src/ChangeLog trunk/src/main.c trunk/src/olflange.cpp trunk/src/passphrase-dialog.c Log: Additional test for old OL versions. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-14 12:13:21 UTC (rev 139) +++ trunk/NEWS 2006-03-20 12:05:18 UTC (rev 140) @@ -1,3 +1,8 @@ +Noteworthy changes for version 0.9.7 +================================================= + + + Noteworthy changes for version 0.9.6 (2006-01-26) ================================================= Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-14 12:13:21 UTC (rev 139) +++ trunk/configure.ac 2006-03-20 12:05:18 UTC (rev 140) @@ -16,7 +16,7 @@ # Version number: Remember to change it immediately *after* a release. # Make sure to run "svn up" before a "make dist". # Add a "-cvs" prefix for non-released code. -AC_INIT(gpgol, 0.9.6, bug-gpgol@g10code.com) +AC_INIT(gpgol, 0.9.7-cvs, bug-gpgol@g10code.com) NEED_GPGME_API=1 NEED_GPGME_VERSION=1.1.0 Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-03-14 12:13:21 UTC (rev 139) +++ trunk/src/ChangeLog 2006-03-20 12:05:18 UTC (rev 140) @@ -1,3 +1,11 @@ +2006-03-20 Werner Koch + + * olflange.cpp (Install): Also check major part of build version. + +2006-03-15 Werner Koch + + * olflange.cpp (Install): Print gpgol version for debugging. + 2006-03-14 Timo Schulz * passphrase-dialog.c (decrypt_dlg_proc): When used @@ -4,6 +12,10 @@ as a signing key selection dialog, use a different title. * gpgol-rsrcs.rc: Use German titles for German dialog versions. +2006-02-23 Werner Koch + + * main.c (read_options): Set default caching time to 10 minutes. + 2006-01-16 Werner Koch * verify-dialog.c (load_sigbox): Give a hint in case of a bad @@ -13,7 +25,7 @@ 2005-12-07 Werner Koch - * olflange.cpp (Install): Cehck the version and print a warning. + * olflange.cpp (Install): Check the version and print a warning. * olflange-dlgs.cpp (GPGOptionsDlgProc): Simplified the default key code. Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2006-03-14 12:13:21 UTC (rev 139) +++ trunk/src/main.c 2006-03-20 12:05:18 UTC (rev 140) @@ -388,8 +388,10 @@ opt.enable_default_key = val == NULL || *val != '1' ? 0 : 1; xfree (val); val = NULL; - load_extension_value ("storePasswdTime", &val); - opt.passwd_ttl = val == NULL || *val == '0'? 0 : atol (val); + if (load_extension_value ("storePasswdTime", &val) ) + opt.passwd_ttl = 600; /* Initial default. */ + else + opt.passwd_ttl = val == NULL || *val == '0'? 0 : atol (val); xfree (val); val = NULL; load_extension_value ("encodingFormat", &val); Modified: trunk/src/olflange.cpp =================================================================== --- trunk/src/olflange.cpp 2006-03-14 12:13:21 UTC (rev 139) +++ trunk/src/olflange.cpp 2006-03-20 12:05:18 UTC (rev 140) @@ -706,6 +706,7 @@ lFlags); /* Check version. */ + log_debug ("GPGol: this is %s\n", SRCNAME, __func__, PACKAGE_STRING); pEECB->GetVersion (&lBuildVersion, EECBGV_GETBUILDVERSION); pEECB->GetVersion (&lActualVersion, EECBGV_GETACTUALVERSION); pEECB->GetVersion (&lVirtualVersion, EECBGV_GETVIRTUALVERSION); @@ -733,7 +734,8 @@ SRCNAME, __func__, lBuildVersion); return S_FALSE; } - if ((lBuildVersion & EECBGV_BUILDVERSION_MINOR_MASK) < 1573) + if ((lBuildVersion & EECBGV_BUILDVERSION_MAJOR_MASK) < 13 + ||(lBuildVersion & EECBGV_BUILDVERSION_MINOR_MASK) < 1573) { static int shown; HWND hwnd; Modified: trunk/src/passphrase-dialog.c =================================================================== --- trunk/src/passphrase-dialog.c 2006-03-14 12:13:21 UTC (rev 139) +++ trunk/src/passphrase-dialog.c 2006-03-20 12:05:18 UTC (rev 140) @@ -559,7 +559,7 @@ /* Display a signer dialog which contains all secret keys, useable for signing data. The key is returned in R_KEY. The passprase in - r_passwd. IF Encrypting is true, the message will get encrypted + r_passwd. If Encrypting is true, the message will get encrypted later. */ int signer_dialog_box (gpgme_key_t *r_key, char **r_passwd, int encrypting) @@ -659,8 +659,8 @@ For caching we need to use the long keyid from case 1; the main keyid can't be used because a key may have different passphrases on the subkeys. Caching for symmetrical keys is - not possible becuase there is no information on what - key(i.e. passphrase) to use. Caching of of PINs is not yet + not possible because there is no information on what + key(i.e. passphrase) to use. Caching of PINs is not yet possible because we don't have information on the card's serial number yet; that must be solved by gpgme. @@ -710,7 +710,7 @@ assert (strlen (keyidstr) < sizeof dec->keyid); strcpy (dec->keyid, keyidstr); - /* If we have no cached pssphrase, popup the passphrase dialog. */ + /* If we have no cached passphrase, popup the passphrase dialog. */ if (!dec->pass) { int rc; From cvs at cvs.gnupg.org Mon Mar 20 14:13:57 2006 From: cvs at cvs.gnupg.org (svn author twoaday) Date: Mon Mar 20 13:46:57 2006 Subject: [svn] GPGol - r141 - trunk/src Message-ID: Author: twoaday Date: 2006-03-20 14:13:56 +0100 (Mon, 20 Mar 2006) New Revision: 141 Removed: trunk/src/keylist.c Modified: trunk/src/ChangeLog trunk/src/common.c trunk/src/config-dialog.c trunk/src/intern.h trunk/src/passphrase-dialog.c trunk/src/recipient-dialog.c trunk/src/verify-dialog.c trunk/src/w32-gettext.c Log: 2006-03-17 Timo Schulz * w32-gettext.c (utf8_to_native): Make it global. * config-dialog.c (get_open_file_name): Make sure the selected file really exists. * passphrase-dialog.c (decrypt_dlg_proc): UTF8 conversion. (passphrase_callback_box): Likewise. * recipient-dialog.c (recipient_dlg_proc): Likewise. * verify-dialog.c (load_akalist): Likewise. (load_sigbox): Likewise. * common.c (utf_to_wincp): New. (keylist.c: removed unsued test file.) Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-03-20 12:05:18 UTC (rev 140) +++ trunk/src/ChangeLog 2006-03-20 13:13:56 UTC (rev 141) @@ -1,7 +1,19 @@ -2006-03-20 Werner Koch +2006-03-20 Werner Koch * olflange.cpp (Install): Also check major part of build version. + +2006-03-17 Timo Schulz + * w32-gettext.c (utf8_to_native): Make it global. + * config-dialog.c (get_open_file_name): Make sure the selected + file really exists. + * passphrase-dialog.c (decrypt_dlg_proc): UTF8 conversion. + (passphrase_callback_box): Likewise. + * recipient-dialog.c (recipient_dlg_proc): Likewise. + * verify-dialog.c (load_akalist): Likewise. + (load_sigbox): Likewise. + * common.c (utf_to_wincp): New. + 2006-03-15 Werner Koch * olflange.cpp (Install): Print gpgol version for debugging. Modified: trunk/src/common.c =================================================================== --- trunk/src/common.c 2006-03-20 12:05:18 UTC (rev 140) +++ trunk/src/common.c 2006-03-20 13:13:56 UTC (rev 141) @@ -22,6 +22,7 @@ #include "gpgme.h" #include "intern.h" +#include "util.h" HINSTANCE glob_hinst = NULL; @@ -79,7 +80,6 @@ is returned. */ char * get_save_filename (HWND root, const char *srcname) - { char filter[] = "All Files (*.*)\0*.*\0\0"; char fname[MAX_PATH+1]; @@ -98,7 +98,7 @@ ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.Flags |= OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - ofn.lpstrTitle = "GPG - Save decrypted attachment"; + ofn.lpstrTitle = _("GPG - Save decrypted attachment"); ofn.lpstrFilter = filter; if (GetSaveFileName (&ofn)) @@ -288,6 +288,57 @@ } +/* CP850 -> CP1251 charset table. */ +static unsigned char cp850_to_cp1251[] = +{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, + 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, + 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, + 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, + 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, + 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, + 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0xc7, 0xfc, + 0xe9, 0xe2, 0xe4, 0xe0, 0xe5, 0xe7, 0xea, 0xeb, 0xe8, 0xef, 0xee, 0xec, 0xc4, + 0xc5, 0xc9, 0xe6, 0xc6, 0xf4, 0xf6, 0xf2, 0xfb, 0xf9, 0xff, 0xd6, 0xdc, 0xf8, + 0xa3, 0xd8, 0xd7, 0x00, 0xe1, 0xed, 0xf3, 0xfa, 0xf1, 0xd1, 0xaa, 0xba, 0xbf, + 0xae, 0xac, 0xbd, 0xbc, 0xa1, 0xab, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, + 0xc2, 0xc0, 0xa9, 0x00, 0x00, 0x00, 0x00, 0xa2, 0xa5, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xe3, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, + 0xf0, 0xd0, 0xca, 0xcb, 0xc8, 0x00, 0xcd, 0xce, 0xcf, 0x00, 0x00, 0x00, 0x00, + 0xa6, 0xcc, 0x00, 0xd3, 0xdf, 0xd4, 0xd2, 0xf5, 0xd5, 0xb5, 0xfe, 0xde, 0xda, + 0xdb, 0xd9, 0xfd, 0xdd, 0xaf, 0xb4, 0xad, 0xb1, 0x00, 0xbe, 0xb6, 0xa7, 0xf7, + 0xb8, 0xb0, 0xa8, 0xb7, 0xb9, 0xb3, 0xb2, 0x00, 0xa0, +}; + +char *utf8_to_native (const char *string); + +/* Convert the console (CP850) encoded UTF8 data from STRING into + the current window charset and return it. + Caller must free string. */ +char * +utf8_to_wincp (const char *string) +{ + char *res; + unsigned char *res_8; + size_t i; + + res_8 = res = utf8_to_native (string); + + /* XXX: currently only CP850->CP1251 is supported. */ + for (i=0; i < strlen (res); i++) + { + unsigned char ch = cp850_to_cp1251[res_8[i]]; + if (ch != 0x00) + res_8[i] = ch; + } + + return res; +} + + /* Assume STRING is a Latin-1 encoded and convert it to utf-8. Returns a newly malloced UTF-8 string. */ char * Modified: trunk/src/config-dialog.c =================================================================== --- trunk/src/config-dialog.c 2006-03-20 12:05:18 UTC (rev 140) +++ trunk/src/config-dialog.c 2006-03-20 13:13:56 UTC (rev 141) @@ -49,6 +49,7 @@ memset (fname, 0, sizeof (fname)); ofn.hwndOwner = GetDesktopWindow (); ofn.hInstance = glob_hinst; + ofn.Flags = OFN_FILEMUSTEXIST; ofn.lpstrTitle = title; ofn.lStructSize = sizeof (ofn); ofn.lpstrInitialDir = dir; Modified: trunk/src/intern.h =================================================================== --- trunk/src/intern.h 2006-03-20 12:05:18 UTC (rev 140) +++ trunk/src/intern.h 2006-03-20 13:13:56 UTC (rev 141) @@ -114,11 +114,11 @@ } opt; - /*-- common.c --*/ void set_global_hinstance (HINSTANCE hinst); void center_window (HWND childwnd, HWND style); char *get_save_filename (HWND root, const char *srcname); +char *utf8_to_wincp (const char *string); HRESULT w32_shgetfolderpath (HWND a, int b, HANDLE c, DWORD d, LPSTR e); Deleted: trunk/src/keylist.c Modified: trunk/src/passphrase-dialog.c =================================================================== --- trunk/src/passphrase-dialog.c 2006-03-20 12:05:18 UTC (rev 140) +++ trunk/src/passphrase-dialog.c 2006-03-20 13:13:56 UTC (rev 141) @@ -227,8 +227,8 @@ while (!gpgme_op_keylist_next (ctx, &key)) { - const char *name, *email, *keyid, *algo; - char *p; + const char *email, *keyid, *algo; + char *p, *name; long idx; if (key->revoked || key->expired || key->disabled || key->invalid) @@ -242,15 +242,17 @@ continue; } - name = key->uids->name; - if (!name) - name = ""; + if (!key->uids->name) + name = strdup (""); + else + name = utf8_to_wincp (key->uids->name); email = key->uids->email; if (!email) email = ""; keyid = key->subkeys->keyid; if (!keyid || strlen (keyid) < 8) { + xfree (name); gpgme_key_release (key); continue; } @@ -262,8 +264,9 @@ else sprintf (p, "%s (0x%s, %s)", name, keyid+8, algo); idx = SendDlgItemMessage (dlg, ctlid, CB_ADDSTRING, 0, - (LPARAM)(const char *) p); + (LPARAM)(const char *)p); xfree (p); + xfree (name); if (idx < 0) /* Error. */ { gpgme_key_release (key); @@ -322,10 +325,7 @@ _("Invalid passphrase; please try again..."):""); if (dec && !context->use_as_cb) - { - context->keyarray = load_secbox (dlg, IDC_DEC_KEYLIST); - SetWindowText (dlg, _("Select Signing Key")); - } + context->keyarray = load_secbox (dlg, IDC_DEC_KEYLIST); CheckDlgButton (dlg, IDC_DEC_HIDE, BST_CHECKED); center_window (dlg, NULL); @@ -338,6 +338,8 @@ else SetFocus (GetDlgItem (dlg, IDC_DEC_PASS)); + if (!context->use_as_cb) + SetWindowText (dlg, _("Select Signing Key")); SetForegroundWindow (dlg); return FALSE; } @@ -733,7 +735,7 @@ else s = "[no user Id]"; xfree (dec->user_id); - dec->user_id = xstrdup (s); + dec->user_id = utf8_to_wincp (s); dec->last_was_bad = prev_was_bad; if (dec->flags & 0x01) { Modified: trunk/src/recipient-dialog.c =================================================================== --- trunk/src/recipient-dialog.c 2006-03-20 12:05:18 UTC (rev 140) +++ trunk/src/recipient-dialog.c 2006-03-20 13:13:56 UTC (rev 141) @@ -170,8 +170,8 @@ continue; } - /* Ignore keys without a user ID or woithout a subkey */ - if (!key->uids || !key->subkeys ) + /* Ignore keys without a user ID or without a subkey */ + if (!key->uids || !key->subkeys) { gpgme_key_release (key); continue; @@ -179,8 +179,9 @@ ListView_InsertItem (hwnd, &lvi); - s = key->uids->name; + s = utf8_to_wincp (key->uids->name); ListView_SetItemText (hwnd, 0, COL_NAME, s); + xfree (s); s = key->uids->email; ListView_SetItemText (hwnd, 0, COL_EMAIL, s); @@ -352,7 +353,7 @@ { static struct recipient_cb_s * rset_cb; static int rset_state = 1; - NMHDR * notify; + NMHDR *notify; HWND hrset; const char *warn; size_t pos; @@ -365,7 +366,7 @@ initialize_rsetbox (GetDlgItem (dlg, IDC_ENC_RSET1)); rset_cb->keyarray = load_rsetbox (GetDlgItem (dlg, IDC_ENC_RSET1), - &rset_cb->keyarray_count ); + &rset_cb->keyarray_count); initialize_rsetbox (GetDlgItem (dlg, IDC_ENC_RSET2)); @@ -382,6 +383,10 @@ SetForegroundWindow (dlg); return TRUE; + case WM_DESTROY: + rset_state = 1; /* reset to default. */ + break; + case WM_SYSCOMMAND: if (wparam == SC_CLOSE) EndDialog (dlg, TRUE); @@ -409,7 +414,7 @@ break; } - switch ( LOWORD (wparam) ) + switch (LOWORD (wparam)) { case IDOK: hrset = GetDlgItem (dlg, IDC_ENC_RSET2); Modified: trunk/src/verify-dialog.c =================================================================== --- trunk/src/verify-dialog.c 2006-03-20 12:05:18 UTC (rev 140) +++ trunk/src/verify-dialog.c 2006-03-20 13:13:56 UTC (rev 141) @@ -58,18 +58,22 @@ static int load_akalist (HWND dlg, gpgme_key_t key) { - gpgme_user_id_t u; - int n = 0; - - u = key->uids; - if (!u->next) - return n; - for (u=u->next; u; u=u->next) { - SendDlgItemMessage (dlg, IDC_VRY_AKALIST, LB_ADDSTRING, - 0, (LPARAM)(const char*)u->uid); - n++; + gpgme_user_id_t u; + char *uid; + int n = 0; + + u = key->uids; + if (!u->next) + return n; + for (u=u->next; u; u=u->next) + { + uid = utf8_to_wincp (u->uid); + SendDlgItemMessage (dlg, IDC_VRY_AKALIST, LB_ADDSTRING, + 0, (LPARAM)(const char*)uid); + free (uid); + n++; } - return n; + return n; } @@ -139,8 +143,9 @@ if (key && key->uids) { - s = key->uids->uid; - SetDlgItemText (dlg, IDC_VRY_ISSUER, s); + p = utf8_to_wincp (key->uids->uid); + SetDlgItemText (dlg, IDC_VRY_ISSUER, p); + free (p); n = load_akalist (dlg, key); gpgme_key_release (key); Modified: trunk/src/w32-gettext.c =================================================================== --- trunk/src/w32-gettext.c 2006-03-20 12:05:18 UTC (rev 140) +++ trunk/src/w32-gettext.c 2006-03-20 13:13:56 UTC (rev 141) @@ -1461,7 +1461,7 @@ } -static char * +char * utf8_to_native (const char *string) { wchar_t *wstring; From cvs at cvs.gnupg.org Mon Mar 20 17:13:53 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Mon Mar 20 16:46:52 2006 Subject: [svn] GnuPG - r4072 - trunk Message-ID: Author: dshaw Date: 2006-03-20 17:13:52 +0100 (Mon, 20 Mar 2006) New Revision: 4072 Modified: trunk/ChangeLog trunk/configure.ac Log: * configure.ac: Improved --disable-endian-check that doesn't involve changing #ifdefs in the rest of the code. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-20 00:57:33 UTC (rev 4071) +++ trunk/ChangeLog 2006-03-20 16:13:52 UTC (rev 4072) @@ -1,3 +1,8 @@ +2006-03-20 David Shaw + + * configure.ac: Improved --disable-endian-check that doesn't + involve changing #ifdefs in the rest of the code. + 2006-03-19 David Shaw * configure.ac: Add --disable-endian-check for building fat Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-20 00:57:33 UTC (rev 4071) +++ trunk/configure.ac 2006-03-20 16:13:52 UTC (rev 4072) @@ -405,6 +405,18 @@ ]) AH_BOTTOM([ +/* We didn't define endianness above, so get it from OS macros. This +is intended for making fat binary builds on OS X. */ +#if !defined(BIG_ENDIAN_HOST) && !defined(LITTLE_ENDIAN_HOST) +#if defined(__BIG_ENDIAN__) +#define BIG_ENDIAN_HOST 1 +#elif defined(__LITTLE_ENDIAN__) +#define LITTLE_ENDIAN_HOST 1 +#else +#error "No endianness found" +#endif +#endif + #if !(defined(HAVE_FORK) && defined(HAVE_PIPE) && defined(HAVE_WAITPID)) #define EXEC_TEMPFILE_ONLY #endif @@ -824,15 +836,11 @@ AC_DECL_SYS_SIGLIST AC_ARG_ENABLE(endian-check, - AC_HELP_STRING([--disable-endian-check],[disable the endian check and trust the OS provided macros]), + AC_HELP_STRING([--disable-endian-check], + [disable the endian check and trust the OS provided macros]), endiancheck=$enableval,endiancheck=yes) -if test x"$endiancheck" = xno ; then - # don't do an endian check so we can build universal ("fat") - # binaries on OS X. - AC_DEFINE_UNQUOTED(LITTLE_ENDIAN_HOST,__LITTLE_ENDIAN__) - AC_DEFINE_UNQUOTED(BIG_ENDIAN_HOST,__BIG_ENDIAN__) -else +if test x"$endiancheck" = xyes ; then GNUPG_CHECK_ENDIAN fi From cvs at cvs.gnupg.org Mon Mar 20 17:40:30 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Mon Mar 20 17:13:28 2006 Subject: [svn] GnuPG - r4073 - trunk/cipher Message-ID: Author: dshaw Date: 2006-03-20 17:40:28 +0100 (Mon, 20 Mar 2006) New Revision: 4073 Modified: trunk/cipher/ChangeLog trunk/cipher/blowfish.c trunk/cipher/md5.c trunk/cipher/rmd160.c trunk/cipher/sha1.c trunk/cipher/sha256.c trunk/cipher/sha512.c Log: * blowfish.c, md5.c, rmd160.c, sha1.c, sha256.c, sha512.c: Revert previous change. It's now all done in configure. Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2006-03-20 16:13:52 UTC (rev 4072) +++ trunk/cipher/ChangeLog 2006-03-20 16:40:28 UTC (rev 4073) @@ -1,3 +1,8 @@ +2006-03-20 David Shaw + + * blowfish.c, md5.c, rmd160.c, sha1.c, sha256.c, sha512.c: Revert + previous change. It's now all done in configure. + 2006-03-19 David Shaw * blowfish.c, md5.c, rmd160.c, sha1.c, sha256.c, sha512.c: Use Modified: trunk/cipher/blowfish.c =================================================================== --- trunk/cipher/blowfish.c 2006-03-20 16:13:52 UTC (rev 4072) +++ trunk/cipher/blowfish.c 2006-03-20 16:40:28 UTC (rev 4073) @@ -251,7 +251,7 @@ { u16 a, b, c, d; -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST a = ((byte*)&x)[0]; b = ((byte*)&x)[1]; c = ((byte*)&x)[2]; @@ -267,7 +267,7 @@ } #endif -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST #define F(x) ((( s0[((byte*)&x)[0]] + s1[((byte*)&x)[1]]) \ ^ s2[((byte*)&x)[2]]) + s3[((byte*)&x)[3]] ) #else @@ -528,7 +528,7 @@ } for(i=j=0; i < BLOWFISH_ROUNDS+2; i++ ) { -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST ((byte*)&data)[0] = key[j]; ((byte*)&data)[1] = key[(j+1)%keylen]; ((byte*)&data)[2] = key[(j+2)%keylen]; Modified: trunk/cipher/md5.c =================================================================== --- trunk/cipher/md5.c 2006-03-20 16:13:52 UTC (rev 4072) +++ trunk/cipher/md5.c 2006-03-20 16:40:28 UTC (rev 4073) @@ -100,7 +100,7 @@ u32 D = ctx->D; u32 *cwp = correct_words; -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST { int i; byte *p2, *p1; for(i=0, p1=data, p2=(byte*)correct_words; i < 16; i++, p2 += 4 ) { @@ -311,7 +311,7 @@ burn_stack (80+6*sizeof(void*)); p = hd->buf; -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST #define X(a) do { *p++ = hd-> a ; *p++ = hd-> a >> 8; \ *p++ = hd-> a >> 16; *p++ = hd-> a >> 24; } while(0) #else /* little endian */ Modified: trunk/cipher/rmd160.c =================================================================== --- trunk/cipher/rmd160.c 2006-03-20 16:13:52 UTC (rev 4072) +++ trunk/cipher/rmd160.c 2006-03-20 16:40:28 UTC (rev 4073) @@ -176,7 +176,7 @@ transform( RMD160_CONTEXT *hd, byte *data ) { u32 a,b,c,d,e,aa,bb,cc,dd,ee,t; -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST u32 x[16]; { int i; byte *p2, *p1; @@ -515,7 +515,7 @@ burn_stack (108+5*sizeof(void*)); p = hd->buf; -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST #define X(a) do { *p++ = hd->h##a ; *p++ = hd->h##a >> 8; \ *p++ = hd->h##a >> 16; *p++ = hd->h##a >> 24; } while(0) #else /* little endian */ Modified: trunk/cipher/sha1.c =================================================================== --- trunk/cipher/sha1.c 2006-03-20 16:13:52 UTC (rev 4072) +++ trunk/cipher/sha1.c 2006-03-20 16:40:28 UTC (rev 4073) @@ -91,7 +91,7 @@ d = hd->h3; e = hd->h4; -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST memcpy( x, data, 64 ); #else { int i; @@ -305,7 +305,7 @@ burn_stack (88+4*sizeof(void*)); p = hd->buf; -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST #define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0) #else /* little endian */ #define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \ Modified: trunk/cipher/sha256.c =================================================================== --- trunk/cipher/sha256.c 2006-03-20 16:13:52 UTC (rev 4072) +++ trunk/cipher/sha256.c 2006-03-20 16:40:28 UTC (rev 4073) @@ -111,7 +111,7 @@ g = hd->h6; h = hd->h7; -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST memcpy( w, data, 64 ); #else { @@ -257,7 +257,7 @@ burn_stack (328); p = hd->buf; -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST #define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0) #else /* little endian */ #define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \ Modified: trunk/cipher/sha512.c =================================================================== --- trunk/cipher/sha512.c 2006-03-20 16:13:52 UTC (rev 4072) +++ trunk/cipher/sha512.c 2006-03-20 16:40:28 UTC (rev 4073) @@ -171,7 +171,7 @@ g = hd->h6; h = hd->h7; -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST memcpy( w, data, 128 ); #else { @@ -332,7 +332,7 @@ burn_stack (768); p = hd->buf; -#if BIG_ENDIAN_HOST +#ifdef BIG_ENDIAN_HOST #define X(a) do { *(u64*)p = hd->h##a ; p += 8; } while(0) #else /* little endian */ #define X(a) do { *p++ = hd->h##a >> 56; *p++ = hd->h##a >> 48; \ From cvs at cvs.gnupg.org Tue Mar 21 10:56:47 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Mar 21 10:29:41 2006 Subject: [svn] GnuPG - r4074 - in branches/GNUPG-1-9-BRANCH: . sm Message-ID: Author: wk Date: 2006-03-21 10:56:47 +0100 (Tue, 21 Mar 2006) New Revision: 4074 Modified: branches/GNUPG-1-9-BRANCH/NEWS branches/GNUPG-1-9-BRANCH/TODO branches/GNUPG-1-9-BRANCH/sm/ChangeLog branches/GNUPG-1-9-BRANCH/sm/certchain.c branches/GNUPG-1-9-BRANCH/sm/gpgsm.h branches/GNUPG-1-9-BRANCH/sm/qualified.c Log: Add Kludge for RegTP sillyness. Modified: branches/GNUPG-1-9-BRANCH/NEWS =================================================================== --- branches/GNUPG-1-9-BRANCH/NEWS 2006-03-20 16:40:28 UTC (rev 4073) +++ branches/GNUPG-1-9-BRANCH/NEWS 2006-03-21 09:56:47 UTC (rev 4074) @@ -8,7 +8,10 @@ * Cards are not anymore reseted at the end of a connection. + * [gpgsm] Kludge to allow use of Bundesnetzagentur issued + certificates. + Noteworthy changes in version 1.9.20 (2005-12-20) ------------------------------------------------- Modified: branches/GNUPG-1-9-BRANCH/TODO =================================================================== --- branches/GNUPG-1-9-BRANCH/TODO 2006-03-20 16:40:28 UTC (rev 4073) +++ branches/GNUPG-1-9-BRANCH/TODO 2006-03-21 09:56:47 UTC (rev 4074) @@ -18,8 +18,10 @@ * sm/certchain.c ** When a certificate chain was sucessfully verified, make ephemeral certs used in this chain permanent. +** Try to keep certificate references somewhere + This will help with some of our caching code. We also need to test + that cachining; in particular "regtp_ca_chainlen". - * sm/decrypt.c ** replace leading zero in integer hack by a cleaner solution Modified: branches/GNUPG-1-9-BRANCH/sm/ChangeLog =================================================================== --- branches/GNUPG-1-9-BRANCH/sm/ChangeLog 2006-03-20 16:40:28 UTC (rev 4073) +++ branches/GNUPG-1-9-BRANCH/sm/ChangeLog 2006-03-21 09:56:47 UTC (rev 4074) @@ -1,3 +1,12 @@ +2006-03-21 Werner Koch + + * certchain.c (get_regtp_ca_info): New. + (allowed_ca): Use it. + +2006-03-20 Werner Koch + + * qualified.c (gpgsm_is_in_qualified_list): New optional arg COUNTRY. + 2006-02-17 Werner Koch * call-dirmngr.c (start_dirmngr): Print name of dirmngr to be started. Modified: branches/GNUPG-1-9-BRANCH/sm/certchain.c =================================================================== --- branches/GNUPG-1-9-BRANCH/sm/certchain.c 2006-03-20 16:40:28 UTC (rev 4073) +++ branches/GNUPG-1-9-BRANCH/sm/certchain.c 2006-03-21 09:56:47 UTC (rev 4074) @@ -1,5 +1,6 @@ /* certchain.c - certificate chain validation - * Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2003, 2004, 2005, + * 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -39,6 +40,10 @@ #include "i18n.h" +static int get_regtp_ca_info (ksba_cert_t cert, int *chainlen); + + + /* If LISTMODE is true, print FORMAT using LISTMODE to FP. If LISTMODE is false, use the string to print an log_info or, if IS_ERROR is true, and log_error. */ @@ -128,6 +133,11 @@ return err; if (!flag) { + if (get_regtp_ca_info (cert, chainlen)) + { + return 0; /* RegTP issued certificate. */ + } + do_list (1, listmode, fp,_("issuer certificate is not marked as a CA")); return gpg_error (GPG_ERR_BAD_CA_CERT); } @@ -267,7 +277,7 @@ } -/* Helper fucntion for find_up. This resets the key handle and search +/* Helper function for find_up. This resets the key handle and search for an issuer ISSUER with a subjectKeyIdentifier of KEYID. Returns 0 obn success or -1 when not found. */ static int @@ -796,7 +806,7 @@ { /* Need to consult the list of root certificates for qualified signatures. */ - err = gpgsm_is_in_qualified_list (ctrl, subject_cert); + err = gpgsm_is_in_qualified_list (ctrl, subject_cert, NULL); if (!err) is_qualified = 1; else if ( gpg_err_code (err) == GPG_ERR_NOT_FOUND) @@ -807,8 +817,8 @@ gpg_strerror (err)); if ( is_qualified != -1 ) { - /* Cache the result but don't care toomuch about - an error. */ + /* Cache the result but don't care too much + about an error. */ buf[0] = !!is_qualified; err = ksba_cert_set_user_data (subject_cert, "is_qualified", buf, 1); @@ -1181,3 +1191,110 @@ return rc; } + + +/* Check whether the certificate CERT has been issued by the German + authority for qualified signature. They do not set the + basicConstraints and thus we need this workaround. It works by + looking up the root certificate and checking whether that one is + listed as a qualified certificate for Germany. + + We also try to cache this data but as long as don't keep a + reference to the certificate this won't be used. + + Returns: True if CERT is a RegTP issued CA cert (i.e. the root + certificate itself or one of the CAs). In that case CHAINLEN will + receive the length of the chain which is either 0 or 1. +*/ +static int +get_regtp_ca_info (ksba_cert_t cert, int *chainlen) +{ + gpg_error_t err; + ksba_cert_t next; + int rc = 0; + int i, depth; + char country[3]; + ksba_cert_t array[4]; + char buf[2]; + size_t buflen; + int dummy_chainlen; + + if (!chainlen) + chainlen = &dummy_chainlen; + + *chainlen = 0; + err = ksba_cert_get_user_data (cert, "regtp_ca_chainlen", + &buf, sizeof (buf), &buflen); + if (!err) + { + /* Got info. */ + if (buflen < 2 || !*buf) + return 0; /* Nothing found. */ + *chainlen = buf[1]; + return 1; /* This is a regtp CA. */ + } + else if (gpg_err_code (err) != GPG_ERR_NOT_FOUND) + { + log_error ("ksba_cert_get_user_data(%s) failed: %s\n", + "regtp_ca_chainlen", gpg_strerror (err)); + return 0; /* Nothing found. */ + } + + /* Need to gather the info. This requires to walk up the chain + until we have found the root. Because we are only interested in + German Bundesnetzagentur (former RegTP) derived certificates 3 + levels are enough. (The German signature law demands a 3 tier + hierachy; thus there is only one CA between the EE and the Root + CA.) */ + memset (&array, 0, sizeof array); + + depth = 0; + ksba_cert_ref (cert); + array[depth++] = cert; + ksba_cert_ref (cert); + while (depth < DIM(array) && !(rc=gpgsm_walk_cert_chain (cert, &next))) + { + ksba_cert_release (cert); + ksba_cert_ref (next); + array[depth++] = next; + cert = next; + } + ksba_cert_release (cert); + if (rc != -1 || !depth || depth == DIM(array) ) + { + /* We did not reached the root. */ + goto leave; + } + + /* If this is a German signature law issued certificate, we store + additional additional information. */ + if (!gpgsm_is_in_qualified_list (NULL, array[depth-1], country) + && !strcmp (country, "de")) + { + /* Setting the pathlen for the root CA and the CA flag for the + next one is all what we need to do. */ + err = ksba_cert_set_user_data (array[depth-1], "regtp_ca_chainlen", + "\x01\x01", 2); + if (!err && depth > 1) + err = ksba_cert_set_user_data (array[depth-2], "regtp_ca_chainlen", + "\x01\x00", 2); + if (err) + log_error ("ksba_set_user_data(%s) failed: %s\n", + "regtp_ca_chainlen", gpg_strerror (err)); + for (i=0; i < depth; i++) + ksba_cert_release (array[i]); + *chainlen = (depth>1? 0:1); + return 1; + } + + leave: + /* Nothing special with this certificate. Mark the target + certificate anyway to avoid duplicate lookups. */ + err = ksba_cert_set_user_data (cert, "regtp_ca_chainlen", "", 1); + if (err) + log_error ("ksba_set_user_data(%s) failed: %s\n", + "regtp_ca_chainlen", gpg_strerror (err)); + for (i=0; i < depth; i++) + ksba_cert_release (array[i]); + return 0; +} Modified: branches/GNUPG-1-9-BRANCH/sm/gpgsm.h =================================================================== --- branches/GNUPG-1-9-BRANCH/sm/gpgsm.h 2006-03-20 16:40:28 UTC (rev 4073) +++ branches/GNUPG-1-9-BRANCH/sm/gpgsm.h 2006-03-21 09:56:47 UTC (rev 4074) @@ -296,7 +296,8 @@ int gpgsm_genkey (ctrl_t ctrl, int in_fd, FILE *out_fp); /*-- qualified.c --*/ -gpg_error_t gpgsm_is_in_qualified_list (ctrl_t ctrl, ksba_cert_t cert); +gpg_error_t gpgsm_is_in_qualified_list (ctrl_t ctrl, ksba_cert_t cert, + char *country); gpg_error_t gpgsm_qualified_consent (ctrl_t ctrl, ksba_cert_t cert); gpg_error_t gpgsm_not_qualified_warning (ctrl_t ctrl, ksba_cert_t cert); Modified: branches/GNUPG-1-9-BRANCH/sm/qualified.c =================================================================== --- branches/GNUPG-1-9-BRANCH/sm/qualified.c 2006-03-20 16:40:28 UTC (rev 4073) +++ branches/GNUPG-1-9-BRANCH/sm/qualified.c 2006-03-21 09:56:47 UTC (rev 4074) @@ -145,24 +145,29 @@ per user because it is not a decision of the user. Returns: 0 if the certificate is included. GPG_ERR_NOT_FOUND if it - is not in the liost or any other error (e.g. if no list of - qualified signatures is available. */ + is not in the list or any other error (e.g. if no list of + qualified signatures is available. If COUNTRY has not been passed + as NULL a string witha maximum length of 2 will be copied into it; + thus the caller needs to provide a buffer of length 3. */ gpg_error_t -gpgsm_is_in_qualified_list (ctrl_t ctrl, ksba_cert_t cert) +gpgsm_is_in_qualified_list (ctrl_t ctrl, ksba_cert_t cert, char *country) { gpg_error_t err; char *fpr; char key[41]; - char country[2]; + char mycountry[3]; int lnr = 0; + if (country) + *country = 0; + fpr = gpgsm_get_fingerprint_hexstring (cert, GCRY_MD_SHA1); if (!fpr) return gpg_error (GPG_ERR_GENERAL); if (listfp) rewind (listfp); - while (!(err = read_list (key, country, &lnr))) + while (!(err = read_list (key, mycountry, &lnr))) { if (!strcmp (key, fpr)) break; @@ -170,6 +175,9 @@ if (gpg_err_code (err) == GPG_ERR_EOF) err = gpg_error (GPG_ERR_NOT_FOUND); + if (!err && country) + strcpy (country, mycountry); + xfree (fpr); return err; } From cvs at cvs.gnupg.org Tue Mar 21 10:57:38 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Mar 21 10:30:31 2006 Subject: [svn] ksba - r233 - trunk/src Message-ID: Author: wk Date: 2006-03-21 10:57:38 +0100 (Tue, 21 Mar 2006) New Revision: 233 Modified: trunk/src/ChangeLog trunk/src/ber-decoder.c trunk/src/cert.c trunk/src/cms-parser.c Log: Fixed a CMS parsing problem. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2005-11-24 11:56:11 UTC (rev 232) +++ trunk/src/ChangeLog 2006-03-21 09:57:38 UTC (rev 233) @@ -1,3 +1,8 @@ +2006-03-20 Werner Koch + + * ber-decoder.c: Dump debug info always to stderr and not to stdout. + (decoder_next): Take zero length SETs into account. + 2005-11-13 Werner Koch * cert.c (ksba_cert_set_user_data): Fixed. Modified: trunk/src/ber-decoder.c =================================================================== --- trunk/src/ber-decoder.c 2005-11-24 11:56:11 UTC (rev 232) +++ trunk/src/ber-decoder.c 2006-03-21 09:57:38 UTC (rev 233) @@ -115,12 +115,12 @@ for (i=0; i < ds->idx; i++) { - fprintf (stdout," ds stack[%d] (", i); + fprintf (stderr," ds stack[%d] (", i); if (ds->stack[i].node) - _ksba_asn_node_dump (ds->stack[i].node, stdout); + _ksba_asn_node_dump (ds->stack[i].node, stderr); else - printf ("Null"); - fprintf (stdout,") %s%d (%d)%s\n", + fprintf (stderr, "Null"); + fprintf (stderr,") %s%d (%d)%s\n", ds->stack[i].ndef_length? "ndef ":"", ds->stack[i].length, ds->stack[i].nread, @@ -475,22 +475,22 @@ if (!node) { if (debug) - puts (" looking for anchor"); + fputs (" looking for anchor\n", stderr); node = find_anchor_node (root, ti); if (!node) - fputs (" anchor node not found\n", stdout); + fputs (" anchor node not found\n", stderr); } else if (ds->cur.again) { if (debug) - puts (" doing last again"); + fputs (" doing last again\n", stderr); ds->cur.again = 0; } else if (_ksba_asn_is_primitive (node->type) || node->type == TYPE_ANY || node->type == TYPE_SIZE || node->type == TYPE_DEFAULT ) { if (debug) - puts (" primitive type - get next"); + fputs (" primitive type - get next\n", stderr); if (node->right) node = node->right; else if (!node->flags.in_choice) @@ -498,7 +498,7 @@ if (node->flags.is_implicit) { if (debug) - puts (" node was implicit - advancing"); + fputs (" node was implicit - advancing\n", stderr); while (node->left && node->left->right == node) node = node->left; node = node->left; /* this is the up pointer */ @@ -511,7 +511,7 @@ else /* in choice */ { if (debug) - puts (" going up after choice - get next"); + fputs (" going up after choice - get next\n", stderr); while (node->left && node->left->right == node) node = node->left; node = node->left; /* this is the up pointer */ @@ -523,20 +523,20 @@ { if (debug) { - printf (" prepare for seq/set_of (%d %d) ", + fprintf (stderr, " prepare for seq/set_of (%d %d) ", ds->cur.length, ds->cur.nread); - printf (" cur: ("); _ksba_asn_node_dump (node, stdout); - printf (")\n"); + fprintf (stderr, " cur: ("); _ksba_asn_node_dump (node, stderr); + fprintf (stderr, ")\n"); if (ds->cur.node->flags.in_array) - puts (" This is in an array!"); + fputs (" This is in an array!\n", stderr); if (ds->cur.went_up) - puts (" And we are going up!"); + fputs (" And we are going up!\n", stderr); } if ((ds->cur.went_up && !ds->cur.node->flags.in_array) || (ds->idx && ds->cur.nread >= ds->stack[ds->idx-1].length)) { if (debug) - printf (" advancing\n"); + fprintf (stderr, " advancing\n"); if (node->right) node = node->right; else @@ -560,7 +560,7 @@ && ds->cur.went_up) { if (debug) - puts (" Reiterating"); + fputs (" Reiterating\n", stderr); node = _ksba_asn_insert_copy (node); if (node) prepare_copied_tree (node); @@ -572,14 +572,14 @@ { if (debug) { - printf (" prepare for constructed (%d %d) ", + fprintf (stderr, " prepare for constructed (%d %d) ", ds->cur.length, ds->cur.nread); - printf (" cur: ("); _ksba_asn_node_dump (node, stdout); - printf (")\n"); + fprintf (stderr, " cur: ("); _ksba_asn_node_dump (node, stderr); + fprintf (stderr, ")\n"); if (ds->cur.node->flags.in_array) - puts (" This is in an array!"); + fputs (" This is in an array!\n", stderr); if (ds->cur.went_up) - puts (" And we going up!"); + fputs (" And we going up!\n", stderr); } ds->cur.in_seq_of = 0; @@ -587,7 +587,7 @@ && ds->cur.went_up) { if (debug) - puts (" Reiterating this"); + fputs (" Reiterating this\n", stderr); node = _ksba_asn_insert_copy (node); if (node) prepare_copied_tree (node); @@ -625,33 +625,33 @@ if (debug) { - printf (" Expect ("); _ksba_asn_node_dump (node,stdout); printf (")\n"); + fprintf (stderr, " Expect ("); _ksba_asn_node_dump (node,stderr); fprintf (stderr, ")\n"); } if (node->flags.skip_this) { if (debug) - printf (" skipping this\n"); + fprintf (stderr, " skipping this\n"); return 1; } if (node->type == TYPE_SIZE) { if (debug) - printf (" skipping size tag\n"); + fprintf (stderr, " skipping size tag\n"); return 1; } if (node->type == TYPE_DEFAULT) { if (debug) - printf (" skipping default tag\n"); + fprintf (stderr, " skipping default tag\n"); return 1; } if (node->flags.is_implicit) { if (debug) - printf (" dummy accept for implicit tag\n"); + fprintf (stderr, " dummy accept for implicit tag\n"); return 1; /* again */ } @@ -664,22 +664,22 @@ if (node->type == TYPE_CHOICE) { if (debug) - printf (" testing choice...\n"); + fprintf (stderr, " testing choice...\n"); for (node = node->down; node; node = node->right) { if (debug) { - printf (" %s (", node->flags.skip_this? "skip":" cmp"); - _ksba_asn_node_dump (node, stdout); - printf (")\n"); + fprintf (stderr, " %s (", node->flags.skip_this? "skip":" cmp"); + _ksba_asn_node_dump (node, stderr); + fprintf (stderr, ")\n"); } if (!node->flags.skip_this && cmp_tag (node, ti) == 1) { if (debug) { - printf (" choice match <"); dump_tlv (ti, stdout); - printf (">\n"); + fprintf (stderr, " choice match <"); dump_tlv (ti, stderr); + fprintf (stderr, ">\n"); } /* mark the remaining as done */ for (node=node->right; node; node = node->right) @@ -695,14 +695,14 @@ if (node->flags.in_choice) { if (debug) - printf (" skipping non matching choice\n"); + fprintf (stderr, " skipping non matching choice\n"); return 1; } if (node->flags.is_optional) { if (debug) - printf (" skipping optional element\n"); + fprintf (stderr, " skipping optional element\n"); if (node->type == TYPE_TAG) ds->cur.next_tag = 1; return 1; @@ -711,7 +711,7 @@ if (node->flags.has_default) { if (debug) - printf (" use default value\n"); + fprintf (stderr, " use default value\n"); if (node->type == TYPE_TAG) ds->cur.next_tag = 1; *retnode = node; @@ -731,7 +731,7 @@ clear_help_flags (d->root); d->bypass = 0; if (d->debug) - printf ("DECODER_INIT for `%s'\n", start_name? start_name: "[root]"); + fprintf (stderr, "DECODER_INIT for `%s'\n", start_name? start_name: "[root]"); return 0; } @@ -742,7 +742,7 @@ d->ds = NULL; d->val.node = NULL; if (d->debug) - printf ("DECODER_DEINIT\n"); + fprintf (stderr, "DECODER_DEINIT\n"); } @@ -763,7 +763,9 @@ if (debug) { - printf ("ReadTLV <"); dump_tlv (&ti, stdout); printf (">\n"); + fprintf (stderr, "ReadTLV <"); + dump_tlv (&ti, stderr); + fprintf (stderr, ">\n"); } if (d->use_image) @@ -800,7 +802,9 @@ case -1: if (debug) { - printf (" FAIL <"); dump_tlv (&ti, stdout); printf (">\n"); + fprintf (stderr, " FAIL <"); + dump_tlv (&ti, stderr); + fprintf (stderr, ">\n"); } if (d->honor_module_end) { @@ -813,28 +817,30 @@ break; case 0: if (debug) - puts (" End of description"); + fputs (" End of description\n", stderr); d->bypass = 1; break; case 1: /* again */ if (debug) - printf (" Again\n"); + fprintf (stderr, " Again\n"); again = 1; break; case 2: /* Use default value + again */ if (debug) - printf (" Using default\n"); + fprintf (stderr, " Using default\n"); again = 1; break; case 4: /* Match of ANY on a constructed type */ if (debug) - printf (" ANY"); + fprintf (stderr, " ANY"); ds->cur.in_any = 1; case 3: /* match */ case 5: /* end tag */ if (debug) { - printf (" Match <"); dump_tlv (&ti, stdout); printf (">\n"); + fprintf (stderr, " Match <"); + dump_tlv (&ti, stderr); + fprintf (stderr, ">\n"); } /* Increment by the header length */ ds->cur.nread += ti.nhdr; @@ -846,7 +852,7 @@ do { if (debug) - printf (" (length %d nread %d) %s\n", + fprintf (stderr, " (length %d nread %d) %s\n", ds->idx? ds->stack[ds->idx-1].length:-1, ds->cur.nread, ti.is_constructed? "con":"pri"); @@ -856,8 +862,8 @@ && (ds->cur.nread > ds->stack[ds->idx-1].length)) { - fprintf (stderr, " ERROR: object length field %d octects" - " too large\n", + fprintf (stderr, " ERROR: object length field " + "%d octects too large\n", ds->cur.nread > ds->cur.length); ds->cur.nread = ds->cur.length; } @@ -879,7 +885,7 @@ && (ds->cur.nread >= ds->stack[ds->idx-1].length)); - if (ti.is_constructed) + if (ti.is_constructed && (ti.length || ti.ndef)) { /* prepare for the next level */ ds->cur.length = ti.length; @@ -890,7 +896,7 @@ ds->cur.nread = 0; } if (debug) - printf (" (length %d nread %d) end\n", + fprintf (stderr, " (length %d nread %d) end\n", ds->idx? ds->stack[ds->idx-1].length:-1, ds->cur.nread); break; @@ -1160,8 +1166,8 @@ *r_imagelen = d->image.used; if (d->debug) { - fputs ("Value Tree:\n", stdout); - _ksba_asn_node_dump_all (*r_root, stdout); + fputs ("Value Tree:\n", stderr); + _ksba_asn_node_dump_all (*r_root, stderr); } } Modified: trunk/src/cert.c =================================================================== --- trunk/src/cert.c 2005-11-24 11:56:11 UTC (rev 232) +++ trunk/src/cert.c 2006-03-21 09:57:38 UTC (rev 233) @@ -132,7 +132,7 @@ On error (i.e. out or memory) an already existing data object stored under KEY may get deleted. - This function is not thread safe because we don't have employ any + This function is not thread safe because we don't employ any locking. */ gpg_error_t ksba_cert_set_user_data (ksba_cert_t cert, Modified: trunk/src/cms-parser.c =================================================================== --- trunk/src/cms-parser.c 2005-11-24 11:56:11 UTC (rev 232) +++ trunk/src/cms-parser.c 2006-03-21 09:57:38 UTC (rev 233) @@ -735,6 +735,7 @@ return gpg_error (GPG_ERR_INV_CMS_OBJ); si_tail = &cms->signer_info; + while (ti.length) { size_t off1, off2; From cvs at cvs.gnupg.org Tue Mar 21 13:48:52 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Mar 21 13:21:56 2006 Subject: [svn] GnuPG - r4075 - in branches/GNUPG-1-9-BRANCH: . doc scd Message-ID: Author: wk Date: 2006-03-21 13:48:51 +0100 (Tue, 21 Mar 2006) New Revision: 4075 Modified: branches/GNUPG-1-9-BRANCH/NEWS branches/GNUPG-1-9-BRANCH/TODO branches/GNUPG-1-9-BRANCH/doc/scdaemon.texi branches/GNUPG-1-9-BRANCH/scd/ChangeLog branches/GNUPG-1-9-BRANCH/scd/command.c Log: Allo RMD160 signatures Modified: branches/GNUPG-1-9-BRANCH/NEWS =================================================================== --- branches/GNUPG-1-9-BRANCH/NEWS 2006-03-21 09:56:47 UTC (rev 4074) +++ branches/GNUPG-1-9-BRANCH/NEWS 2006-03-21 12:48:51 UTC (rev 4075) @@ -11,7 +11,9 @@ * [gpgsm] Kludge to allow use of Bundesnetzagentur issued certificates. + * [scdaemon] Added --hash=xxx option to the PKSIGN command. + Noteworthy changes in version 1.9.20 (2005-12-20) ------------------------------------------------- Modified: branches/GNUPG-1-9-BRANCH/TODO =================================================================== --- branches/GNUPG-1-9-BRANCH/TODO 2006-03-21 09:56:47 UTC (rev 4074) +++ branches/GNUPG-1-9-BRANCH/TODO 2006-03-21 12:48:51 UTC (rev 4075) @@ -3,6 +3,7 @@ * src/base64 ** Make parsing more robust Currently we don't cope with overlong lines in the best way. +** Check that we really release the ksba reader/writer objects. * sm/call-agent.c ** The protocol uses an incomplete S-expression Modified: branches/GNUPG-1-9-BRANCH/doc/scdaemon.texi =================================================================== --- branches/GNUPG-1-9-BRANCH/doc/scdaemon.texi 2006-03-21 09:56:47 UTC (rev 4074) +++ branches/GNUPG-1-9-BRANCH/doc/scdaemon.texi 2006-03-21 12:48:51 UTC (rev 4075) @@ -444,9 +444,16 @@ @end example where @var{keyid} is the hexified ID of the key to be used. The key id -may have been retrieved using the command @code{LEARN}. +may have been retrieved using the command @code{LEARN}. If another +hash algorithm than SHA-1 is used, that algorithm may be given like: +@example + PKSIGN --hash=@var{algoname} @var{keyid} +@end example +With @var{algoname} are one of @code{sha1}, @code{rmd160} or @code{md5}. + + @node Scdaemon PKDECRYPT @subsection Decrypting data with a Smartcard Modified: branches/GNUPG-1-9-BRANCH/scd/ChangeLog =================================================================== --- branches/GNUPG-1-9-BRANCH/scd/ChangeLog 2006-03-21 09:56:47 UTC (rev 4074) +++ branches/GNUPG-1-9-BRANCH/scd/ChangeLog 2006-03-21 12:48:51 UTC (rev 4075) @@ -1,3 +1,7 @@ +2006-03-21 Werner Koch + + * command.c (cmd_pksign): Add --hash option. + 2006-03-01 Werner Koch * command.c (status_file_update_lock): New. Modified: branches/GNUPG-1-9-BRANCH/scd/command.c =================================================================== --- branches/GNUPG-1-9-BRANCH/scd/command.c 2006-03-21 09:56:47 UTC (rev 4074) +++ branches/GNUPG-1-9-BRANCH/scd/command.c 2006-03-21 12:48:51 UTC (rev 4075) @@ -708,8 +708,10 @@ } -/* PKSIGN +/* PKSIGN [--hash=[rmd160|sha1|md5]] + The --hash option is optional; the default is SHA1. + */ static int cmd_pksign (assuan_context_t ctx, char *line) @@ -719,7 +721,27 @@ unsigned char *outdata; size_t outdatalen; char *keyidstr; + int hash_algo; + if (has_option (line, "--hash=rmd160")) + hash_algo = GCRY_MD_RMD160; + else if (has_option (line, "--hash=sha1")) + hash_algo = GCRY_MD_SHA1; + else if (has_option (line, "--hash=md5")) + hash_algo = GCRY_MD_MD5; + else if (!strstr (line, "--")) + hash_algo = GCRY_MD_SHA1; + else + return set_error (Parameter_Error, "invalid hash algorithm"); + /* Skip over options. */ + while ( *line == '-' && line[1] == '-' ) + { + while (*line && !spacep (line)) + line++; + while (spacep (line)) + line++; + } + if ( IS_LOCKED (ctrl) ) return gpg_error (GPG_ERR_LOCKED); @@ -734,7 +756,7 @@ return ASSUAN_Out_Of_Core; rc = app_sign (ctrl->app_ctx, - keyidstr, GCRY_MD_SHA1, + keyidstr, hash_algo, pin_cb, ctx, ctrl->in_data.value, ctrl->in_data.valuelen, &outdata, &outdatalen); @@ -777,7 +799,7 @@ if (!ctrl->app_ctx) return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION); - /* We have to use a copy of the key ID because the function may use + /* We have to use a copy of the key ID because the function may use the pin_cb which in turn uses the assuan line buffer and thus overwriting the original line with the keyid */ keyidstr = xtrystrdup (line); From cvs at cvs.gnupg.org Tue Mar 21 14:01:47 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Mar 21 13:34:39 2006 Subject: [svn] GnuPG - r4076 - trunk/g10 Message-ID: Author: wk Date: 2006-03-21 14:01:45 +0100 (Tue, 21 Mar 2006) New Revision: 4076 Modified: trunk/g10/ChangeLog trunk/g10/card-util.c trunk/g10/cardglue.c Log: Allow for rmd160 signatures when using gpg-agent. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-21 12:48:51 UTC (rev 4075) +++ trunk/g10/ChangeLog 2006-03-21 13:01:45 UTC (rev 4076) @@ -1,3 +1,8 @@ +2006-03-21 Werner Koch + + * cardglue.c (agent_scd_pksign): Allow the use of ripemd-160 along + with scdaemon. + 2006-03-16 David Shaw * keyserver.c (keyserver_import_cert): Handle the IPGP CERT type @@ -36,6 +41,10 @@ keys originally generated with older GnuPGs that included comments in the secret keys. +2006-03-10 Werner Koch + + * card-util.c (get_manufacturer): Added Vendor 3 + 2006-03-09 David Shaw * build-packet.c (string_to_notation): Add ability to indicate a Modified: trunk/g10/card-util.c =================================================================== --- trunk/g10/card-util.c 2006-03-21 12:48:51 UTC (rev 4075) +++ trunk/g10/card-util.c 2006-03-21 13:01:45 UTC (rev 4076) @@ -158,6 +158,7 @@ case 0xffff: return "test card"; case 0x0001: return "PPC Card Systems"; case 0x0002: return "Prism"; + case 0x0003: return "OpenFortress"; default: return "unknown"; } } Modified: trunk/g10/cardglue.c =================================================================== --- trunk/g10/cardglue.c 2006-03-21 12:48:51 UTC (rev 4075) +++ trunk/g10/cardglue.c 2006-03-21 13:01:45 UTC (rev 4076) @@ -1225,7 +1225,9 @@ if (!rc) { init_membuf (&data, 1024); - snprintf (line, DIM(line)-1, "SCD PKSIGN %s", serialno); + snprintf (line, DIM(line)-1, "SCD PKSIGN %s%s", + hashalgo == GCRY_MD_RMD160? "--hash=rmd160 ": "", + serialno); line[DIM(line)-1] = 0; rc = test_transact (assuan_transact (app->assuan_ctx, line, membuf_data_cb, &data, From cvs at cvs.gnupg.org Tue Mar 21 16:57:47 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Mar 21 16:30:39 2006 Subject: [svn] GPGol - r142 - trunk Message-ID: Author: wk Date: 2006-03-21 16:57:47 +0100 (Tue, 21 Mar 2006) New Revision: 142 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac Log: Preparing 0.9.7 Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-20 13:13:56 UTC (rev 141) +++ trunk/ChangeLog 2006-03-21 15:57:47 UTC (rev 142) @@ -1,3 +1,7 @@ +2006-03-21 Werner Koch + + Released 0.9.7. + 2006-01-26 Werner Koch Released 0.9.6. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-20 13:13:56 UTC (rev 141) +++ trunk/NEWS 2006-03-21 15:57:47 UTC (rev 142) @@ -1,8 +1,8 @@ -Noteworthy changes for version 0.9.7 +Noteworthy changes for version 0.9.7 (2006-03-21) ================================================= +* Minor changes - Noteworthy changes for version 0.9.6 (2006-01-26) ================================================= Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-20 13:13:56 UTC (rev 141) +++ trunk/configure.ac 2006-03-21 15:57:47 UTC (rev 142) @@ -1,5 +1,5 @@ # configure.ac - for GPGol -# Copyright (C) 2005 g10 Code GmbH +# Copyright (C) 2005, 2006 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without @@ -16,7 +16,7 @@ # Version number: Remember to change it immediately *after* a release. # Make sure to run "svn up" before a "make dist". # Add a "-cvs" prefix for non-released code. -AC_INIT(gpgol, 0.9.7-cvs, bug-gpgol@g10code.com) +AC_INIT(gpgol, 0.9.7, bug-gpgol@g10code.com) NEED_GPGME_API=1 NEED_GPGME_VERSION=1.1.0 From cvs at cvs.gnupg.org Wed Mar 22 15:37:54 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed Mar 22 15:10:40 2006 Subject: [svn] GnuPG - r4077 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-22 15:37:53 +0100 (Wed, 22 Mar 2006) New Revision: 4077 Modified: trunk/g10/ChangeLog trunk/g10/mainproc.c Log: * mainproc.c (get_pka_address): Fix bug introduced as part of sig_to_notation conversion. Noted by Peter Palfradrer. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-21 13:01:45 UTC (rev 4076) +++ trunk/g10/ChangeLog 2006-03-22 14:37:53 UTC (rev 4077) @@ -1,3 +1,8 @@ +2006-03-22 David Shaw + + * mainproc.c (get_pka_address): Fix bug introduced as part of + sig_to_notation conversion. Noted by Peter Palfradrer. + 2006-03-21 Werner Koch * cardglue.c (agent_scd_pksign): Allow the use of ripemd-160 along Modified: trunk/g10/mainproc.c =================================================================== --- trunk/g10/mainproc.c 2006-03-21 13:01:45 UTC (rev 4076) +++ trunk/g10/mainproc.c 2006-03-22 14:37:53 UTC (rev 4077) @@ -1347,7 +1347,7 @@ /* For now we only use the first valid PKA notation. In future we might want to keep additional PKA notations in a linked list. */ - if (is_valid_mailbox (pka->email)) + if (is_valid_mailbox (nd->value)) { pka = xmalloc (sizeof *pka + strlen(nd->value)); pka->valid = 0; From cvs at cvs.gnupg.org Wed Mar 22 17:44:00 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed Mar 22 17:16:52 2006 Subject: [svn] GnuPG - r4078 - trunk/g10 Message-ID: Author: wk Date: 2006-03-22 17:43:59 +0100 (Wed, 22 Mar 2006) New Revision: 4078 Modified: trunk/g10/ChangeLog trunk/g10/misc.c trunk/g10/sig-check.c Log: Changed URLs Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-22 14:37:53 UTC (rev 4077) +++ trunk/g10/ChangeLog 2006-03-22 16:43:59 UTC (rev 4078) @@ -1,3 +1,8 @@ +2006-03-22 Werner Koch + + * sig-check.c (signature_check2): Changed warning URL to include faq. + * misc.c (idea_cipher_warn): Ditto. + 2006-03-22 David Shaw * mainproc.c (get_pka_address): Fix bug introduced as part of Modified: trunk/g10/misc.c =================================================================== --- trunk/g10/misc.c 2006-03-22 14:37:53 UTC (rev 4077) +++ trunk/g10/misc.c 2006-03-22 16:43:59 UTC (rev 4078) @@ -445,8 +445,8 @@ if(!warned || show) { log_info(_("the IDEA cipher plugin is not present\n")); - log_info(_("please see http://www.gnupg.org/why-not-idea.html " - "for more information\n")); + log_info(_("please see %s for more information\n"), + "http://www.gnupg.org/faq/why-not-idea.html"); warned=1; } } Modified: trunk/g10/sig-check.c =================================================================== --- trunk/g10/sig-check.c 2006-03-22 14:37:53 UTC (rev 4077) +++ trunk/g10/sig-check.c 2006-03-22 16:43:59 UTC (rev 4078) @@ -101,7 +101,7 @@ log_info(_("WARNING: signing subkey %s is not" " cross-certified\n"),keystr_from_pk(pk)); log_info(_("please see %s for more information\n"), - "http://www.gnupg.org/subkey-cross-certify.html"); + "http://www.gnupg.org/faq/subkey-cross-certify.html"); /* --require-cross-certification makes this warning an error. TODO: change the default to require this after more keys have backsigs. */ From cvs at cvs.gnupg.org Thu Mar 23 00:05:34 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed Mar 22 23:38:19 2006 Subject: [svn] GnuPG - r4079 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-23 00:05:32 +0100 (Thu, 23 Mar 2006) New Revision: 4079 Modified: trunk/g10/ChangeLog trunk/g10/getkey.c Log: * getkey.c (parse_auto_key_locate): Silently strip out duplicates rather than causing an error. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-22 16:43:59 UTC (rev 4078) +++ trunk/g10/ChangeLog 2006-03-22 23:05:32 UTC (rev 4079) @@ -1,3 +1,8 @@ +2006-03-22 David Shaw + + * getkey.c (parse_auto_key_locate): Silently strip out duplicates + rather than causing an error. + 2006-03-22 Werner Koch * sig-check.c (signature_check2): Changed warning URL to include faq. Modified: trunk/g10/getkey.c =================================================================== --- trunk/g10/getkey.c 2006-03-22 16:43:59 UTC (rev 4078) +++ trunk/g10/getkey.c 2006-03-22 23:05:32 UTC (rev 4079) @@ -2934,6 +2934,7 @@ while((tok=optsep(&options))) { struct akl *akl,*last; + int dupe=0; if(tok[0]=='\0') continue; @@ -2969,15 +2970,19 @@ || (akl->type==AKL_SPEC && strcmp(last->spec->uri,akl->spec->uri)==0))) { + dupe=1; free_akl(akl); - return 0; + break; } } - if(last) - last->next=akl; - else - opt.auto_key_locate=akl; + if(!dupe) + { + if(last) + last->next=akl; + else + opt.auto_key_locate=akl; + } } return 1; From cvs at cvs.gnupg.org Sat Mar 25 04:05:31 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Sat Mar 25 03:38:03 2006 Subject: [svn] GnuPG - r4080 - trunk Message-ID: Author: dshaw Date: 2006-03-25 04:05:30 +0100 (Sat, 25 Mar 2006) New Revision: 4080 Modified: trunk/ChangeLog trunk/README Log: * README: Missing some instructions on building a fat binary. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-22 23:05:32 UTC (rev 4079) +++ trunk/ChangeLog 2006-03-25 03:05:30 UTC (rev 4080) @@ -1,3 +1,7 @@ +2006-03-24 David Shaw + + * README: Missing some instructions on building a fat binary. + 2006-03-20 David Shaw * configure.ac: Improved --disable-endian-check that doesn't Modified: trunk/README =================================================================== --- trunk/README 2006-03-22 23:05:32 UTC (rev 4079) +++ trunk/README 2006-03-25 03:05:30 UTC (rev 4080) @@ -742,7 +742,7 @@ You can build a universal ("fat") binary that will work on both PPC and Intel Macs with something like: - ./configure CFLAGS="-arch ppc -arch i386" \ + ./configure CFLAGS="-arch ppc -arch i386" --disable-endian-check \ --disable-dependency-tracking --disable-asm If you are doing the build on a OS X 10.4 (Tiger) PPC machine you From cvs at cvs.gnupg.org Mon Mar 27 21:06:47 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Mon Mar 27 20:39:03 2006 Subject: [svn] GnuPG - r4081 - trunk/keyserver Message-ID: Author: dshaw Date: 2006-03-27 21:06:46 +0200 (Mon, 27 Mar 2006) New Revision: 4081 Modified: trunk/keyserver/ChangeLog trunk/keyserver/gpgkeys_ldap.c Log: * gpgkeys_ldap.c: #define LDAP_DEPRECATED for newer OpenLDAPs so they use the regular old API that is compatible with other LDAP libraries. Modified: trunk/keyserver/ChangeLog =================================================================== --- trunk/keyserver/ChangeLog 2006-03-25 03:05:30 UTC (rev 4080) +++ trunk/keyserver/ChangeLog 2006-03-27 19:06:46 UTC (rev 4081) @@ -1,3 +1,9 @@ +2006-03-27 David Shaw + + * gpgkeys_ldap.c: #define LDAP_DEPRECATED for newer OpenLDAPs so + they use the regular old API that is compatible with other LDAP + libraries. + 2006-03-03 David Shaw * gpgkeys_ldap.c (main): Fix build problem with non-OpenLDAP LDAP Modified: trunk/keyserver/gpgkeys_ldap.c =================================================================== --- trunk/keyserver/gpgkeys_ldap.c 2006-03-25 03:05:30 UTC (rev 4080) +++ trunk/keyserver/gpgkeys_ldap.c 2006-03-27 19:06:46 UTC (rev 4081) @@ -37,6 +37,8 @@ #ifdef NEED_LBER_H #include #endif +/* For OpenLDAP, to enable the API that we're using. */ +#define LDAP_DEPRECATED 1 #include #endif From cvs at cvs.gnupg.org Mon Mar 27 21:31:09 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Mar 27 21:03:27 2006 Subject: [svn] GPGol - r143 - in trunk: . po src Message-ID: Author: wk Date: 2006-03-27 21:31:08 +0200 (Mon, 27 Mar 2006) New Revision: 143 Modified: trunk/NEWS trunk/configure.ac trunk/po/de.po trunk/src/ChangeLog trunk/src/engine-gpgme.c trunk/src/engine.h trunk/src/gpgmsg.cpp trunk/src/intern.h trunk/src/main.c trunk/src/olflange.cpp trunk/src/pgpmime.c trunk/src/pgpmime.h trunk/src/rfc822parse.c trunk/src/rfc822parse.h Log: Support verification of (some) PGP/MIME messages. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/NEWS 2006-03-27 19:31:08 UTC (rev 143) @@ -1,3 +1,9 @@ +Noteworthy changes for version 0.9.8 +================================================= + +* PGP/MIME signature verification may now work in some cases. + + Noteworthy changes for version 0.9.7 (2006-03-21) ================================================= Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/configure.ac 2006-03-27 19:31:08 UTC (rev 143) @@ -16,7 +16,7 @@ # Version number: Remember to change it immediately *after* a release. # Make sure to run "svn up" before a "make dist". # Add a "-cvs" prefix for non-released code. -AC_INIT(gpgol, 0.9.7, bug-gpgol@g10code.com) +AC_INIT(gpgol, 0.9.8-cvs, bug-gpgol@g10code.com) NEED_GPGME_API=1 NEED_GPGME_VERSION=1.1.0 Modified: trunk/po/de.po =================================================================== --- trunk/po/de.po 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/po/de.po 2006-03-27 19:31:08 UTC (rev 143) @@ -7,74 +7,78 @@ msgstr "" "Project-Id-Version: GPGol 0.9.4\n" "Report-Msgid-Bugs-To: bug-gpgol@g10code.com\n" -"POT-Creation-Date: 2006-01-16 12:15+0100\n" -"PO-Revision-Date: 2006-01-16 12:16+0100\n" +"POT-Creation-Date: 2006-03-27 20:56+0200\n" +"PO-Revision-Date: 2006-03-27 21:01+0200\n" "Last-Translator: Werner Koch \n" "Language-Team: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -#: src/config-dialog.c:289 +#: src/common.c:101 +msgid "GPG - Save decrypted attachment" +msgstr "GPG - Sichern der entschl?sselten Anlage" + +#: src/config-dialog.c:290 msgid "Select GPG Key Manager" msgstr "Das Schl?sselverwaltungsprogramm festlegen" -#: src/engine-gpgme.c:942 +#: src/engine-gpgme.c:978 msgid "Fingerprint: " msgstr "Fingerabdruck: " -#: src/engine-gpgme.c:999 +#: src/engine-gpgme.c:1035 msgid "This signature is valid\n" msgstr "Diese Unterschrift ist korrekt\n" -#: src/engine-gpgme.c:1001 +#: src/engine-gpgme.c:1037 msgid "signature state is \"green\"\n" msgstr "Status der Unterschrift ist \"gr?n\"\n" -#: src/engine-gpgme.c:1003 +#: src/engine-gpgme.c:1039 msgid "signature state is \"red\"\n" msgstr "Status der Unterschrift ist \"rot\"\n" -#: src/engine-gpgme.c:1007 +#: src/engine-gpgme.c:1043 msgid "Warning: One of the keys has been revoked\n" msgstr "Warnung: Einer der Schl?ssel wurde widerrufen\n" -#: src/engine-gpgme.c:1017 +#: src/engine-gpgme.c:1053 msgid "Warning: The key used to create the signature expired at: " msgstr "" "Warnung: Der Schl?ssel mit der diese Unterschrift erzeugt wurde verfiel am: " -#: src/engine-gpgme.c:1023 +#: src/engine-gpgme.c:1059 msgid "Warning: At least one certification key has expired\n" msgstr "" "Warnung: Mindestens einer der Zertifizierungsschl?ssel ist abgelaufen\n" -#: src/engine-gpgme.c:1029 +#: src/engine-gpgme.c:1065 msgid "Warning: The signature expired at: " msgstr "Die Unterschrift verfiel am: " -#: src/engine-gpgme.c:1035 +#: src/engine-gpgme.c:1071 msgid "Can't verify due to a missing key or certificate\n" msgstr "" "Aufrund eines fehlenden Schl?ssels ist eine ?berpr?fung nicht m?glich\n" -#: src/engine-gpgme.c:1039 +#: src/engine-gpgme.c:1075 msgid "The CRL is not available\n" msgstr "Die CRL ist nicht verf?gbar\n" -#: src/engine-gpgme.c:1045 +#: src/engine-gpgme.c:1081 msgid "Available CRL is too old\n" msgstr "Die vorhandene CRL ist zu alt\n" -#: src/engine-gpgme.c:1050 +#: src/engine-gpgme.c:1086 msgid "A policy requirement was not met\n" msgstr "Eine Richtlinie wurde nicht erf?llt\n" -#: src/engine-gpgme.c:1056 +#: src/engine-gpgme.c:1092 msgid "A system error occured" msgstr "Ein Systemfehler ist aufgetreten" -#: src/engine-gpgme.c:1093 +#: src/engine-gpgme.c:1129 msgid "" "WARNING: We have NO indication whether the key belongs to the person named " "as shown above\n" @@ -82,12 +86,12 @@ "WARNUNG: Es gibt keinen Hinweis darauf, ob der Schl?ssel wirklich der Person " "geh?rt, die oben angezeigt ist\n" -#: src/engine-gpgme.c:1100 +#: src/engine-gpgme.c:1136 msgid "WARNING: The key does NOT BELONG to the person named as shown above\n" msgstr "" "WARNUNG: Der Schl?ssel geh?rt NICHT der Person die oben angezeigt ist\n" -#: src/engine-gpgme.c:1104 +#: src/engine-gpgme.c:1140 msgid "" "WARNING: It is NOT certain that the key belongs to the person named as shown " "above\n" @@ -95,72 +99,89 @@ "WARNING: Es ist nicht sicher, da? der Schl?ssel der Person geh?rt, die oben " "angezeigt ist\n" -#: src/engine-gpgme.c:1137 +#: src/engine-gpgme.c:1173 msgid "Verification started at: " msgstr "?berpr?fung begann am: " -#: src/engine-gpgme.c:1142 +#: src/engine-gpgme.c:1178 msgid "Verification result for: " msgstr "Pr?fungsresultat f?r: " -#: src/engine-gpgme.c:1143 +#: src/engine-gpgme.c:1179 msgid "[unnamed part]" msgstr "[Unbenannter Teil]" -#: src/engine-gpgme.c:1161 src/engine-gpgme.c:1191 +#: src/engine-gpgme.c:1197 src/engine-gpgme.c:1227 msgid "Good signature from: " msgstr "Korrekte Unterschrift von: " -#: src/engine-gpgme.c:1168 +#: src/engine-gpgme.c:1204 msgid " aka: " msgstr " alias: " -#: src/engine-gpgme.c:1172 src/engine-gpgme.c:1194 +#: src/engine-gpgme.c:1208 src/engine-gpgme.c:1230 msgid " created: " msgstr " erzeugt: " -#: src/engine-gpgme.c:1181 +#: src/engine-gpgme.c:1217 msgid "*BAD* signature claimed to be from: " msgstr "*FALSCHE* Unterschrift, vorgeblich von: " -#: src/engine-gpgme.c:1204 +#: src/engine-gpgme.c:1240 msgid "Error checking signature" -msgstr "Fehler beim Pr?fen der Unetrschrift" +msgstr "Fehler beim Pr?fen der Unterschrift" -#: src/engine-gpgme.c:1220 +#: src/engine-gpgme.c:1256 msgid "*** Begin Notation (signature by: " msgstr "*** Anfang Notation (Unterschrift von: " -#: src/engine-gpgme.c:1240 +#: src/engine-gpgme.c:1276 msgid "*** End Notation ***\n" msgstr "*** Ende Notation ***\n" -#: src/gpgmsg.cpp:1039 +#: src/gpgmsg.cpp:1186 msgid "No valid OpenPGP data found." msgstr "Keine g?ltigen OpenPGP Daten gefunden" -#: src/gpgmsg.cpp:1040 src/gpgmsg.cpp:1084 src/gpgmsg.cpp:1098 -#: src/gpgmsg.cpp:1114 src/gpgmsg.cpp:1279 +#: src/gpgmsg.cpp:1187 src/gpgmsg.cpp:1270 src/gpgmsg.cpp:1284 +#: src/gpgmsg.cpp:1300 src/gpgmsg.cpp:1466 msgid "Decryption" msgstr "Entschl?sselung" -#: src/gpgmsg.cpp:1075 +#: src/gpgmsg.cpp:1239 +msgid "" +"Note: This is a PGP/MIME signed message. The GPGol plugin is not always " +"able to verify such a message due to missing support in Outlook.\n" +"\n" +"(This message will be shown only once per session)" +msgstr "" +"Hinweis: Dies is eine PGP/MIME signierte Nachricht. Das GPGol Plugin\n" +"ist nicht immer in der Lage, eine solche Nachricht zu verifizieren.\n" +"Der Grund hierzu liegt in der fehlenden Unterst?tzung von Outlook.\n" +"\n" +"(Dieser Hinweis wird nur einmalif je Session angezeigt)" + +#: src/gpgmsg.cpp:1243 +msgid "Verification" +msgstr "?berpr?fung" + +#: src/gpgmsg.cpp:1261 msgid "[This is a PGP/MIME message]" msgstr "[PGP/MIME Nachricht]" -#: src/gpgmsg.cpp:1083 src/gpgmsg.cpp:1097 src/gpgmsg.cpp:1113 +#: src/gpgmsg.cpp:1269 src/gpgmsg.cpp:1283 src/gpgmsg.cpp:1299 msgid "Problem decrypting PGP/MIME message" msgstr "Problem bei Entschl?sseln einer PGP/MIME Nachricht" -#: src/gpgmsg.cpp:1234 +#: src/gpgmsg.cpp:1421 msgid "Verification Failure" msgstr "?berpr?fungsfehler" -#: src/gpgmsg.cpp:1237 +#: src/gpgmsg.cpp:1424 msgid "Decryption Failure" msgstr "Entschl?sselungsfehler" -#: src/gpgmsg.cpp:1273 +#: src/gpgmsg.cpp:1460 msgid "" "The message text cannot be displayed.\n" "You have to save the decrypted message to view it.\n" @@ -176,7 +197,7 @@ #. TRANSLATORS: Keep the @LIST@ verbatim on a separate line; it #. will be expanded to a list of atatchment names. -#: src/gpgmsg.cpp:1300 +#: src/gpgmsg.cpp:1487 msgid "" "Signed attachments found.\n" "\n" @@ -188,13 +209,13 @@ "@LIST@\n" "M?chten Sie diese Unterschriften ?berpr?fen?" -#: src/gpgmsg.cpp:1308 +#: src/gpgmsg.cpp:1495 msgid "Attachment Verification" msgstr "?berpr?fung der Anh?nge" #. TRANSLATORS: Keep the @LIST@ verbatim on a separate line; it #. will be expanded to a list of atatchment names. -#: src/gpgmsg.cpp:1329 +#: src/gpgmsg.cpp:1516 msgid "" "Encrypted attachments found.\n" "\n" @@ -206,31 +227,31 @@ "@LIST@\n" "M?chten Sie diese entschl?sseln und abspeichern?" -#: src/gpgmsg.cpp:1336 +#: src/gpgmsg.cpp:1523 msgid "Attachment Decryption" msgstr "Entschl?sselung eines Anhangs" -#: src/gpgmsg.cpp:1405 +#: src/gpgmsg.cpp:1592 msgid "Signing Failure" msgstr "Unterschrifterstellungsfehler" -#: src/gpgmsg.cpp:1581 +#: src/gpgmsg.cpp:1768 msgid "Encryption Failure" msgstr "Verschl?sselungsfehler" -#: src/gpgmsg.cpp:1635 src/gpgmsg.cpp:2930 +#: src/gpgmsg.cpp:1822 src/gpgmsg.cpp:3117 msgid "Attachment Encryption Failure" msgstr "Verschl?sselungsfehler eines Anhangs" -#: src/gpgmsg.cpp:2337 +#: src/gpgmsg.cpp:2524 msgid "Attachment Verification Failure" msgstr "?berpr?fungsfehler eines Anhangs" -#: src/gpgmsg.cpp:2520 src/gpgmsg.cpp:2569 +#: src/gpgmsg.cpp:2707 src/gpgmsg.cpp:2756 msgid "Attachment Decryption Failure" msgstr "Entschl?sselungsfehler eines Anhangs" -#: src/gpgmsg.cpp:2739 +#: src/gpgmsg.cpp:2926 msgid "Attachment Signing Failure" msgstr "Unterschrifterstellungsfehler eines Anhangs" @@ -238,7 +259,7 @@ msgid "The default key may not contain any spaces." msgstr "Der Standardschl?ssel darf keine Leerzeichen enthalten." -#: src/olflange.cpp:748 +#: src/olflange.cpp:750 msgid "" "This version of Outlook is too old!\n" "\n" @@ -255,7 +276,7 @@ "\n" "Bitte updaten Sie auf SP2 bevor Sie versuchen eine Nachricht zu versenden." -#: src/olflange.cpp:937 +#: src/olflange.cpp:939 msgid "" "Sorry, we can only encrypt plain text messages and\n" "no RTF messages. Please make sure that only the text\n" @@ -266,51 +287,51 @@ "Sie sicher, da? lediglich das Text Format ausgew?hlt wurde.\n" "(In der Men?leiste: \"Format\" => \"Nur Text\")" -#: src/olflange.cpp:1327 +#: src/olflange.cpp:1329 msgid "&Decrypt and verify message" msgstr "Entschl?sseln/Pr?fen der Nachricht" -#: src/olflange.cpp:1365 +#: src/olflange.cpp:1367 msgid "GPG &encrypt message" msgstr "Mit GPG &verschl?sseln" -#: src/olflange.cpp:1371 +#: src/olflange.cpp:1373 msgid "GPG &sign message" msgstr "Mit GPG unter&schreiben" -#: src/olflange.cpp:1417 +#: src/olflange.cpp:1419 msgid "GPG Key &Manager" msgstr "GPG Schl?ssel&verwaltung" -#: src/olflange.cpp:1549 +#: src/olflange.cpp:1551 msgid "Could not start Key-Manager" msgstr "Dei Schl?sselverwaltung konnte nicht aufgerufen werden" -#: src/olflange.cpp:1595 +#: src/olflange.cpp:1597 msgid "Decrypt and verify the message." msgstr "Entschl?sseln und Pr?fen der Nachricht." -#: src/olflange.cpp:1603 +#: src/olflange.cpp:1605 msgid "Select this option to encrypt the message." msgstr "W?hlen Sie diese Option zum Verschl?sseln der Nachricht." -#: src/olflange.cpp:1609 +#: src/olflange.cpp:1611 msgid "Select this option to sign the message." msgstr "W?hlen Sie diese Option zum Unterschreiben der Nachricht." -#: src/olflange.cpp:1618 src/olflange.cpp:1679 src/olflange.cpp:1761 +#: src/olflange.cpp:1620 src/olflange.cpp:1681 src/olflange.cpp:1763 msgid "Open GPG Key Manager" msgstr "Die GPG Schl?sselverwaltung ?ffnen" -#: src/olflange.cpp:1648 src/olflange.cpp:1712 +#: src/olflange.cpp:1650 src/olflange.cpp:1714 msgid "Decrypt message and verify signature" msgstr "Nachricht entschl?sseln und Unterschrift pr?fen" -#: src/olflange.cpp:1659 src/olflange.cpp:1730 +#: src/olflange.cpp:1661 src/olflange.cpp:1732 msgid "Encrypt message with GPG" msgstr "Nachricht mit GPG verschl?sseln" -#: src/olflange.cpp:1668 src/olflange.cpp:1745 +#: src/olflange.cpp:1670 src/olflange.cpp:1747 msgid "Sign message with GPG" msgstr "Nachricht mit GPG unterschreiben" @@ -318,11 +339,15 @@ msgid "No key hint given." msgstr "Kein Hinweis auf den Schl?ssel" -#: src/passphrase-dialog.c:322 src/passphrase-dialog.c:464 +#: src/passphrase-dialog.c:325 src/passphrase-dialog.c:469 msgid "Invalid passphrase; please try again..." msgstr "Ung?ltige Passphrase; bitte nochmal versuchen..." -#: src/passphrase-dialog.c:404 src/passphrase-dialog.c:523 +#: src/passphrase-dialog.c:342 +msgid "Select Signing Key" +msgstr "Signaturschl?ssel ausw?hlen" + +#: src/passphrase-dialog.c:409 src/passphrase-dialog.c:528 msgid "" "If you cancel this dialog, the message will be sent in cleartext!\n" "\n" @@ -333,7 +358,7 @@ "\n" "M?chten Sie wirklich abbrechen?" -#: src/passphrase-dialog.c:410 +#: src/passphrase-dialog.c:415 msgid "" "If you cancel this dialog, the message will be sent without signing.\n" "\n" @@ -344,11 +369,11 @@ "\n" "M?chten Sie wirklich abbrechen?" -#: src/passphrase-dialog.c:419 src/passphrase-dialog.c:538 +#: src/passphrase-dialog.c:424 src/passphrase-dialog.c:543 msgid "Secret Key Dialog" msgstr "Auswahl des geheimen Schl?ssels" -#: src/passphrase-dialog.c:529 +#: src/passphrase-dialog.c:534 msgid "" "If you cancel this dialog, the message will be sent without signing.\n" "Do you really want to cancel?" @@ -358,7 +383,7 @@ "\n" "M?chten Sie wirklich abbrechen?" -#: src/pgpmime.c:421 +#: src/pgpmime.c:485 msgid "" "Error creating file\n" "Please select another one" @@ -366,23 +391,39 @@ "Fehler bei der Erstellung der Datei.\n" "Bitte w?hlen Sie eine anderen Namen." -#: src/pgpmime.c:423 src/pgpmime.c:557 +#: src/pgpmime.c:487 src/pgpmime.c:638 msgid "I/O-Error" msgstr "Ein-/Ausgabefehler" -#: src/pgpmime.c:556 +#: src/pgpmime.c:637 msgid "Error writing file" msgstr "Dateischreibfehler" -#: src/pgpmime.c:613 +#: src/pgpmime.c:713 msgid "[PGP/MIME message]" msgstr "[PGP/MIME Nachricht]" -#: src/pgpmime.c:630 +#: src/pgpmime.c:730 msgid "[PGP/MIME message without plain text body]" msgstr "[PGP/MIME Nachricht ohne reinen Textk?rper]" -#: src/recipient-dialog.c:477 +#: src/pgpmime.c:802 +msgid "[PGP/MIME signed message without a plain text body]" +msgstr "[PGP/MIME signierte Nachricht ohne reinen Textk?rper]" + +#: src/pgpmime.c:812 +msgid "[PGP/MIME signature]" +msgstr "[PGP/MIME Signatur]" + +#: src/recipient-dialog.c:423 +msgid "Please select at least one recipient key." +msgstr "Bitte w?hlen Sie mindestens einen Empf?ngerschl?ssel." + +#: src/recipient-dialog.c:424 src/recipient-dialog.c:485 +msgid "Recipient Dialog" +msgstr "Auswahl des Empf?ngerschl?ssels" + +#: src/recipient-dialog.c:482 msgid "" "If you cancel this dialog, the message will be sent in cleartext.\n" "\n" @@ -393,60 +434,56 @@ "\n" "M?chten Sie wirklich abbrechen?" -#: src/recipient-dialog.c:480 -msgid "Recipient Dialog" -msgstr "Auswahl des Empf?ngerschl?ssels" - -#: src/recipient-dialog.c:555 src/verify-dialog.c:152 +#: src/recipient-dialog.c:560 src/verify-dialog.c:157 msgid "User-ID not found" msgstr "User-ID nicht gefunden" -#: src/verify-dialog.c:121 +#: src/verify-dialog.c:125 msgid "Good signature" msgstr "Korrekte Unterschrift" -#: src/verify-dialog.c:123 +#: src/verify-dialog.c:127 msgid "BAD signature!" msgstr "FALSCHE Unterschrift!" -#: src/verify-dialog.c:125 +#: src/verify-dialog.c:129 msgid "Good signature from revoked key" msgstr "Korrekte Unterschrift; aber Schl?ssel wurde widerrufen" -#: src/verify-dialog.c:127 +#: src/verify-dialog.c:131 msgid "Good signature from expired key" msgstr "Korrekte Unterschrift; allerdings ist der Schl?ssel abgelaufen" -#: src/verify-dialog.c:129 +#: src/verify-dialog.c:133 msgid "Good expired signature" msgstr "Korrekte aber abgelaufene Unterschrift" -#: src/verify-dialog.c:132 +#: src/verify-dialog.c:136 msgid "Could not check signature: missing key" msgstr "Unterschrift konnte nicht gepr?ft werden: Schl?ssel fehlt" -#: src/verify-dialog.c:136 +#: src/verify-dialog.c:140 msgid "Verification error" msgstr "?berpr?fungsfehler" -#: src/verify-dialog.c:164 +#: src/verify-dialog.c:169 msgid "This may be due to a wrong option setting" msgstr "M?glicherweise durch falsche Einstellungen verursacht" -#: src/verify-dialog.c:170 +#: src/verify-dialog.c:175 #, c-format msgid "Signature expired on %s" msgstr "Unterschrift abgelaufen am %s" -#: src/verify-dialog.c:182 +#: src/verify-dialog.c:187 msgid "Signature issued by a key we do NOT trust." msgstr "Die Unterschrift stammt von einem Schl?ssel dem wir NICHT vertrauen." -#: src/verify-dialog.c:189 +#: src/verify-dialog.c:194 msgid "Signature issued by a non-valid key." msgstr "Die Unterschrift stammt von einem ung?ltigen Schl?ssel." -#: src/verify-dialog.c:211 +#: src/verify-dialog.c:216 msgid "Verification Result" msgstr "Pr?fungsresultat" Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/src/ChangeLog 2006-03-27 19:31:08 UTC (rev 143) @@ -1,3 +1,21 @@ +2006-03-27 Werner Koch + + * engine-gpgme.c (op_verify_detached_sig_gpgme): New. + + * pgpmime.c (pgpmime_verify): New. First take on a PGP/MIME + signature verification. + + * gpgmsg.cpp (is_pgpmime): Renamed to is_pgpmime_enc. + (class GpgMsgImpl): Niew members media_type. media_subtype and + ct_protocol. + (get_msg_content_type): New. + (decrypt): Show a warning for PGP/MIME signed messages. + +2006-03-26 Werner Koch + + * intern.h: New option PREFER_HTML. + * main.c (write_options, read_options): Ditto. + 2006-03-20 Werner Koch * olflange.cpp (Install): Also check major part of build version. @@ -12,7 +30,7 @@ * recipient-dialog.c (recipient_dlg_proc): Likewise. * verify-dialog.c (load_akalist): Likewise. (load_sigbox): Likewise. - * common.c (utf_to_wincp): New. + * common.c (utf8_to_wincp): New. 2006-03-15 Werner Koch Modified: trunk/src/engine-gpgme.c =================================================================== --- trunk/src/engine-gpgme.c 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/src/engine-gpgme.c 2006-03-27 19:31:08 UTC (rev 143) @@ -1,5 +1,5 @@ /* engine-gpgme.c - Crypto engine with GPGME - * Copyright (C) 2005 g10 Code GmbH + * Copyright (C) 2005, 2006 g10 Code GmbH * * This file is part of GPGol. * @@ -917,6 +917,42 @@ } +/* Verify a detached message where the data is in the gpgme object + DATA and the signature is the gpgme object SIG. FILENAME will be + shown by the verification status dialog box. If ATTESTATION is not + NULL a text with the result of the signature verification will get + printed to it. */ +int +op_verify_detached_sig_gpgme (gpgme_data_t data, gpgme_data_t sig, + const char *filename, gpgme_data_t attestation) +{ + gpgme_ctx_t ctx = NULL; + gpgme_error_t err; + gpgme_verify_result_t res = NULL; + + op_init (); + + err = gpgme_new (&ctx); + if (err) + goto leave; + + err = gpgme_op_verify (ctx, sig, data, NULL); + if (!err) + { + res = gpgme_op_verify_result (ctx); + if (res) + verify_dialog_box (res, filename); + if (res && attestation) + add_verify_attestation (attestation, ctx, res, filename); + } + + leave: + if (ctx) + gpgme_release (ctx); + return err; +} + + static void at_puts (gpgme_data_t a, const char *s) @@ -1133,7 +1169,7 @@ if (!gpgme_data_seek (a, 0, SEEK_CUR)) { - /* Nothing yet written to the stream. Insert the curretn time. */ + /* Nothing yet written to the stream. Insert the current time. */ at_puts (a, _("Verification started at: ")); at_print_time (a, time (NULL)); at_puts (a, "\n\n"); Modified: trunk/src/engine.h =================================================================== --- trunk/src/engine.h 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/src/engine.h 2006-03-27 19:31:08 UTC (rev 143) @@ -75,6 +75,9 @@ int op_verify_detached_sig_mem (const char *data_string, const char *sig_string, const char *filename, gpgme_data_t attestation); +int op_verify_detached_sig_gpgme (gpgme_data_t data, gpgme_data_t sig, + const char *filename, + gpgme_data_t attestation); int op_export_keys (const char *pattern[], const char *outfile); Modified: trunk/src/gpgmsg.cpp =================================================================== --- trunk/src/gpgmsg.cpp 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/src/gpgmsg.cpp 2006-03-27 19:31:08 UTC (rev 143) @@ -1,5 +1,5 @@ /* gpgmsg.cpp - Implementation ofthe GpgMsg class - * Copyright (C) 2005 g10 Code GmbH + * Copyright (C) 2005, 2006 g10 Code GmbH * * This file is part of GPGol. * @@ -37,7 +37,9 @@ #include "pgpmime.h" #include "engine.h" #include "display.h" +#include "rfc822parse.h" + static const char oid_mimetag[] = {0x2A, 0x86, 0x48, 0x86, 0xf7, 0x14, 0x03, 0x0a, 0x04}; @@ -99,10 +101,16 @@ { message = NULL; exchange_cb = NULL; - is_pgpmime = false; + is_pgpmime_enc = false; has_attestation = false; preview = false; + got_message_ct = false; + media_type = NULL; + media_subtype = NULL; + ct_protocol = NULL; + transport_message_headers = NULL; + attestation = NULL; attach.att_table = NULL; @@ -111,6 +119,11 @@ ~GpgMsgImpl () { + xfree (media_type); + xfree (media_subtype); + xfree (ct_protocol); + xfree (transport_message_headers); + if (message) message->Release (); @@ -136,6 +149,7 @@ { message->Release (); message = NULL; + got_message_ct = false; } if (msg) { @@ -186,15 +200,21 @@ private: LPMESSAGE message; /* Pointer to the message. */ void *exchange_cb; /* Call back used with the display function. */ - bool is_pgpmime; /* True if the message is a PGP/MIME encrypted one. */ + bool is_pgpmime_enc;/* True if the message is a PGP/MIME encrypted one. */ bool has_attestation;/* True if we found an attestation attachment. */ bool preview; /* Don't pop up message boxes and run only a body decryption. */ /* If not NULL, collect attestation information here. */ gpgme_data_t attestation; - + /* Store information from the messages headers. */ + bool got_message_ct; /* Flag indicating whether we retrieved the info. */ + char *media_type; /* Media type from the content-type or NULL. */ + char *media_subtype; /* Media sybtype from the content-type or NULL. */ + char *ct_protocol; /* Protocol from the content_type or NULL. */ + char *transport_message_headers; /* Al the message headers as one string. */ + /* This structure collects the information about attachments. */ struct { @@ -204,6 +224,7 @@ void free_attach_info (void); char *loadBody (bool want_html); + void get_msg_content_type (void); bool isPgpmimeVersionPart (int pos); void writeAttestation (void); gpg_error_t createHtmlAttachment (const char *text); @@ -363,7 +384,7 @@ -/* Load the body from the MAP and return it as an UTF8 string. +/* Load the body from the MAPI and return it as an UTF8 string. Returns NULL on error. */ char * GpgMsgImpl::loadBody (bool want_html) @@ -561,6 +582,114 @@ #endif + +/* Helper for get_msg_content_type() */ +static int +get_msg_content_type_cb (void *dummy_arg, + rfc822parse_event_t event, rfc822parse_t msg) +{ + if (event == RFC822PARSE_T2BODY) + return 42; /* Hack to stop immediately the parsing. This is + required because the code would else prepare for + MIME handling and we don't want this to happen. In + general it would be better to do any parsing of the + headers here but we need to access instance + variables and it is more complex to do this in a + callback. */ + return 0; +} + + +/* Find Content-Type of the current message. The result will be put + into instance variables. */ +void +GpgMsgImpl::get_msg_content_type (void) +{ + HRESULT hr; + LPSPropValue propval = NULL; + rfc822parse_t msg; + const char *header_lines, *s; + rfc822parse_field_t ctx; + size_t length; + + if (got_message_ct) + return; + got_message_ct = 1; + + xfree (media_type); + media_type = NULL; + xfree (media_subtype); + media_subtype = NULL; + xfree (ct_protocol); + ct_protocol = NULL; + xfree (transport_message_headers); + transport_message_headers = NULL; + + hr = HrGetOneProp ((LPMAPIPROP)message, + PR_TRANSPORT_MESSAGE_HEADERS_A, &propval); + if (FAILED (hr)) + { + log_error ("%s:%s: error getting the headers lines: hr=%#lx", + SRCNAME, __func__, hr); + return; + } + if ( PROP_TYPE (propval->ulPropTag) != PT_STRING8 ) + { + /* As per rfc822, header lines must be plain ascii, so no need to + cope withy unicode etc. */ + log_error ("%s:%s: proptag=%#lx not supported\n", + SRCNAME, __func__, propval->ulPropTag); + MAPIFreeBuffer (propval); + return; + } + + header_lines = propval->Value.lpszA; + + /* Save the header lines in case we need them for signature + verification. */ + transport_message_headers = xstrdup (header_lines); + + /* Read the headers into an rfc822 object. */ + msg = rfc822parse_open (get_msg_content_type_cb, NULL); + if (!msg) + { + log_error ("%s:%s: rfc822parse_open failed\n", SRCNAME, __func__); + MAPIFreeBuffer (propval); + return; + } + + while ((s = strchr (header_lines, '\n'))) + { + length = (s - header_lines); + if (length && s[-1] == '\r') + length--; + rfc822parse_insert (msg, (const unsigned char*)header_lines, length); + header_lines = s+1; + } + + /* Parse the content-type field. */ + ctx = rfc822parse_parse_field (msg, "Content-Type", -1); + if (ctx) + { + const char *s1, *s2; + s1 = rfc822parse_query_media_type (ctx, &s2); + if (s1) + { + media_type = xstrdup (s1); + media_subtype = xstrdup (s2); + s = rfc822parse_query_parameter (ctx, "protocol", 0); + if (s) + ct_protocol = xstrdup (s); + } + rfc822parse_release_field (ctx); + } + + rfc822parse_close (msg); + MAPIFreeBuffer (propval); +} + + + /* Return the type of a message with the body text in TEXT. */ openpgp_t GpgMsgImpl::getMessageType (const char *text) @@ -949,6 +1078,7 @@ unsigned int n_attach = 0; unsigned int n_encrypted = 0; unsigned int n_signed = 0; + int is_pgpmime_sig = 0; int have_pgphtml_sig = 0; int have_pgphtml_enc = 0; unsigned int pgphtml_pos = 0; @@ -957,6 +1087,21 @@ int is_html = 0; char *body; + get_msg_content_type (); + log_debug ("%s:%s: parsed content-type: media=%s/%s protocol=%s\n", + SRCNAME, __func__, + media_type? media_type:"[none]", + media_subtype? media_subtype:"[none]", + ct_protocol? ct_protocol : "[none]"); + if (media_type && media_subtype && ct_protocol + && !strcmp (media_type, "multipart") + && !strcmp (media_subtype, "signed") + && !strcmp (ct_protocol, "application/pgp-signature")) + { + /* This is a PGP/MIME signature. */ + is_pgpmime_sig = 1; + } + /* Load the body text into BODY. Note that body may be NULL but in this case MTYPE will be OPENPGP_NONE. */ body = loadBody (false); @@ -966,9 +1111,10 @@ attachments. We check right now because we need to get into the decryption code even if the body is not encrypted but attachments are available. */ - table = gatherAttachmentInfo (); + table = is_pgpmime_sig? NULL : gatherAttachmentInfo (); if (table) { + /* Fixup for the special pgphtml attachment. */ for (pos=0; !table[pos].end_of_table; pos++) if (table[pos].is_encrypted) { @@ -1005,8 +1151,9 @@ log_debug ("%s:%s: message has %u attachments with " "%u signed and %d encrypted\n", SRCNAME, __func__, n_attach, n_signed, n_encrypted); + if (mtype == OPENPGP_NONE && !n_encrypted && !n_signed - && !have_pgphtml_enc && !have_pgphtml_sig) + && !have_pgphtml_enc && !have_pgphtml_sig && !is_pgpmime_sig) { /* Because we usually work around the OL object model, it can't notice that we changed the windows's text behind its back (by @@ -1060,8 +1207,47 @@ gpgme_data_new (&attestation); /* Process according to type of message. */ - if (is_pgpmime) + if (is_pgpmime_sig) { + static int warning_shown; + + /* We need to do duplicate some work: For retrieving the headers + we already used our own rfc822 parser. For actually + verifying the signature we need to concatentate the body with + these hesaders and passs it down to pgpmime.c where they will + be parsed again. Probably easier to maintain than merging the + MAPI access with our rc822 parser code. */ + const char *mybody = body? body: ""; + char *tmp; + + assert (transport_message_headers); + tmp = (char*)xmalloc (strlen (transport_message_headers) + + strlen (mybody)); + strcpy (stpcpy (tmp, transport_message_headers), mybody); + + /* Note, that we don't do an attestation. This is becuase we + don't run the code to check for duplicate attestations. */ + err = pgpmime_verify (tmp, + opt.passwd_ttl, &plaintext, NULL, + hwnd, preview); + xfree (tmp); + + if (err && !warning_shown) + { + warning_shown = 1; + MessageBox + (hwnd, _("Note: This is a PGP/MIME signed message. The GPGol " + "plugin is not always able to verify such a message " + "due to missing support in Outlook.\n\n" + "(This message will be shown only once per session)"), + _("Verification"), MB_ICONWARNING|MB_OK); + } + + if (!err) + pgpmime_succeeded = 1; + } + else if (is_pgpmime_enc) + { LPATTACH att; int method; LPSTREAM from; @@ -1225,9 +1411,10 @@ } else err = gpg_error (GPG_ERR_NO_DATA); + if (err) { - if (!is_pgpmime && n_attach && gpg_err_code (err) == GPG_ERR_NO_DATA) + if (!is_pgpmime_enc && n_attach && gpg_err_code (err) == GPG_ERR_NO_DATA) ; else if (mtype == OPENPGP_CLEARSIG) MessageBox (hwnd, op_strerror (err), @@ -2102,7 +2289,7 @@ unsigned int attestation_count = 0; unsigned int invalid_count = 0; - is_pgpmime = false; + is_pgpmime_enc = false; has_attestation = false; n_attach = getAttachments (); log_debug ("%s:%s: message has %u attachments\n", @@ -2251,7 +2438,7 @@ log_debug ("\tThis is a PGP/MIME encrypted message - table adjusted"); table[0].is_encrypted = 0; table[1].is_encrypted = 1; - is_pgpmime = true; + is_pgpmime_enc = true; } return table; Modified: trunk/src/intern.h =================================================================== --- trunk/src/intern.h 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/src/intern.h 2006-03-27 19:31:08 UTC (rev 143) @@ -100,6 +100,7 @@ char *default_key; /* The key we want to always encrypt to. */ int enable_default_key; /* Enable the use of DEFAULT_KEY. */ int preview_decrypt; /* Decrypt in preview window. */ + int prefer_html; /* Prefer html in html/text alternatives. */ /* The compatibility flags. */ struct Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/src/main.c 2006-03-27 19:31:08 UTC (rev 143) @@ -406,6 +406,10 @@ set_default_key (val); xfree (val); val = NULL; + load_extension_value ("preferHtml", &val); + opt.prefer_html = val == NULL || *val != '1'? 0 : 1; + xfree (val); val = NULL; + /* Note, that on purpose these flags are only Registry changeable. The format of the entry is a string of of "0" and "1" digits; see the switch below for a description. */ @@ -457,6 +461,7 @@ {"logFile", 2, 0, logfile}, {"defaultKey", 2, 0, opt.default_key}, {"enableDefaultKey", 0, opt.enable_default_key}, + {"preferHtml", 0, opt.prefer_html}, {NULL, 0} }; char buf[32]; Modified: trunk/src/olflange.cpp =================================================================== --- trunk/src/olflange.cpp 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/src/olflange.cpp 2006-03-27 19:31:08 UTC (rev 143) @@ -706,7 +706,7 @@ lFlags); /* Check version. */ - log_debug ("GPGol: this is %s\n", SRCNAME, __func__, PACKAGE_STRING); + log_debug ("GPGol: this is %s\n", PACKAGE_STRING); pEECB->GetVersion (&lBuildVersion, EECBGV_GETBUILDVERSION); pEECB->GetVersion (&lActualVersion, EECBGV_GETACTUALVERSION); pEECB->GetVersion (&lVirtualVersion, EECBGV_GETVIRTUALVERSION); Modified: trunk/src/pgpmime.c =================================================================== --- trunk/src/pgpmime.c 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/src/pgpmime.c 2006-03-27 19:31:08 UTC (rev 143) @@ -89,15 +89,28 @@ rfc822parse_t msg; /* The handle of the RFC822 parser. */ int preview; /* Do only decryption and pop up no message bozes. */ + + int verify_mode; /* True if we want to verify a PGP/MIME signature. */ int nesting_level; /* Current MIME nesting level. */ int in_data; /* We are currently in data (body or attachment). */ + gpgme_data_t signed_data;/* NULL or the data object used to collect + the signed data. It would bet better to + just hash it but there is no support in + gpgme for this yet. */ + gpgme_data_t sig_data; /* NULL or data object to collect the + signature attachment which should be a + signature then. */ gpgme_data_t body; /* NULL or a data object used to collect the body part we are going to display later. */ int collect_body; /* True if we are collecting the body lines. */ int collect_attachment; /* True if we are collecting an attachment. */ + int collect_signeddata; /* True if we are collecting the signed data. */ + int collect_signature; /* True if we are collecting a signature. */ + int start_hashing; /* Flag used to start collecting signed data. */ + int hashing_level; /* MIME level where we started hashing. */ int is_qp_encoded; /* Current part is QP encoded. */ int is_base64_encoded; /* Current part is base 64 encoded. */ int is_utf8; /* Current part has charset utf-8. */ @@ -292,10 +305,26 @@ HRESULT hr; debug_message_event (ctx, event); + + if (event == RFC822PARSE_BEGIN_HEADER || event == RFC822PARSE_T2BODY) + { + /* We need to check here whether to start collecting signed data + because attachments might come without header lines and thus + we won't see the BEGIN_HEADER event. */ + if (ctx->start_hashing == 1) + { + ctx->start_hashing = 2; + ctx->hashing_level = ctx->nesting_level; + ctx->collect_signeddata = 1; + gpgme_data_new (&ctx->signed_data); + } + } + + if (event == RFC822PARSE_T2BODY) { rfc822parse_field_t field; - const char *s1, *s2; + const char *s1, *s2, *s3; size_t off; char *p; int is_text = 0; @@ -318,12 +347,42 @@ For now encapsulated signed or encrypted containers are not processed in a special way as - they should. */ + they should. Except for the simple verify + mode. */ + if (ctx->verify_mode && !ctx->signed_data + && !strcmp (s2,"signed") + && (s3 = rfc822parse_query_parameter (field, + "protocol", 0)) + && !strcmp (s3, "application/pgp-signature")) + { + /* Need to start the hashing after the next + boundary. */ + ctx->start_hashing = 1; + } } else if (!strcmp (s1, "text")) { is_text = 1; } + else if (ctx->verify_mode + && ctx->nesting_level == 1 + && !ctx->sig_data + && !strcmp (s1, "application") + && !strcmp (s2, "pgp-signature")) + { + /* This is the second part of a PGP/MIME signature. + We only support here full messages thus checking + the nesting level is sufficient. We do this only + for the first signature (i.e. if sig_data has not + been set yet). We do this only while in verify + mode because we don't want to write a full MUA + (although this would be easier than to tame this + Outlook beast). */ + if (!ctx->preview && !gpgme_data_new (&ctx->sig_data)) + { + ctx->collect_signature = 1; + } + } else /* Other type. */ { if (!ctx->preview) @@ -345,6 +404,9 @@ } ctx->in_data = 1; + log_debug ("%s: this body: nesting=%d part_counter=%d is_text=%d\n", + SRCNAME, ctx->nesting_level, ctx->part_counter, is_text); + /* Need to figure out the encoding. */ ctx->is_qp_encoded = 0; ctx->is_base64_encoded = 0; @@ -382,9 +444,11 @@ ctx->collect_attachment = 1; } - /* Now that if we have an attachment prepare for writing it out. */ + if (ctx->collect_attachment) { + /* Now that if we have an attachment prepare for writing it + out. */ p = NULL; field = rfc822parse_parse_field (msg, "Content-Disposition", -1); if (field) @@ -457,6 +521,11 @@ IStream_Release (ctx->outstream); ctx->outstream = NULL; } + if (ctx->start_hashing == 2 && ctx->hashing_level == ctx->nesting_level) + { + ctx->start_hashing = 3; /* Avoid triggering it again. */ + ctx->collect_signeddata = 0; + } } else if (event == RFC822PARSE_BEGIN_HEADER) { @@ -502,10 +571,22 @@ return 0; /* Error. */ } + + if (ctx->collect_signeddata && ctx->signed_data) + { + /* Save the signed data. Note that we need to delay + the CR/LF because the last line ending belongs to the + next boundary. */ + if (ctx->collect_signeddata == 2) + gpgme_data_write (ctx->signed_data, "\r\n", 2); + gpgme_data_write (ctx->signed_data, ctx->linebuf, pos); + ctx->collect_signeddata = 2; + } + if (ctx->in_data && ctx->collect_body && ctx->body) { /* We are inside the body of the message. Save it away - to a gpgme data object. Note that this gets only + to a gpgme data object. Note that this is only used for the first text part. */ if (ctx->collect_body == 1) /* Need to skip the first line. */ ctx->collect_body = 2; @@ -560,6 +641,25 @@ } } } + else if (ctx->in_data && ctx->collect_signature) + { + /* We are inside of a signature attachment part. */ + if (ctx->collect_signature == 1) /* Skip the first line. */ + ctx->collect_signature = 2; + else if (ctx->sig_data) + { + if (ctx->is_qp_encoded) + len = qp_decode (ctx->linebuf, pos); + else if (ctx->is_base64_encoded) + len = base64_decode (ctx, ctx->linebuf, pos); + else + len = pos; + if (len) + gpgme_data_write (ctx->sig_data, ctx->linebuf, len); + if (!ctx->is_base64_encoded) + gpgme_data_write (ctx->sig_data, "\r\n", 2); + } + } /* Continue with next line. */ pos = 0; @@ -648,3 +748,89 @@ } return err; } + + + +int +pgpmime_verify (const char *message, int ttl, char **body, + gpgme_data_t attestation, HWND hwnd, int preview_mode) +{ + gpg_error_t err = 0; + pgpmime_context_t ctx; + const char *s; + + *body = NULL; + + ctx = xcalloc (1, sizeof *ctx + LINEBUFSIZE); + ctx->linebufsize = LINEBUFSIZE; + ctx->hwnd = hwnd; + ctx->preview = preview_mode; + ctx->verify_mode = 1; + + ctx->msg = rfc822parse_open (message_cb, ctx); + if (!ctx->msg) + { + err = gpg_error_from_errno (errno); + log_error ("failed to open the RFC822 parser: %s", strerror (errno)); + goto leave; + } + + /* Need to pass the data line by line to the handler. */ + for (;(s = strchr (message, '\n')); message = s+1) + { + plaintext_handler (ctx, message, (s - message) + 1); + if (ctx->parser_error || ctx->line_too_long) + { + err = gpg_error (GPG_ERR_GENERAL); + break; + } + } + + /* Unless there is an error we should return the body. */ + if (!err) + { + if (ctx->body) + { + /* Return the buffer but first make sure it is a string. */ + if (gpgme_data_write (ctx->body, "", 1) == 1) + { + *body = gpgme_data_release_and_get_mem (ctx->body, NULL); + ctx->body = NULL; + } + } + else + *body = xstrdup (_("[PGP/MIME signed message without a " + "plain text body]")); + } + + /* Now actually verify the signature. */ + if (!err && ctx->signed_data && ctx->sig_data) + { + gpgme_data_seek (ctx->signed_data, 0, SEEK_SET); + gpgme_data_seek (ctx->sig_data, 0, SEEK_SET); + err = op_verify_detached_sig_gpgme (ctx->signed_data, ctx->sig_data, + _("[PGP/MIME signature]"), + attestation); + } + + + leave: + if (ctx) + { + if (ctx->outstream) + { + IStream_Revert (ctx->outstream); + IStream_Release (ctx->outstream); + } + rfc822parse_close (ctx->msg); + if (ctx->body) + gpgme_data_release (ctx->body); + if (ctx->signed_data) + gpgme_data_release (ctx->signed_data); + if (ctx->sig_data) + gpgme_data_release (ctx->sig_data); + xfree (ctx->filename); + xfree (ctx); + } + return err; +} Modified: trunk/src/pgpmime.h =================================================================== --- trunk/src/pgpmime.h 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/src/pgpmime.h 2006-03-27 19:31:08 UTC (rev 143) @@ -31,9 +31,10 @@ int pgpmime_decrypt (LPSTREAM instream, int ttl, char **body, gpgme_data_t attestation, HWND hwnd, int preview_mode); +int pgpmime_verify (const char *message, int ttl, char **body, + gpgme_data_t attestation, HWND hwnd, int preview_mode); - #ifdef __cplusplus } #endif Modified: trunk/src/rfc822parse.c =================================================================== --- trunk/src/rfc822parse.c 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/src/rfc822parse.c 2006-03-27 19:31:08 UTC (rev 143) @@ -1005,9 +1005,9 @@ in RFC2045. Returns a pointer to the value which is valid as long as the parse context is valid; NULL is returned in case that attr is not - defined in the header, a missing value is reppresented by an empty string. + defined in the header, a missing value is represented by an empty string. - With LOWER_VALUE set to true, a matching field valuebe be + With LOWER_VALUE set to true, a matching field value will be lowercased. Note, that ATTR should be lowercase. Modified: trunk/src/rfc822parse.h =================================================================== --- trunk/src/rfc822parse.h 2006-03-21 15:57:47 UTC (rev 142) +++ trunk/src/rfc822parse.h 2006-03-27 19:31:08 UTC (rev 143) @@ -20,7 +20,14 @@ #ifndef RFC822PARSE_H #define RFC822PARSE_H +#ifdef __cplusplus +extern "C" { +#if 0 +} +#endif +#endif + struct rfc822parse_context; typedef struct rfc822parse_context *rfc822parse_t; @@ -78,4 +85,7 @@ const char *rfc822parse_query_media_type (rfc822parse_field_t ctx, const char **subtype); +#ifdef __cplusplus +} +#endif #endif /*RFC822PARSE_H */ From cvs at cvs.gnupg.org Tue Mar 28 12:06:51 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Mar 28 11:39:03 2006 Subject: [svn] GPGol - r144 - in trunk: . src Message-ID: Author: wk Date: 2006-03-28 12:06:51 +0200 (Tue, 28 Mar 2006) New Revision: 144 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac trunk/src/ChangeLog trunk/src/display.cpp trunk/src/gpgmsg.cpp trunk/src/olflange-dlgs.cpp trunk/src/olflange-ids.h trunk/src/olflange-rsrcs.rc Log: Preparing for 0.9.8 Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-27 19:31:08 UTC (rev 143) +++ trunk/ChangeLog 2006-03-28 10:06:51 UTC (rev 144) @@ -1,3 +1,7 @@ +2006-03-28 Werner Koch + + Released 0.9.8. + 2006-03-21 Werner Koch Released 0.9.7. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-03-27 19:31:08 UTC (rev 143) +++ trunk/NEWS 2006-03-28 10:06:51 UTC (rev 144) @@ -1,9 +1,11 @@ -Noteworthy changes for version 0.9.8 +Noteworthy changes for version 0.9.8 (2006-03-28) ================================================= * PGP/MIME signature verification may now work in some cases. +* New option to prefer displaying of the HTML part. + Noteworthy changes for version 0.9.7 (2006-03-21) ================================================= Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-03-27 19:31:08 UTC (rev 143) +++ trunk/configure.ac 2006-03-28 10:06:51 UTC (rev 144) @@ -16,7 +16,7 @@ # Version number: Remember to change it immediately *after* a release. # Make sure to run "svn up" before a "make dist". # Add a "-cvs" prefix for non-released code. -AC_INIT(gpgol, 0.9.8-cvs, bug-gpgol@g10code.com) +AC_INIT(gpgol, 0.9.8, bug-gpgol@g10code.com) NEED_GPGME_API=1 NEED_GPGME_VERSION=1.1.0 Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-03-27 19:31:08 UTC (rev 143) +++ trunk/src/ChangeLog 2006-03-28 10:06:51 UTC (rev 144) @@ -1,3 +1,11 @@ +2006-03-28 Werner Koch + + * olflange-rsrcs.rc (IDD_GPG_OPTIONS_DE): Add new control box. + (IDD_GPG_OPTIONS): Updated to match German version. + * olflange-dlgs.cpp (GPGOptionsDlgProc): Ditto. + * gpgmsg.cpp (decrypt): Implemented PREFER_HTML option. + (get_long_attach_data): New. + 2006-03-27 Werner Koch * engine-gpgme.c (op_verify_detached_sig_gpgme): New. Modified: trunk/src/display.cpp =================================================================== --- trunk/src/display.cpp 2006-03-27 19:31:08 UTC (rev 143) +++ trunk/src/display.cpp 2006-03-28 10:06:51 UTC (rev 144) @@ -161,7 +161,7 @@ } else if (exchange_cb && !opt.compat.no_oom_write) { - log_debug ("updating display using OOM to `%s'", text); + log_debug ("updating display using OOM\n"); /* Bug in OL 2002 and 2003 - as a workaround set the body first to empty. */ if (is_html) Modified: trunk/src/gpgmsg.cpp =================================================================== --- trunk/src/gpgmsg.cpp 2006-03-27 19:31:08 UTC (rev 143) +++ trunk/src/gpgmsg.cpp 2006-03-28 10:06:51 UTC (rev 144) @@ -87,6 +87,7 @@ static int get_attach_method (LPATTACH obj); static char *get_short_attach_data (LPATTACH obj); +static char *get_long_attach_data (LPMESSAGE msg, attach_info_t table,int pos); static bool set_x_header (LPMESSAGE msg, const char *name, const char *val); @@ -392,7 +393,6 @@ HRESULT hr; LPSPropValue lpspvFEID = NULL; LPSTREAM stream; -// SPropValue prop; STATSTG statInfo; ULONG nread; char *body = NULL; @@ -491,8 +491,8 @@ ready: if (body) - log_debug ("%s:%s: loaded body `%s' at %p\n", - SRCNAME, __func__, body, body); + log_debug ("%s:%s: loaded body %d bytes of body at %p\n", + SRCNAME, __func__, strlen (body), body); // prop.ulPropTag = PR_ACCESS; @@ -1082,6 +1082,7 @@ int have_pgphtml_sig = 0; int have_pgphtml_enc = 0; unsigned int pgphtml_pos = 0; + unsigned int pgphtml_pos_sig = 0; HRESULT hr; int pgpmime_succeeded = 0; int is_html = 0; @@ -1135,13 +1136,14 @@ { if (!have_pgphtml_sig && !have_pgphtml_enc && table[pos].filename - && !strcmp (table[pos].filename, "PGPexch.htm.asc") + && !strcmp (table[pos].filename, "PGPexch.htm") && table[pos].content_type - && !strcmp (table[pos].content_type, - "application/pgp-signature")) + && !strcmp (table[pos].content_type, "text/html") + && table[pos].sig_pos != pos) { have_pgphtml_sig = 1; pgphtml_pos = pos; + pgphtml_pos_sig = table[pos].sig_pos; } else n_signed++; @@ -1151,6 +1153,13 @@ log_debug ("%s:%s: message has %u attachments with " "%u signed and %d encrypted\n", SRCNAME, __func__, n_attach, n_signed, n_encrypted); + if (have_pgphtml_enc) + log_debug ("%s:%s: pgphtml encrypted attachment found at pos %d\n", + SRCNAME, __func__, pgphtml_pos); + if (have_pgphtml_sig) + log_debug ("%s:%s: pgphtml signature attachment found at pos %d\n", + SRCNAME, __func__, pgphtml_pos); + if (mtype == OPENPGP_NONE && !n_encrypted && !n_signed && !have_pgphtml_enc && !have_pgphtml_sig && !is_pgpmime_sig) @@ -1200,6 +1209,7 @@ { if (attestation) gpgme_data_release (attestation); + attestation = NULL; log_debug ("%s:%s: we already have an attestation\n", SRCNAME, __func__); } @@ -1313,39 +1323,51 @@ if (!err) pgpmime_succeeded = 1; } - else if (mtype == OPENPGP_CLEARSIG ) + else if (mtype == OPENPGP_CLEARSIG && !(have_pgphtml_sig && opt.prefer_html)) { + /* Cleartext signature. */ + assert (body); err = preview? 0 : op_verify (body, NULL, NULL, attestation); } - else if (body && *body) + else if ( (body && *body) + && !((have_pgphtml_enc||have_pgphtml_sig) && opt.prefer_html)) { + /* Standard encrypted body. We do not enter this if we also + have an pgphtml encrypted attachment and the prefer_html + option is activ. */ + err = op_decrypt (body, &plaintext, opt.passwd_ttl, NULL, attestation, preview); - if (!err && have_pgphtml_enc) - is_html = 1; } - else if (mtype == OPENPGP_NONE && have_pgphtml_sig) + else if ((mtype == OPENPGP_NONE || opt.prefer_html) && have_pgphtml_sig) { + /* There is no body but a pgphtml signed attachment - decrypt + that one. */ if (preview) err = 0; else { + /* Note that we don't access the HTML body. It seems that + Outlooks creates that one on the fly and it will break + the signature. It is better to use the attachment + directly. */ LPATTACH att; - char *htmlbody = loadBody (true); - if (htmlbody && *htmlbody) + plaintext = get_long_attach_data (message, table, pgphtml_pos); + + if (plaintext && *plaintext) { is_html = 1; - hr = message->OpenAttach (pgphtml_pos, NULL, + hr = message->OpenAttach (pgphtml_pos_sig, NULL, MAPI_BEST_ACCESS, &att); if (FAILED (hr)) { log_error ("%s:%s: can't open attachment %d (sig): hr=%#lx", - SRCNAME, __func__, pgphtml_pos, hr); + SRCNAME, __func__, pgphtml_pos_sig, hr); err = gpg_error (GPG_ERR_GENERAL); } - else if (table[pgphtml_pos].method != ATTACH_BY_VALUE) + else if (table[pgphtml_pos_sig].method != ATTACH_BY_VALUE) { log_error ("%s:%s: HTML attachment: method not supported", SRCNAME, __func__); @@ -1360,7 +1382,7 @@ err = gpg_error (GPG_ERR_GENERAL); else { - err = op_verify_detached_sig_mem (htmlbody, sigpart, + err = op_verify_detached_sig_mem (plaintext, sigpart, NULL, attestation); xfree (sigpart); } @@ -1368,11 +1390,12 @@ } else err = gpg_error (GPG_ERR_NO_DATA); - xfree (htmlbody); } } - else if (mtype == OPENPGP_NONE && have_pgphtml_enc) + else if ((mtype == OPENPGP_NONE || opt.prefer_html) && have_pgphtml_enc) { + /* There is no body but a pgphtml encrypted attachment - decrypt + that one. */ LPATTACH att; LPSTREAM from; @@ -2059,8 +2082,8 @@ switch ( PROP_TYPE (propval->ulPropTag) ) { case PT_BINARY: - /* This is a binary obnject but we know that it must be plain - ASCII due to the armoed format. */ + /* This is a binary object but we know that it must be plain + ASCII due to the armored format. */ data = (char*)xmalloc (propval->Value.bin.cb + 1); memcpy (data, propval->Value.bin.lpb, propval->Value.bin.cb); data[propval->Value.bin.cb] = 0; @@ -2077,6 +2100,77 @@ } +/* Get an statchment as one long C string. We assume that there are + no binary nuls in it. Returns NULL on failure. */ +static char * +get_long_attach_data (LPMESSAGE msg, attach_info_t table, int pos) +{ + HRESULT hr; + LPATTACH att; + LPSTREAM stream; + STATSTG statInfo; + ULONG nread; + char *buffer; + + hr = msg->OpenAttach (pos, NULL, MAPI_BEST_ACCESS, &att); + if (FAILED (hr)) + { + log_error ("%s:%s: can't open attachment %d: hr=%#lx", + SRCNAME, __func__, pos, hr); + return NULL; + } + if (table[pos].method != ATTACH_BY_VALUE) + { + log_error ("%s:%s: attachment: method not supported", SRCNAME, __func__); + att->Release (); + return NULL; + } + + hr = att->OpenProperty (PR_ATTACH_DATA_BIN, &IID_IStream, + 0, 0, (LPUNKNOWN*) &stream); + if (FAILED (hr)) + { + log_error ("%s:%s: can't open data stream of attachment: hr=%#lx", + SRCNAME, __func__, hr); + att->Release (); + return NULL; + } + + hr = stream->Stat (&statInfo, STATFLAG_NONAME); + if ( hr != S_OK ) + { + log_error ("%s:%s: Stat failed: hr=%#lx", SRCNAME, __func__, hr); + stream->Release (); + att->Release (); + return NULL; + } + + buffer = (char*)xmalloc ((size_t)statInfo.cbSize.QuadPart + 2); + hr = stream->Read (buffer, (size_t)statInfo.cbSize.QuadPart, &nread); + if ( hr != S_OK ) + { + log_error ("%s:%s: Read failed: hr=%#lx", SRCNAME, __func__, hr); + xfree (buffer); + stream->Release (); + att->Release (); + return NULL; + } + buffer[nread] = 0; + buffer[nread+1] = 0; + if (nread != statInfo.cbSize.QuadPart) + { + log_error ("%s:%s: not enough bytes returned\n", SRCNAME, __func__); + xfree (buffer); + buffer = NULL; + } + stream->Release (); + att->Release (); + + return buffer; +} + + + /* Check whether the attachment at position POS in the attachment table is the first part of a PGP/MIME message. This routine should only be called if it has already been checked that the content-type @@ -2378,7 +2472,7 @@ if (table[pos].invalid) continue; if (table[pos].filename && (s = strrchr (table[pos].filename, '.')) - && !stricmp (s, ".asc") + && !stricmp (s, ".asc") && table[pos].content_type && !stricmp (table[pos].content_type, "application/pgp-signature")) { Modified: trunk/src/olflange-dlgs.cpp =================================================================== --- trunk/src/olflange-dlgs.cpp 2006-03-27 19:31:08 UTC (rev 143) +++ trunk/src/olflange-dlgs.cpp 2006-03-28 10:06:51 UTC (rev 144) @@ -1,6 +1,6 @@ /* olflange-dlgs.cpp - New dialogs for Outlook. * Copyright (C) 2001 G Data Software AG, http://www.gdata.de - * Copyright (C) 2004, 2005 g10 Code GmbH + * Copyright (C) 2004, 2005, 2006 g10 Code GmbH * * This file is part of GPGol. * @@ -148,6 +148,8 @@ !!opt.auto_sign_attach, 0L); SendDlgItemMessage (hDlg, IDC_PREVIEW_DECRYPT, BM_SETCHECK, !!opt.preview_decrypt, 0L); + SendDlgItemMessage (hDlg, IDC_PREFER_HTML, BM_SETCHECK, + !!opt.prefer_html, 0L); bMsgResult = FALSE; /* accepts activation */ break; } @@ -185,6 +187,8 @@ (hDlg, IDC_SIGN_ATTACHMENTS, BM_GETCHECK, 0, 0L); opt.preview_decrypt = !!SendDlgItemMessage (hDlg, IDC_PREVIEW_DECRYPT, BM_GETCHECK, 0, 0L); + opt.prefer_html = !!SendDlgItemMessage + (hDlg, IDC_PREFER_HTML, BM_GETCHECK, 0, 0L); write_options (); bMsgResult = PSNRET_NOERROR; Modified: trunk/src/olflange-ids.h =================================================================== --- trunk/src/olflange-ids.h 2006-03-27 19:31:08 UTC (rev 143) +++ trunk/src/olflange-ids.h 2006-03-28 10:06:51 UTC (rev 144) @@ -26,5 +26,6 @@ #define IDC_SIGN_ATTACHMENTS 4011 #define IDD_GPG_OPTIONS_DE 4012 #define IDC_PREVIEW_DECRYPT 4013 +#define IDC_PREFER_HTML 4014 #endif /*OLFLANGE_IDS_H*/ Modified: trunk/src/olflange-rsrcs.rc =================================================================== --- trunk/src/olflange-rsrcs.rc 2006-03-27 19:31:08 UTC (rev 143) +++ trunk/src/olflange-rsrcs.rc 2006-03-28 10:06:51 UTC (rev 144) @@ -1,5 +1,5 @@ /* olflange-rsrcs.rc - Olflange specific resource. -*- c -*- - * Copyright (C) 2004, 2005 g10 Code GmbH + * Copyright (C) 2004, 2005, 2006 g10 Code GmbH * * This file is part of GPGol. * @@ -56,7 +56,7 @@ CAPTION "GnuPG" FONT 8, "MS Sans Serif" BEGIN - GROUPBOX "Optionen",IDC_STATIC,9,9,242,100 + GROUPBOX "Optionen",IDC_STATIC,9,9,242,112 CONTROL "Neue Nachrichten per Voreinstellung verschlüsseln", IDC_ENCRYPT_DEFAULT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,19,177,10 @@ -77,11 +77,15 @@ IDC_PREVIEW_DECRYPT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, 24,95,162,10 - GROUPBOX "Passphrase",IDC_STATIC,9,110,242,31 - LTEXT "Passphrase speichern für",IDC_STATIC,24,124,80,8 - EDITTEXT IDC_TIME_PHRASES,107,123,39,14,ES_AUTOHSCROLL - LTEXT "Sekunden",IDC_STATIC,151,125,34,8 + CONTROL "Wenn möglich, HTML Version anzeigen", + IDC_PREFER_HTML,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 24,107,162,10 + GROUPBOX "Passphrase",IDC_STATIC,9,124,242,31 + LTEXT "Passphrase speichern für",IDC_STATIC,24,136,80,8 + EDITTEXT IDC_TIME_PHRASES,107,135,39,14,ES_AUTOHSCROLL + LTEXT "Sekunden",IDC_STATIC,151,137,34,8 + PUSHBUTTON "&Erweitert...",IDC_GPG_OPTIONS,202,166,50,14 LTEXT "GPGol by g10 Code GmbH", IDC_STATIC,8,185,100,8 LTEXT "Version x ",IDC_VERSION_INFO,150,185,200,9 @@ -132,7 +136,7 @@ CAPTION "GnuPG" FONT 8, "MS Sans Serif" BEGIN - GROUPBOX "Options",IDC_STATIC,9,9,242,87 + GROUPBOX "Options",IDC_STATIC,9,9,242,112 CONTROL "&Encrypt new messages by default",IDC_ENCRYPT_DEFAULT, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,19,121,10 CONTROL "&Sign new messages by default",IDC_SIGN_DEFAULT,"Button", @@ -146,10 +150,22 @@ IDC_ENCRYPT_WITH_STANDARD_KEY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,67,148,10 EDITTEXT IDC_ENCRYPT_TO,36,79,133,12,ES_AUTOHSCROLL - GROUPBOX "Passphrase",IDC_STATIC,9,100,242,31 - LTEXT "Cache &passphrase for",IDC_STATIC,24,114,70,8 - EDITTEXT IDC_TIME_PHRASES,107,113,39,14,ES_AUTOHSCROLL - LTEXT "seconds",IDC_STATIC,151,115,28,8 + + CONTROL "Also decrypt in preview window", + IDC_PREVIEW_DECRYPT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 24,95,162,10 + + CONTROL "Show HTML Version is possible", + IDC_PREFER_HTML,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 24,107,162,10 + + + GROUPBOX "Passphrase",IDC_STATIC,9,124,242,31 + LTEXT "Cache &passphrase for",IDC_STATIC,24,136,70,8 + EDITTEXT IDC_TIME_PHRASES,107,135,39,14,ES_AUTOHSCROLL + LTEXT "seconds",IDC_STATIC,151,137,28,8 + + PUSHBUTTON "Ad&vanced..",IDC_GPG_OPTIONS,202,166,50,14 LTEXT "GPGol by g10 Code GmbH", IDC_STATIC,8,185,100,8 LTEXT "Version x ",IDC_VERSION_INFO,150,185,200,9 From cvs at cvs.gnupg.org Tue Mar 28 12:16:11 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Mar 28 11:48:22 2006 Subject: [svn] GPGol - r145 - tags Message-ID: Author: wk Date: 2006-03-28 12:16:11 +0200 (Tue, 28 Mar 2006) New Revision: 145 Added: tags/gpgol-0.9.8/ Log: Release Copied: tags/gpgol-0.9.8 (from rev 144, trunk) From cvs at cvs.gnupg.org Thu Mar 30 16:13:36 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Mar 30 15:45:37 2006 Subject: [svn] GnuPG - r4082 - trunk/util Message-ID: Author: dshaw Date: 2006-03-30 16:13:35 +0200 (Thu, 30 Mar 2006) New Revision: 4082 Modified: trunk/util/ChangeLog trunk/util/cert.c Log: * cert.c (main): Fix test program build warning on OSX. Modified: trunk/util/ChangeLog =================================================================== --- trunk/util/ChangeLog 2006-03-27 19:06:46 UTC (rev 4081) +++ trunk/util/ChangeLog 2006-03-30 14:13:35 UTC (rev 4082) @@ -1,3 +1,7 @@ +2006-03-30 David Shaw + + * cert.c (main): Fix test program build warning on OSX. + 2006-03-16 David Shaw * cert.c (get_cert): Handle the fixed IPGP type with fingerprint. Modified: trunk/util/cert.c =================================================================== --- trunk/util/cert.c 2006-03-27 19:06:46 UTC (rev 4081) +++ trunk/util/cert.c 2006-03-30 14:13:35 UTC (rev 4082) @@ -221,7 +221,7 @@ printf("no answer\n"); else if(rc==1) { - printf("key found: %d bytes\n",iobuf_get_temp_length(iobuf)); + printf("key found: %d bytes\n",(int)iobuf_get_temp_length(iobuf)); iobuf_close(iobuf); } else if(rc==2) @@ -229,7 +229,7 @@ if(fpr) { size_t i; - printf("Fingerprint found (%d bytes): ",fpr_len); + printf("Fingerprint found (%d bytes): ",(int)fpr_len); for(i=0;i Author: dshaw Date: 2006-03-30 16:19:08 +0200 (Thu, 30 Mar 2006) New Revision: 4083 Modified: trunk/ChangeLog trunk/README Log: * README: Some more notes about building fat binaries. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-03-30 14:13:35 UTC (rev 4082) +++ trunk/ChangeLog 2006-03-30 14:19:08 UTC (rev 4083) @@ -1,3 +1,7 @@ +2006-03-30 David Shaw + + * README: Some more notes about building fat binaries. + 2006-03-24 David Shaw * README: Missing some instructions on building a fat binary. Modified: trunk/README =================================================================== --- trunk/README 2006-03-30 14:13:35 UTC (rev 4082) +++ trunk/README 2006-03-30 14:19:08 UTC (rev 4083) @@ -747,7 +747,10 @@ If you are doing the build on a OS X 10.4 (Tiger) PPC machine you may need to add "-isysroot /Developer/SDKs/MacOSX10.4u.sdk" to - those CFLAGS. + those CFLAGS. Note that any third-party libraries you may link + with need to be universal as well. All Apple-supplied libraries + (even libraries not originally written by Apple like curl, zip, + and BZ2) are universal. GnuPG 1.4 and GnuPG 1.9 From cvs at cvs.gnupg.org Thu Mar 30 17:14:14 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Mar 30 16:46:17 2006 Subject: [svn] ksba - r234 - trunk/doc Message-ID: Author: wk Date: 2006-03-30 17:14:14 +0200 (Thu, 30 Mar 2006) New Revision: 234 Modified: trunk/doc/ChangeLog trunk/doc/ksba.texi Log: Applied doc patches. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-03-21 09:57:38 UTC (rev 233) +++ trunk/doc/ChangeLog 2006-03-30 15:14:14 UTC (rev 234) @@ -1,3 +1,7 @@ +2006-03-30 Brad Hards (wk) + + * ksba.texi: Fixed typos and other errors. + 2005-04-15 Werner Koch * ksba.texi: Added a new function. Markup improvements. Modified: trunk/doc/ksba.texi =================================================================== --- trunk/doc/ksba.texi 2006-03-21 09:57:38 UTC (rev 233) +++ trunk/doc/ksba.texi 2006-03-30 15:14:14 UTC (rev 234) @@ -84,7 +84,7 @@ * Preparation:: What you should do before using the library. * Certificate Handling:: How to work with X.509 certificates. * CMS:: How to work with CMS (PKCS#7) messages. -* CRLs:: How to wor with Certificate Revocation Lists. +* CRLs:: How to work with Certificate Revocation Lists. * PKCS10:: How to request certificates. * Utilities:: Various utility functions. * Error Handling:: Error numbers and their meanings. @@ -93,7 +93,7 @@ * Component Labels:: Labels used in string representations. * Copying:: The GNU General Public License says how you - can copy and share `GnuPG Made Easy'. + can copy and share this manual. Indices @@ -118,7 +118,7 @@ * Creating certificates:: How to create a certificate object. * Retrieving attributes:: How to get the attributes of a certificate. -* Setting attributes:: How to set certicates attributes. +* Setting attributes:: How to set certificates attributes. * User data:: How to associate other data with a certificate. Mastering the Cryptographic Message Syntax @@ -131,8 +131,8 @@ @node Introduction @chapter Introduction -@acronym{KSBA} is a library to make the taks of working with X.509 -certifictes, CMS data and related data more easy. +@acronym{KSBA} is a library to make the task of working with X.509 +certificates, CMS data and related data more easy. @menu * Getting Started:: @@ -171,7 +171,7 @@ General Public License (@pxref{Copying}). @item It hides the low level stuff -`KSBA' a highlevel interface to the implemented protocols and presents +`KSBA' a high level interface to the implemented protocols and presents the data in a consistent way. There is no more need to worry about all the nasty details of the protocols. The API gives the C programmer a more usual way of interacting with the data. @@ -234,7 +234,7 @@ It is often desirable to check that the version of `KSBA' used is indeed one which fits all requirements. Even with binary compatibility, new features may have been introduced but through peculiarities of the -runtime linker an old version gets actually used. So you bettero check +runtime linker an old version gets actually used. So you better check that the version is as expected right after program startup. @deftypefun {const char *} ksba_check_version (@w{const char *@var{req_version}}) @@ -244,7 +244,7 @@ the library; return @code{NULL} if the condition is not met. If @code{NULL} is passed to this function, no check is done and only the version string is returned. It is a pretty good idea to run this -function as soon as possible, because it may also intializes some +function as soon as possible, because it may also initializes some subsystems. In a multi-threaded environment if should be called before any more threads are created. @end deftypefun @@ -280,7 +280,7 @@ (via the @option{-L} option). For this, the option @option{--libs} of @command{ksba-config} can be used. For convenience, this option also outputs all other options that are required to link the program with the -`KSBA' libararies (in particular, the @samp{-lksba} option). The +`KSBA' libraries (in particular, the @samp{-lksba} option). The example shows how to link @file{foo.o} with the `KSBA' libraries to a program @command{foo}. @@ -307,16 +307,16 @@ @end deftp @deftp {Data type} ksba_sexp_t -The @code{ksba_sexp_t} type descripes a canonical encodes S-expression -stored in a memory buffer. It is alias for @code{unisgned char *}. +The @code{ksba_sexp_t} type describes a canonically encoded S-expression +stored in a memory buffer. It is alias for @code{unsigned char *}. Note that a length argument is not required because the length of such -an S-expression is intrinsic available. +an S-expression is intrinsically available. @end deftp @menu * Creating certificates:: How to create a certificate object. * Retrieving attributes:: How to get the attributes of a certificate. -* Setting attributes:: How to set certicates attributes. +* Setting attributes:: How to set certificates attributes. * User data:: How to associate other data with a certificate. @end menu @@ -346,7 +346,7 @@ The function @code{ksba_cert_release} destroys the certificate object with the handle @var{cert} and releases all associated resources. Due to the use of reference counting no actual memory may be released if -another refrence still exists. It is okay to pass @code{NULL} to the +another reference still exists. It is okay to pass @code{NULL} to the function in which case nothing happens. @end deftypefun @@ -365,8 +365,8 @@ Parse the @var{buffer} which should contain a @acronym{DER} encoded certificate of @var{length} and initialize the certificate object -@var{cert} with it. This function is intended as a conveninence -function to be used when a certifciate is already available in a +@var{cert} with it. This function is intended as a convenience +function to be used when a certificate is already available in a internal memory buffer. This avoids the extra code needed to setup the reader object. Note that @var{cert} must be a valid certificate object. @@ -379,7 +379,7 @@ The functions in this section allow accessing the attributes of a certificate in a well defined manner. An error will be returned if the -certificate object has not yet been initialzied by means of +certificate object has not yet been initialized by means of @code{ksba_cert_read_der} or @code{ksba_cert_init_from_mem}. @deftypefun {const unsigned char *} ksba_cert_get_image (@w{ksba_cert_t @var{cert}}, @w{size_t *@var{r_length}}) @@ -391,7 +391,7 @@ The function returns @code{NULL} on error or a pointer to a buffer with the raw certificate data. That pointer is only valid as long as the -certificat object @var{cert} is valid and has not been reinitialized. +certificate object @var{cert} is valid and has not been reinitialized. @end deftypefun @deftypefun gpg_error_t ksba_cert_hash (@w{ksba_cert_t @var{cert}}, @w{int @var{what}}, @w{void (*@var{hasher})(void *, const void *, size_t length)}, @w{void *@var{hasher_arg}}) @@ -436,7 +436,7 @@ usually is the name of a certification authority (@acronym{CA}). The format of the returned string is in accordance with RFC-2253. @code{NULL} is returned if the @acronym{DN} is not available; This is a -severe error and actually should have been catched by the certificate +severe error and actually should have been caught by the certificate reading function. With @var{idx} greater than zero, the function may be used to enumerate @@ -445,12 +445,12 @@ @code{libksba} are returned, others are simply skipped. The format of the returned name is either a RFC-2253 formated string which can be detected by checking whether the first character is a letter or digit. -RFC-822 conform email addresses are returned enclosed in angle +RFC-822 conformant email addresses are returned enclosed in angle brackets; the opening angle bracket should be used to detect this. Other formats are returned as an S-Expression in canonical format, so a -opening parenthesis should be used to detect this encoding, the name may +opening parenthesis should be used to detect this encoding. The name may include binary null characters, thus strlen may return a length shorter -than actually used. The real length is implictly given by the structure +than actually used. The real length is implicitly given by the structure of the S-expression, an extra null is appended for safety reasons. The caller must free the returned string using @code{ksba_free} or @@ -475,7 +475,7 @@ Other formats are returned as an S-Expression in canonical format, so a opening parenthesis should be used to detect this encoding, the name may include binary null characters, thus strlen may return a length shorter -than actually used. The real length is implictly given by the structure +than actually used. The real length is implicitly given by the structure of the S-expression, an extra null is appended for safety reasons. The caller must free the returned string using @code{ksba_free} or @@ -486,20 +486,20 @@ @deftp {Data type} ksba_isotime_t Due to problems with the C data type @code{time_t}, which will overflow on most 32 bit machines in the year 2038, it was not advisable to use -this type for referencing times stored in certificates. Thus this type -has been defined. It is also useful to represent any time since the -year 0. +this type for referencing times stored in certificates. Instead, you +should use the @code{ksba_isotime_t} type, which can represent any time +since the year 0. It is implemented as a buffer of 16 bytes and may be handled like a -standard string. It should be initialized to zero (i.e. the first byte -needs to be 0x00) if it does not hold a valid date. Date values -themselfs are stored in ISO format and assumed to mean UTC. The string -with the date value is always guaranteed to be of length 15 and having a -format like: @samp{"19610711T172059"}. Note that the `T' is required by -ISO rules. +standard string. It should be initialized to zero (i.e. the first +byte needs to be 0x00) if it does not hold a valid date. Date values +themselves are stored in ISO format and assumed to be referenced from +UTC. The string with the date value is always guaranteed to be of +length 15 and having a format like: @samp{"19610711T172059"}. Note +that the `T' is required by ISO rules. -A simple assignment of these data types is no good idea. You may use -@code{strcpy} or better a specialized function like: +A simple assignment of these data types is not a good idea. You may +use @code{strcpy} or better a specialized function like: @example void @@ -528,8 +528,8 @@ Return the validity dates from the certificate. If no value is available an empty date object (i.e. a @code{strlen} will be -stored at @var{timebuf}, otherwiese it will receive the date. On failure -an error ode is returned. +stored at @var{timebuf}, otherwise it will receive the date. On failure +an error code is returned. To return the `notBefore' date, the value @code{0} must be supplied for @var{what}; @code{1} yields the `notAfter' value. @@ -560,7 +560,7 @@ Return information on the basicConstraint (2.5.19.19) of CERT. R_CA receives true if this is a CA and only in that case R_PATHLEN is set to -the maximim certification path length or -1 if there is no such +the maximum certification path length or -1 if there is no such limitation @end deftypefun @@ -575,7 +575,7 @@ @deftypefun gpg_error_t ksba_cert_get_cert_policies (@w{ksba_cert_t @var{cert}, char **@var{r_policies}}) Return a string with the certificatePolicies delimited by linefeeds. -The return values may be extended to carry more information er line, so +The return values may be extended to carry more information per line, so the caller should only use the first white-space delimited token per line. The function returns @code{GPG_ERR_NO_DATA} when this extension is not used. Caller must free the returned value. @@ -596,7 +596,7 @@ This is a bit encoded value with no bit set if no reason has been specified in the certificate. -The caller may pass @code{NULL} to any of the pointer argumenst if he is +The caller may pass @code{NULL} to any of the pointer arguments if he is not interested in this value. The return values for @var{r_distpoint} and @var{r_issuer} must be released by the caller using @code{ksba_name_release}. @@ -632,10 +632,10 @@ that OID. The returned values for @var{r_method} and @var{r_location} must be released by the caller unless the function returned an error; the function will however make sure that @var{r_method} and -@var{r_location} will point to @code{NULL} if the function retruns an +@var{r_location} will point to @code{NULL} if the function returns an error. -See RFC-2459, section 4.2.2.1 for the defintion of this attribute. +See RFC-2459, section 4.2.2.1 for the definition of this attribute. @end deftypefun @deftypefun gpg_error_t ksba_cert_get_subject_info_access (@w{ksba_cert_t @var{cert}, int @var{idx}, char **@var{r_method}, ksba_name_t *@var{r_location}}) @@ -647,10 +647,10 @@ that OID. The returned values for @var{r_method} and @var{r_location} must be released by the caller unless the function returned an error; the function will however make sure that @var{r_method} and -@var{r_location} will point to @code{NULL} if the function retruns an +@var{r_location} will point to @code{NULL} if the function returns an error. -See RFC-2459, section 4.2.2.2 for the defintion of this attribute. +See RFC-2459, section 4.2.2.2 for the definition of this attribute. @end deftypefun @@ -674,7 +674,7 @@ the buffer @var{data} of length @var{datalen}. It will be stored under the string @var{key}. If data is already stored under this key it will be replaced by the new data. Using @code{NULL} for @var{data} will -effectivly delete the data. +effectively delete the data. On error (i.e. out of memory) an already existing data object stored under @var{key} may get deleted. @@ -695,7 +695,7 @@ If @var{buffer} is given as @code{NULL}, @var{bufferlen} will be ignored and the required length of the buffer will be returned at @var{datalen}. -On success 0 is returned. If no data is stored under thengiven key, +On success 0 is returned. If no data is stored under the given key, @code{GPG_ERR_NOT_FOUND} is returned. If the provided buffer is too short and @var{buffer} is not @code{NULL}, @code{GPG_ERR_BUFFER_TOO_SHORT} will be returned. @@ -718,7 +718,7 @@ @node CMS Basics @section CMS Basics All operations with the CMS framework require the use of a so called CMS -object which is internally used to keeptrack of the current state and to +object which is internally used to keep track of the current state and to store some meta information. @deftp {Data type} ksba_cms_t @@ -742,7 +742,7 @@ @deftypefun void ksba_cms_release (@w{ksba_cms_t @var{cms}}) -Release allresources associated with the @var{CMS} object. It is +Release all resources associated with the @var{CMS} object. It is perfectly okay to pass @code{NULL} to this function in which case nothing happens. @end deftypefun @@ -750,16 +750,16 @@ @deftypefun gpg_error_t ksba_cms_set_reader_writer (@w{ksba_cms_t @var{cms}, ksba_reader_t @var{r}, ksba_writer_t @var{w}}) About all usages of the CMS framework require some input and output data -(great surprise!). Do accomplish this in the most abstract way, no +(great surprise!). To accomplish this in the most abstract way, no direct output functions are used - instead special reader and writer -objects are to be used. Depending on the desired operations either a +objects are used instead. Depending on the desired operations either a reader, a writer or both must be given. Associate a reader object with -@var{cms} by passing it as @var{r} and a wrter object by passing it as +@var{cms} by passing it as @var{r} and a writer object by passing it as @var{w}. Note that no reference counting is done,so make sure that those objects have a lifetime at least as long as @var{CMS}. If you forget to set these objects, you will get an appropriate error -later when data is actually to be read or written. The fnction returns +later when data is actually to be read or written. The function returns zero on success or an error code when invalid objects are passed. @end deftypefun @@ -777,18 +777,18 @@ @deftypefun gpg_error_t ksba_cms_parse (@w{ksba_cms_t @var{cms}, ksba_stop_reason_t *@var{r_stopreason}}) This is the core function of the parser and commonly used in a loop. -The parsing process is divided into serveral phases to allow the user to -get information at the right timeand prepare for further processing. -The caller has to act on certain stop reasons which are returned by -@var{r_stopreason} adn set up things accordingly; @acronym{KSBA} may -introduce new stop reasons to let the caller know other details; there -is no need for the caller to act on every stop reason; he should oly do -so for reasons he knows and which are mandatory. The function does -return with an error if the caller did not setup things correctly for -certain stop reasons. +The parsing process is divided into several phases to allow the user +to get information at the right time and prepare for further +processing. The caller has to act on certain stop reasons which are +returned by @var{r_stopreason} and set up things accordingly; +@acronym{KSBA} may introduce new stop reasons to let the caller know +other details; there is no need for the caller to act on every stop +reason; it should only do so for reasons that the caller understands +and which are mandatory. The function will return with an error if +the caller did not setup things correctly for certain stop reasons. @end deftypefun -The use of the function is best explained by an example, leaving out all +The use of this function is best explained by an example, leaving out all error checking. @example do @@ -807,14 +807,15 @@ @} while (stopreason != KSBA_SR_READY); @end example -This function assumes that the parsed data issocalld `enveloped data'. +This function assumes that the parsed data is so called `enveloped data'. @c FIXME: Reference to a list of stop reasons used here. As @acronym{CMS} provides a common framework for a variety of data -formats, it is probably very useful tocheck the type of that data very +formats, it is probably very useful to check the type of that data very early. This can be accomplished by hooking into the stop reason -@code{KSBA_SR_GOT_CONTENT} and retrieving the content using +@code{KSBA_SR_GOT_CONTENT} and retrieving the content using the following +function. @deftypefun ksba_content_t ksba_cms_get_content_type (@w{ksba_cms_t @var{cms}, int @var{what}}) @@ -829,14 +830,14 @@ @table @code @item KSBA_CT_NONE -No content type know, this one has the value @code{0} +No content type known (value @code{0}) @item KSBA_CT_DATA The content is plain data, not further interpreted. @item KSBA_CT_SIGNED_DATA -The content is an signed CMS object. This alosincludes the case of a -detachedsignature where no actual data is included in the message. +The content is an signed CMS object. This also includes the case of a +detached signature where no actual data is included in the message. @item KSBA_CT_ENVELOPED_DATA The content is encrypted using a session key. @@ -859,8 +860,8 @@ Return the object ID of @var{cms}. This is a constant string valid as long as the context is valid and no new parse is started. This function is similar to @code{ksba_cms_get_content_type} but returns the -@acronym{OID} actually used in the data. Debinding on the value of -@var{what} different values are returned: USing a value of @code{0} +@acronym{OID} actually used in the data. Depending on the value of +@var{what} different values are returned: Using a value of @code{0} yields the OID of the outer container, a value of @code{1} yields the OID of the inner container if available and the value @code{2} returns the OID of the algorithm used to encrypt the inner container. @@ -869,8 +870,8 @@ @node CRLs @chapter Certification Revocation Lists KSBA also comes with an API to process certification revocation lists. -The API is similar to the @acronym{CMS} one but does return entry by -entry. +The API is similar to the @acronym{CMS} one but returns the contents +entry by entry. @node PKCS10 @@ -915,15 +916,15 @@ By iterating @var{idx} up starting with 0, this function returns all General Names stored in @var{name}. The format of the returned name is either a RFC-2253 formated one which can be detected by checking whether the -first character is letter or a digit. RFC 2822 conform email addresses +first character is letter or a digit. RFC 2822 conformant email addresses are returned enclosed in angle brackets, the opening angle bracket should be used to detect this. Other formats are returned as an -S-Expression in canonical format, so a opening parenthesis may be used +S-Expression in canonical format, so an opening parenthesis may be used to detect this encoding, in this case the name may include binary null characters, so strlen might return a length shorter than actually used, -the real length is implictly given by the structure of the S-Exp, an +the real length is implicitly given by the structure of the S-Exp, an extra null is appended for safety reasons. One common format return is -probably an Universal Resource Identifier which has the S-expression: +a Universal Resource Identifier which has the S-expression: @samp{(uri )}. The returned string has the same lifetime as @var{name}. @@ -970,17 +971,18 @@ @node Error Handling @chapter Error Handling -Most functions in `KSBA' are returning an error if they fail. +Most functions in `KSBA' will return an error if they fail. For this reason, the application should always catch the error condition and take appropriate measures, for example by releasing the resources and passing the error up to the caller, or by displaying a -descriptive message to the user and cancelling the operation. +descriptive message to the user and canceling the operation. -Some error values do not indicate a system error or an error in the operation, -but the result of an operation that failed properly. For example, if you try -to access optional attributes of a certificate you get an appropriate error -message. Some error values have specific meanings if returned by a specific -function. Such cases are described in the documentation of those functions. +Some error values do not indicate a system error or an error in the +operation, but the reasonable result of an operation. For example, if +you try to access optional attributes of a certificate that are not +present, you get an appropriate error message. Some error values have +specific meanings if returned by a specific function. Such cases are +described in the documentation of those functions. All error codes are defined by the library @code{libgpg-error}. See there for ways to check the error values and print descriptive @@ -1012,7 +1014,7 @@ @node Component Labels @appendix Component Labels -RFC-2253 defines the following table with string representions of name +RFC-2253 defines the following table with string representations of name components: @multitable {SERIALNUMBER} {organizationalUnit} {xxx} @@ -1035,7 +1037,7 @@ represented by their OID. For the other direction, i.e. creating a DN from the string -representation, Libksba recognizes the follwing extra labels: +representation, KSBA recognizes the following extra labels: @multitable {SERIALNUMBER} {organizationalUnit} {xxx} @item Label @tab Component @tab OID From cvs at cvs.gnupg.org Thu Mar 30 21:21:01 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Mar 30 20:53:01 2006 Subject: [svn] GnuPG - r4084 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-30 21:20:59 +0200 (Thu, 30 Mar 2006) New Revision: 4084 Modified: trunk/g10/ChangeLog trunk/g10/main.h trunk/g10/seskey.c trunk/g10/sig-check.c trunk/g10/sign.c Log: * main.h, seskey.c (encode_md_value): Modify to allow a q size greater than 160 bits as per DSA2. This will allow us to verify and issue DSA2 signatures for some backwards compatibility once we start generating DSA2 keys. * sign.c (do_sign), sig-check.c (do_check): Change all callers. * sign.c (do_sign): Enforce the 160-bit check for new signatures here since encode_md_value can handle non-160-bit digests now. This will need to come out once the standard for DSA2 is firmed up. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-03-30 14:19:08 UTC (rev 4083) +++ trunk/g10/ChangeLog 2006-03-30 19:20:59 UTC (rev 4084) @@ -1,3 +1,16 @@ +2006-03-30 David Shaw + + * main.h, seskey.c (encode_md_value): Modify to allow a q size + greater than 160 bits as per DSA2. This will allow us to verify + and issue DSA2 signatures for some backwards compatibility once we + start generating DSA2 keys. + * sign.c (do_sign), sig-check.c (do_check): Change all callers. + + * sign.c (do_sign): Enforce the 160-bit check for new signatures + here since encode_md_value can handle non-160-bit digests now. + This will need to come out once the standard for DSA2 is firmed + up. + 2006-03-22 David Shaw * getkey.c (parse_auto_key_locate): Silently strip out duplicates Modified: trunk/g10/main.h =================================================================== --- trunk/g10/main.h 2006-03-30 14:19:08 UTC (rev 4083) +++ trunk/g10/main.h 2006-03-30 19:20:59 UTC (rev 4084) @@ -203,8 +203,8 @@ /*-- seskey.c --*/ void make_session_key( DEK *dek ); MPI encode_session_key( DEK *dek, unsigned nbits ); -MPI encode_md_value( int pubkey_algo, MD_HANDLE md, - int hash_algo, unsigned nbits ); +MPI encode_md_value( PKT_public_key *pk, PKT_secret_key *sk, + MD_HANDLE md, int hash_algo ); /*-- import.c --*/ int parse_import_options(char *str,unsigned int *options,int noisy); Modified: trunk/g10/seskey.c =================================================================== --- trunk/g10/seskey.c 2006-03-30 14:19:08 UTC (rev 4083) +++ trunk/g10/seskey.c 2006-03-30 19:20:59 UTC (rev 4084) @@ -195,36 +195,76 @@ /**************** * Encode a message digest into an MPI. - * v3compathack is used to work around a bug in old GnuPG versions - * which did put the algo identifier inseatd of the block type 1 into - * the encoded value. Setting this flag forces the old behaviour. + * If it's for a DSA signature, make sure that the hash is large + * enough to fill up q. If the hash is too big, take the leftmost + * bits. */ MPI -encode_md_value( int pubkey_algo, MD_HANDLE md, - int hash_algo, unsigned nbits ) +encode_md_value( PKT_public_key *pk, PKT_secret_key *sk, + MD_HANDLE md, int hash_algo ) { - int algo = hash_algo? hash_algo : md_get_algo(md); - const byte *asn; - size_t asnlen, mdlen; - MPI frame; + MPI frame; - if( pubkey_algo == PUBKEY_ALGO_DSA ) { - mdlen = md_digest_length (hash_algo); - if (mdlen != 20) { - log_error (_("DSA requires the use of a 160 bit hash algorithm\n")); - return NULL; - } + assert(hash_algo); + assert(pk || sk); - frame = md_is_secure(md)? mpi_alloc_secure((md_digest_length(hash_algo) - +BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB ) - : mpi_alloc((md_digest_length(hash_algo) - +BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB ); - mpi_set_buffer( frame, md_read(md, hash_algo), - md_digest_length(hash_algo), 0 ); + if((pk?pk->pubkey_algo:sk->pubkey_algo) == PUBKEY_ALGO_DSA) + { + /* It's a DSA signature, so find out the size of q. */ + + unsigned int qbytes=mpi_get_nbits(pk?pk->pkey[1]:sk->skey[1]); + + /* Make sure it is a multiple of 8 bits. */ + + if(qbytes%8) + { + log_error(_("DSA requires the hash length to be a" + " multiple of 8 bits\n")); + return NULL; + } + + /* Don't allow any q smaller than 160 bits. This might need a + revisit as the DSA2 design firms up, but for now, we don't + want someone to issue signatures from a key with a 16-bit q + or something like that, which would look correct but allow + trivial forgeries. Yes, I know this rules out using MD5 with + DSA. ;) */ + + if(qbytes<160) + { + log_error(_("DSA key %s uses an unsafe (%u bit) hash\n"), + pk?keystr_from_pk(pk):keystr_from_sk(sk),qbytes); + return NULL; + } + + qbytes/=8; + + /* Check if we're too short. Too long is safe as we'll + automatically left-truncate. */ + + if(md_digest_length(hash_algo) < qbytes) + { + log_error(_("DSA key %s requires a %u bit or larger hash\n"), + pk?keystr_from_pk(pk):keystr_from_sk(sk),qbytes*8); + return NULL; + } + + frame = md_is_secure(md)? mpi_alloc_secure((qbytes+BYTES_PER_MPI_LIMB-1) + / BYTES_PER_MPI_LIMB ) + : mpi_alloc((qbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB ); + + mpi_set_buffer( frame, md_read(md, hash_algo), qbytes, 0 ); } - else { - asn = md_asn_oid( algo, &asnlen, &mdlen ); - frame = do_encode_md( md, algo, mdlen, nbits, asn, asnlen ); + else + { + const byte *asn; + size_t asnlen,mdlen; + + asn = md_asn_oid( hash_algo, &asnlen, &mdlen ); + frame = do_encode_md( md, hash_algo, mdlen, + mpi_get_nbits(pk?pk->pkey[0]:sk->skey[0]), + asn, asnlen ); } - return frame; + + return frame; } Modified: trunk/g10/sig-check.c =================================================================== --- trunk/g10/sig-check.c 2006-03-30 14:19:08 UTC (rev 4083) +++ trunk/g10/sig-check.c 2006-03-30 19:20:59 UTC (rev 4084) @@ -274,8 +274,7 @@ } md_final( digest ); - result = encode_md_value( pk->pubkey_algo, digest, sig->digest_algo, - mpi_get_nbits(pk->pkey[0]) ); + result = encode_md_value( pk, NULL, digest, sig->digest_algo ); if (!result) return G10ERR_GENERAL; ctx.sig = sig; Modified: trunk/g10/sign.c =================================================================== --- trunk/g10/sign.c 2006-03-30 14:19:08 UTC (rev 4083) +++ trunk/g10/sign.c 2006-03-30 19:20:59 UTC (rev 4084) @@ -319,8 +319,17 @@ } else { - frame = encode_md_value( sk->pubkey_algo, md, - digest_algo, mpi_get_nbits(sk->skey[0]) ); + /* TODO: remove this check in the future once all the + variable-q DSA stuff makes it into the standard. */ + if(!opt.expert + && sk->pubkey_algo==PUBKEY_ALGO_DSA + && md_digest_length(digest_algo)!=20) + { + log_error(_("DSA requires the use of a 160 bit hash algorithm\n")); + return G10ERR_GENERAL; + } + + frame = encode_md_value( NULL, sk, md, digest_algo ); if (!frame) return G10ERR_GENERAL; rc = pubkey_sign( sk->pubkey_algo, sig->data, frame, sk->skey ); @@ -336,9 +345,7 @@ if( get_pubkey( pk, sig->keyid ) ) rc = G10ERR_NO_PUBKEY; else { - frame = encode_md_value (pk->pubkey_algo, md, - sig->digest_algo, - mpi_get_nbits(pk->pkey[0]) ); + frame = encode_md_value (pk, NULL, md, sig->digest_algo ); if (!frame) rc = G10ERR_GENERAL; else From cvs at cvs.gnupg.org Fri Mar 31 01:55:46 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Fri Mar 31 01:27:41 2006 Subject: [svn] GnuPG - r4085 - trunk/g10 Message-ID: Author: dshaw Date: 2006-03-31 01:55:45 +0200 (Fri, 31 Mar 2006) New Revision: 4085 Modified: trunk/g10/seskey.c Log: Update copyright Modified: trunk/g10/seskey.c =================================================================== --- trunk/g10/seskey.c 2006-03-30 19:20:59 UTC (rev 4084) +++ trunk/g10/seskey.c 2006-03-30 23:55:45 UTC (rev 4085) @@ -1,5 +1,6 @@ /* seskey.c - make sesssion keys etc. - * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, + * 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. *