CosEncryption.java
23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.io.ByteWriterFactory
* com.adobe.internal.io.ByteWriterFactory$Fixed
* com.adobe.internal.io.stream.InputByteStream
* com.adobe.internal.io.stream.OutputByteStream
* com.adobe.internal.io.stream.StreamManager
*/
package com.adobe.internal.pdftoolkit.core.cos;
import com.adobe.internal.io.ByteWriterFactory;
import com.adobe.internal.io.stream.InputByteStream;
import com.adobe.internal.io.stream.OutputByteStream;
import com.adobe.internal.io.stream.StreamManager;
import com.adobe.internal.pdftoolkit.core.cos.CosArray;
import com.adobe.internal.pdftoolkit.core.cos.CosContainer;
import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
import com.adobe.internal.pdftoolkit.core.cos.CosDocument;
import com.adobe.internal.pdftoolkit.core.cos.CosLinearization;
import com.adobe.internal.pdftoolkit.core.cos.CosName;
import com.adobe.internal.pdftoolkit.core.cos.CosNull;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
import com.adobe.internal.pdftoolkit.core.cos.CosObjectInfo;
import com.adobe.internal.pdftoolkit.core.cos.CosObjectStream;
import com.adobe.internal.pdftoolkit.core.cos.CosStream;
import com.adobe.internal.pdftoolkit.core.cos.CosString;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFCosParseException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityAuthorizationException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityConfigurationException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFUnsupportedFeatureException;
import com.adobe.internal.pdftoolkit.core.securityframework.DecryptedState;
import com.adobe.internal.pdftoolkit.core.securityframework.EncryptionHandler;
import com.adobe.internal.pdftoolkit.core.securityframework.EncryptionHandlerState;
import com.adobe.internal.pdftoolkit.core.securityframework.SecurityHandler;
import com.adobe.internal.pdftoolkit.core.securityframework.SecurityManager;
import com.adobe.internal.pdftoolkit.core.securityframework.impl.EnableEncryption;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class CosEncryption {
private EnableEncryption mEncryptionHandle = null;
private CosDictionary mDecryptDictionary = null;
private CosDocument mDoc;
private SecurityManager mEncryptionManager = null;
private Map mEncryptionMap = null;
private Map mDecryptionStateHandlers = null;
private Map mEncryptionStateHandlers = null;
private boolean mNeedsDecryption;
private boolean mNeedsEncryption = false;
private boolean mDoDecryption;
private boolean mIsNewEncryption = false;
private boolean mInSave = false;
private static final String ENCRYPT_IMPL = "com.adobe.internal.pdftoolkit.core.encryption.EncryptionImpl";
private static final String ENCRYPT_METADATA = ASName.k_EncryptMetadata.asString(true);
private static final String STMF = ASName.k_StmF.asString(true);
private static final String CF = ASName.k_CF.asString(true);
private static final String V = ASName.k_V.asString(true);
public CosEncryption(CosDocument doc) {
this.mDoc = doc;
if (doc == null) {
this.mNeedsDecryption = false;
this.mDoDecryption = false;
}
}
public void setupDecryption() throws PDFCosParseException, PDFIOException, PDFSecurityException {
if (this.mDoc != null) {
CosDictionary trailer;
this.mNeedsDecryption = this.mDoc.isEncrypted();
if (this.mNeedsDecryption && (trailer = this.mDoc.getTrailer()) != null) {
this.mDecryptDictionary = trailer.containsKey(ASName.k_Encrypt) ? trailer.getCosDictionary(ASName.k_Encrypt) : null;
}
}
this.mDoDecryption = true;
}
public boolean needsDecryption() {
return this.mNeedsDecryption;
}
public boolean setNeedsDecryption(boolean decrypt) {
boolean old = this.mNeedsDecryption;
this.mNeedsDecryption = decrypt;
return old;
}
public boolean needsEncryption() {
return this.mNeedsEncryption;
}
public CosDictionary getEncryption() {
return this.mDecryptDictionary;
}
public Map getDecryptionMap() throws PDFCosParseException, PDFIOException, PDFSecurityException {
return (Map)this.mDecryptDictionary.getValue();
}
public Map getEncryptionMap() throws PDFSecurityAuthorizationException {
return this.getEncryptionImpl().getEncryptionParameters();
}
public SecurityHandler getDefaultDecryptionHandler() throws PDFCosParseException, PDFSecurityException {
if (this.mEncryptionHandle == null) {
throw new PDFSecurityConfigurationException("Security Manager is not set");
}
return this.getDefaultHandler(this.mEncryptionHandle.getDecryptionParameters(), this.mEncryptionHandle.getDecryptionSecurityManager());
}
private SecurityHandler getDefaultHandler(Map encryptParams, SecurityManager secMgr) throws PDFCosParseException, PDFSecurityException {
if (this.mEncryptionHandle == null || secMgr == null) {
throw new PDFSecurityConfigurationException("Security Manager is not set");
}
SecurityHandler handler = null;
String handlerName = (String)encryptParams.get("Filter");
if (handlerName != null) {
handler = secMgr.getSecurityHandler(handlerName, encryptParams);
}
if (handler != null) {
return handler;
}
throw new PDFCosParseException("Invalid /Encrypt dictionary");
}
public EnableEncryption getEncryptionImpl() throws PDFUnsupportedFeatureException {
if (this.mEncryptionHandle == null) {
try {
this.mEncryptionHandle = (EnableEncryption)Class.forName("com.adobe.internal.pdftoolkit.core.encryption.EncryptionImpl").getConstructor(new Class[0]).newInstance(new Object[0]);
}
catch (Exception exp) {
throw new PDFUnsupportedFeatureException("Encryption is not supported", exp);
}
}
return this.mEncryptionHandle;
}
private boolean shouldEncryptMetadata1(CosStream stream, ASName cryptFilter, boolean encrypting) throws PDFCosParseException, PDFIOException, PDFSecurityException {
Map cryptDict;
Map encryptParams;
Map cfDict;
String cryptName;
Boolean toEncrypt = null;
if (stream.containsKey(ASName.k_Type) && stream.getName(ASName.k_Type).equals(ASName.k_Metadata) && (toEncrypt = (Boolean)(encryptParams = encrypting ? this.getEncryptionMap() : this.getDecryptionMap()).get(ENCRYPT_METADATA)) == null && (cfDict = (Map)encryptParams.get(ASName.k_CF.asString(true))) != null && (cryptDict = (Map)cfDict.get(cryptName = cryptFilter == null ? (String)encryptParams.get(STMF) : cryptFilter.asString(true))) != null) {
toEncrypt = (Boolean)cryptDict.get(ENCRYPT_METADATA);
}
return toEncrypt == null || toEncrypt != false;
}
private boolean shouldEncryptMetadata(ASName type, ASName cryptFilter, boolean encrypting) throws PDFCosParseException, PDFIOException, PDFSecurityException {
Map cryptDict;
Map encryptParams;
Map cfDict;
String cryptName;
Boolean toEncrypt = null;
if (ASName.k_Metadata.equals(type) && (toEncrypt = (Boolean)(encryptParams = encrypting ? this.getEncryptionMap() : this.getDecryptionMap()).get(ENCRYPT_METADATA)) == null && (cfDict = (Map)encryptParams.get(ASName.k_CF.asString(true))) != null && (cryptDict = (Map)cfDict.get(cryptName = cryptFilter == null ? (String)encryptParams.get(STMF) : cryptFilter.asString(true))) != null) {
toEncrypt = (Boolean)cryptDict.get(ENCRYPT_METADATA);
}
return toEncrypt == null || toEncrypt != false;
}
boolean shouldDecryptOrEncrypt1(CosStream stream, ASName cryptFilter, boolean encrypting) throws PDFCosParseException, PDFIOException, PDFSecurityException, IOException {
boolean encryptMetadata = this.shouldEncryptMetadata1(stream, cryptFilter, encrypting);
if (!this.mInSave) {
return encryptMetadata;
}
if (!encryptMetadata) {
return false;
}
if (this.mIsNewEncryption) {
return true;
}
if (stream.isDirty()) {
return true;
}
if (!(stream instanceof CosObjectStream || stream.getCryptFilter() == null && stream.getDocument().getLinearization() != null)) {
return false;
}
return true;
}
int shouldDecryptOrEncrypt(ASName type, ASName cryptFilter, boolean encrypting) throws PDFCosParseException, PDFIOException, PDFSecurityException {
int retVal = 0;
boolean encryptMetadata = this.shouldEncryptMetadata(type, cryptFilter, encrypting);
if (!this.mInSave) {
retVal = encryptMetadata ? 1 : -1;
} else if (!encryptMetadata) {
retVal = -1;
} else if (this.mIsNewEncryption) {
retVal = 1;
}
return retVal;
}
public SecurityManager getDecryptionSecurityManager() {
return this.mEncryptionHandle != null ? this.mEncryptionHandle.getDecryptionSecurityManager() : null;
}
public boolean authenticateDecryption(DecryptedState decryptedState) throws PDFSecurityException {
SecurityHandler secHandler;
try {
secHandler = this.getDefaultDecryptionHandler();
}
catch (PDFCosParseException excp) {
throw new PDFSecurityAuthorizationException("Authentication failed", excp);
}
return this.mEncryptionHandle.authenticateSecurity(secHandler, decryptedState);
}
public void setDecryptionSecurityManager(SecurityManager securityMgr) throws PDFSecurityException, PDFCosParseException, PDFIOException {
try {
this.setDecryptionSecurityManager(securityMgr, this.getDecryptionMap());
}
catch (IOException e) {
throw new PDFIOException(e);
}
}
void setDecryptionSecurityManager(SecurityManager securityMgr, Map encryptParams) throws PDFSecurityException, PDFCosParseException, PDFIOException, IOException {
if (this.mEncryptionHandle == null) {
this.getEncryptionImpl();
}
if (this.mEncryptionHandle.getDecryptionSecurityManager() == null) {
this.setupDecryption();
this.mEncryptionHandle.setDecryptionSecurityManager(securityMgr, encryptParams, this.getIDForEncryption());
if (this.mEncryptionHandle.getEncryptionSecurityManager() == null) {
this.setEncryptionSecurityManager(securityMgr, encryptParams);
this.mEncryptionHandle.setEncryptionSecurityManager(securityMgr, encryptParams, this.getIDForEncryption());
this.mIsNewEncryption = false;
}
} else {
throw new PDFSecurityAuthorizationException("Cannot unlock again already unlocked document");
}
}
public SecurityManager getEncryptionSecurityManager() {
return this.mEncryptionHandle != null ? this.mEncryptionHandle.getEncryptionSecurityManager() : null;
}
public void setEncryptionSecurityManager(SecurityManager securityMgr, Map encryptParams) {
this.getEncryptionImpl();
this.mNeedsEncryption = true;
this.mIsNewEncryption = true;
this.mEncryptionManager = securityMgr;
this.mEncryptionMap = encryptParams;
}
public void setDecryptionAsEncryption() throws PDFSecurityException, PDFCosParseException, PDFIOException {
try {
if (this.mDoc.isEncrypted()) {
SecurityManager encryptionMgr = this.getEncryptionSecurityManager();
Map encryptionMap = this.getEncryptionMap();
this.resetDecryptionSecurityManager();
if (encryptionMgr != null) {
this.setDecryptionSecurityManager(encryptionMgr, encryptionMap);
}
} else {
this.resetDecryptionSecurityManager();
}
this.mIsNewEncryption = false;
this.mInSave = false;
this.setupDecryption();
}
catch (IOException e) {
throw new PDFIOException(e);
}
}
public void setupEncryption() throws PDFCosParseException, PDFIOException, PDFSecurityException {
try {
this.mInSave = true;
if (!this.mNeedsEncryption) {
return;
}
this.getEncryptionImpl();
this.mEncryptionHandle.setEncryptionSecurityManager(this.mEncryptionManager, this.mEncryptionMap, this.getIDForEncryption());
if (this.mIsNewEncryption) {
SecurityHandler defaultHandler = this.getDefaultHandler(this.mEncryptionMap, this.mEncryptionManager);
this.mEncryptionHandle.authenticateSecurity(this.mEncryptionMap, this.getIDForEncryption(), defaultHandler, null);
}
}
catch (IOException e) {
throw new PDFIOException(e);
}
}
public void resetEncryptionSecurityManager() {
if (this.mEncryptionHandle != null) {
this.mEncryptionHandle.resetEncryptionSecurityManager();
}
this.mNeedsEncryption = false;
this.mEncryptionManager = null;
this.mIsNewEncryption = true;
}
public void resetDecryptionSecurityManager() {
if (this.mEncryptionHandle != null) {
this.mEncryptionHandle.resetDecryptionSecurityManager();
}
}
private int getEncryptVersion() {
Integer versionObj;
int version = 0;
if (this.mEncryptionMap != null && (versionObj = (Integer)this.mEncryptionMap.get(V)) != null) {
version = versionObj;
}
return version;
}
private int getDecryptVersion() throws PDFSecurityException {
int version = 0;
if (this.mDecryptDictionary != null && this.mDecryptDictionary.containsKey(ASName.k_V)) {
try {
version = this.mDecryptDictionary.getInt(ASName.k_V);
}
catch (PDFCosParseException e) {
throw new PDFSecurityException("PDFCosParseException while reading /Encrypt/V ", e);
}
catch (PDFIOException e) {
throw new PDFSecurityException("PDFIOException while reading /Encrypt/V ", e);
}
}
return version;
}
public byte[] encryptString(CosString strObj, byte[] content) throws PDFSecurityException {
if (this.needsEncryption(strObj)) {
byte[] addKey = this.getEncryptVersion() < 5 ? strObj.getObjectEncryptionKey(true) : null;
return this.getEncryptionImpl().encryptString(content, addKey);
}
return content;
}
public byte[] decryptString(CosString strObj, byte[] content) throws PDFSecurityException {
if (this.needsDecryption(strObj)) {
byte[] addKey = this.getDecryptVersion() < 5 ? strObj.getObjectEncryptionKey(false) : null;
return this.getEncryptionImpl().decryptString(content, addKey);
}
return content;
}
public InputByteStream decryptStream(ASName cryptFilter, CosStream strObj, InputByteStream content) throws PDFIOException, PDFSecurityException, PDFCosParseException {
try {
this.getEncryptionImpl();
OutputByteStream dest = strObj.getStreamManager().getOutputByteStreamEncryptedDocument(ByteWriterFactory.Fixed.GROWABLE, content.length());
this.mEncryptionHandle.decryptStream(cryptFilter != null ? cryptFilter.asString(true) : null, content, dest, this.getStreamEncryptionKey(strObj, false));
return dest.closeAndConvert();
}
catch (IOException e) {
throw new PDFIOException(e);
}
}
byte[] getStreamEncryptionKey(CosStream stream, boolean write) throws PDFCosParseException, PDFIOException, PDFSecurityException, IOException {
byte[] addKey = null;
if (stream.getCryptFilter() == null) {
int version;
int n = version = write ? this.getEncryptVersion() : this.getDecryptVersion();
if (version < 5) {
addKey = stream.getObjectEncryptionKey(write);
}
}
return addKey;
}
public InputByteStream encryptStream(ASName cryptFilter, CosStream strObj, InputByteStream content) throws PDFCosParseException, PDFIOException, PDFSecurityException {
try {
this.getEncryptionImpl();
OutputByteStream dest = strObj.getStreamManager().getOutputByteStreamEncryptedDocument(ByteWriterFactory.Fixed.GROWABLE, content.length());
content.seek(0);
this.mEncryptionHandle.encryptStream(cryptFilter != null ? cryptFilter.asString(true) : null, content, dest, this.getStreamEncryptionKey(strObj, true));
return dest.closeAndConvert();
}
catch (IOException e) {
throw new PDFIOException(e);
}
}
public boolean setEncryptionState(boolean doIt) {
boolean old = this.getEncryptionState();
this.mDoDecryption = doIt;
return old;
}
public boolean getEncryptionState() {
return this.mDoDecryption;
}
private byte[] getIDForEncryption() throws PDFCosParseException, PDFIOException, PDFSecurityException, IOException {
CosObject idStr;
byte[] id = null;
CosDictionary trailer = this.mDoc.getTrailer();
if (trailer != null && (idStr = trailer.get(ASName.k_ID)) != null && idStr.getType() == 5) {
id = ((CosString)((CosArray)idStr).get(0)).byteArrayValue();
}
return id;
}
private boolean hasEFF() throws PDFSecurityAuthorizationException {
Map encryptionParams;
boolean result = false;
if (this.needsEncryption() && (encryptionParams = this.getEncryptionMap()) != null && encryptionParams.containsKey("EFF")) {
result = true;
}
return result;
}
private boolean needsEncryption(CosString stringObj) {
if (!this.needsEncryption()) {
return false;
}
CosObjectInfo strInfo = stringObj.getInfo();
if (strInfo == null) {
CosContainer parent = stringObj.getParentObj();
if (parent == null) {
return true;
}
strInfo = parent.getInfo();
}
if (strInfo == null) {
return true;
}
return this.mDoDecryption && !strInfo.isWriteCompressed();
}
private boolean needsDecryption(CosString stringObj) {
if (!this.needsDecryption()) {
return false;
}
CosObjectInfo strInfo = stringObj.getInfo();
if (strInfo == null) {
CosContainer parent = stringObj.getParentObj();
if (parent == null) {
return true;
}
strInfo = parent.getInfo();
}
if (strInfo == null) {
return true;
}
return this.mDoDecryption && !strInfo.isCompressed();
}
CosArray checkEFFOutputFilter(CosStream stmObj) throws PDFCosParseException, PDFIOException, PDFSecurityException {
CosArray outputFilters = stmObj.getOutputFiltersList();
if (outputFilters == null && this.hasEFF() && stmObj.isDirty() && (outputFilters = stmObj.getInputFiltersList()) != null) {
this.removeCryptFilter(outputFilters);
}
return outputFilters;
}
CosArray checkMetadataStream(CosStream stmObj) throws PDFCosParseException, PDFIOException, PDFSecurityException, IOException {
CosArray outputFilters = stmObj.getOutputFiltersList();
CosObject type = stmObj.get(ASName.k_Type);
if (type != null && this.needsEncryption() && ASName.k_Metadata.equals(type.nameValue())) {
Map encryptParams;
if (outputFilters == null) {
outputFilters = stmObj.getInputFiltersList();
}
if ((encryptParams = this.getEncryptionMap()) != null) {
this.removeCryptFilter(outputFilters);
if (encryptParams.containsKey(CF) && !this.shouldEncryptMetadata(type.nameValue(), null, true)) {
CosArray cryptFilter = this.mDoc.createCosArray();
cryptFilter.add(this.mDoc.createCosName(ASName.k_Crypt));
cryptFilter.add(this.mDoc.createCosNull());
outputFilters.add(0, cryptFilter);
}
}
}
return outputFilters;
}
private boolean removeCryptFilter(CosArray filters) throws PDFCosParseException, PDFIOException, PDFSecurityException {
Iterator<CosObject> filtersIter = filters.iterator();
while (filtersIter.hasNext()) {
CosArray filterAtIndex = (CosArray)filtersIter.next();
if (!ASName.k_Crypt.equals(((CosName)filterAtIndex.get(0)).nameValue())) continue;
filtersIter.remove();
return true;
}
return false;
}
EncryptionHandler getStreamDecryptionHandler(String cryptName) throws PDFSecurityException {
this.getEncryptionImpl();
return this.mEncryptionHandle.getStreamDecryptionHandler(cryptName);
}
EncryptionHandler getStreamEncryptionHandler(String cryptName) throws PDFSecurityException {
this.getEncryptionImpl();
return this.mEncryptionHandle.getStreamEncryptionHandler(cryptName);
}
EncryptionHandlerState getStreamDecryptionStateHandler(CosStream stream, InputByteStream content) throws PDFCosParseException, PDFIOException, PDFSecurityException, IOException {
EncryptionHandlerState stateHandler;
if (!stream.needsDecryption(content)) {
return null;
}
ASName cryptFilter = stream.getCryptFilter();
String cryptName = cryptFilter == null ? null : cryptFilter.asString(true);
this.getEncryptionImpl();
EncryptionHandler handler = this.mEncryptionHandle.getStreamDecryptionHandler(cryptName);
if (handler == null) {
return null;
}
if (this.mDecryptionStateHandlers == null) {
this.mDecryptionStateHandlers = new HashMap();
}
if ((stateHandler = (EncryptionHandlerState)this.mDecryptionStateHandlers.get(handler)) == null) {
stateHandler = handler.createEncryptionHandlerState();
this.mDecryptionStateHandlers.put(handler, stateHandler);
}
return stateHandler;
}
EncryptionHandlerState getStreamEncryptionStateHandler(CosStream stream) throws PDFCosParseException, PDFIOException, PDFSecurityException, IOException {
EncryptionHandlerState stateHandler;
if (!stream.needsEncryption()) {
return null;
}
this.getEncryptionImpl();
ASName cryptFilter = stream.getCryptFilter();
String cryptName = cryptFilter == null ? null : cryptFilter.asString(true);
EncryptionHandler handler = this.mEncryptionHandle.getStreamEncryptionHandler(cryptName);
if (handler == null) {
return null;
}
if (this.mEncryptionStateHandlers == null) {
this.mEncryptionStateHandlers = new HashMap();
}
if ((stateHandler = (EncryptionHandlerState)this.mEncryptionStateHandlers.get(handler)) == null) {
stateHandler = handler.createEncryptionHandlerState();
this.mEncryptionStateHandlers.put(handler, stateHandler);
}
return stateHandler;
}
void resetDecryptionStateHandlers() {
this.mDecryptionStateHandlers = null;
}
void resetEncryptionStateHandlers() {
this.mEncryptionStateHandlers = null;
}
}