MCPcopy Create free account
hub / github.com/XTLS/Go / explicitNonceLen

Method explicitNonceLen

conn.go:275–294  ·  view source on GitHub ↗

explicitNonceLen returns the number of bytes of explicit nonce or IV included in each record. Explicit nonces are present only in CBC modes after TLS 1.0 and in certain AEAD modes in TLS 1.2.

()

Source from the content-addressed store, hash-verified

273// in each record. Explicit nonces are present only in CBC modes after TLS 1.0
274// and in certain AEAD modes in TLS 1.2.
275func (hc *halfConn) explicitNonceLen() int {
276 if hc.cipher == nil {
277 return 0
278 }
279
280 switch c := hc.cipher.(type) {
281 case cipher.Stream:
282 return 0
283 case aead:
284 return c.explicitNonceLen()
285 case cbcMode:
286 // TLS 1.1 introduced a per-record explicit IV to fix the BEAST attack.
287 if hc.version >= VersionTLS11 {
288 return c.BlockSize()
289 }
290 return 0
291 default:
292 panic("unknown cipher type")
293 }
294}
295
296// extractPadding returns, in constant time, the length of the padding to remove
297// from the end of payload. It also returns a byte which is equal to 255 if the

Callers 2

decryptMethod · 0.95
encryptMethod · 0.95

Calls 2

BlockSizeMethod · 0.80
explicitNonceLenMethod · 0.65

Tested by

no test coverage detected