Support expiration of metadata by package archives

Expiring package metadata is done by checking the timestamp in package
archive file.  This is intended to limit the effectiveness of a replay
attack.  The onus is on the package archives to implement a secure and
reasonable policy.  (Debian uses 7 days before metadata expires.)

Together with package checksums, this adds sufficient protection
against metadata replay attacks.  (Bug#19479)

* lisp/emacs-lisp/package.el (package-check-timestamp): New defcustom.
(bad-timestamp): New error.
(package--parse-header-from-buffer)
(package--parse-valid-until-from-buffer)
(package--parse-last-updated-from-buffer)
(package--archive-verify-timestamp)
(package--archive-verify-not-expired)
(package--compare-archive-timestamps)
(package--check-archive-timestamp): New defuns.
(package--download-one-archive): Check timestamp of the
'archive-contents' file using above functions.  It is only checked if
it exists, which makes this change backwards compatible.

* lisp/calendar/iso8601.el (iso8601-parse): Add autoload cookie.

* test/lisp/emacs-lisp/package-tests.el
(package-test-parse-valid-until-from-buffer)
(package-test-parse-last-updated-from-buffer)
(package-test-archive-verify-timestamp)
(package-test-check-archive-timestamp)
(package-test-check-archive-timestamp/not-expired)
(package-test-check-archive-timestamp/expired): New tests.

* test/lisp/emacs-lisp/package-resources/archives/older/archive-contents:
* test/lisp/emacs-lisp/package-resources/archives/newer/archive-contents:
New files.

* doc/lispref/package.texi (Package Archives, Archive Web Server):
Document how to increase the security of a package archive using
checksums, signing and timestamps.
2 jobs for scratch/package-security in 12 seconds (queued for 3 seconds)
latest
Status Job ID Name Coverage
  Test
failed #8929
test-filenotify-gio

00:00:12

failed #8930
test-gnustep

00:00:12

 
Name Stage Failure
failed
test-filenotify-gio Test There has been a runner system failure, please try again
Running with gitlab-runner 12.0.2 (d0b76032)
on emba-docker-runner 2oEDrUT7
Using Docker executor with image debian:stretch ...
Pulling docker image debian:stretch ...
Using docker image sha256:b33ba41eae78980b0cd524b0d80983ac11025f6c5f2776ed4a861c9d5f805ede for debian:stretch ...
Running on runner-2oEDrUT7-project-1-concurrent-0 via emba.gnu.org...
WARNING: Possibly zombie container runner-2oEDrUT7-project-1-concurrent-0-predefined-1 is disconnected from network bridge
ERROR: Job failed (system failure): Error: No such container: 7cf2124784bde852af481b989a58779de0afae1c3fae072db493d5cb35282b70 (executor_docker.go:769:0s)
failed
test-gnustep Test
Removing src/timefns.o
Removing src/undo.o
Removing src/window.o
Removing src/xdisp.o
Removing src/xfaces.o
Removing src/xml.o
Removing test/Makefile
HEAD is now at 789ee3e1d55 Handle connection-local null-device and path-separator variables
ERROR: Job failed: exit code 137