Skip to content

Commit 230a88a

Browse files
committed
Add support for changing kSecUseDataProtectionKeychain
Rename variables and functions to match Apple
1 parent f65a47c commit 230a88a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

keychain.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,23 @@ var syncTypeRef = map[Synchronizable]C.CFTypeRef{
190190
SynchronizableNo: C.CFTypeRef(C.kCFBooleanFalse),
191191
}
192192

193+
// DataProtection is the items data protection status
194+
type UseDataProtectionKeychain int
195+
196+
const (
197+
// UseDataProtectionKeychainYes enables data protection mode
198+
UseDataProtectionKeychainYes = 1
199+
// UseDataProtectionKeychainNo disables data protection mode
200+
UseDataProtectionKeychainNo = 2
201+
)
202+
203+
// DataProtectionKey is the key type for DataProtection
204+
var UseDataProtectionKey = attrKey(C.CFTypeRef(C.kSecUseDataProtectionKeychain))
205+
var dataProtectionTypeRef = map[UseDataProtectionKeychain]C.CFTypeRef{
206+
UseDataProtectionKeychainYes: C.CFTypeRef(C.kCFBooleanTrue),
207+
UseDataProtectionKeychainNo: C.CFTypeRef(C.kCFBooleanFalse),
208+
}
209+
193210
// Accessible is the items accessibility
194211
type Accessible int
195212

@@ -303,6 +320,11 @@ func (k *Item) SetSynchronizable(sync Synchronizable) {
303320
}
304321
}
305322

323+
// SetSynchronizable sets the synchronizable attribute
324+
func (k *Item) SetUseDataProtectionKeychain(dataProtection UseDataProtectionKeychain) {
325+
k.attr[UseDataProtectionKey] = dataProtectionTypeRef[dataProtection]
326+
}
327+
306328
// SetAccessible sets the accessible attribute
307329
func (k *Item) SetAccessible(accessible Accessible) {
308330
if accessible != AccessibleDefault {

0 commit comments

Comments
 (0)