If optional 3rd argument MODE is t or 'detached, it makes a detached signature.
If it is nil or 'normal, it makes a normal signature.
Otherwise, it makes a cleartext signature."
- (let ((input-file (if (or (eq (epg-context-protocol context) 'CMS)
- (condition-case nil
- (progn
- (epg-check-configuration (epg-configuration))
- t)
- (error)))
- (epg--make-temp-file "epg-input")))
+ (let ((input-file
+ (unless (or (eq (epg-context-protocol context) 'CMS)
+ (condition-case nil
+ (progn
+ (epg-check-configuration (epg-configuration))
+ t)
+ (error)))
+ (epg--make-temp-file "epg-input")))
(coding-system-for-write 'binary))
- (unwind-protect
- (progn
- (epg-context-set-output-file context
- (epg--make-temp-file "epg-output"))
- (if input-file
- (write-region plain nil input-file nil 'quiet))
- (epg-start-sign context
- (if input-file
- (epg-make-data-from-file input-file)
- (epg-make-data-from-string plain))
- mode)
- (epg-wait-for-completion context)
- (unless (epg-context-result-for context 'sign)
- (if (epg-context-result-for context 'error)
- (error "Sign failed: %S"
- (epg-context-result-for context 'error))
- (error "Sign failed")))
- (epg-read-output context))
- (epg-delete-output-file context)
- (if input-file
- (delete-file input-file))
- (epg-reset context))))
+ (unwind-protect
+ (progn
+ (epg-context-set-output-file context
+ (epg--make-temp-file "epg-output"))
+ (if input-file
+ (write-region plain nil input-file nil 'quiet))
+ (epg-start-sign context
+ (if input-file
+ (epg-make-data-from-file input-file)
+ (epg-make-data-from-string plain))
+ mode)
+ (epg-wait-for-completion context)
+ (unless (epg-context-result-for context 'sign)
+ (if (epg-context-result-for context 'error)
+ (error "Sign failed: %S"
+ (epg-context-result-for context 'error))
+ (error "Sign failed")))
+ (epg-read-output context))
+ (epg-delete-output-file context)
+ (if input-file
+ (delete-file input-file))
+ (epg-reset context))))
;;;###autoload
(defun epg-start-encrypt (context plain recipients
&optional sign always-trust)
"Encrypt a string PLAIN.
If RECIPIENTS is nil, it performs symmetric encryption."
- (unwind-protect
- (progn
- (epg-context-set-output-file context
- (epg--make-temp-file "epg-output"))
- (epg-start-encrypt context (epg-make-data-from-string plain)
- recipients sign always-trust)
- (epg-wait-for-completion context)
- (if (and sign
- (not (epg-context-result-for context 'sign)))
- (if (epg-context-result-for context 'error)
- (error "Sign failed: %S"
- (epg-context-result-for context 'error))
- (error "Sign failed")))
- (if (epg-context-result-for context 'error)
- (error "Encrypt failed: %S"
- (epg-context-result-for context 'error)))
- (epg-read-output context))
- (epg-delete-output-file context)
- (epg-reset context)))
+ (let ((input-file
+ (unless (or (not sign)
+ (eq (epg-context-protocol context) 'CMS)
+ (condition-case nil
+ (progn
+ (epg-check-configuration (epg-configuration))
+ t)
+ (error)))
+ (epg--make-temp-file "epg-input")))
+ (coding-system-for-write 'binary))
+ (unwind-protect
+ (progn
+ (epg-context-set-output-file context
+ (epg--make-temp-file "epg-output"))
+ (if input-file
+ (write-region plain nil input-file nil 'quiet))
+ (epg-start-encrypt context
+ (if input-file
+ (epg-make-data-from-file input-file)
+ (epg-make-data-from-string plain))
+ recipients sign always-trust)
+ (epg-wait-for-completion context)
+ (if (and sign
+ (not (epg-context-result-for context 'sign)))
+ (if (epg-context-result-for context 'error)
+ (error "Sign failed: %S"
+ (epg-context-result-for context 'error))
+ (error "Sign failed")))
+ (if (epg-context-result-for context 'error)
+ (error "Encrypt failed: %S"
+ (epg-context-result-for context 'error)))
+ (epg-read-output context))
+ (epg-delete-output-file context)
+ (if input-file
+ (delete-file input-file))
+ (epg-reset context))))
;;;###autoload
(defun epg-start-export-keys (context keys)