2 * Copyright (c) 2017 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 #import <Foundation/Foundation.h>
28 #import <utilities/SecCFWrappers.h>
29 #import <Security/SecTrustPriv.h>
31 #include "SecurityCommands.h"
33 static int check_OTA_Supplementals_asset(void) {
34 CFErrorRef error = NULL;
35 uint64_t version = SecTrustOTAPKIGetUpdatedAsset(&error);
37 CFStringRef errorDescription = CFErrorCopyDescription(error);
38 if (errorDescription) {
39 char *errMsg = CFStringToCString(errorDescription);
40 fprintf(stdout, "Update failed: %s\n", errMsg);
41 if (errMsg) { free(errMsg); }
42 CFRelease(errorDescription);
44 fprintf(stdout, "Update failed: no description\n");
48 fprintf(stdout, "Updated succeeded\n");
51 fprintf(stdout, "Asset Content Version: %llu\n", version);
58 int check_trust_update(int argc, char * const *argv) {
60 bool check_trust_supplementals = false;
63 return SHOW_USAGE_MESSAGE;
66 while ((arg = getopt(argc, argv, "s")) != -1) {
69 check_trust_supplementals = true;
73 return SHOW_USAGE_MESSAGE;
77 if (check_trust_supplementals) {
78 return check_OTA_Supplementals_asset();