PBSHStandardCipher.java
3.91 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityAuthorizationException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityConfigurationException
* com.adobe.internal.pdftoolkit.core.permissionprovider.PermissionProvider
* com.adobe.internal.pdftoolkit.core.securityframework.EncryptionHandler
* com.adobe.internal.pdftoolkit.core.securityframework.SecurityHandler
* com.adobe.internal.pdftoolkit.core.securityframework.impl.SecurityProvidersImpl
*/
package com.adobe.internal.pdftoolkit.core.encryption;
import com.adobe.internal.pdftoolkit.core.encryption.EncryptionKeyImpl;
import com.adobe.internal.pdftoolkit.core.encryption.IdentityEncryptionHandler;
import com.adobe.internal.pdftoolkit.core.encryption.PBSHStandard;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityAuthorizationException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityConfigurationException;
import com.adobe.internal.pdftoolkit.core.permissionprovider.PermissionProvider;
import com.adobe.internal.pdftoolkit.core.securityframework.EncryptionHandler;
import com.adobe.internal.pdftoolkit.core.securityframework.SecurityHandler;
import com.adobe.internal.pdftoolkit.core.securityframework.impl.SecurityProvidersImpl;
import java.security.MessageDigest;
import java.util.Map;
public class PBSHStandardCipher
extends PBSHStandard
implements SecurityHandler {
public PBSHStandardCipher(byte[] owner, byte[] user, Map encrypt, PermissionProvider encryptionPermissions, SecurityProvidersImpl providers) throws PDFSecurityConfigurationException {
super(owner, user, encrypt, encryptionPermissions, providers);
this.setInternalRC4Encryption();
}
public PBSHStandardCipher(byte[] password, SecurityProvidersImpl providers) throws PDFSecurityConfigurationException {
super(password, providers);
this.setInternalRC4Encryption();
}
public static PBSHStandard newInstance(byte[] owner, byte[] user, Map encrypt, PermissionProvider encryptionPermissions) throws PDFSecurityConfigurationException {
return new PBSHStandardCipher(owner, user, encrypt, encryptionPermissions, null);
}
public static PBSHStandard newInstance(byte[] password) throws PDFSecurityConfigurationException {
return new PBSHStandardCipher(password, null);
}
public static PBSHStandard newInstance(byte[] owner, byte[] user, Map encrypt, PermissionProvider encryptionPermissions, SecurityProvidersImpl providers) throws PDFSecurityConfigurationException {
return new PBSHStandardCipher(owner, user, encrypt, encryptionPermissions, providers);
}
public static PBSHStandard newInstance(byte[] password, SecurityProvidersImpl providers) throws PDFSecurityConfigurationException {
return new PBSHStandardCipher(password, providers);
}
public EncryptionHandler getEncryptionHandler(String cryptName, Map encryptParams, byte[] docID) throws PDFSecurityConfigurationException, PDFSecurityAuthorizationException {
if ("Identity".equals(cryptName)) {
return new IdentityEncryptionHandler();
}
String algorithm = EncryptionKeyImpl.getEncryptionAlgorithm(encryptParams, cryptName);
return this.getEncryptionHandler(cryptName, algorithm, encryptParams, docID);
}
protected EncryptionHandler getEncryptionHandler(String handlerName, String algorithm, Map encryptParams, byte[] docID) throws PDFSecurityConfigurationException, PDFSecurityAuthorizationException {
if (this.mainEncryption == null || docID != this.curDocID) {
if (!this.decryptedUsingState) {
this.checkPassword(handlerName, encryptParams, docID);
}
this.mainEncryption = EncryptionKeyImpl.getEncryptionHandler(this.encryptKey, algorithm, this.md5Digest, encryptParams, this.secProviders);
}
return this.mainEncryption;
}
}