Skip to content

Commit faabbf7

Browse files
authored
Merge pull request #648 from RUB-NDS/ocsp-last3.3.1
OCSP & 'Certificate Status' TLS message support
2 parents 2c3fee2 + 711a3ec commit faabbf7

File tree

47 files changed

+3022
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3022
-26
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ Utils/.settings/org.eclipse.jdt.core.prefs
4545
test.sh
4646
.settings/
4747
.classpath
48+
.idea
49+
*.iml
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* TLS-Attacker - A Modular Penetration Testing Framework for TLS
3+
*
4+
* Copyright 2014-2020 Ruhr University Bochum, Paderborn University,
5+
* and Hackmanit GmbH
6+
*
7+
* Licensed under Apache License 2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*/
10+
package de.rub.nds.tlsattacker.core.certificate;
11+
12+
import com.google.common.collect.BiMap;
13+
import com.google.common.collect.HashBiMap;
14+
15+
public class CrlReason {
16+
private static final BiMap<Integer, String> reasonMap = HashBiMap.create();
17+
18+
static {
19+
reasonMap.put(0, "unspecified");
20+
reasonMap.put(1, "keyCompromise");
21+
reasonMap.put(2, "cACompromise");
22+
reasonMap.put(3, "affiliationChanged");
23+
reasonMap.put(4, "superseded");
24+
reasonMap.put(5, "cessationOfOperation");
25+
reasonMap.put(6, "certificateHold");
26+
// case 7 is undefined by standard
27+
reasonMap.put(8, "removeFromCRL");
28+
reasonMap.put(9, "privilegeWithdrawn");
29+
reasonMap.put(10, "aACompromise");
30+
}
31+
32+
public static String translate(Integer input) {
33+
String translated;
34+
translated = reasonMap.get(input);
35+
return translated;
36+
}
37+
38+
public static Integer translate(String input) {
39+
Integer translated;
40+
translated = reasonMap.inverse().get(input);
41+
return translated;
42+
}
43+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* TLS-Attacker - A Modular Penetration Testing Framework for TLS
3+
*
4+
* Copyright 2014-2020 Ruhr University Bochum, Paderborn University,
5+
* and Hackmanit GmbH
6+
*
7+
* Licensed under Apache License 2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*/
10+
package de.rub.nds.tlsattacker.core.certificate;
11+
12+
public enum ExtensionObjectIdentifier {
13+
OCSP("1.3.6.1.5.5.7.48.1"),
14+
CERTIFICATE_AUTHORITY_ISSUER("1.3.6.1.5.5.7.48.2"),
15+
AUTHORITY_INFO_ACCESS("1.3.6.1.5.5.7.1.1"),
16+
TLS_FEATURE("1.3.6.1.5.5.7.1.24");
17+
18+
private final String objectIdentifier;
19+
20+
/**
21+
* @param objectIdentifier
22+
*/
23+
24+
ExtensionObjectIdentifier(final String objectIdentifier) {
25+
this.objectIdentifier = objectIdentifier;
26+
}
27+
28+
public String getOID() {
29+
return objectIdentifier;
30+
}
31+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/**
2+
* TLS-Attacker - A Modular Penetration Testing Framework for TLS
3+
*
4+
* Copyright 2014-2020 Ruhr University Bochum, Paderborn University,
5+
* and Hackmanit GmbH
6+
*
7+
* Licensed under Apache License 2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*/
10+
package de.rub.nds.tlsattacker.core.certificate;
11+
12+
import com.google.common.collect.BiMap;
13+
import com.google.common.collect.HashBiMap;
14+
15+
public class ObjectIdentifierTranslator {
16+
private static final BiMap<String, String> oidMap = HashBiMap.create();
17+
18+
static {
19+
// Algorithms
20+
oidMap.put("1.2.840.10045.4.1", "ecdsa-with-SHA1");
21+
oidMap.put("1.2.840.10045.4.2", "ecdsa-with-Recommended");
22+
oidMap.put("1.2.840.10045.4.3", "ecdsa-with-SHA2");
23+
oidMap.put("1.2.840.10045.4.3.1", "ecdsa-with-SHA224");
24+
oidMap.put("1.2.840.10045.4.3.2", "ecdsa-with-SHA256");
25+
oidMap.put("1.2.840.10045.4.3.3", "ecdsa-with-SHA384");
26+
oidMap.put("1.2.840.10045.4.3.4", "ecdsa-with-SHA512");
27+
28+
oidMap.put("1.2.840.113549.1.1.0", "modules"); // ASN.1 modules?
29+
oidMap.put("1.2.840.113549.1.1.1", "rsaEncryption");
30+
oidMap.put("1.2.840.113549.1.1.2", "md2WithRSAEncryption");
31+
oidMap.put("1.2.840.113549.1.1.3", "md4withRSAEncryption");
32+
oidMap.put("1.2.840.113549.1.1.4", "md5WithRSAEncryption");
33+
oidMap.put("1.2.840.113549.1.1.5", "sha1-with-rsa-signature");
34+
oidMap.put("1.2.840.113549.1.1.6", "rsaOAEPEncryptionSet");
35+
oidMap.put("1.2.840.113549.1.1.7", "id-RSAES-OAEP");
36+
oidMap.put("1.2.840.113549.1.1.8", "id-mgf1");
37+
oidMap.put("1.2.840.113549.1.1.9", "id-pSpecified");
38+
oidMap.put("1.2.840.113549.1.1.10", "rsassa-pss");
39+
oidMap.put("1.2.840.113549.1.1.11", "sha256WithRSAEncryption");
40+
oidMap.put("1.2.840.113549.1.1.12", "sha384WithRSAEncryption");
41+
oidMap.put("1.2.840.113549.1.1.13", "sha512WithRSAEncryption");
42+
oidMap.put("1.2.840.113549.1.1.14", "sha224WithRSAEncryption");
43+
oidMap.put("1.2.840.113549.1.1.15", "sha512-224WithRSAEncryption");
44+
oidMap.put("1.2.840.113549.1.1.16", "sha512-256WithRSAEncryption");
45+
46+
oidMap.put("1.3.14.3.2.1", "rsa");
47+
oidMap.put("1.3.14.3.2.2", "md4WithRSA");
48+
oidMap.put("1.3.14.3.2.3", "md5WithRSA");
49+
oidMap.put("1.3.14.3.2.4", "md4WithRSAEncryption");
50+
oidMap.put("1.3.14.3.2.6", "desECB");
51+
oidMap.put("1.3.14.3.2.7", "desCBC");
52+
oidMap.put("1.3.14.3.2.8", "desOFB");
53+
oidMap.put("1.3.14.3.2.9", "desCFB");
54+
oidMap.put("1.3.14.3.2.10", "desMAC");
55+
oidMap.put("1.3.14.3.2.11", "rsaSignature");
56+
oidMap.put("1.3.14.3.2.12", "dsa");
57+
oidMap.put("1.3.14.3.2.13", "dsaWithSHA");
58+
oidMap.put("1.3.14.3.2.14", "mdc2WithRSASignature");
59+
oidMap.put("1.3.14.3.2.15", "shaWithRSASignature");
60+
oidMap.put("1.3.14.3.2.16", "dhWithCommonModulus");
61+
oidMap.put("1.3.14.3.2.17", "desEDE");
62+
oidMap.put("1.3.14.3.2.18", "sha");
63+
oidMap.put("1.3.14.3.2.19", "mdc-2");
64+
oidMap.put("1.3.14.3.2.20", "dsaCommon");
65+
oidMap.put("1.3.14.3.2.21", "dsaCommonWithSHA");
66+
oidMap.put("1.3.14.3.2.22", "rsa-key-transport");
67+
oidMap.put("1.3.14.3.2.23", "keyed-hash-seal");
68+
oidMap.put("1.3.14.3.2.24", "md2WithRSASignature");
69+
oidMap.put("1.3.14.3.2.25", "md5WithRSASignature");
70+
oidMap.put("1.3.14.3.2.26", "SHA1");
71+
oidMap.put("1.3.14.3.2.27", "dsaWithSHA1");
72+
oidMap.put("1.3.14.3.2.28", "dsaWithCommonSHA1");
73+
oidMap.put("1.3.14.3.2.29", "sha1WithRSAEncryption");
74+
75+
// Distinguished Name, short form
76+
oidMap.put("2.5.4.3", "CN");
77+
oidMap.put("2.5.4.4", "SN");
78+
oidMap.put("2.5.4.5", "Serial Number");
79+
oidMap.put("2.5.4.6", "C");
80+
oidMap.put("2.5.4.7", "L");
81+
oidMap.put("2.5.4.8", "S");
82+
oidMap.put("2.5.4.10", "O");
83+
oidMap.put("2.5.4.11", "OU");
84+
oidMap.put("2.5.4.12", "Title");
85+
oidMap.put("2.5.4.42", "GN");
86+
oidMap.put("2.5.4.43", "Initials");
87+
oidMap.put("2.5.4.44", "Generation Qualifier");
88+
oidMap.put("2.5.4.65", "Pseudonym");
89+
}
90+
91+
public static String translate(String input) {
92+
String translated;
93+
// Forward check
94+
translated = oidMap.get(input);
95+
96+
// Reverse check
97+
if (translated == null) {
98+
translated = oidMap.inverse().get(input);
99+
}
100+
101+
// Return input if not found
102+
if (translated == null) {
103+
translated = input;
104+
}
105+
return translated;
106+
}
107+
}

0 commit comments

Comments
 (0)