書いてる人: 高橋カヲル | [mixi] | [PGP] | [TETRiS DS] | [portscout] | [RSS]
Solaris も libc.so.1 が消えるとそれなりに痛い。 /usr/sbin/static/ と /sbin/ が使えるのはいいのだが、肝心の libc.so.1 がないのでお手上げ。
office で上映会やってた。
stream cipher の理解が甘かった。
blocklen - data block length in bytes (value 1 must be used for stream cipher algorithms).
ってあるから stream は 1byte 以下の単位なんじゃろうきっと。手元の本で
の違いをきちんと理解するか。
$USER でなく $SUDO_USER を使えば sudo を叩いたユーザを取れることに気づく。ので、某所の Makefile を書き換える。
update: sudo cvs -d :ext:$$SUDO_USER@cvs.example.org:/export/cvsroot update -dP
こういうことをしたかっただけ。諸事情で :local も :pserver も使えない。
Randal の YAPC での発表資料。
An Introduction to Linguistics for Perl Developers or "Wouldn't know a tagmeme if it bit me on the parse."
理解を深めるために実装してみた。
(eval-when-compile
(require 'cl))
(defun rc4-swap-byte (array index1 index2)
"Swap array[i] array[j] value."
(let ((swapbyte))
(setq swapbyte (aref array index1))
(aset array index1 (aref array index2))
(aset array index2 swapbyte))
array)
(defun rc4-init-key (keydata)
(let ((state (make-vector 256 0)))
(dotimes (i 256)
(aset state i i))
(let ((index1 0) (index2 0))
(dotimes (i 256)
(setq index2
(mod (+ (aref keydata index1) (aref state i) index2) 256))
(rc4-swap-byte state i index2)
(setq index1 (mod (1+ index1) (length keydata)))))
(list 0 0 state)))
(defun rc4 (input key)
(let ((x (nth 0 key)) (y (nth 1 key)) (state (nth 2 key))
(output (make-vector (length input) 0)))
(dotimes (i (length input))
(setq x (mod (1+ x) 256))
(setq y (mod (+ (aref state x) y) 256))
(rc4-swap-byte state x y)
(let (xorindex)
(setq xorindex (mod (+ (aref state x) (aref state y)) 256))
(aset output i
(logxor (aref input i) (aref state xorindex)))))
(setcar (cdr key) y)
(setcar key x)
output))
/usr/src/crypto/openssl/crypto/rc4/rc4test.c から testcase をパクってくる。
(equal
(let ((key))
(progn
(setq key (rc4-init-key [#x01 #x23 #x45 #x67 #x89 #xab #xcd #xef]))
(rc4-encrypt [#x01 #x23 #x45 #x67 #x89 #xab #xcd #xef] key)))
[#x75 #xb7 #x87 #x80 #x99 #xe0 #xc5 #x96])
Powered by 早起き生活