Lines Matching refs:hc

193 func (hc *halfConn) setErrorLocked(err error) error {
194 hc.err = err
198 func (hc *halfConn) error() error {
202 err := hc.err
208 func (hc *halfConn) prepareCipherSpec(version uint16, cipher interface{}, mac macFunction) {
209 hc.wireVersion = version
210 protocolVersion, ok := wireToVersion(version, hc.isDTLS)
214 hc.version = protocolVersion
215 hc.nextCipher = cipher
216 hc.nextMac = mac
221 func (hc *halfConn) changeCipherSpec(config *Config) error {
222 if hc.nextCipher == nil {
225 hc.cipher = hc.nextCipher
226 hc.mac = hc.nextMac
227 hc.nextCipher = nil
228 hc.nextMac = nil
229 hc.config = config
230 hc.incEpoch()
233 hc.cipher = nullCipher{}
234 hc.mac = nil
240 func (hc *halfConn) useTrafficSecret(version uint16, suite *cipherSuite, secret []byte, side traffi…
241 hc.wireVersion = version
242 protocolVersion, ok := wireToVersion(version, hc.isDTLS)
246 hc.version = protocolVersion
247 hc.cipher = deriveTrafficAEAD(version, suite, secret, side)
248 if hc.config.Bugs.NullAllCiphers {
249 hc.cipher = nullCipher{}
251 hc.trafficSecret = secret
252 hc.incEpoch()
258 func (hc *halfConn) resetCipher() {
259 hc.cipher = nil
260 hc.incEpoch()
264 func (hc *halfConn) incSeq(isOutgoing bool) {
267 if hc.isDTLS {
272 increment += uint64(hc.seq[i])
273 hc.seq[i] = byte(increment)
284 hc.updateOutSeq()
288 func (hc *halfConn) incNextSeq() {
289 for i := len(hc.nextSeq) - 1; i >= 0; i-- {
290 hc.nextSeq[i]++
291 if hc.nextSeq[i] != 0 {
300 func (hc *halfConn) incEpoch() {
301 if hc.isDTLS {
303 hc.seq[i]++
304 if hc.seq[i] != 0 {
311 copy(hc.seq[2:], hc.nextSeq[:])
312 for i := range hc.nextSeq {
313 hc.nextSeq[i] = 0
316 for i := range hc.seq {
317 hc.seq[i] = 0
321 hc.updateOutSeq()
324 func (hc *halfConn) updateOutSeq() {
325 if hc.config.Bugs.SequenceNumberMapping != nil {
326 seqU64 := binary.BigEndian.Uint64(hc.seq[:])
327 seqU64 = hc.config.Bugs.SequenceNumberMapping(seqU64)
328 binary.BigEndian.PutUint64(hc.outSeq[:], seqU64)
331 copy(hc.outSeq[:2], hc.seq[:2])
335 copy(hc.outSeq[:], hc.seq[:])
338 func (hc *halfConn) recordHeaderLen() int {
339 if hc.isDTLS {
413 func (hc *halfConn) decrypt(b *block) (ok bool, prefixLen int, contentType recordType, alertValue a…
414 recordHeaderLen := hc.recordHeaderLen()
420 if hc.mac != nil {
421 macSize = hc.mac.Size()
427 seq := hc.seq[:]
428 if hc.isDTLS {
434 if hc.cipher != nil {
435 switch c := hc.cipher.(type) {
450 if hc.version < VersionTLS13 {
468 if hc.version >= VersionTLS11 || hc.isDTLS {
481 if hc.version == VersionSSL30 {
504 if hc.version >= VersionTLS13 {
520 if hc.mac != nil {
531 …localMAC := hc.mac.MAC(hc.inDigestBuf, seq, b.data[:3], b.data[recordHeaderLen-2:recordHeaderLen],…
536 hc.inDigestBuf = localMAC
538 hc.incSeq(false)
572 func (hc *halfConn) encrypt(b *block, explicitIVLen int, typ recordType) (bool, alert) {
573 recordHeaderLen := hc.recordHeaderLen()
576 if hc.mac != nil {
577 …mac := hc.mac.MAC(hc.outDigestBuf, hc.outSeq[0:], b.data[:3], b.data[recordHeaderLen-2:recordHeade…
582 hc.outDigestBuf = mac
588 if hc.cipher != nil {
590 if hc.version >= VersionTLS13 {
591 paddingLen := hc.config.Bugs.RecordPadding
592 if hc.config.Bugs.OmitRecordContents {
603 switch c := hc.cipher.(type) {
609 nonce := hc.outSeq[:]
617 if hc.version < VersionTLS13 {
619 copy(additionalData, hc.outSeq[:])
638 prefix, finalBlock := padToBlockSize(payload, blockSize, hc.config)
653 hc.incSeq(true)
722 func (hc *halfConn) newBlock() *block {
723 b := hc.bfree
727 hc.bfree = b.link
737 func (hc *halfConn) freeBlock(b *block) {
738 b.link = hc.bfree
739 hc.bfree = b
745 func (hc *halfConn) splitBlock(b *block, n int) (*block, *block) {
749 bb := hc.newBlock()