Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,23 @@ var syncTypeRef = map[Synchronizable]C.CFTypeRef{
SynchronizableNo: C.CFTypeRef(C.kCFBooleanFalse),
}

// DataProtection is the items data protection status
type UseDataProtectionKeychain int

const (
// UseDataProtectionKeychainYes enables data protection mode
UseDataProtectionKeychainYes = 1
// UseDataProtectionKeychainNo disables data protection mode
UseDataProtectionKeychainNo = 2
)

// DataProtectionKey is the key type for DataProtection
var UseDataProtectionKey = attrKey(C.CFTypeRef(C.kSecUseDataProtectionKeychain))
var dataProtectionTypeRef = map[UseDataProtectionKeychain]C.CFTypeRef{
UseDataProtectionKeychainYes: C.CFTypeRef(C.kCFBooleanTrue),
UseDataProtectionKeychainNo: C.CFTypeRef(C.kCFBooleanFalse),
}

// Accessible is the items accessibility
type Accessible int

Expand Down Expand Up @@ -303,6 +320,11 @@ func (k *Item) SetSynchronizable(sync Synchronizable) {
}
}

// SetSynchronizable sets the synchronizable attribute
Copy link
Member

@joshblum joshblum Mar 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// SetSynchronizable sets the synchronizable attribute
// SetUseDataProtectionKeychain sets the data protection attribute

func (k *Item) SetUseDataProtectionKeychain(dataProtection UseDataProtectionKeychain) {
k.attr[UseDataProtectionKey] = dataProtectionTypeRef[dataProtection]
}

// SetAccessible sets the accessible attribute
func (k *Item) SetAccessible(accessible Accessible) {
if accessible != AccessibleDefault {
Expand Down