(?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")
(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)))
\\([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)
"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.
`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"
(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
(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))
;;;###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