github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/crypto/rc4/rc4.go (about)

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // パッケージrc4はBruce Schneierの「応用暗号化」で定義されている
     6  // RC4暗号を実装しています。
     7  //
     8  // RC4は暗号学的に脆弱であり、安全なアプリケーションには使用すべきではありません。
     9  package rc4
    10  
    11  // Cipherは特定のキーを使用したRC4のインスタンスです。
    12  type Cipher struct {
    13  	s    [256]uint32
    14  	i, j uint8
    15  }
    16  
    17  type KeySizeError int
    18  
    19  func (k KeySizeError) Error() string
    20  
    21  // NewCipherは新しい [Cipher] を作成し、返します。キーアーギュメントはRC4キーであり、少なくとも1バイト、最大256バイトである必要があります。
    22  func NewCipher(key []byte) (*Cipher, error)
    23  
    24  // Resetはキーデータをゼロ化し、 [Cipher] を使用できなくします。
    25  //
    26  // Deprecated: Resetはキーがプロセスのメモリから完全に削除されることを保証できません。
    27  func (c *Cipher) Reset()
    28  
    29  // XORKeyStreamは、キーストリームを使用してsrcとXOR演算した結果をdstに設定します。
    30  // Dstとsrcは完全に重なるか、まったく重ならない必要があります。
    31  func (c *Cipher) XORKeyStream(dst, src []byte)