key

Wraps an existing raw key ByteArray as a Dir encryption key.

The byte length must match the Content Encryption Algorithm's required key size (e.g. 16 bytes for A128GCM, 32 bytes for A256GCM). The returned EncryptionKey is an EncryptionKey.EncryptionKeyPair usable for both encryption and decryption since dir uses the same symmetric key for both operations.

Return

an EncryptionKey wrapping the provided key bytes.

Parameters

key

the raw symmetric key bytes to wrap.

keyId

optional key ID to associate with this key. Defaults to null.