* smime.el (smime-x509-hash): Use `call-process' instead of
[elisp/semi.git] / pgg-parse.el
index 0154ea6..040ae1a 100644 (file)
@@ -92,7 +92,7 @@
   :group 'pgg-parse
   :type 'alist)
 
-(defcustom pgg-ignore-packet-checksum (featurep 'xemacs); XXX
+(defcustom pgg-ignore-packet-checksum t; XXX
   "If non-nil checksum of each ascii armored packet will be ignored."
   :group 'pgg-parse
   :type 'boolean)
         0))
 
 (defmacro pgg-byte-after (&optional pos)
-  `(char-int (char-after ,pos)))
+  `(char-int (char-after ,(or pos `(point)))))
 
 (defmacro pgg-read-byte ()
   `(char-int (char-after (prog1 (point) (forward-char)))))
   `(setq ,alist (nconc ,alist (list (cons ,key ,value)))))
 
 (unless-broken ccl-usable
-  (check-broken-facility ccl-cascading-read)
-
   (define-ccl-program pgg-parse-crc24
     '(1
-      ((r1 = 183) (r2 = 1230)
-       (loop
+      ((loop
        (read r0) (r1 ^= r0) (r2 ^= 0)
        (r5 = 0)
        (loop
         (if (r5 < 7)
             ((r5 += 1)
              (repeat))))
-       (repeat)))
-      ((r1 &= 255) 
-       (r3 = (r2 & 255))
-       (r2 = ((r2 >> 8) & 255))
-       (write r1 r2 r3))))
-
-  (make-ccl-coding-system 
-   'pgg-parse-crc24 ?C "CRC24 checker"
-   'pgg-parse-crc24 'pgg-parse-crc24)
+       (repeat)))))
 
   (defun pgg-parse-crc24-string (string)
-    (encode-coding-string string 'pgg-parse-crc24))
+    (let ((h (vector nil 183 1230 nil nil nil nil nil nil)))
+      (ccl-execute-on-string pgg-parse-crc24 h string)
+      (format "%c%c%c"
+             (logand (aref h 1) 255)
+             (logand (lsh (aref h 2) -8) 255)
+             (logand (aref h 2) 255))))
   )
 
 (defmacro pgg-parse-length-type (c)
     (mime-decode-region (point-min) marker "base64")
     (static-when (fboundp 'pgg-parse-crc24-string )
       (or pgg-ignore-packet-checksum
-         (string-equal (mime-encode-string 
-                        (pgg-parse-crc24-string 
-                         (buffer-substring (point-min)(point-max)))
-                        "base64")
-                       checksum)
+         (string-equal 
+          (funcall (mel-find-function 'mime-encode-string "base64")
+                   (pgg-parse-crc24-string 
+                    (buffer-substring (point-min)(point-max))))
+          checksum)
          (error "PGP packet checksum does not match.")))))
 
 (defun pgg-decode-armor-region (start end)