Value of kSecAttrApplicationLabel is CFDataRef, but documented to be CFStringRef

Originator:wiml
Number:rdar://24496368 Date Originated:03-Feb-2016 06:58 PM
Status:Open Resolved:
Product:iOS Product Version:iOS 9.2 (13C75)
Classification:Bug Reproducible:Always
 
Summary:
You can insert a key into the keychain with a kSecAttrApplicationLabel which is documented to take a string, but when you read it back, you get a CFDataRef.

Steps to Reproduce:
Insert a key, e.g.:

SecItemAdd({
    atag = <50424b44 46322473 68613124 2fca980b c1ed8c4d 2a7eb032 2e313f75 f44d8b56>;
    class = keys;
    kcls = 2;
    klbl = blah123;
    pdmn = cku;
    perm = 1;
    sync = 0;
    unwp = 1;
    "v_Data" = <4acc7099 28a7c9b5 106020cb e7966c72>;
    wrap = 1;
})

Then read it back using SecItemCopyMatching and a matching class, keyclass, tag, and label.

Expected Results:
kSecAttrApplicationLabel is documented to be a CFString (docs say: "Application label attribute key. The corresponding value is of type CFStringRef and contains a label for this item."), so I expect it to be a CFString.

Actual Results:
It is actually a CFData:

After insert, readback = (
        {
        agrp = "34YW5XSRB7.com.omnigroup.TestApp.Debug";
        atag = <50424b44 46322473 68613124 2fca980b c1ed8c4d 2a7eb032 2e313f75 f44d8b56>;
        bsiz = 0;
        cdat = "2016-02-04 02:52:14 +0000";
        class = keys;
        crtr = 0;
        edat = "2001-01-01 00:00:00 +0000";
        esiz = 0;
        kcls = 2;
        klbl = <626c6168 313233>;
        mdat = "2016-02-04 02:52:14 +0000";
        pdmn = cku;
        perm = 1;
        sdat = "2001-01-01 00:00:00 +0000";
        sync = 0;
        tomb = 0;
        type = 0;
        unwp = 1;
        "v_Data" = <4acc7099 28a7c9b5 106020cb e7966c72>;
        wrap = 1;
    }
)

Version:
iOS 9.2 (13C75)

Notes:
Same behavior on the device and in the simulator.

It actually makes more sense for this to be a CFData than a CFString, if it is used to look up keypairs by key hash; in which case perhaps this is a documentation bug.

See also RADAR 19804744.


Configuration:
iPhone 6

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!