From: ueno Date: Mon, 1 May 2006 03:42:56 +0000 (+0000) Subject: * epg.el (epg-new-signature-type-alist): New variable. X-Git-Tag: epg-0_0_2~55 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c5e884532688d090831d0d0d6d983d1883861cd;p=elisp%2Fepg.git * epg.el (epg-new-signature-type-alist): New variable. (epg-make-new-signature): New object epg-new-signature. (epg-status-SIG_CREATED): Set epg-new-signature object. --- diff --git a/ChangeLog b/ChangeLog index 1413703..6b618e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,9 @@ (epg-generate-key-from-string): New function. (epg-status-KEY_CREATED): New function. (epg-status-KEY_NOT_CREATED): New function. + (epg-new-signature-type-alist): New variable. + (epg-make-new-signature): New object epg-new-signature. + (epg-status-SIG_CREATED): Set epg-new-signature object. 2006-04-30 Daiki Ueno diff --git a/epg.el b/epg.el index 67ae99c..d2ba8ec 100644 --- a/epg.el +++ b/epg.el @@ -128,6 +128,11 @@ (?c . certify) (?a . authentication))) +(defvar epg-new-signature-type-alist + '((?D . detached) + (?C . clear) + (?S . normal))) + (defvar epg-dn-type-alist '(("1.2.840.113549.1.9.1" . "EMail") ("2.5.4.12" . "T") @@ -436,6 +441,48 @@ This function is for internal use only." (signal 'wrong-type-argument (list 'epg-signature-p signature))) (aset (cdr signature) 7 digest-algorithm)) +(defun epg-make-new-signature (type pubkey-algorithm digest-algorithm + class creation-time fingerprint) + "Return a new signature object." + (cons 'epg-new-signature (vector type pubkey-algorithm digest-algorithm + class creation-time fingerprint))) + +(defun epg-new-signature-type (new-signature) + "Return the type of NEW-SIGNATURE." + (unless (eq (car new-signature) 'epg-new-signature) + (signal 'wrong-type-argument (list 'epg-new-signature-p new-signature))) + (aref (cdr new-signature) 0)) + +(defun epg-new-signature-pubkey-algorithm (new-signature) + "Return the public key algorithm of NEW-SIGNATURE." + (unless (eq (car new-signature) 'epg-new-signature) + (signal 'wrong-type-argument (list 'epg-new-signature-p new-signature))) + (aref (cdr new-signature) 1)) + +(defun epg-new-signature-digest-algorithm (new-signature) + "Return the digest algorithm of NEW-SIGNATURE." + (unless (eq (car new-signature) 'epg-new-signature) + (signal 'wrong-type-argument (list 'epg-new-signature-p new-signature))) + (aref (cdr new-signature) 2)) + +(defun epg-new-signature-class (new-signature) + "Return the class of NEW-SIGNATURE." + (unless (eq (car new-signature) 'epg-new-signature) + (signal 'wrong-type-argument (list 'epg-new-signature-p new-signature))) + (aref (cdr new-signature) 3)) + +(defun epg-new-signature-creation-time (new-signature) + "Return the creation time of NEW-SIGNATURE." + (unless (eq (car new-signature) 'epg-new-signature) + (signal 'wrong-type-argument (list 'epg-new-signature-p new-signature))) + (aref (cdr new-signature) 4)) + +(defun epg-new-signature-fingerprint (new-signature) + "Return the fingerprint of NEW-SIGNATURE." + (unless (eq (car new-signature) 'epg-new-signature) + (signal 'wrong-type-argument (list 'epg-new-signature-p new-signature))) + (aref (cdr new-signature) 5)) + (defun epg-make-key (owner-trust) "Return a key object." (cons 'epg-key (vector owner-trust nil nil))) @@ -1028,14 +1075,14 @@ This function is for internal use only." \\([0-9A-Fa-F][0-9A-Fa-F]\\) \\(.*\\) " string) (epg-context-set-result-for epg-context 'sign - (cons (list (cons 'type (string-to-char (match-string 1 string))) - (cons 'pubkey-algorithm - (string-to-number (match-string 2 string))) - (cons 'digest-algorithm - (string-to-number (match-string 3 string))) - (cons 'class (string-to-number (match-string 4 string) 16)) - (cons 'creation-time (match-string 5 string)) - (cons 'fingerprint (substring string (match-end 0)))) + (cons (epg-make-new-signature + (cdr (assq (aref (match-string 1 string) 0) + epg-new-signature-type-alist)) + (string-to-number (match-string 2 string)) + (string-to-number (match-string 3 string)) + (string-to-number (match-string 4 string) 16) + (match-string 5 string) + (substring string (match-end 0))) (epg-context-result-for epg-context 'sign))))) (defun epg-status-KEY_CREATED (process string) @@ -1427,7 +1474,7 @@ For a normal or a clear text signature, SIGNED-TEXT should be nil." "Initiate a sign operation on PLAIN. PLAIN is a data object. -If optional 3rd argument MODE is 'clearsign, it makes a clear text signature. +If optional 3rd argument MODE is 'clear, it makes a clear text signature. If MODE is t or 'detached, it makes a detached signature. Otherwise, it makes a normal signature. @@ -1438,7 +1485,7 @@ If you are unsure, use synchronous version of this function `epg-sign-file' or `epg-sign-string' instead." (epg-context-set-result context nil) (epg-start context - (append (list (if (eq mode 'clearsign) + (append (list (if (eq mode 'clear) "--clearsign" (if (or (eq mode t) (eq mode 'detached)) "--detach-sign" @@ -1466,7 +1513,7 @@ If you are unsure, use synchronous version of this function (defun epg-sign-file (context plain signature &optional mode) "Sign a file PLAIN and store the result to a file SIGNATURE. If SIGNATURE is nil, it returns the result as a string. -If optional 3rd argument MODE is 'clearsign, it makes a clear text signature. +If optional 3rd argument MODE is 'clear, it makes a clear text signature. If MODE is t or 'detached, it makes a detached signature. Otherwise, it makes a normal signature." (unwind-protect @@ -1477,10 +1524,7 @@ Otherwise, it makes a normal signature." (epg-make-temp-file "epg-output"))) (epg-start-sign context (epg-make-data-from-file plain) mode) (epg-wait-for-completion context) - (if (epg-context-result-for context 'sign) - (if (epg-context-result-for context 'error) - (message "Sign warning: %S" - (epg-context-result-for context 'error))) + (unless (epg-context-result-for context 'sign) (if (epg-context-result-for context 'error) (error "Sign failed: %S" (epg-context-result-for context 'error)) @@ -1494,7 +1538,7 @@ Otherwise, it makes a normal signature." ;;;###autoload (defun epg-sign-string (context plain &optional mode) "Sign a string PLAIN and return the output as string. -If optional 3rd argument MODE is 'clearsign, it makes a clear text signature. +If optional 3rd argument MODE is 'clear, it makes a clear text signature. If MODE is t or 'detached, it makes a detached signature. Otherwise, it makes a normal signature." (unwind-protect diff --git a/pgg-epg.el b/pgg-epg.el index 6445c4c..27b6e42 100644 --- a/pgg-epg.el +++ b/pgg-epg.el @@ -162,7 +162,7 @@ passphrase cache or user." (epg-sign-string context (buffer-substring start end) (if cleartext - 'clearsign + 'clear 'detached)) pgg-epg-secret-key-id-list nil) (error