cose

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Encrypt0MessageTag = 16

	Encrypt0Context = "Encrypt0"
)
View Source
const (
	KeyTypeECDSA     = cose.KeyTypeECDSA
	KeyTypeSymmetric = 4

	AlgorithmAESGCM128 = 1

	CurveNISTP521 = 3
)

Variables

View Source
var (
	AESGCMNumbers = map[int]int{
		128: coseAlgA128GCM,
		192: coseAlgA192GCM,
		256: coseAlgA256GCM,
	}

	ErrInvalidAESKeyLength = errors.New("invalid key size")
	ErrUnsupportedAlg      = errors.New("unsupported algorithm")
)
View Source
var (
	ErrUnexpectedKeyType   = errors.New("unexpected key type")
	ErrUnexpectedAlgorithm = errors.New("unexpected algorithm")
)

Functions

func MarshallAESKey

func MarshallAESKey(aeskey []byte) ([]byte, error)

func MarshallECKey

func MarshallECKey(eckey *ecdsa.PublicKey) ([]byte, error)

func UnMarshallAESKey

func UnMarshallAESKey(data []byte) ([]byte, error)

func UnMarshallECKey

func UnMarshallECKey(data []byte) (*ecdsa.PublicKey, error)

Types

type AESKey

type AESKey struct {
	K []byte `cbor:"-1,keyasint"`
	// contains filtered or unexported fields
}

type Encrypt0Message

type Encrypt0Message struct {
	Headers    *cose.Headers
	Payload    []byte
	Ciphertext []byte
}

Encrypt0Message represents an unencrypted Encrypt0Message.

func Encrypt0MessageFromCBOR

func Encrypt0MessageFromCBOR(marshalled []byte) (message *Encrypt0Message, err error)

func NewEncrypt0Message

func NewEncrypt0Message(payload []byte) (message *Encrypt0Message)

func (*Encrypt0Message) AddKID

func (m *Encrypt0Message) AddKID(kid []byte)

func (*Encrypt0Message) DecodeAESGCMMessage

func (m *Encrypt0Message) DecodeAESGCMMessage(key []byte) (err error)

func (*Encrypt0Message) EncodeAESGCMMessage

func (m *Encrypt0Message) EncodeAESGCMMessage(key []byte) (err error)

func (*Encrypt0Message) MarshalCBOR

func (m *Encrypt0Message) MarshalCBOR() (encoded []byte, err error)

type SignMessage

type SignMessage struct {
	*cose.SignMessage
}

func NewSignMessage

func NewSignMessage(payload []byte) (msg *SignMessage)

NewSignMessage creates a basic sign message with a payload.

func SignMessageFromCBOR

func SignMessageFromCBOR(encSignMessage []byte) (m *SignMessage, err error)

SignMessageFromCBOR takes CBOR encoded data and returns a new SignMessage.

func (*SignMessage) ESSignatureDigests added in v0.2.6

func (sm *SignMessage) ESSignatureDigests(publicKey *ecdsa.PublicKey, kid []byte) (digests [][]byte, err error)

ESSignatureDigests returns the hashed signature digests of the message signatures. We take the public key of the (possibly unknown) private key for the curve params.

func (*SignMessage) SignWithESKey

func (sm *SignMessage) SignWithESKey(privateKey *ecdsa.PrivateKey, kid []byte) (err error)

SignWithESKey adds a signer with kid, and then signs the message with the ECDSA Key.

func (*SignMessage) UnmarshalCBOR added in v0.2.6

func (sm *SignMessage) UnmarshalCBOR(data []byte) error

func (*SignMessage) VerifyWithESKey

func (sm *SignMessage) VerifyWithESKey(publicKey *ecdsa.PublicKey) (err error)

VerifyWithESKey verifies if the SignMessage has been signed with the given key.

Jump to

Keyboard shortcuts

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