1
2/*
3 * Copyright (c) 2009 Apple Inc. All rights reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25#ifndef _EAP8021X_SIMACCESS_H
26#define _EAP8021X_SIMACCESS_H
27
28
29/*
30 * Modification History
31 *
32 * January 15, 2009	Dieter Siegmund (dieter@apple.com)
33 * - created
34 */
35
36/*
37 * SIMAccess.h
38 * - API's to access the SIM
39 */
40
41#include <stdint.h>
42#include <stdbool.h>
43#include <CoreFoundation/CFString.h>
44#include "EAPSIMAKA.h"
45
46CFStringRef
47SIMCopyIMSI(void);
48
49CFStringRef
50SIMCopyRealm(void);
51
52/*
53 * Function: SIMAuthenticateGSM
54 * Purpose:
55 *   Communicate with SIM to retrieve the (SRES, Kc) pairs for the given
56 *   set of RANDs.
57 * Parameters:
58 *   rand_p		input buffer containing RANDs;
59 *			size must be at least 'count' * SIM_RAND_SIZE
60 *   count		the number of values in rand_p, kc_p, and sres_p
61 *   kc_p		output buffer to return Kc values;
62 *			size must be at least 'count' * SIM_KC_SIZE
63 *   sres_p		output buffer to return SRES values;
64 * 			size must be at least 'count' * SIM_SRES_SIZE
65 * Returns:
66 *   TRUE if RANDS were processed and kc_p and sres_p were filled in,
67 *   FALSE on failure.
68 */
69bool
70SIMAuthenticateGSM(const uint8_t * rand_p, int count,
71		   uint8_t * kc_p, uint8_t * sres_p);
72
73typedef struct {
74    CFDataRef	ck;
75    CFDataRef	ik;
76    CFDataRef	res;
77    CFDataRef	auts;
78} AKAAuthResults, * AKAAuthResultsRef;
79
80void
81AKAAuthResultsSetCK(AKAAuthResultsRef results, CFDataRef ck);
82
83void
84AKAAuthResultsSetIK(AKAAuthResultsRef results, CFDataRef ik);
85
86void
87AKAAuthResultsSetRES(AKAAuthResultsRef results, CFDataRef res);
88
89void
90AKAAuthResultsSetAUTS(AKAAuthResultsRef results, CFDataRef auts);
91
92void
93AKAAuthResultsInit(AKAAuthResultsRef results);
94
95void
96AKAAuthResultsRelease(AKAAuthResultsRef results);
97
98/*
99 * Function: SIMAuthenticateAKA
100 * Purpose:
101 *   Run the AKA algorithms on the AT_RAND data.
102 *
103 * Returns:
104 *   FALSE if the request could not be completed (SIM unavailable).
105 *
106 *   TRUE if results are available:
107 *   - if authentication was successful, AKAAuthResultsRef contains non-NULL
108 *     res, ck, and ik values.
109 *   - if there's a sync failure, AKAAuthResultsRef will contain non-NULL
110 *     auts value.
111 *   - otherwise, there was an auth reject.
112 */
113bool
114SIMAuthenticateAKA(CFDataRef rand, CFDataRef autn, AKAAuthResultsRef results);
115
116#endif /* _EAP8021X_SIMACCESS_H */
117
118