INNER CODE UNIT · Swift

decrypt

jedisct1/swift-sodium · Sources/Sodium/Aead.swift:95

    func decrypt(authenticatedCipherText: Bytes, secretKey: Key, nonce: Nonce, additionalData: Bytes? = nil) -> Bytes? {
        guard authenticatedCipherText.count >= ABytes else { return nil }

        var message = Bytes(count: authenticatedCipherText.count - ABytes)
        var messageLen: UInt64 = 0

        guard crypto_aead_aegis128l_decrypt(
            &message, &messageLen,
            nil,
            authenticatedCipherText, UInt64(authenticatedCipherText.count),
            additionalData, UInt64(additionalData?.count ?? 0),
            nonce, secretKey
        ).exitCode == .SUCCESS else { return nil }

        return message
    }
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…