| | | |
Offset 7, 15 lines modified | Offset 7, 14 lines modified |
7 | import·com.android.internal.net.ipsec.ike.message.IkePayload; | 7 | import·com.android.internal.net.ipsec.ike.message.IkePayload; |
8 | import·com.android.internal.net.ipsec.ike.message.IkeSaPayload; | 8 | import·com.android.internal.net.ipsec.ike.message.IkeSaPayload; |
9 | import·java.util.List; | 9 | import·java.util.List; |
10 | import·android.net.ipsec.ike.exceptions.IkeInternalException; | 10 | import·android.net.ipsec.ike.exceptions.IkeInternalException; |
11 | import·android.net.ipsec.ike.exceptions.IkeException; | 11 | import·android.net.ipsec.ike.exceptions.IkeException; |
12 | import·android.os.Bundle; | 12 | import·android.os.Bundle; |
13 | import·android.os.Message; | 13 | import·android.os.Message; |
14 | import·com.android.internal.net.ipsec.ike.utils.IkeAlarm$IkeAlarmConfig; | |
15 | import·java.util.Iterator; | 14 | import·java.util.Iterator; |
16 | import·com.android.internal.net.ipsec.ike.message.IkeSaPayload$DhGroupTransform; | 15 | import·com.android.internal.net.ipsec.ike.message.IkeSaPayload$DhGroupTransform; |
17 | import·java.util.Collection; | 16 | import·java.util.Collection; |
18 | import·java.util.Arrays; | 17 | import·java.util.Arrays; |
19 | import·android.net.ipsec.ike.SaProposal; | 18 | import·android.net.ipsec.ike.SaProposal; |
20 | import·java.util.LinkedHashSet; | 19 | import·java.util.LinkedHashSet; |
21 | import·java.util.concurrent.Executor; | 20 | import·java.util.concurrent.Executor; |
Offset 25, 49 lines modified | Offset 24, 50 lines modified |
25 | import·android.net.ipsec.ike.ChildSaProposal; | 24 | import·android.net.ipsec.ike.ChildSaProposal; |
26 | import·com.android.internal.net.ipsec.ike.utils.RandomnessFactory; | 25 | import·com.android.internal.net.ipsec.ike.utils.RandomnessFactory; |
27 | import·android.net.ipsec.ike.IkeTrafficSelector; | 26 | import·android.net.ipsec.ike.IkeTrafficSelector; |
28 | import·java.net.InetAddress; | 27 | import·java.net.InetAddress; |
29 | import·com.android.internal.net.ipsec.ike.utils.IpSecSpiGenerator; | 28 | import·com.android.internal.net.ipsec.ike.utils.IpSecSpiGenerator; |
30 | import·android.net.IpSecManager; | 29 | import·android.net.IpSecManager; |
31 | import·com.android.internal.net.ipsec.ike.crypto.IkeMacPrf; | 30 | import·com.android.internal.net.ipsec.ike.crypto.IkeMacPrf; |
32 | import·android.os.Handler; | |
33 | import·android.content.Context; | 31 | import·android.content.Context; |
34 | import·com.android.internal.net.ipsec.ike.utils.State; | 32 | import·com.android.internal.net.ipsec.ike.utils.State; |
35 | import·android.net.ipsec.ike.ChildSessionParams; | 33 | import·android.net.ipsec.ike.ChildSessionParams; |
36 | import·com.android.internal.net.ipsec.ike.crypto.IkeMacIntegrity; | 34 | import·com.android.internal.net.ipsec.ike.crypto.IkeMacIntegrity; |
37 | import·com.android.internal.net.ipsec.ike.crypto.IkeCipher; | 35 | import·com.android.internal.net.ipsec.ike.crypto.IkeCipher; |
| 36 | import·android.app.AlarmManager; |
38 | import·android.util.SparseArray; | 37 | import·android.util.SparseArray; |
| |
39 | public·class·ChildSessionStateMachine·extends·AbstractSessionStateMachine | 38 | public·class·ChildSessionStateMachine·extends·AbstractSessionStateMachine |
40 | { | 39 | { |
41 | ····private·static·final·int·CMD_GENERAL_BASE·=·300; | 40 | ····private·static·final·int·CMD_GENERAL_BASE·=·300; |
42 | ····private·static·final·int·CMD_HANDLE_FIRST_CHILD_EXCHANGE·=·301; | 41 | ····private·static·final·int·CMD_HANDLE_FIRST_CHILD_EXCHANGE·=·301; |
43 | ····private·static·final·int·CMD_HANDLE_RECEIVED_REQUEST·=·302; | 42 | ····private·static·final·int·CMD_HANDLE_RECEIVED_REQUEST·=·302; |
44 | ····private·static·final·int·CMD_HANDLE_RECEIVED_RESPONSE·=·303; | 43 | ····private·static·final·int·CMD_HANDLE_RECEIVED_RESPONSE·=·303; |
| 44 | ····private·static·final·int·CMD_KILL_SESSION·=·304; |
45 | ····private·static·final·SparseArray·CMD_TO_STR; | 45 | ····private·static·final·SparseArray·CMD_TO_STR; |
46 | ····private·static·final·int·CREATE_STATUS_CHILD_ERROR_INVALID_MSG·=·1; | 46 | ····private·static·final·int·CREATE_STATUS_CHILD_ERROR_INVALID_MSG·=·1; |
47 | ····private·static·final·int·CREATE_STATUS_CHILD_ERROR_RCV_NOTIFY·=·2; | 47 | ····private·static·final·int·CREATE_STATUS_CHILD_ERROR_RCV_NOTIFY·=·2; |
48 | ····private·static·final·int·CREATE_STATUS_OK·=·0; | 48 | ····private·static·final·int·CREATE_STATUS_OK·=·0; |
49 | ····private·static·final·int·SPI_NOT_REGISTERED·=·0; | 49 | ····private·static·final·int·SPI_NOT_REGISTERED·=·0; |
50 | ····private·static·final·String·TAG·=·"ChildSessionStateMachine"; | 50 | ····private·static·final·String·TAG·=·"ChildSessionStateMachine"; |
| 51 | ····private·final·AlarmManager·mAlarmManager; |
51 | ····IkeCipher·mChildCipher; | 52 | ····IkeCipher·mChildCipher; |
52 | ····IkeMacIntegrity·mChildIntegrity; | 53 | ····IkeMacIntegrity·mChildIntegrity; |
53 | ····SaRecord$ChildSaRecord·mChildSaRecordSurviving; | 54 | ····SaRecord$ChildSaRecord·mChildSaRecordSurviving; |
54 | ····final·ChildSessionParams·mChildSessionParams; | 55 | ····final·ChildSessionParams·mChildSessionParams; |
55 | ····private·final·ChildSessionStateMachine$IChildSessionSmCallback·mChildSmCallback; | 56 | ····private·final·ChildSessionStateMachine$IChildSessionSmCallback·mChildSmCallback; |
56 | ····final·State·mClosedAndAwaitResponse; | 57 | ····final·State·mClosedAndAwaitResponse; |
57 | ····private·final·Context·mContext; | 58 | ····private·final·Context·mContext; |
58 | ····final·State·mCreateChildLocalCreate; | 59 | ····final·State·mCreateChildLocalCreate; |
59 | ····SaRecord$ChildSaRecord·mCurrentChildSaRecord; | 60 | ····SaRecord$ChildSaRecord·mCurrentChildSaRecord; |
60 | ····final·State·mDeleteChildLocalDelete; | 61 | ····final·State·mDeleteChildLocalDelete; |
61 | ····final·State·mDeleteChildRemoteDelete; | 62 | ····final·State·mDeleteChildRemoteDelete; |
62 | ····final·State·mIdle; | 63 | ····final·State·mIdle; |
63 | ····final·State·mIdleWithDeferredRequest; | 64 | ····final·State·mIdleWithDeferredRequest; |
64 | ····int·mIkeDhGroup; | 65 | ····int·mIkeDhGroup; |
65 | ····private·final·Handler·mIkeHandler; | |
66 | ····IkeMacPrf·mIkePrf; | 66 | ····IkeMacPrf·mIkePrf; |
67 | ····private·final·int·mIkeSessionId; | 67 | ····private·final·int·mIkeSessionId; |
68 | ····final·State·mInitial; | 68 | ····final·State·mInitial; |
69 | ····private·final·IpSecManager·mIpSecManager; | 69 | ····private·final·IpSecManager·mIpSecManager; |
70 | ····private·final·IpSecSpiGenerator·mIpSecSpiGenerator; | 70 | ····private·final·IpSecSpiGenerator·mIpSecSpiGenerator; |
71 | ····boolean·mIsFirstChild; | 71 | ····boolean·mIsFirstChild; |
72 | ····final·State·mKillChildSessionParent; | 72 | ····final·State·mKillChildSessionParent; |
Offset 90, 17 lines modified | Offset 90, 18 lines modified |
90 | ····private·final·ChildSessionCallback·mUserCallback; | 90 | ····private·final·ChildSessionCallback·mUserCallback; |
91 | ···· | 91 | ···· |
92 | ····static·{ | 92 | ····static·{ |
93 | ········final·SparseArray·cmd_TO_STR·=·new·SparseArray(); | 93 | ········final·SparseArray·cmd_TO_STR·=·new·SparseArray(); |
94 | ········(CMD_TO_STR·=·cmd_TO_STR).put(301,·(Object)"Handle·First·Child"); | 94 | ········(CMD_TO_STR·=·cmd_TO_STR).put(301,·(Object)"Handle·First·Child"); |
95 | ········cmd_TO_STR.put(302,·(Object)"Rcv·request"); | 95 | ········cmd_TO_STR.put(302,·(Object)"Rcv·request"); |
96 | ········cmd_TO_STR.put(303,·(Object)"Rcv·response"); | 96 | ········cmd_TO_STR.put(303,·(Object)"Rcv·response"); |
| 97 | ········cmd_TO_STR.put(304,·(Object)"Kill·session"); |
97 | ····} | 98 | ····} |
98 | ···· | 99 | ···· |
99 | ····ChildSessionStateMachine(final·Looper·looper,·final·Context·mContext,·final·int·mIkeSessionId,·final·Handler·mIkeHandler,·final·RandomnessFactory·mRandomFactory,·final·IpSecManager·mIpSecManager,·final·IpSecSpiGenerator·mIpSecSpiGenerator,·final·ChildSessionParams·mChildSessionParams,·final·Executor·executor,·final·ChildSessionCallback·mUserCallback,·final·ChildSessionStateMachine$IChildSessionSmCallback·mChildSmCallback)·{ | 100 | ····ChildSessionStateMachine(final·Looper·looper,·final·Context·mContext,·final·int·mIkeSessionId,·final·AlarmManager·mAlarmManager,·final·RandomnessFactory·mRandomFactory,·final·IpSecManager·mIpSecManager,·final·IpSecSpiGenerator·mIpSecSpiGenerator,·final·ChildSessionParams·mChildSessionParams,·final·Executor·executor,·final·ChildSessionCallback·mUserCallback,·final·ChildSessionStateMachine$IChildSessionSmCallback·mChildSmCallback)·{ |
100 | ········super("ChildSessionStateMachine",·looper,·executor); | 101 | ········super("ChildSessionStateMachine",·looper,·executor); |
101 | ········this.mLocalRequestFactory·=·new·IkeLocalRequestScheduler$LocalRequestFactory(); | 102 | ········this.mLocalRequestFactory·=·new·IkeLocalRequestScheduler$LocalRequestFactory(); |
102 | ········final·ChildSessionStateMachine$KillChildSessionParent·mKillChildSessionParent·=·new·ChildSessionStateMachine$KillChildSessionParent(this,·(ChildSessionStateMachine$1)null); | 103 | ········final·ChildSessionStateMachine$KillChildSessionParent·mKillChildSessionParent·=·new·ChildSessionStateMachine$KillChildSessionParent(this,·(ChildSessionStateMachine$1)null); |
103 | ········this.mKillChildSessionParent·=·(State)mKillChildSessionParent; | 104 | ········this.mKillChildSessionParent·=·(State)mKillChildSessionParent; |
104 | ········final·ChildSessionStateMachine$Initial·childSessionStateMachine$Initial·=·new·ChildSessionStateMachine$Initial(this); | 105 | ········final·ChildSessionStateMachine$Initial·childSessionStateMachine$Initial·=·new·ChildSessionStateMachine$Initial(this); |
105 | ········this.mInitial·=·(State)childSessionStateMachine$Initial; | 106 | ········this.mInitial·=·(State)childSessionStateMachine$Initial; |
106 | ········final·ChildSessionStateMachine$CreateChildLocalCreate·mCreateChildLocalCreate·=·new·ChildSessionStateMachine$CreateChildLocalCreate(this); | 107 | ········final·ChildSessionStateMachine$CreateChildLocalCreate·mCreateChildLocalCreate·=·new·ChildSessionStateMachine$CreateChildLocalCreate(this); |
Offset 123, 15 lines modified | Offset 124, 15 lines modified |
123 | ········this.mRekeyChildRemoteCreate·=·(State)mRekeyChildRemoteCreate; | 124 | ········this.mRekeyChildRemoteCreate·=·(State)mRekeyChildRemoteCreate; |
124 | ········final·ChildSessionStateMachine$RekeyChildLocalDelete·mRekeyChildLocalDelete·=·new·ChildSessionStateMachine$RekeyChildLocalDelete(this); | 125 | ········final·ChildSessionStateMachine$RekeyChildLocalDelete·mRekeyChildLocalDelete·=·new·ChildSessionStateMachine$RekeyChildLocalDelete(this); |
125 | ········this.mRekeyChildLocalDelete·=·(State)mRekeyChildLocalDelete; | 126 | ········this.mRekeyChildLocalDelete·=·(State)mRekeyChildLocalDelete; |
126 | ········final·ChildSessionStateMachine$RekeyChildRemoteDelete·mRekeyChildRemoteDelete·=·new·ChildSessionStateMachine$RekeyChildRemoteDelete(this); | 127 | ········final·ChildSessionStateMachine$RekeyChildRemoteDelete·mRekeyChildRemoteDelete·=·new·ChildSessionStateMachine$RekeyChildRemoteDelete(this); |
127 | ········this.mRekeyChildRemoteDelete·=·(State)mRekeyChildRemoteDelete; | 128 | ········this.mRekeyChildRemoteDelete·=·(State)mRekeyChildRemoteDelete; |
128 | ········this.mContext·=·mContext; | 129 | ········this.mContext·=·mContext; |
129 | ········this.mIkeSessionId·=·mIkeSessionId; | 130 | ········this.mIkeSessionId·=·mIkeSessionId; |
130 | ········this.mIkeHandler·=·mIkeHandler; | 131 | ········this.mAlarmManager·=·mAlarmManager; |
131 | ········this.mRandomFactory·=·mRandomFactory; | 132 | ········this.mRandomFactory·=·mRandomFactory; |
132 | ········this.mIpSecManager·=·mIpSecManager; | 133 | ········this.mIpSecManager·=·mIpSecManager; |
133 | ········this.mIpSecSpiGenerator·=·mIpSecSpiGenerator; | 134 | ········this.mIpSecSpiGenerator·=·mIpSecSpiGenerator; |
134 | ········this.mChildSessionParams·=·mChildSessionParams; | 135 | ········this.mChildSessionParams·=·mChildSessionParams; |
135 | ········this.mUserCallback·=·mUserCallback; | 136 | ········this.mUserCallback·=·mUserCallback; |
136 | ········this.mChildSmCallback·=·mChildSmCallback; | 137 | ········this.mChildSmCallback·=·mChildSmCallback; |
137 | ········this.addState((State)mKillChildSessionParent); | 138 | ········this.addState((State)mKillChildSessionParent); |
Offset 163, 17 lines modified | Offset 164, 15 lines modified |
163 | ········} | 164 | ········} |
164 | ········final·IkeSaPayload$DhGroupTransform[]·array·=·new·IkeSaPayload$DhGroupTransform[set.size()]; | 165 | ········final·IkeSaPayload$DhGroupTransform[]·array·=·new·IkeSaPayload$DhGroupTransform[set.size()]; |
165 | ········set.toArray(array); | 166 | ········set.toArray(array); |
166 | ········return·new·ChildSaProposal(this.mSaProposal.getEncryptionTransforms(),·this.mSaProposal.getIntegrityTransforms(),·array,·this.mSaProposal.getEsnTransforms()); | 167 | ········return·new·ChildSaProposal(this.mSaProposal.getEncryptionTransforms(),·this.mSaProposal.getIntegrityTransforms(),·array,·this.mSaProposal.getEsnTransforms()); |
167 | ····} | 168 | ····} |
168 | ···· | 169 | ···· |
169 | ····private·SaRecord$SaLifetimeAlarmScheduler·buildSaLifetimeAlarmSched(final·int·n)·{ | 170 | ····private·SaRecord$SaLifetimeAlarmScheduler·buildSaLifetimeAlarmSched(final·int·n)·{ |
| 171 | ········return·new·SaRecord$SaLifetimeAlarmScheduler(this.mChildSessionParams.getHardLifetimeMsInternal(),·this.mChildSessionParams.getSoftLifetimeMsInternal(),·IkeSessionStateMachine.buildIkeAlarmIntent(this.mContext,·"IkeAlarmReceiver.ACTION_DELETE_CHILD",·this.getIntentIdentifier(n),·this.getIntentIkeSmMsg(2,·n)),·IkeSessionStateMachine.buildIkeAlarmIntent(this.mContext,·"IkeAlarmReceiver.ACTION_REKEY_CHILD",·this.getIntentIdentifier(n),·this.getIntentIkeSmMsg(3,·n)),·this.mAlarmManager); |
170 | ········final·Message·intentIkeSmMsg·=·this.getIntentIkeSmMsg(2,·n); | |
171 | ········final·Message·intentIkeSmMsg2·=·this.getIntentIkeSmMsg(3,·n); | |
172 | ········return·new·SaRecord$SaLifetimeAlarmScheduler(new·IkeAlarm$IkeAlarmConfig(this.mContext,·"IkeAlarmReceiver.ACTION_DELETE_CHILD",·this.mChildSessionParams.getHardLifetimeMsInternal(),·IkeSessionStateMachine.buildIkeAlarmIntent(this.mContext,·"IkeAlarmReceiver.ACTION_DELETE_CHILD",·this.getIntentIdentifier(n),·intentIkeSmMsg),·intentIkeSmMsg),·new·IkeAlarm$IkeAlarmConfig(this.mContext,·"IkeAlarmReceiver.ACTION_REKEY_CHILD",·this.mChildSessionParams.getSoftLifetimeMsInternal(),·IkeSessionStateMachine.buildIkeAlarmIntent(this.mContext,·"IkeAlarmReceiver.ACTION_REKEY_CHILD",·this.getIntentIdentifier(n),·intentIkeSmMsg2),·intentIkeSmMsg2)); | |
173 | ····} | 172 | ····} |
174 | ···· | 173 | ···· |
175 | ····private·void·closeAllSaRecords(final·boolean·b)·{ | 174 | ····private·void·closeAllSaRecords(final·boolean·b)·{ |
176 | ········this.closeChildSaRecord(this.mCurrentChildSaRecord,·b); | 175 | ········this.closeChildSaRecord(this.mCurrentChildSaRecord,·b); |
177 | ········this.closeChildSaRecord(this.mLocalInitNewChildSaRecord,·b); | 176 | ········this.closeChildSaRecord(this.mLocalInitNewChildSaRecord,·b); |
178 | ········this.closeChildSaRecord(this.mRemoteInitNewChildSaRecord,·b); | 177 | ········this.closeChildSaRecord(this.mRemoteInitNewChildSaRecord,·b); |
179 | ········this.mCurrentChildSaRecord·=·null; | 178 | ········this.mCurrentChildSaRecord·=·null; |
Offset 209, 15 lines modified | Offset 208, 15 lines modified |
209 | ········sb.append(i); | 208 | ········sb.append(i); |
210 | ········return·sb.toString(); | 209 | ········return·sb.toString(); |
211 | ····} | 210 | ····} |
212 | ···· | 211 | ···· |
213 | ····private·Message·getIntentIkeSmMsg(final·int·n,·final·int·n2)·{ | 212 | ····private·Message·getIntentIkeSmMsg(final·int·n,·final·int·n2)·{ |
214 | ········final·Bundle·bundle·=·new·Bundle(); | 213 | ········final·Bundle·bundle·=·new·Bundle(); |
215 | ········bundle.putInt("BUNDLE_KEY_CHILD_REMOTE_SPI",·n2); | 214 | ········bundle.putInt("BUNDLE_KEY_CHILD_REMOTE_SPI",·n2); |
216 | ········return·this.mIkeHandler.obtainMessage(315,·this.mIkeSessionId,·n,·(Object)bundle); | 215 | ········return·this.obtainMessage(315,·this.mIkeSessionId,·n,·(Object)bundle); |
217 | ····} | 216 | ····} |
218 | ···· | 217 | ···· |
219 | ····private·void·handleChildFatalError(final·Exception·ex)·{ | 218 | ····private·void·handleChildFatalError(final·Exception·ex)·{ |
220 | ········Object·o; | 219 | ········Object·o; |
221 | ········if·(ex·instanceof·IkeException)·{ | 220 | ········if·(ex·instanceof·IkeException)·{ |
222 | ············o·=·ex; | 221 | ············o·=·ex; |
223 | ········} | 222 | ········} |
Offset 277, 14 lines modified | Offset 276, 18 lines modified |
277 | ········this.mIkePrf·=·mIkePrf; | 276 | ········this.mIkePrf·=·mIkePrf; |
278 | ········this.mIkeDhGroup·=·mIkeDhGroup; | 277 | ········this.mIkeDhGroup·=·mIkeDhGroup; |
279 | ········this.mSkD·=·mSkD; | 278 | ········this.mSkD·=·mSkD; |
280 | ········this.mIsFirstChild·=·true; | 279 | ········this.mIsFirstChild·=·true; |
281 | ········this.sendMessage(301,·(Object)new·ChildSessionStateMachine$FirstChildNegotiationData(list,·list2,·this.registerProvisionalChildAndGetSpi(list2))); | 280 | ········this.sendMessage(301,·(Object)new·ChildSessionStateMachine$FirstChildNegotiationData(list,·list2,·this.registerProvisionalChildAndGetSpi(list2))); |
282 | ····} | 281 | ····} |
283 | ···· | 282 | ···· |
| 283 | ····public·void·killSession()·{ |
| 284 | ········this.sendMessage(304); |
| 285 | ····} |
| 286 | ···· |
284 | ····protected·void·onQuitting()·{ | 287 | ····protected·void·onQuitting()·{ |
285 | ········this.closeAllSaRecords(true); | 288 | ········this.closeAllSaRecords(true); |
286 | ········this.mChildSmCallback.onProcedureFinished(this); | 289 | ········this.mChildSmCallback.onProcedureFinished(this); |
287 | ········this.mChildSmCallback.onChildSessionClosed(this.mUserCallback); | 290 | ········this.mChildSmCallback.onChildSessionClosed(this.mUserCallback); |
288 | ····} | 291 | ····} |
289 | ···· | 292 | ···· |
290 | ····public·void·receiveRequest(final·int·n,·final·int·n2,·final·List·list)·{ | 293 | ····public·void·receiveRequest(final·int·n,·final·int·n2,·final·List·list)·{ |