#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <Security/Security.h>
+#include <Security/SecKey.h>
#include <Security/SecPolicyPriv.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/param.h>
-#include "test/testenv.h"
+#include "regressions/test/testenv.h"
#include "utilities/SecCFRelease.h"
#include "keychain_regressions.h"
};
unsigned int Test_7875801__Code_Signing__cer_len = 999;
-/* Test certificate for S/MIME policy (encrypt only, no sign), expires April 2026
+/* Test certificate for S/MIME policy (encrypt only, no sign), expires September 2026
*/
unsigned char Test_smime_encryptonly[]={
0x30, 0x82, 0x04, 0x07, 0x30, 0x82, 0x02, 0xef, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x04, 0x02, 0xb8, 0x95, 0x23, 0x30,
0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x81, 0x9e, 0x31, 0x21, 0x30,
- 0x1f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x18, 0x54, 0x65, 0x73, 0x74, 0x2d, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74,
- 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x53, 0x2f, 0x4d, 0x49, 0x4d, 0x45, 0x29, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04,
- 0x0a, 0x0c, 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03,
- 0x55, 0x04, 0x0b, 0x0c, 0x07, 0x43, 0x6f, 0x72, 0x65, 0x20, 0x4f, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04,
- 0x08, 0x0c, 0x02, 0x43, 0x41, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x12,
- 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x09, 0x43, 0x75, 0x70, 0x65, 0x72, 0x74, 0x69, 0x6e, 0x6f, 0x31, 0x23,
+ 0x1f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x18, 0x54, 0x65, 0x73, 0x74, 0x2d, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74,
+ 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x53, 0x2f, 0x4d, 0x49, 0x4d, 0x45, 0x29, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04,
+ 0x07, 0x13, 0x09, 0x43, 0x75, 0x70, 0x65, 0x72, 0x74, 0x69, 0x6e, 0x6f, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04,
+ 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x02, 0x43, 0x41, 0x31, 0x10,
+ 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x07, 0x43, 0x6f, 0x72, 0x65, 0x20, 0x4f, 0x53, 0x31, 0x14, 0x30, 0x12,
+ 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x23,
0x30, 0x21, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x14, 0x73, 0x6d, 0x69, 0x6d, 0x65,
0x2d, 0x74, 0x65, 0x73, 0x74, 0x40, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x1e, 0x17, 0x0d, 0x31,
- 0x36, 0x30, 0x34, 0x30, 0x34, 0x32, 0x32, 0x32, 0x32, 0x33, 0x36, 0x5a, 0x17, 0x0d, 0x32, 0x36, 0x30, 0x34, 0x30, 0x32,
- 0x32, 0x32, 0x32, 0x32, 0x33, 0x36, 0x5a, 0x30, 0x81, 0x9e, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
+ 0x36, 0x30, 0x39, 0x32, 0x30, 0x31, 0x32, 0x30, 0x32, 0x31, 0x33, 0x5a, 0x17, 0x0d, 0x32, 0x36, 0x30, 0x39, 0x31, 0x38,
+ 0x31, 0x32, 0x30, 0x32, 0x31, 0x33, 0x5a, 0x30, 0x81, 0x9e, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
0x18, 0x54, 0x65, 0x73, 0x74, 0x2d, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x53, 0x2f,
- 0x4d, 0x49, 0x4d, 0x45, 0x29, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0b, 0x41, 0x70, 0x70, 0x6c,
- 0x65, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x07, 0x43, 0x6f,
- 0x72, 0x65, 0x20, 0x4f, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x43, 0x41, 0x31, 0x0b,
- 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x07,
- 0x0c, 0x09, 0x43, 0x75, 0x70, 0x65, 0x72, 0x74, 0x69, 0x6e, 0x6f, 0x31, 0x23, 0x30, 0x21, 0x06, 0x09, 0x2a, 0x86, 0x48,
+ 0x4d, 0x49, 0x4d, 0x45, 0x29, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x09, 0x43, 0x75, 0x70, 0x65,
+ 0x72, 0x74, 0x69, 0x6e, 0x6f, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b,
+ 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x02, 0x43, 0x41, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0b,
+ 0x13, 0x07, 0x43, 0x6f, 0x72, 0x65, 0x20, 0x4f, 0x53, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0b,
+ 0x41, 0x70, 0x70, 0x6c, 0x65, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x23, 0x30, 0x21, 0x06, 0x09, 0x2a, 0x86, 0x48,
0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x14, 0x73, 0x6d, 0x69, 0x6d, 0x65, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x40, 0x61,
0x70, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01,
- 0x00, 0xc6, 0x5a, 0xe9, 0x94, 0x4a, 0x9e, 0x4d, 0x47, 0xa3, 0x9d, 0x06, 0xb3, 0xd5, 0x05, 0xad, 0x05, 0x71, 0xaf, 0x93,
- 0x42, 0x9d, 0x02, 0x58, 0x33, 0x30, 0xee, 0xcb, 0xe4, 0x96, 0x24, 0x4b, 0x35, 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0xbf, 0x22, 0xd0, 0xf7, 0xd1, 0xa4, 0x32, 0x80, 0x9f, 0x2e, 0x17, 0x0a, 0x17,
+ 0xbc, 0x48, 0xf3, 0x2c, 0x6d, 0x40, 0x3b, 0xf0, 0xf5, 0x0b, 0x10, 0x98, 0x93, 0x50, 0xcc, 0x46, 0x64, 0x57, 0x6d, 0xb5,
+ 0xa0, 0xda, 0x8f, 0xd7, 0xc6, 0x0a, 0x01, 0x1d, 0x89, 0x0b, 0x2f, 0xe3, 0x98, 0xcc, 0x9a
};
unsigned int Test_Encryption__S_MIME__cer_len = 1035;
}
}
+static void PrintStringToMatchRelease(CFStringRef CF_CONSUMED nameStr)
+{
+ PrintStringToMatch(nameStr);
+ CFReleaseNull(nameStr);
+}
+
static void PrintSecCertificate(SecCertificateRef certificate)
{
CFStringRef nameStr;
+ if(!certificate) {
+ return;
+ }
+
OSStatus status = SecCertificateCopyCommonName(certificate, &nameStr);
if (status) {
fprintf(stderr, "### SecCertificateCopyCommonName error %d\n", (int)status);
static void PrintSecIdentity(SecIdentityRef identity)
{
SecCertificateRef certRef;
+ if(!identity) {
+ return;
+ }
+
OSStatus status = SecIdentityCopyCertificate(identity, &certRef);
if (status) {
fprintf(stderr, "### SecIdentityCopyCertificate error %d\n", (int)status);
};
status = SecItemImport(p12DataRef,
NULL, &format, &itemType, flags, &keyParams, keychain, NULL);
+ CFReleaseSafe(p12DataRef);
CFRelease(keyUsagesArray);
CFRelease(keyAttrsArray);
#endif
};
status = SecItemImport(p12DataRef,
NULL, &format, &itemType, flags, &keyParams, keychain, NULL);
+ CFReleaseSafe(p12DataRef);
CFRelease(keyUsagesArray);
CFRelease(keyAttrsArray);
#endif
};
status = SecItemImport(p12DataRef,
NULL, &format, &itemType, flags, &keyParams, keychain, NULL);
+ CFReleaseNull(p12DataRef);
CFRelease(keyUsagesArray);
CFRelease(keyAttrsArray);
ok_status(status, "Unable to import TestIDSSL2007_p12 identity: error %d\n", (int)status);
};
status = SecItemImport(p12DataRef,
NULL, &format, &itemType, flags, &keyParams, keychain, NULL);
+ CFReleaseSafe(p12DataRef);
CFRelease(keyUsagesArray);
CFRelease(keyAttrsArray);
ok_status(status, "Unable to import TestIDSMIME2007_p12 identity: error %d\n", (int)status);
CFTypeRef results = NULL;
if (debug) {
PrintStringToMatch(nameStr);
- PrintStringToMatch(CFCopyDescription(validOnDate));
+ PrintStringToMatchRelease(CFCopyDescription(validOnDate));
}
OSStatus status = SecItemCopyMatching(query, &results);
CFTypeRef returnType,
CFTypeRef matchLimit,
CFIndex minMatchesExpected,
+ CFIndex maxMatchesExpected,
OSStatus expected)
{
/* create a SecPolicyRef for S/MIME */
CFTypeRef results = NULL;
if (debug) {
PrintStringToMatch(emailAddr);
- PrintStringToMatch(CFCopyDescription(kSecPolicyAppleSMIME));
- PrintStringToMatch(CFCopyDescription(validOnDate));
+ PrintStringToMatchRelease(CFCopyDescription(kSecPolicyAppleSMIME));
+ PrintStringToMatchRelease(CFCopyDescription(validOnDate));
}
OSStatus status = SecItemCopyMatching(query, &results);
if (!status && results) {
- status = CheckResults(results, minMatchesExpected, MAXITEMS);
+ status = CheckResults(results, minMatchesExpected, maxMatchesExpected);
CFRelease(results);
}
if (query)
if (debug) {
PrintStringToMatch(emailAddr);
- PrintStringToMatch(CFCopyDescription(validOnDate));
+ PrintStringToMatchRelease(CFCopyDescription(validOnDate));
}
status = SecItemCopyMatching(query, (CFTypeRef*)&validatedCertificate);
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
- if (debug) PrintStringToMatch(CFCopyDescription(policyIdentifier));
+ if (debug) PrintStringToMatchRelease(CFCopyDescription(policyIdentifier));
status = SecItemCopyMatching(query, &results);
CFTypeRef results = NULL;
if (debug) {
PrintStringToMatch(nameStr);
- PrintStringToMatch(CFCopyDescription(validOnDate));
+ PrintStringToMatchRelease(CFCopyDescription(validOnDate));
}
OSStatus status = SecItemCopyMatching(query, &results);
if (debug) {
PrintStringToMatch(emailAddr);
- PrintStringToMatch(CFCopyDescription(validOnDate));
+ PrintStringToMatchRelease(CFCopyDescription(validOnDate));
}
status = SecItemCopyMatching(query, (CFTypeRef*)&validatedIdentity);
-const CFStringRef gPrefix = CFSTR("Test Key");
-const CFStringRef gLabel = CFSTR("Test AES Encryption Key");
-const CFStringRef gUUID = CFSTR("550e8400-e29b-41d4-a716-446655441234");
+const CFStringRef g18Prefix = CFSTR("Test Key");
+const CFStringRef g18Label = CFSTR("Test AES Encryption Key");
+const CFStringRef g18UUID = CFSTR("550e8400-e29b-41d4-a716-446655441234");
// CreateSymmetricKey will create a new AES-128 symmetric encryption key
// with the provided label, application label, and application tag.
// note: the access descriptor should be the same string as will be used for the item's label,
// since it's the string that is displayed by the access confirmation dialog to describe the item.
SecAccessRef access = NULL;
- status = SecAccessCreate(gLabel, NULL, &access);
+ status = SecAccessCreate(g18Label, NULL, &access);
// create a dictionary of parameters describing the key we want to create
CFMutableDictionaryRef params = CFDictionaryCreateMutable(NULL, 0,
CFDictionaryAddValue( params, kSecAttrAccess, access );
CFDictionaryAddValue( params, kSecAttrKeyClass, kSecAttrKeyClassSymmetric );
CFDictionaryAddValue( params, kSecAttrKeyType, kSecAttrKeyTypeAES );
- CFDictionaryAddValue( params, kSecAttrKeySizeInBits, keySize );
+ CFDictionaryAddValue( params, kSecAttrKeySizeInBits, keySize ); CFReleaseNull(keySize);
CFDictionaryAddValue( params, kSecAttrIsPermanent, kCFBooleanTrue );
CFDictionaryAddValue( params, kSecAttrCanEncrypt, kCFBooleanTrue );
CFDictionaryAddValue( params, kSecAttrCanDecrypt, kCFBooleanTrue );
// look up identity by policy, want first result as a CFDictionary of attributes (should find "Test SSL User" identity)
result += FindIdentityByPolicy(keychain, sslPolicy, kSecReturnAttributes, kSecMatchLimitOne, 1, noErr);
+ CFReleaseNull(sslPolicy);
// look up identity by policy, expect errSecItemNotFound error (this assumes no code signing identity is present!)
result += FindIdentityByPolicy(keychain, codeSigningPolicy, kSecReturnRef, kSecMatchLimitOne, 0, errSecItemNotFound);
+ CFReleaseNull(codeSigningPolicy);
// -------------------------
// test kSecMatchValidOnDate
CFDateRef aPastValidDate = CFDateCreate(kCFAllocatorDefault, CFGregorianDateGetAbsoluteTime(aPastValidGDate, NULL));
if (FindIdentityByNameAndValidDate(keychain, CFSTR(" 2007"), aPastValidDate, kSecReturnRef, kSecMatchLimitAll, 0, noErr))
++result;
+ CFReleaseNull(aPastValidDate);
// test the ability of kCFNull to denote "currently valid" (should not find anything, since the " 2007" certs are expired)
if (FindIdentityByNameAndValidDate(keychain, CFSTR(" 2007"), kCFNull, kSecReturnRef, kSecMatchLimitAll, 0, errSecItemNotFound))
++result;
+
// test Ian's bug: <rdar://8197632>; the 4th argument is a string which should NOT be present in any found items
if (FindIdentityByPolicyAndValidDate(keychain, kSecPolicyAppleSMIME, FALSE, kCFNull, CFSTR(" 2007"), kSecReturnAttributes, kSecMatchLimitAll, 0, errSecSuccess))
++result;
// look up cert by email address for SMIME encryption, date valid today, want array of all results as SecCertificateRef
// (note that a date value of kCFNull is interpreted as the current date)
result += FindCertificateForSMIMEEncryption(keychain, CFSTR("smime-test@apple.com"), kCFNull,
- kSecReturnRef, kSecMatchLimitAll, 1, noErr);
+ kSecReturnRef, kSecMatchLimitAll, 1, 1, noErr);
CFReleaseSafe(sslPolicy);
CFReleaseSafe(codeSigningPolicy);
++result;
// define a valid date for this preferred certificate (typically this would just be kCFNull in a real program, meaning "now")
- CFGregorianDate aCurrentGDate = { 2016, 7, 27, 21, 0, 0 }; // Jul 27 2016 9:00 PM
+ CFGregorianDate aCurrentGDate = { 2016, 9, 27, 21, 0, 0 }; // September 27 2016 9:00 PM
CFDateRef aCurrentDate = CFDateCreate(kCFAllocatorDefault, CFGregorianDateGetAbsoluteTime(aCurrentGDate, NULL));
if (FindPreferredCertificateForSMIMEEncryption(keychain, CFSTR("smime-test@apple.com"), aCurrentDate))
++result;
int result = 0;
// look up our symmetric key by label and UUID (it might not exist yet)
- if (FindSymmetricKey(keychain, gLabel, gUUID, NULL, errSecItemNotFound) != errSecSuccess) {
+ if (FindSymmetricKey(keychain, g18Label, g18UUID, NULL, errSecItemNotFound) != errSecSuccess) {
// create test key (unique by UUID only)
- if (CreateSymmetricKey(keychain, gLabel, gUUID, NULL, errSecSuccess) != errSecSuccess)
+ if (CreateSymmetricKey(keychain, g18Label, g18UUID, NULL, errSecSuccess) != errSecSuccess)
++result;
// look it up again (it should exist now!)
- if (FindSymmetricKey(keychain, gLabel, gUUID, NULL, errSecSuccess) != errSecSuccess)
+ if (FindSymmetricKey(keychain, g18Label, g18UUID, NULL, errSecSuccess) != errSecSuccess)
++result;
}
// (so we can make sure on a daily basis that SecKeyGenerateSymmetric is still working)
CFGregorianDate curGDate = CFAbsoluteTimeGetGregorianDate(CFAbsoluteTimeGetCurrent(), NULL);
CFStringRef curDateLabel = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%4d-%02d-%02d)"),
- gPrefix, (int32_t) curGDate.year, (int8_t) curGDate.month, (int8_t) curGDate.day);
+ g18Prefix, (int32_t) curGDate.year, (int8_t) curGDate.month, (int8_t) curGDate.day);
//
//%%% FIXME Creating a symmetric key with attributes that would duplicate an existing
CFStringRef curAppTag = CFSTR("SecItemFind");
// look up our date-based symmetric key by label, UUID, and tag (it might not exist yet)
- if (FindSymmetricKey(keychain, curDateLabel, gUUID, curAppTag, errSecItemNotFound) != errSecSuccess) {
+ if (FindSymmetricKey(keychain, curDateLabel, g18UUID, curAppTag, errSecItemNotFound) != errSecSuccess) {
// create test key (unique by combination of UUID and application tag)
- if (CreateSymmetricKey(keychain, curDateLabel, gUUID, curAppTag, errSecSuccess) != errSecSuccess)
+ if (CreateSymmetricKey(keychain, curDateLabel, g18UUID, curAppTag, errSecSuccess) != errSecSuccess)
++result;
// look it up again (it should exist now!)
- if (FindSymmetricKey(keychain, curDateLabel, gUUID, curAppTag, errSecSuccess) != errSecSuccess)
+ if (FindSymmetricKey(keychain, curDateLabel, g18UUID, curAppTag, errSecSuccess) != errSecSuccess)
++result;
}
// test handling of duplicate symmetric key items (<rdar://8289559>)
- if (CreateSymmetricKey(keychain, curDateLabel, gUUID, curAppTag, errSecDuplicateItem) != errSecDuplicateItem)
+ if (CreateSymmetricKey(keychain, curDateLabel, g18UUID, curAppTag, errSecDuplicateItem) != errSecDuplicateItem)
++result;
CFRelease(curDateLabel);
CFNumberRef keySize = CFNumberCreate(NULL, kCFNumberIntType, &keySizeValue);
CFStringRef keyLabel = CFSTR("AppleID 8658820 test key");
CFDictionaryAddValue( params, kSecAttrKeyType, kSecAttrKeyTypeRSA );
- CFDictionaryAddValue( params, kSecAttrKeySizeInBits, keySize );
+ CFDictionaryAddValue( params, kSecAttrKeySizeInBits, keySize ); CFReleaseNull(keySize);
CFDictionaryAddValue( params, kSecAttrLabel, keyLabel );
CFDictionaryAddValue( params, kSecUseKeychain, keychain );
// CFDictionaryAddValue( params, kSecAttrAccess, access );
++result;
// delete our test symmetric keys (no partial string matching for key items! need an ER Radar...)
- if (FindAndDeleteItemsByName(keychain, gLabel, NULL, kSecClassKey, kSecMatchLimitAll, 1, noErr))
+ if (FindAndDeleteItemsByName(keychain, g18Label, NULL, kSecClassKey, kSecMatchLimitAll, 1, noErr))
++result;
CFGregorianDate curGDate = CFAbsoluteTimeGetGregorianDate(CFAbsoluteTimeGetCurrent(), NULL);
CFStringRef curDateLabel = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ (%4d-%02d-%02d)"),
- gPrefix, (int32_t) curGDate.year, (int8_t) curGDate.month, (int8_t) curGDate.day);
+ g18Prefix, (int32_t) curGDate.year, (int8_t) curGDate.month, (int8_t) curGDate.day);
if (FindAndDeleteItemsByName(keychain, curDateLabel, NULL, kSecClassKey, kSecMatchLimitAll, 1, noErr))
++result;
CFRelease(curDateLabel);