|
| 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