Skip to main content

Module write

Module write 

Source
Expand description

Creating keychains and adding items.

Three operations, all of which have to agree with macOS byte for byte to be useful:

  • create writes a new database: the four schema tables replayed from apple_schema, an empty table per record relation, and a metadata record holding a fresh DbBlob sealed with the caller’s password.
  • KeychainFile::add_password stores an item: a wrapped item key in the symmetric-key table and the encrypted secret in the item record.
  • KeychainFile::add_identity stores a certificate and its private key, adding the certificate relation to the schema first if the keychain has never held one.

Every write rebuilds the indexes of the tables it touched, because their offsets are table-relative: a stale index region sends macOS into the middle of a record and it reports errSecNoSuchAttr.

Structs§

CreateOptions
Settings for a new keychain. The defaults are what macOS writes.
NewIdentity
An identity to store: a certificate and the private key that matches it.
NewItem
What to store for a new password item.

Functions§

create
Build a new keychain protected by password.
expected_format
Formats used by the password relations, for tests and diagnostics.
format_timestamp
Format a timestamp the way keychain date attributes are written.
now_timestamp
Timestamp for right now.
schema_of_created
Verify a schema built by create against the file’s own declarations.