@@ -149,8 +149,8 @@ type streamPacketCipher struct {
149
149
macResult []byte
150
150
}
151
151
152
- // readPacket reads and decrypt a single packet from the reader argument.
153
- func (s * streamPacketCipher ) readPacket (seqNum uint32 , r io.Reader ) ([]byte , error ) {
152
+ // readCipherPacket reads and decrypt a single packet from the reader argument.
153
+ func (s * streamPacketCipher ) readCipherPacket (seqNum uint32 , r io.Reader ) ([]byte , error ) {
154
154
if _ , err := io .ReadFull (r , s .prefix [:]); err != nil {
155
155
return nil , err
156
156
}
@@ -221,8 +221,8 @@ func (s *streamPacketCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, err
221
221
return s .packetData [:length - paddingLength - 1 ], nil
222
222
}
223
223
224
- // writePacket encrypts and sends a packet of data to the writer argument
225
- func (s * streamPacketCipher ) writePacket (seqNum uint32 , w io.Writer , rand io.Reader , packet []byte ) error {
224
+ // writeCipherPacket encrypts and sends a packet of data to the writer argument
225
+ func (s * streamPacketCipher ) writeCipherPacket (seqNum uint32 , w io.Writer , rand io.Reader , packet []byte ) error {
226
226
if len (packet ) > maxPacket {
227
227
return errors .New ("ssh: packet too large" )
228
228
}
@@ -327,7 +327,7 @@ func newGCMCipher(key, iv, unusedMacKey []byte, unusedAlgs directionAlgorithms)
327
327
328
328
const gcmTagSize = 16
329
329
330
- func (c * gcmCipher ) writePacket (seqNum uint32 , w io.Writer , rand io.Reader , packet []byte ) error {
330
+ func (c * gcmCipher ) writeCipherPacket (seqNum uint32 , w io.Writer , rand io.Reader , packet []byte ) error {
331
331
// Pad out to multiple of 16 bytes. This is different from the
332
332
// stream cipher because that encrypts the length too.
333
333
padding := byte (packetSizeMultiple - (1 + len (packet ))% packetSizeMultiple )
@@ -370,7 +370,7 @@ func (c *gcmCipher) incIV() {
370
370
}
371
371
}
372
372
373
- func (c * gcmCipher ) readPacket (seqNum uint32 , r io.Reader ) ([]byte , error ) {
373
+ func (c * gcmCipher ) readCipherPacket (seqNum uint32 , r io.Reader ) ([]byte , error ) {
374
374
if _ , err := io .ReadFull (r , c .prefix [:]); err != nil {
375
375
return nil , err
376
376
}
@@ -486,8 +486,8 @@ type cbcError string
486
486
487
487
func (e cbcError ) Error () string { return string (e ) }
488
488
489
- func (c * cbcCipher ) readPacket (seqNum uint32 , r io.Reader ) ([]byte , error ) {
490
- p , err := c .readPacketLeaky (seqNum , r )
489
+ func (c * cbcCipher ) readCipherPacket (seqNum uint32 , r io.Reader ) ([]byte , error ) {
490
+ p , err := c .readCipherPacketLeaky (seqNum , r )
491
491
if err != nil {
492
492
if _ , ok := err .(cbcError ); ok {
493
493
// Verification error: read a fixed amount of
@@ -500,7 +500,7 @@ func (c *cbcCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
500
500
return p , err
501
501
}
502
502
503
- func (c * cbcCipher ) readPacketLeaky (seqNum uint32 , r io.Reader ) ([]byte , error ) {
503
+ func (c * cbcCipher ) readCipherPacketLeaky (seqNum uint32 , r io.Reader ) ([]byte , error ) {
504
504
blockSize := c .decrypter .BlockSize ()
505
505
506
506
// Read the header, which will include some of the subsequent data in the
@@ -576,7 +576,7 @@ func (c *cbcCipher) readPacketLeaky(seqNum uint32, r io.Reader) ([]byte, error)
576
576
return c .packetData [prefixLen :paddingStart ], nil
577
577
}
578
578
579
- func (c * cbcCipher ) writePacket (seqNum uint32 , w io.Writer , rand io.Reader , packet []byte ) error {
579
+ func (c * cbcCipher ) writeCipherPacket (seqNum uint32 , w io.Writer , rand io.Reader , packet []byte ) error {
580
580
effectiveBlockSize := maxUInt32 (cbcMinPacketSizeMultiple , c .encrypter .BlockSize ())
581
581
582
582
// Length of encrypted portion of the packet (header, payload, padding).
@@ -665,7 +665,7 @@ func newChaCha20Cipher(key, unusedIV, unusedMACKey []byte, unusedAlgs directionA
665
665
return c , nil
666
666
}
667
667
668
- func (c * chacha20Poly1305Cipher ) readPacket (seqNum uint32 , r io.Reader ) ([]byte , error ) {
668
+ func (c * chacha20Poly1305Cipher ) readCipherPacket (seqNum uint32 , r io.Reader ) ([]byte , error ) {
669
669
nonce := [3 ]uint32 {0 , 0 , bits .ReverseBytes32 (seqNum )}
670
670
s := chacha20 .New (c .contentKey , nonce )
671
671
var polyKey [32 ]byte
@@ -723,7 +723,7 @@ func (c *chacha20Poly1305Cipher) readPacket(seqNum uint32, r io.Reader) ([]byte,
723
723
return plain , nil
724
724
}
725
725
726
- func (c * chacha20Poly1305Cipher ) writePacket (seqNum uint32 , w io.Writer , rand io.Reader , payload []byte ) error {
726
+ func (c * chacha20Poly1305Cipher ) writeCipherPacket (seqNum uint32 , w io.Writer , rand io.Reader , payload []byte ) error {
727
727
nonce := [3 ]uint32 {0 , 0 , bits .ReverseBytes32 (seqNum )}
728
728
s := chacha20 .New (c .contentKey , nonce )
729
729
var polyKey [32 ]byte
0 commit comments