# Class: AEADEncryptedDataPacket

## AEADEncryptedDataPacket()

Implementation of the Symmetrically Encrypted Authenticated Encryption with Additional Data (AEAD) Protected Data Packet

https://tools.ietf.org/html/draft-ford-openpgp-format-00#section-2.1: AEAD Protected Data Packet

## Constructor

#### new AEADEncryptedDataPacket()

Source:
  - packet/aead_encrypted_data.js, line 53

### Members

#### aeadAlgorithm :enums.aead

##### Type:

- enums.aead

Source:
  - packet/aead_encrypted_data.js, line 58

#### cipherAlgorithm :enums.symmetric

##### Type:

- enums.symmetric

Source:
  - packet/aead_encrypted_data.js, line 56

### Methods

#### (async) crypt(fn, key, data) → {Promise.<(Uint8Array|ReadableStream.<Uint8Array>)>}

En/decrypt the payload.

##### Parameters:

Name | Type | Description
--- | --- | ---
`fn` | encrypt | decrypt | Whether to encrypt or decrypt
`key` | Uint8Array | The session key used to en/decrypt the payload
`data` | Uint8Array | ReadableStream.<Uint8Array> | The data to en/decrypt

Source:
  - packet/aead_encrypted_data.js, line 136

##### Returns:

Type
  Promise.<(Uint8Array|ReadableStream.<Uint8Array>)>

#### (async) decrypt(sessionKeyAlgorithm, key, configopt)

Decrypt the encrypted payload.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`sessionKeyAlgorithm` | enums.symmetric |  | The session key's cipher algorithm
`key` | Uint8Array |  | The session key used to encrypt the payload
`config` | Object | <optional> | Full configuration, defaults to openpgp.config

Source:
  - packet/aead_encrypted_data.js, line 102

##### Throws:

if decryption was not successful

Type
  Error

#### (async) encrypt(sessionKeyAlgorithm, key, configopt)

Encrypt the packet payload.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`sessionKeyAlgorithm` | enums.symmetric |  | The session key's cipher algorithm
`key` | Uint8Array |  | The session key used to encrypt the payload
`config` | Object | <optional> | Full configuration, defaults to openpgp.config

Source:
  - packet/aead_encrypted_data.js, line 118

##### Throws:

if encryption was not successful

Type
  Error

#### (async) read(bytes)

Parse an encrypted payload of bytes in the order: version, IV, ciphertext (see specification)

##### Parameters:

Name | Type | Description
--- | --- | ---
`bytes` | Uint8Array | ReadableStream.<Uint8Array> |

Source:
  - packet/aead_encrypted_data.js, line 70

##### Throws:

on parsing failure

Type
  Error

#### write() → {Uint8Array|ReadableStream.<Uint8Array>}

Write the encrypted payload of bytes in the order: version, IV, ciphertext (see specification)

Source:
  - packet/aead_encrypted_data.js, line 90

##### Returns:

The encrypted payload.

Type
  Uint8Array | ReadableStream.<Uint8Array>