* * Copyright 2018 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http:www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *

package conn

import (
	
	
	
)

GcmTagSize is the GCM tag size is the difference in length between plaintext and ciphertext. From crypto/cipher/gcm.go in Go crypto library.
	GcmTagSize = 16
)
ErrAuth occurs on authentication failure.
var ErrAuth = errors.New("message authentication failed")
SliceForAppend takes a slice and a requested number of bytes. It returns a slice with the contents of the given slice followed by that many bytes and a second slice that aliases into it and contains only the extra bytes. If the original slice has sufficient capacity then no allocation is performed.
func ( []byte,  int) (,  []byte) {
	if  := len() + ; cap() >=  {
		 = [:]
	} else {
		 = make([]byte, )
		copy(, )
	}
	 = [len():]
	return , 
}
ParseFramedMsg parse the provided buffer and returns a frame of the format msgLength+msg and any remaining bytes in that buffer.
If the size field is not complete, return the provided buffer as remaining buffer.
	if len() < MsgLenFieldSize {
		return nil, , nil
	}
	 := [:MsgLenFieldSize]
	 := binary.LittleEndian.Uint32()
	if  >  {
		return nil, nil, fmt.Errorf("received the frame length %d larger than the limit %d", , )
	}
Frame is not complete yet.
		return nil, , nil
	}
	return [:MsgLenFieldSize+], [MsgLenFieldSize+:], nil