github.com/pion/dtls/v2@v2.2.12/internal/ciphersuite/aes_256_ccm.go (about)

     1  // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
     2  // SPDX-License-Identifier: MIT
     3  
     4  package ciphersuite
     5  
     6  import (
     7  	"github.com/pion/dtls/v2/pkg/crypto/ciphersuite"
     8  	"github.com/pion/dtls/v2/pkg/crypto/clientcertificate"
     9  )
    10  
    11  // Aes256Ccm is a base class used by multiple AES-CCM Ciphers
    12  type Aes256Ccm struct {
    13  	AesCcm
    14  }
    15  
    16  func newAes256Ccm(clientCertificateType clientcertificate.Type, id ID, psk bool, cryptoCCMTagLen ciphersuite.CCMTagLen, keyExchangeAlgorithm KeyExchangeAlgorithm, ecc bool) *Aes256Ccm {
    17  	return &Aes256Ccm{
    18  		AesCcm: AesCcm{
    19  			clientCertificateType: clientCertificateType,
    20  			id:                    id,
    21  			psk:                   psk,
    22  			cryptoCCMTagLen:       cryptoCCMTagLen,
    23  			keyExchangeAlgorithm:  keyExchangeAlgorithm,
    24  			ecc:                   ecc,
    25  		},
    26  	}
    27  }
    28  
    29  // Init initializes the internal Cipher with keying material
    30  func (c *Aes256Ccm) Init(masterSecret, clientRandom, serverRandom []byte, isClient bool) error {
    31  	const prfKeyLen = 32
    32  	return c.AesCcm.Init(masterSecret, clientRandom, serverRandom, isClient, prfKeyLen)
    33  }