ChaChaPoly

public enum ChaChaPoly : Cipher

ChaCha20-Poly1305 as described in RFC 7539 with 96-bit nonces.

  • Encrypts and seals data using ChaCha20-Poly1305.

    Throws

    CipherError errors

    Declaration

    Swift

    public static func seal<Plaintext: DataProtocol, AuthenticatedData: DataProtocol>
        (_ message: Plaintext, using key: SymmetricKey, nonce: Nonce? = nil, authenticating authenticatedData: AuthenticatedData) throws -> SealedBox

    Parameters

    message

    The message to encrypt and authenticate

    key

    A 256-bit encryption key

    nonce

    A nonce for ChaChaPoly encryption. The nonce must be unique for every use of the key to seal data. It can be safely generated with ChaChaPoly.Nonce()

    authenticatedData

    Data to authenticate as part of the seal

    Return Value

    A sealed box returning the authentication tag (seal) and the ciphertext

  • Encrypts and seals data using ChaCha20-Poly1305.

    Throws

    CipherError errors

    Declaration

    Swift

    public static func seal<Plaintext: DataProtocol>
        (_ message: Plaintext, using key: SymmetricKey, nonce: Nonce? = nil) throws -> SealedBox

    Parameters

    message

    The message to encrypt and authenticate

    key

    A 256-bit encryption key

    nonce

    A nonce for ChaChaPoly encryption. The nonce must be unique for every use of the key to seal data. It can be safely generated with ChaChaPoly.Nonce()

    Return Value

    A sealed box returning the authentication tag (seal) and the ciphertext

  • Authenticates and decrypts data using ChaCha20-Poly1305.

    Throws

    CipherError errors. If the authentication of the sealedbox failed, incorrectTag is thrown.

    Declaration

    Swift

    public static func open<AuthenticatedData: DataProtocol>
        (_ sealedBox: SealedBox, using key: SymmetricKey, authenticating authenticatedData: AuthenticatedData) throws -> Data

    Parameters

    sealedBox

    The sealed box to authenticate and decrypt

    key

    A 256-bit encryption key

    nonce

    The nonce that was provided for encryption.

    authenticatedData

    Data that was authenticated as part of the seal

    Return Value

    The ciphertext if opening was successful

  • Authenticates and decrypts data using ChaCha20-Poly1305.

    Throws

    CipherError errors. If the authentication of the sealedbox failed, incorrectTag is thrown.

    Declaration

    Swift

    public static func open
        (_ sealedBox: SealedBox, using key: SymmetricKey) throws -> Data

    Parameters

    sealedBox

    The sealed box to authenticate and decrypt

    key

    A 256-bit encryption key

    nonce

    The nonce that was provided for encryption.

    Return Value

    The ciphertext if opening was successful

  • Undocumented

    See more

    Declaration

    Swift

    @frozen
    public struct SealedBox : AEADSealedBox

ChaChaPoly + Nonce