INTERNET-DRAFT K.Kaukonen 14 July 1999 R.Thayer Expires: 17 December 1999 SSH ストリーム暗号アルゴリズム "Arcfour" このメモの位置付け このドキュメントはインターネットドラフトであり、RFC2026の第10章に記載 されているすべての条項に従う。 インターネットドラフトは、Internet Engineering Task Force(IETF)とその エリア、そしてそのワーキンググループにおいて作成中のドキュメントのこと である。その他のグループが、作成中のドキュメントをインターネットドラフト として配布することも認められている。 インターネットドラフトは最大6ヶ月間有効で、その後アップデートや置き換え をすることができる。もしくは、他のドキュメントによりいつでも無効にする ことができる。インターネットドラフトを参考文献として引用すること、もし くは "work in progress" 以上の扱いで引用するのは適切ではない。 現在のインターネットドラフトは、次のところからアクセスすることができる。 http://www.ietf.org/ietf/1id-abstracts.txt インターネットドラフトのミラーサイトのリストは、次のところからアクセス することができる。 http://www.ietf.org/shadow.html 要旨 このドキュメントでは、RC4 アルゴリズムと完全に相互運用できると考えられる Arcfourと呼ばれるアルゴリズムを記述する。RC4は、RSA Data Security, Inc. の商標である。インターネットコミュニティには、すでに商用暗号アプリケー ションにおいて利用されている暗号化アルゴリズムと相互運用することのできる 暗号へのニーズがある。相互運用により、商用暗号アルゴリズムを、IETFの標準 化プロセスを通じて開発されるプロトコルとして、スムースに移行することが 可能となる。 目次 このメモの位置付け . . . . . . . . . . . . . . . . . . . . . 1 要旨 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 目次 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1. はじめに . . . . . . . . . . . . . . . . . . . . . . . . 3 2. 本暗号アルゴリズムの前提条件 . . . . . . . . . . . . . . 3 3. アルゴリズムの詳細 . . . . . . . . . . . . . . . . . . . 3 3.1 鍵のセットアップ . . . . . . . . . . . . . . . . . . . . 3 3.2 ストリームの生成 . . . . . . . . . . . . . . . . . . . . 4 4. 知的所有権の検討 . . . . . . . . . . . . . . . . . . . . 4 5. 謝辞 . . . . . . . . . . . . . . . . . . . . . . . . . . 4 6. セキュリティに関する考察 . . . . . . . . . . . . . . . . 5 7. 参考文献 . . . . . . . . . . . . . . . . . . . . . . . . 5 8. あとがき . . . . . . . . . . . . . . . . . . . . . . . . 6 8.1 著者のアドレス . . . . . . . . . . . . . . . . . . . . . 6 8.2 このドキュメントについて . . . . . . . . . . . . . . . . 6 8.3 変更暦 . . . . . . . . . . . . . . . . . . . . . . . . . 7 付録 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 A. テストベクトル. . . . . . . . . . . . . . . . . . . . . . 8 B. サンプルコード . . . . . . . . . . . . . . . . . . . . . 11 C. 著作権表示 . . . . . . . . . . . . . . . . . . . . . . . 14 1. はじめに インターネットコミュニティには、すでに商用暗号アプリケーションにおいて 利用されている暗号化アルゴリズムと相互運用することのできる暗号へのニーズ がある。相互運用により、商用暗号アルゴリズムを、IETFの標準化プロセスを 通じて開発されるプロトコルとして、スムースに移行することが可能となる。 このドキュメントでは、この要求を満足するよう、既存のアルゴリズムに関する 記述を行う。 特にHTTP/HTMLブラウザ/サーバ市場においては、暗号化アプリケーションを開 発し、配信するための多大な努力が払われている。これらのブラウザでは通常、 RSA [RSA] によって提供されたRC4暗号化アルゴリズムを実装している。これは IETFの標準化プロセスにとって、既存のインターネット環境に配信することの できるプロトコルを作成するには有益であろう。(IETFで開発された)新しいプロ トコルをエレガントに追加することも可能である。そしてこのことにより、 ユーザが分割されることも少なくなる。なぜならば、既存のプロトコルと、IETF に基づくプロトコルの間で相互運用が可能だからである。 2. 本暗号アルゴリズムの前提条件 ここで記述されるアルゴリズムはArcfourと呼ばれるもので、この名前が選ばれ たのは、ブラウザ市場で最もポピュラーな暗号化アルゴリズムの1つであるRC4 (TM)アルゴリズムと互換性を持つからである(知的所有権の検討、の章を参照)。 Arcfourは、IPSEC [IPSEC]、SSH [SSH]、およびTLS [TLS]を含むさまざまな環境 で有用となる可能性を持っている。すでに、本アルゴリズムをどのように適用 するかについて記述しているインターネットドラフトが存在する。例えば、 [Caronni]、[SSH]、および[TLS]を参照のこと。 アルゴリズムでは、さまざまな鍵長を使用することができる。特に、40ビットの 鍵と128ビットの鍵においても使用することができる。40ビットの鍵の使用に関 しては、セキュリティに関する考察、の章を参照のこと。 商用アルゴリズムと本アルゴリズムとの互換性は、このドキュメントの付録に 記載されているテストベクトルによって生成される暗号化データを比較すること によって、テストすることができる。 3. アルゴリズムの詳細 アルゴリズム自体は、[Schneier] の "Other Stream Ciphers and Real Random Sequence Generators" の章における、397-398ページに記載されている。 3.1 鍵のセットアップ 1. 8ビットで定義される1バイトを256要素持つ配列を確保し、Sボックス として使用する。これを以下のように表す。 S [0] .. S [255] 2. Sボックスを初期化する。それぞれの要素にまず、そのインデックスの値を    格納する。 S [0] = 0; S [1] = 1; ... ; S [255] = 255; 3. 同一のサイズ(256)を持つもう1つの配列に、鍵をセットする。必要なバイト 数だけ繰り返す。 for (i = 0; i < 256; i = i + 1) S2 [i] = key [i % keylen]; 4. 変数 j をゼロにセットし、Sボックスを次のように再初期化する。 for (i = 0; i < 256; i = i + 1) { j = (j + S [i] + S2 [i]) % 256; temp = S [i]; S [i] = S [j]; S [j] = temp; } 5. iとjをゼロに初期化する。スーパーユーザ権限で実行されているプログラム が処理を嗅ぎまわっている恐れがあるならば、(常に)配列S2と鍵配列もまた ゼロへ初期化する。これはよりよい保護となる。なぜならば、鍵がゼロに され忘れられた後に鍵を計算することは、実行不可能であると考えられて いるからである。 3.2 ストリームの生成 暗号化または復号においては、入力テキストは、1度に1バイトずつ処理される。 擬似乱数バイトKは次のように生成する。 i = (i+1) % 256; j = (j + S[i]) % 256; temp = S [i]; S [i] = S [j]; S [j] = temp; t = (S [i] + S [j]) % 256; K = S [t]; 暗号化するには、Kの値と平文の次のバイトとでXORを求める。復号するには、 Kの値と、暗号文の次のバイトとでXORを求める。 4. 知的所有権の検討 このドキュメントでは、知的所有権問題については記述しない。このアルゴリ ズムの所有者、性能、暗号のセキュリティ問題、アルゴリズムに関するその 他の責任問題、実装または使用に関する一切の請求は行われない。 Arcfourアルゴリズムは、RC4アルゴリズムと完全に相互運用できると考えられ ている。"RC4"はRSA Data Security, Inc. の商標である。RC4(TM)アルゴリズム が必要であれば、RSAへ連絡のこと。 5. 謝辞 このドキュメントは、IETF内の数人の同僚との検討に基づいている。 6. セキュリティに関する考察 このアルゴリズムでは、さまざまな鍵サイズを使用することができる。もし鍵長 が128ビットであれば、このアルゴリズムは安全であると考えられる。鍵長がこ れよりかなり短い場合、特に40ビットの場合には、復号することの出来るよく 知られた攻撃法が存在する。暗号的に堅実な方法で本アルゴリズムを使用する ためには、128ビット以上の鍵長を使用するべきである。 一方、このアルゴリズムの40ビットのバージョンは米国政府による特別な規定が 存在する。すなわち40ビットの実装を採用することにより、その他のアルゴリ ズムよりも輸出がより容易であるということを意味する。 2つの平文を、同じ鍵で暗号化してはならないことを、強く推薦しなければなら ない。さもないと、平文が解読されることがある。そしてしばしば解読容易な ものとなる場合がある。もし暗号化されたメッセージ同士でXORしたならば、 結果はオリジナル平文同士のXORである。暗号化されたメッセージがテキスト 文字、クレジットカード番号、もしくはその他の知られた特性を持つバイトスト リームであれば、高い精度で平文を推定することができる。さらなる詳細は、 [DAWSON AND NIELSEN]を参照のこと。 初期のころの暗号解析結果は良好なものであったが、この暗号のセキュリティを 査定するには、最近の文献を参照するべきである。解析結果検索のための良い 出発点は、[GOLIC]であろう。インターネットニュースグループへの投稿として は、[FINNEY]、[JENKINS]および[ROOS]などから始めるのがよいであろう。 7. 参考文献 [Caronni] Caronni, G., Waldvogel, M. "The ESP Stream Transform", ftp://ds.internic.net/internet-drafts/ draft-caronni-esp-stream-01.txt, September, 1996. [COMMERCE] Test vectors issued by United States Department of Commerce, Bureau of Export Administration, Office of Strategic Trade and Foreign Policy, Strategic Trade Controls Division. [CRYPTLIB] Gutmann, P, Young, E., Plumb, C. "Cryptlib, A Portable Encryption Library", Version 2.00. http://www.cs.auckland.ac.nz/~pgut001/cryptlib.html, 1996. [DAWSON AND NIELSEN] Dawson E. and Nielsen L.: Automated Cryptoanalysis of XOR Plaintext Strings, Cryptologia, April 1996, Volume XX, Number 2. [FINNEY] Finney, H. Internet message posted to sci.crypt 21 September, 1994. [GOLIC] Golic, J. "Linear Statistical Weakness of Alleged RC4 Keystream Generator." In, W. Fumy (ed.), Proceedings of Eurocrypt '97, 226-238, Springer-Verlag, 1997. [IPSEC] Atkinson, R, "Security Architecture for the Internet Protocol", ftp://ds.internic.net/rfc/rfc1825.txt, August 1995. [JENKINS] Jenkins, B. Internet message posted to sci.crypt 22 September, 1994. [ROOS] Roos, A. Internet message posted to sci.crypt 28 September, 1995. [RSA] RSA Data Security, Inc., http://www.rsa.com, Address: RSA Data Security, Inc. 100 Marine Parkway, Suite 500, Redwood City, CA 94065-1031. [SCHNEIER] Schneier, B. "Applied Cryptography", Second Edition, http://www.counterpane.com. Published by John Wiley & Sons, Inc. ISBN 0-471-11709-9, 1996. [SSH] Ylonen, T., "SSH Transport Layer Protocol", ftp://ietf.org/internet-drafts/draft-ietf-secsh-transport-00.txt, March, 1997. [SSH ARCFOUR] Kaukonen, K. Long test vectors for Arcfour and RC4 algorithms issued by Kalle Kaukonen, SSH Communications Security, Ltd, July, 1997. [TLS] Freier, A., Karlton, P., Kocher, P., Dierks, T., "The TLS Protocol", ftp://ds.internic.net/internet-drafts/ draft-ietf-tls-protocol-00.txt, December, 1996. 8. あとがき 8.1 著者のアドレス Kalle Kaukonen SSH Communications Security Oy Tekniikantie 12 02150 Espoo Finland kalle@ssh.fi http://www.ssh.fi Rodney Thayer SSH Communications Security, Inc. 650 Castro Street, Suite 220 Mountain View, CA 94041 rodney@ipsec.com 8.2 このドキュメントについて このドキュメントは、‘ifmt'、すなわち一般的なCプラットホームで動作する ように設計されたテキストフォーマッタ、を使用してプレーンテキストで書か れた。オリジナルドキュメントはプレーンasciiであり、NROFFソースから変換 されたものである。これは、このドキュメントが発表されたときのIETFドラフト テンプレートである。 8.3 変更暦 本ドキュメントはdraft-kaukonen-cipher-arcfourの改正02版である。この改訂版 は再提出されたものである。 付録 A. テストベクトル 1. [CRYPTLIB] に記載されているテストベクトル: 平文: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 鍵: 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF 暗号文: 0x74, 0x94, 0xC2, 0xE7, 0x10, 0x4B, 0x08, 0x79 2. [COMMERCE] に記載されているテストベクトル: 平文: 0xdc, 0xee, 0x4c, 0xf9, 0x2c 鍵: 0x61, 0x8a, 0x63, 0xd2, 0xfb 暗号文: 0xf1, 0x38, 0x29, 0xc9, 0xde 3. [SSH ARCFOUR] に記載されているテストベクトル: 平文: 0x52, 0x75, 0x69, 0x73, 0x6c, 0x69, 0x6e, 0x6e, 0x75, 0x6e, 0x20, 0x6c, 0x61, 0x75, 0x6c, 0x75, 0x20, 0x6b, 0x6f, 0x72, 0x76, 0x69, 0x73, 0x73, 0x73, 0x61, 0x6e, 0x69, 0x2c, 0x20, 0x74, 0xe4, 0x68, 0x6b, 0xe4, 0x70, 0xe4, 0x69, 0x64, 0x65, 0x6e, 0x20, 0x70, 0xe4, 0xe4, 0x6c, 0x6c, 0xe4, 0x20, 0x74, 0xe4, 0x79, 0x73, 0x69, 0x6b, 0x75, 0x75, 0x2e, 0x20, 0x4b, 0x65, 0x73, 0xe4, 0x79, 0xf6, 0x6e, 0x20, 0x6f, 0x6e, 0x20, 0x6f, 0x6e, 0x6e, 0x69, 0x20, 0x6f, 0x6d, 0x61, 0x6e, 0x61, 0x6e, 0x69, 0x2c, 0x20, 0x6b, 0x61, 0x73, 0x6b, 0x69, 0x73, 0x61, 0x76, 0x75, 0x75, 0x6e, 0x20, 0x6c, 0x61, 0x61, 0x6b, 0x73, 0x6f, 0x74, 0x20, 0x76, 0x65, 0x72, 0x68, 0x6f, 0x75, 0x75, 0x2e, 0x20, 0x45, 0x6e, 0x20, 0x6d, 0x61, 0x20, 0x69, 0x6c, 0x6f, 0x69, 0x74, 0x73, 0x65, 0x2c, 0x20, 0x73, 0x75, 0x72, 0x65, 0x20, 0x68, 0x75, 0x6f, 0x6b, 0x61, 0x61, 0x2c, 0x20, 0x6d, 0x75, 0x74, 0x74, 0x61, 0x20, 0x6d, 0x65, 0x74, 0x73, 0xe4, 0x6e, 0x20, 0x74, 0x75, 0x6d, 0x6d, 0x75, 0x75, 0x73, 0x20, 0x6d, 0x75, 0x6c, 0x6c, 0x65, 0x20, 0x74, 0x75, 0x6f, 0x6b, 0x61, 0x61, 0x2e, 0x20, 0x50, 0x75, 0x75, 0x6e, 0x74, 0x6f, 0x20, 0x70, 0x69, 0x6c, 0x76, 0x65, 0x6e, 0x2c, 0x20, 0x6d, 0x69, 0x20, 0x68, 0x75, 0x6b, 0x6b, 0x75, 0x75, 0x2c, 0x20, 0x73, 0x69, 0x69, 0x6e, 0x74, 0x6f, 0x20, 0x76, 0x61, 0x72, 0x61, 0x6e, 0x20, 0x74, 0x75, 0x75, 0x6c, 0x69, 0x73, 0x65, 0x6e, 0x2c, 0x20, 0x6d, 0x69, 0x20, 0x6e, 0x75, 0x6b, 0x6b, 0x75, 0x75, 0x2e, 0x20, 0x54, 0x75, 0x6f, 0x6b, 0x73, 0x75, 0x74, 0x20, 0x76, 0x61, 0x6e, 0x61, 0x6d, 0x6f, 0x6e, 0x20, 0x6a, 0x61, 0x20, 0x76, 0x61, 0x72, 0x6a, 0x6f, 0x74, 0x20, 0x76, 0x65, 0x65, 0x6e, 0x2c, 0x20, 0x6e, 0x69, 0x69, 0x73, 0x74, 0xe4, 0x20, 0x73, 0x79, 0x64, 0xe4, 0x6d, 0x65, 0x6e, 0x69, 0x20, 0x6c, 0x61, 0x75, 0x6c, 0x75, 0x6e, 0x20, 0x74, 0x65, 0x65, 0x6e, 0x2e, 0x20, 0x2d, 0x20, 0x45, 0x69, 0x6e, 0x6f, 0x20, 0x4c, 0x65, 0x69, 0x6e, 0x6f 鍵: 0x29, 0x04, 0x19, 0x72, 0xfb, 0x42, 0xba, 0x5f, 0xc7, 0x12, 0x77, 0x12, 0xf1, 0x38, 0x29, 0xc9 暗号文: 0x35, 0x81, 0x86, 0x99, 0x90, 0x01, 0xe6, 0xb5, 0xda, 0xf0, 0x5e, 0xce, 0xeb, 0x7e, 0xee, 0x21, 0xe0, 0x68, 0x9c, 0x1f, 0x00, 0xee, 0xa8, 0x1f, 0x7d, 0xd2, 0xca, 0xae, 0xe1, 0xd2, 0x76, 0x3e, 0x68, 0xaf, 0x0e, 0xad, 0x33, 0xd6, 0x6c, 0x26, 0x8b, 0xc9, 0x46, 0xc4, 0x84, 0xfb, 0xe9, 0x4c, 0x5f, 0x5e, 0x0b, 0x86, 0xa5, 0x92, 0x79, 0xe4, 0xf8, 0x24, 0xe7, 0xa6, 0x40, 0xbd, 0x22, 0x32, 0x10, 0xb0, 0xa6, 0x11, 0x60, 0xb7, 0xbc, 0xe9, 0x86, 0xea, 0x65, 0x68, 0x80, 0x03, 0x59, 0x6b, 0x63, 0x0a, 0x6b, 0x90, 0xf8, 0xe0, 0xca, 0xf6, 0x91, 0x2a, 0x98, 0xeb, 0x87, 0x21, 0x76, 0xe8, 0x3c, 0x20, 0x2c, 0xaa, 0x64, 0x16, 0x6d, 0x2c, 0xce, 0x57, 0xff, 0x1b, 0xca, 0x57, 0xb2, 0x13, 0xf0, 0xed, 0x1a, 0xa7, 0x2f, 0xb8, 0xea, 0x52, 0xb0, 0xbe, 0x01, 0xcd, 0x1e, 0x41, 0x28, 0x67, 0x72, 0x0b, 0x32, 0x6e, 0xb3, 0x89, 0xd0, 0x11, 0xbd, 0x70, 0xd8, 0xaf, 0x03, 0x5f, 0xb0, 0xd8, 0x58, 0x9d, 0xbc, 0xe3, 0xc6, 0x66, 0xf5, 0xea, 0x8d, 0x4c, 0x79, 0x54, 0xc5, 0x0c, 0x3f, 0x34, 0x0b, 0x04, 0x67, 0xf8, 0x1b, 0x42, 0x59, 0x61, 0xc1, 0x18, 0x43, 0x07, 0x4d, 0xf6, 0x20, 0xf2, 0x08, 0x40, 0x4b, 0x39, 0x4c, 0xf9, 0xd3, 0x7f, 0xf5, 0x4b, 0x5f, 0x1a, 0xd8, 0xf6, 0xea, 0x7d, 0xa3, 0xc5, 0x61, 0xdf, 0xa7, 0x28, 0x1f, 0x96, 0x44, 0x63, 0xd2, 0xcc, 0x35, 0xa4, 0xd1, 0xb0, 0x34, 0x90, 0xde, 0xc5, 0x1b, 0x07, 0x11, 0xfb, 0xd6, 0xf5, 0x5f, 0x79, 0x23, 0x4d, 0x5b, 0x7c, 0x76, 0x66, 0x22, 0xa6, 0x6d, 0xe9, 0x2b, 0xe9, 0x96, 0x46, 0x1d, 0x5e, 0x4d, 0xc8, 0x78, 0xef, 0x9b, 0xca, 0x03, 0x05, 0x21, 0xe8, 0x35, 0x1e, 0x4b, 0xae, 0xd2, 0xfd, 0x04, 0xf9, 0x46, 0x73, 0x68, 0xc4, 0xad, 0x6a, 0xc1, 0x86, 0xd0, 0x82, 0x45, 0xb2, 0x63, 0xa2, 0x66, 0x6d, 0x1f, 0x6c, 0x54, 0x20, 0xf1, 0x59, 0x9d, 0xfd, 0x9f, 0x43, 0x89, 0x21, 0xc2, 0xf5, 0xa4, 0x63, 0x93, 0x8c, 0xe0, 0x98, 0x22, 0x65, 0xee, 0xf7, 0x01, 0x79, 0xbc, 0x55, 0x3f, 0x33, 0x9e, 0xb1, 0xa4, 0xc1, 0xaf, 0x5f, 0x6a, 0x54, 0x7f B. サンプルコード /* This code illustrates a sample implementation * of the Arcfour algorithm * Copyright (c) April 29, 1997 Kalle Kaukonen. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that this copyright * notice and disclaimer are retained. * * THIS SOFTWARE IS PROVIDED BY KALLE KAUKONEN AND CONTRIBUTORS ``AS * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KALLE * KAUKONEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ typedef struct { unsigned int x; unsigned int y; unsigned char state[256]; } ArcfourContext; void arcfour_init(ArcfourContext *ctx, const unsigned char *key, unsigned int key_len); unsigned int arcfour_byte(ArcfourContext *ctx); void arcfour_encrypt(ArcfourContext *ctx, unsigned char *dest, const unsigned char *src, unsigned int len); int main(int argc, char **argv) { unsigned char dest[500]; unsigned char mykey[] = {0x29, 0x04, 0x19, 0x72, 0xfb, 0x42, 0xba, 0x5f, 0xc7, 0x12, 0x77, 0x12, 0xf1, 0x38, 0x29, 0xc9}; unsigned char src[] = "Know thyself"; ArcfourContext mycontext; /* Initialize the algoritm */ arcfour_init(&mycontext, mykey, 16); /* Encrypt 13 bytes of the src string */ arcfour_encrypt(&mycontext, dest, src, 13); /* Now "dest" contains the encrypted string. Do whatever you please with it... */ return 0; } void arcfour_init(ArcfourContext *ctx, const unsigned char *key, unsigned int key_len) { unsigned int t, u; unsigned int keyindex; unsigned int stateindex; unsigned char *state; unsigned int counter; state = ctx->state; ctx->x = 0; ctx->y = 0; for (counter = 0; counter < 256; counter++) state[counter] = counter; keyindex = 0; stateindex = 0; for (counter = 0; counter < 256; counter++) { t = state[counter]; stateindex = (stateindex + key[keyindex] + t) & 0xff; u = state[stateindex]; state[stateindex] = t; state[counter] = u; if (++keyindex >= key_len) keyindex = 0; } } unsigned int arcfour_byte(ArcfourContext *ctx) { unsigned int x; unsigned int y; unsigned int sx, sy; unsigned char *state; state = ctx->state; x = (ctx->x + 1) & 0xff; sx = state[x]; y = (sx + ctx->y) & 0xff; sy = state[y]; ctx->x = x; ctx->y = y; state[y] = sx; state[x] = sy; return state[(sx + sy) & 0xff]; } void arcfour_encrypt(ArcfourContext *ctx, unsigned char *dest, const unsigned char *src, unsigned int len) { unsigned int i; for (i = 0; i < len; i++) dest[i] = src[i] ^ arcfour_byte(ctx); } C. 著作権表示 Copyright (C) The Internet Society 1999. All Rights Reserved. This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organisations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process shall be followed, or as required to translate it into languages other than English. The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns. This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 本ドラフトの有効期限は、1999/12/9である。 日本語訳 西原 啓輔 2001年5月 訳者は、訳出した文書を利用することにより発生したいかなる損害に対しても 責任を負いません。 本文書には、技術的あるいは翻訳上の誤りがある可能性があります。技術的に 正しい知識を獲得しなければならない場合は、InterNIC/IETFから発行されて いる原文を参照してください。