Class CMS

Cryptographic Message Syntax (aka PKCS #7)

CMS describes an encapsulation syntax for data protection. It is used to digitally sign, digest, authenticate, or encrypt arbitrary message content.

See RFC 5652 for all the details.

Hierarchy

  • CMS

Index

Constructors

Properties

Methods

Constructors

constructor

  • Creates a new instance with a keychain

    Parameters

    • keychain: Keychain

      the available keys

    • dek: string

    Returns CMS

Properties

keychain

keychain: Keychain

Methods

decrypt

  • decrypt(cmsData: Uint8Array): Promise<Uint8Array>
  • Reads some protected data.

    The keychain must contain one of the keys used to encrypt the data. If none of the keys exists, an Error is returned with the property 'missingKeys'. It is array of key ids.

    Parameters

    • cmsData: Uint8Array

      The CMS encrypted data to decrypt.

    Returns Promise<Uint8Array>

encrypt

  • encrypt(name: string, plain: Uint8Array): Promise<Uint8Array>
  • Creates some protected data.

    The output Uint8Array contains the PKCS #7 message in DER.

    Parameters

    • name: string

      The local key name.

    • plain: Uint8Array

      The data to encrypt.

    Returns Promise<Uint8Array>