#ecdsa #macos #keychain #signatures #touchid


Rust access to macOS Keychain Services, including TouchID-guarded access to cryptographic keys stored in the Secure Enclave Processor (SEP)

4 releases

✓ Uses Rust 2018 edition

0.1.1 Dec 10, 2018
0.1.0 Nov 6, 2018
0.0.2 Nov 1, 2018
0.0.1 Oct 31, 2018

#44 in Hardware support

Download history 11/week @ 2018-12-12 17/week @ 2018-12-19 1/week @ 2018-12-26 12/week @ 2019-01-02 9/week @ 2019-01-09 6/week @ 2019-01-16 1/week @ 2019-01-23 3/week @ 2019-01-30 1/week @ 2019-02-06 1/week @ 2019-02-13 1/week @ 2019-02-20 8/week @ 2019-02-27 7/week @ 2019-03-06 41/week @ 2019-03-20

62 downloads per month
Used in 1 crate



Keychain Services for Rust 🔐 iqlusion

Crate Build Status Apache 2.0 Licensed Maintenance Status: Experimental

Rust binding for macOS Keychain Services, including TouchID-guarded access to cryptographic keys stored in the Secure Enclave Processor (SEP).

This binding aims to provide a thin wrapper using largely the same type names as Keychain Services itself, but also provide a safe, mostly idiomatic API which does not rely on e.g. Core Foundation types.

NOTE: This is an unofficial binding which is in no way affiliated with Apple!



This crate is experimental and may have bugs/memory safety issues. USE AT YOUR OWN RISK!

Below is a rough outline of the Keychain Service API and what is supported by this crate:

  • Keychains (SecKeychain)
    • Creating keychains
    • Deleting keychains
    • Open keychain (SecKeychainOpen)
    • Keychain status (SecKeychainGetStatus)
    • Keychain version (SecKeychainGetVersion)
    • Set default keychain (SecKeychainSetDefault)
  • Keychain Items (SecKeychainItem)
    • Creating keychain items
    • Fetching keychain items
    • Getting keychain item attributes
    • Deleting keychain items
  • Certificates / Identities (SecCertificate)
    • Creating certificates
    • Deleting certificates
    • Querying certificates
    • Signing certificates
  • Cryptographic keys (SecKey)
    • Generating cryptographic keys
    • Importing cryptographic keys
    • Exporting cryptographic keys
    • Deleting cryptographic keys
    • Querying cryptographic keys
    • Querying cryptographic key attributes
    • Digital signatures (ECDSA/RSA)
    • Encryption
  • Passwords
    • Creating passwords
    • Querying passwords
    • Deleting passwords


This crate has two suites of tests:

  • Core: cargo test - run a minimal set of tests (e.g. in CI) that work everywhere, but don't cover all functionality.
  • Interactive: cargo test --features=interactive-tests --no-run compile tests which require user interactions, and additionally must be signed by macOS's code signing in order to work. See code signing notes.

Code Signing

The Keychain Service API requires signed code to access much of its functionality. Accessing many APIs from an unsigned app will return an ErrorKind::MissingEntitlement.

Follow the instructions here to create a self-signed code signing certificate: https://developer.apple.com/library/archive/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html

You will need to use the codesign command-line utility (or XCode) to sign your code before it will be able to access most Keychain Services API functionality.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.


~27K SLoC