<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppleArchive",
  "identifier" : "/documentation/AppleArchive/ArchiveEncryptionContext",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Apple Archive"
    ],
    "preciseIdentifier" : "s:12AppleArchive0B17EncryptionContextC"
  },
  "title" : "ArchiveEncryptionContext"
}
-->

# ArchiveEncryptionContext

An object that encapsulates all parameters, keys, and data necessary to open an encrypted archive for both encryption and decryption streams.

```
class ArchiveEncryptionContext
```

## Topics

### Creating an archive encryption context

[`init(from:)`](/documentation/AppleArchive/ArchiveEncryptionContext/init(from:))

Returns a new encryption context from the specified encrypted stream.

[`init(profile:compressionAlgorithm:compressionBlockSize:)`](/documentation/AppleArchive/ArchiveEncryptionContext/init(profile:compressionAlgorithm:compressionBlockSize:))

Returns a new encryption context from the specified profile, compression algorithm, and block size.

### Setting and retrieving keys

[`mainKey`](/documentation/AppleArchive/ArchiveEncryptionContext/mainKey)

The main key used to append data to an existing archive.

[`symmetricKey`](/documentation/AppleArchive/ArchiveEncryptionContext/symmetricKey)

The symmetric encryption key used to encrypt or decrypt an archive.

[`generateSymmetricKey()`](/documentation/AppleArchive/ArchiveEncryptionContext/generateSymmetricKey())

Generates a symmetric encryption key.

[`setSymmetricKey(_:)`](/documentation/AppleArchive/ArchiveEncryptionContext/setSymmetricKey(_:))

Sets the symmetric encryption key that the context requires for symmetric encryption mode.

[`setRecipientPrivateKey(_:)`](/documentation/AppleArchive/ArchiveEncryptionContext/setRecipientPrivateKey(_:))

Sets the recipient private key that the context requires to decrypt an archive to a specific recipient in ECDHE encryption profiles.

[`setSigningPrivateKey(_:)`](/documentation/AppleArchive/ArchiveEncryptionContext/setSigningPrivateKey(_:))

Sets the signing private key that corresponds to the signing public key that you used to create the archive.

[`setRecipientPublicKey(_:)`](/documentation/AppleArchive/ArchiveEncryptionContext/setRecipientPublicKey(_:))

Sets the recipient public key that the context requires to encrypt an archive to a specific recipient in ECDHE encryption profiles.

[`setSigningPublicKey(_:)`](/documentation/AppleArchive/ArchiveEncryptionContext/setSigningPublicKey(_:))

Sets the signing public key that the context requires to unlock a signed archive.

### Signing an encryption context

[`sign(encryptedStream:encryptionContext:)`](/documentation/AppleArchive/ArchiveEncryptionContext/sign(encryptedStream:encryptionContext:))

Signs an encrypted archive using the credentials stored in the specified encryption context.

[`signatureMode`](/documentation/AppleArchive/ArchiveEncryptionContext/signatureMode-swift.property)

The signature mode, such as an ECDSA Nist P-256 signature.

[`SignatureMode`](/documentation/AppleArchive/ArchiveEncryptionContext/SignatureMode-swift.struct)

Constants that describe the signature modes of an encryption context.

### Getting and setting encryption context properties

[`decryptAttributes()`](/documentation/AppleArchive/ArchiveEncryptionContext/decryptAttributes())

Validates decryption keys, collects archive attributes, and updates the context with decrypted archive attributes.

[`archiveIdentifier`](/documentation/AppleArchive/ArchiveEncryptionContext/archiveIdentifier)

An optional set of data that represents the archive identifier.

[`authData`](/documentation/AppleArchive/ArchiveEncryptionContext/authData)

An optional, unencrypted set of data that’s stored in the archive prologue.

[`checksumMode`](/documentation/AppleArchive/ArchiveEncryptionContext/checksumMode-swift.property)

The checksum mode, such as the 256-bit SHA-256 checksum.

[`ChecksumMode`](/documentation/AppleArchive/ArchiveEncryptionContext/ChecksumMode-swift.struct)

Constants that describe the checksum modes of an encryption context.

[`containerSize`](/documentation/AppleArchive/ArchiveEncryptionContext/containerSize)

The size of the compressed and encrypted archive.

[`encryptionMode`](/documentation/AppleArchive/ArchiveEncryptionContext/encryptionMode-swift.property)

The encryption mode, such as symmetric key encryption.

[`EncryptionMode`](/documentation/AppleArchive/ArchiveEncryptionContext/EncryptionMode-swift.struct)

Constants that describe the checksum modes of an encryption context.

[`compressionAlgorithm`](/documentation/AppleArchive/ArchiveEncryptionContext/compressionAlgorithm)

The compression algorithm, such as LZFSE.

[`ArchiveCompression`](/documentation/AppleArchive/ArchiveCompression)

Constants that describe compression algorithms.

[`compressionBlockSize`](/documentation/AppleArchive/ArchiveEncryptionContext/compressionBlockSize)

The compression block size that defines the size of the blocks, in bytes, that the context splits data into.

[`paddingSize`](/documentation/AppleArchive/ArchiveEncryptionContext/paddingSize)

An integer value that, if not zero, specifies that the size of the final archive is a multiple of the padding size.

[`profile`](/documentation/AppleArchive/ArchiveEncryptionContext/profile-swift.property)

The profile of the archve.

[`Profile`](/documentation/AppleArchive/ArchiveEncryptionContext/Profile-swift.struct)

Constants that describe the profile of an encryption context.

[`rawSize`](/documentation/AppleArchive/ArchiveEncryptionContext/rawSize)

The size of the archive raw data.

[`signatureEncryptionKey`](/documentation/AppleArchive/ArchiveEncryptionContext/signatureEncryptionKey)

The signature encryption key that the context requires to sign an encrypted archive.

### Setting a password

[`password`](/documentation/AppleArchive/ArchiveEncryptionContext/password)

The password used to encrypt or decrypt an archive.

[`generatePassword()`](/documentation/AppleArchive/ArchiveEncryptionContext/generatePassword())

Generates a new password.

[`setPassword(_:)`](/documentation/AppleArchive/ArchiveEncryptionContext/setPassword(_:))

Sets the password from the supplied string.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)