Documentation ¶
Index ¶
- Constants
- Variables
- func AddItem(item Item) error
- func ArrayToCFArray(a []C.CFTypeRef) C.CFArrayRef
- func BytesToCFData(b []byte) (C.CFDataRef, error)
- func CFArrayToArray(cfArray C.CFArrayRef) (a []C.CFTypeRef)
- func CFDataToBytes(cfData C.CFDataRef) ([]byte, error)
- func CFDictionaryToMap(cfDict C.CFDictionaryRef) (m map[C.CFTypeRef]C.CFTypeRef)
- func CFNumberToInterface(cfNumber C.CFNumberRef) interface{}
- func CFStringToString(s C.CFStringRef) string
- func CFTypeDescription(ref C.CFTypeRef) string
- func Convert(ref C.CFTypeRef) (interface{}, error)
- func ConvertCFDictionary(d C.CFDictionaryRef) (map[interface{}]interface{}, error)
- func ConvertMapToCFDictionary(attr map[string]interface{}) (C.CFDictionaryRef, error)
- func DeleteGenericPasswordItem(service string, account string) error
- func DeleteItem(item Item) error
- func DeleteItemRef(ref C.CFTypeRef) error
- func GetAccountsForService(service string) ([]string, error)
- func GetGenericPassword(service string, account string, label string, accessGroup string) ([]byte, error)
- func GetGenericPasswordAccounts(service string) ([]string, error)
- func MapToCFDictionary(m map[C.CFTypeRef]C.CFTypeRef) (C.CFDictionaryRef, error)
- func QueryItemRef(item Item) (C.CFTypeRef, error)
- func Release(ref C.CFTypeRef)
- func StringToCFString(s string) (C.CFStringRef, error)
- type Access
- type Accessible
- type Convertable
- type Error
- type Item
- func (k *Item) SetAccess(a *Access)
- func (k *Item) SetAccessGroup(ag string)
- func (k *Item) SetAccessible(accessible Accessible)
- func (k *Item) SetAccount(a string)
- func (k *Item) SetData(b []byte)
- func (k *Item) SetLabel(l string)
- func (k *Item) SetMatchLimit(matchLimit MatchLimit)
- func (k *Item) SetReturnAttributes(b bool)
- func (k *Item) SetReturnData(b bool)
- func (k *Item) SetReturnRef(b bool)
- func (k *Item) SetSecClass(sc SecClass)
- func (k *Item) SetService(s string)
- func (k *Item) SetString(key string, s string)
- func (k *Item) SetSynchronizable(sync Synchronizable)
- type MatchLimit
- type QueryResult
- type SecClass
- type Synchronizable
Constants ¶
const ( SynchronizableDefault Synchronizable = 0 SynchronizableAny = 1 SynchronizableYes = 2 SynchronizableNo = 3 )
const ( AccessibleDefault Accessible = 0 AccessibleWhenUnlocked = 1 AccessibleAfterFirstUnlock = 2 AccessibleAlways = 3 AccessibleWhenPasscodeSetThisDeviceOnly = 4 AccessibleWhenUnlockedThisDeviceOnly = 5 AccessibleAfterFirstUnlockThisDeviceOnly = 6 AccessibleAccessibleAlwaysThisDeviceOnly = 7 )
const ( MatchLimitDefault MatchLimit = 0 MatchLimitOne = 1 MatchLimitAll = 2 )
Variables ¶
var ( ErrorUnimplemented Error = Error(C.errSecUnimplemented) ErrorParam = Error(C.errSecParam) ErrorAllocate = Error(C.errSecAllocate) ErrorNotAvailable = Error(C.errSecNotAvailable) ErrorAuthFailed = Error(C.errSecAuthFailed) ErrorDuplicateItem = Error(C.errSecDuplicateItem) ErrorItemNotFound = Error(C.errSecItemNotFound) ErrorInteractionNotAllowed = Error(C.errSecInteractionNotAllowed) ErrorDecode = Error(C.errSecDecode) )
var ( ServiceKey = attrKey(C.CFTypeRef(C.kSecAttrService)) LabelKey = attrKey(C.CFTypeRef(C.kSecAttrLabel)) AccountKey = attrKey(C.CFTypeRef(C.kSecAttrAccount)) AccessGroupKey = attrKey(C.CFTypeRef(C.kSecAttrAccessGroup)) DataKey = attrKey(C.CFTypeRef(C.kSecValueData)) )
var (
AccessKey = attrKey(C.CFTypeRef(C.kSecAttrAccess))
)
var AccessibleKey = attrKey(C.CFTypeRef(C.kSecAttrAccessible))
var MatchLimitKey = attrKey(C.CFTypeRef(C.kSecMatchLimit))
var ReturnAttributesKey = attrKey(C.CFTypeRef(C.kSecReturnAttributes))
var ReturnDataKey = attrKey(C.CFTypeRef(C.kSecReturnData))
var ReturnRefKey = attrKey(C.CFTypeRef(C.kSecReturnRef))
var SecClassKey = attrKey(C.CFTypeRef(C.kSecClass))
var SynchronizableKey = attrKey(C.CFTypeRef(C.kSecAttrSynchronizable))
Functions ¶
func ArrayToCFArray ¶
func ArrayToCFArray(a []C.CFTypeRef) C.CFArrayRef
ArrayToCFArray will return a CFArrayRef and if non-nil, must be released with Release(ref).
func BytesToCFData ¶
BytesToCFData will return a CFDataRef and if non-nil, must be released with Release(ref).
func CFArrayToArray ¶
func CFArrayToArray(cfArray C.CFArrayRef) (a []C.CFTypeRef)
CFArrayToArray converts a CFArrayRef to an array of CFTypes.
func CFDataToBytes ¶
CFDataToBytes converts CFData to bytes.
func CFDictionaryToMap ¶
CFDictionaryToMap converts CFDictionaryRef to a map.
func CFNumberToInterface ¶
func CFNumberToInterface(cfNumber C.CFNumberRef) interface{}
CFNumberToInterface converts the CFNumberRef to the most appropriate numeric type. This code is from github.com/kballard/go-osx-plist.
func CFStringToString ¶
func CFStringToString(s C.CFStringRef) string
CFStringToString converts a CFStringRef to a string.
func CFTypeDescription ¶
CFTypeDescription returns type string for CFTypeRef.
func ConvertCFDictionary ¶
func ConvertCFDictionary(d C.CFDictionaryRef) (map[interface{}]interface{}, error)
ConvertCFDictionary converts a CFDictionary to map (deep).
func ConvertMapToCFDictionary ¶
func ConvertMapToCFDictionary(attr map[string]interface{}) (C.CFDictionaryRef, error)
ConvertMapToCFDictionary converts a map to a CFDictionary and if non-nil, must be released with Release(ref).
func DeleteGenericPasswordItem ¶
DeleteGenericPasswordItem removes a generic password item.
func DeleteItemRef ¶
DeleteItemRef deletes a keychain item reference.
func GetAccountsForService ¶
Deprecated
func GetGenericPassword ¶
func GetGenericPassword(service string, account string, label string, accessGroup string) ([]byte, error)
GetGenericPassword returns password data for service and account. This is a convenience method. If item is not found returns nil, nil.
func GetGenericPasswordAccounts ¶
GetGenericPasswordAccounts returns generic password accounts for service. This is a convenience method.
func MapToCFDictionary ¶
MapToCFDictionary will return a CFDictionaryRef and if non-nil, must be released with Release(ref).
func QueryItemRef ¶
QueryItemRef returns query result as CFTypeRef. You must release it when you are done.
func StringToCFString ¶
func StringToCFString(s string) (C.CFStringRef, error)
StringToCFString will return a CFStringRef and if non-nil, must be released with Release(ref).
Types ¶
type Accessible ¶
type Accessible int
type Convertable ¶
Convertable knows how to convert an instance to a CFTypeRef.
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
Item for adding, querying or deleting.
func NewGenericPassword ¶
func NewGenericPassword(service string, account string, label string, data []byte, accessGroup string) Item
NewGenericPassword creates a generic password item. This is a convenience method.
func (*Item) SetAccessGroup ¶
func (*Item) SetAccessible ¶
func (k *Item) SetAccessible(accessible Accessible)
func (*Item) SetAccount ¶
func (*Item) SetMatchLimit ¶
func (k *Item) SetMatchLimit(matchLimit MatchLimit)
func (*Item) SetReturnAttributes ¶
func (*Item) SetReturnData ¶
func (*Item) SetReturnRef ¶
func (*Item) SetSecClass ¶
func (*Item) SetService ¶
func (*Item) SetSynchronizable ¶
func (k *Item) SetSynchronizable(sync Synchronizable)
type MatchLimit ¶
type MatchLimit int
type QueryResult ¶
type QueryResult struct { Service string Account string AccessGroup string Label string Data []byte }
QueryResult stores all possible results from queries. Not all fields are applicable all the time. Results depend on query.
func QueryItem ¶
func QueryItem(item Item) ([]QueryResult, error)
QueryItem returns a list of query results.
type SecClass ¶
type SecClass int
var ( /* kSecClassGenericPassword item attributes: kSecAttrAccess (OS X only) kSecAttrAccessGroup (iOS; also OS X if kSecAttrSynchronizable specified) kSecAttrAccessible (iOS; also OS X if kSecAttrSynchronizable specified) kSecAttrAccount kSecAttrService */ SecClassGenericPassword SecClass = 1 )
Keychain Item Classes
type Synchronizable ¶
type Synchronizable int