aesccm

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package aesccm implements content encryption algorithm AES-CCM for COSE as defined in RFC9053. https://datatracker.ietf.org/doc/html/rfc9053#name-aes-ccm.

(c) 2022-present, LDC Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Package ccm implements a CCM, Counter with CBC-MAC as per RFC 3610.

See https://tools.ietf.org/html/rfc3610

This code was lifted from https://github.com/qwerty-iot/dtls/blob/a3300364a283fcb490d28a93d7fcfa7ba437fbbe/ccm/ccm.go and as such was not written by the Pions authors. Like Pions this code is licensed under MIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckKey

func CheckKey(k key.Key) error

CheckKey checks whether the given key is a valid AES-CCM key.

func GenerateKey

func GenerateKey(alg int) (key.Key, error)

GenerateKey generates a new Key with given algorithm for AES-CCM.

func KeyFrom

func KeyFrom(alg int, k []byte) (key.Key, error)

KeyFrom returns a Key with given algorithm and bytes for AES-CCM.

func MaxNonceLength added in v1.1.3

func MaxNonceLength(pdatalen int) int

MaxNonceLength returns the maximum nonce length for a given plaintext length. A return value <= 0 indicates that plaintext length is too large for any nonce length.

func New

func New(k key.Key) (key.Encryptor, error)

New creates a key.Encryptor for the given AES-CCM key.

Types

type CCM added in v1.1.3

type CCM interface {
	cipher.AEAD
	// MaxLength returns the maxium length of plaintext in calls to Seal.
	// The maximum length of ciphertext in calls to Open is MaxLength()+Overhead().
	// The maximum length is related to CCM's `L` parameter (15-noncesize) and
	// is 1<<(8*L) - 1 (but also limited by the maxium size of an int).
	MaxLength() int
}

CCM is a block cipher in Counter with CBC-MAC mode. Providing authenticated encryption with associated data via the cipher.AEAD interface.

func NewCCM added in v1.1.3

func NewCCM(b cipher.Block, tagsize, noncesize int) (CCM, error)

NewCCM returns the given 128-bit block cipher wrapped in CCM. The tagsize must be an even integer between 4 and 16 inclusive and is used as CCM's `M` parameter. The noncesize must be an integer between 7 and 13 inclusive, 15-noncesize is used as CCM's `L` parameter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL