aes_256_ccm.go 1.0 KB

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