Java Code Examples for sun.security.krb5.EncryptedData#ETYPE_ARCFOUR_HMAC

The following examples show how to use sun.security.krb5.EncryptedData#ETYPE_ARCFOUR_HMAC . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: W83.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        W83 x = new W83();

        // Cannot use OneKDC. kinit command cannot resolve
        // hostname kdc.rabbit.hole
        KDC kdc = new KDC(OneKDC.REALM, "127.0.0.1", 0, true);
        kdc.addPrincipal(OneKDC.USER, OneKDC.PASS);
        kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc);
        System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
        Config.refresh();

        kdc.writeKtab(OneKDC.KTAB);

        KeyTab ktab = KeyTab.getInstance(OneKDC.KTAB);
        for (int etype: EType.getBuiltInDefaults()) {
            if (etype != EncryptedData.ETYPE_ARCFOUR_HMAC) {
                ktab.deleteEntries(new PrincipalName(OneKDC.USER), etype, -1);
            }
        }
        ktab.save();

        if (System.getProperty("6932525") != null) {
            // For 6932525 and 6951366, make sure the etypes sent in 2nd AS-REQ
            // is not restricted to that of preauth
            kdc.setOption(KDC.Option.ONLY_RC4_TGT, true);
        }
        if (System.getProperty("6959292") != null) {
            // For 6959292, make sure that when etype for enc-part in 2nd AS-REQ
            // is different from that of preauth, client can still decrypt it
            kdc.setOption(KDC.Option.RC4_FIRST_PREAUTH, true);
        }
        x.go();
    }
 
Example 2
Source File: KeyImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private String getAlgorithmName(int eType) {
    if (destroyed)
        throw new IllegalStateException("This key is no longer valid");

    switch (eType) {
    case EncryptedData.ETYPE_DES_CBC_CRC:
    case EncryptedData.ETYPE_DES_CBC_MD5:
        return "DES";

    case EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD:
        return "DESede";

    case EncryptedData.ETYPE_ARCFOUR_HMAC:
        return "ArcFourHmac";

    case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96:
        return "AES128";

    case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA1_96:
        return "AES256";

    case EncryptedData.ETYPE_NULL:
        return "NULL";

    default:
        throw new IllegalArgumentException(
            "Unsupported encryption type: " + eType);
    }
}
 
Example 3
Source File: W83.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        W83 x = new W83();

        // Cannot use OneKDC. kinit command cannot resolve
        // hostname kdc.rabbit.hole
        KDC kdc = new KDC(OneKDC.REALM, "127.0.0.1", 0, true);
        kdc.addPrincipal(OneKDC.USER, OneKDC.PASS);
        kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc);
        System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
        Config.refresh();

        kdc.writeKtab(OneKDC.KTAB);

        KeyTab ktab = KeyTab.getInstance(OneKDC.KTAB);
        for (int etype: EType.getBuiltInDefaults()) {
            if (etype != EncryptedData.ETYPE_ARCFOUR_HMAC) {
                ktab.deleteEntries(new PrincipalName(OneKDC.USER), etype, -1);
            }
        }
        ktab.save();

        if (System.getProperty("6932525") != null) {
            // For 6932525 and 6951366, make sure the etypes sent in 2nd AS-REQ
            // is not restricted to that of preauth
            kdc.setOption(KDC.Option.ONLY_RC4_TGT, true);
        }
        if (System.getProperty("6959292") != null) {
            // For 6959292, make sure that when etype for enc-part in 2nd AS-REQ
            // is different from that of preauth, client can still decrypt it
            kdc.setOption(KDC.Option.RC4_FIRST_PREAUTH, true);
        }
        x.go();
    }
 
Example 4
Source File: KeyImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private String getAlgorithmName(int eType) {
    if (destroyed)
        throw new IllegalStateException("This key is no longer valid");

    switch (eType) {
    case EncryptedData.ETYPE_DES_CBC_CRC:
    case EncryptedData.ETYPE_DES_CBC_MD5:
        return "DES";

    case EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD:
        return "DESede";

    case EncryptedData.ETYPE_ARCFOUR_HMAC:
        return "ArcFourHmac";

    case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96:
        return "AES128";

    case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA1_96:
        return "AES256";

    case EncryptedData.ETYPE_NULL:
        return "NULL";

    default:
        throw new IllegalArgumentException(
            "Unsupported encryption type: " + eType);
    }
}
 
Example 5
Source File: W83.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        W83 x = new W83();

        // Cannot use OneKDC. kinit command cannot resolve
        // hostname kdc.rabbit.hole
        KDC kdc = new KDC(OneKDC.REALM, "127.0.0.1", 0, true);
        kdc.addPrincipal(OneKDC.USER, OneKDC.PASS);
        kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc);
        System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
        Config.refresh();

        kdc.writeKtab(OneKDC.KTAB);

        KeyTab ktab = KeyTab.getInstance(OneKDC.KTAB);
        for (int etype: EType.getBuiltInDefaults()) {
            if (etype != EncryptedData.ETYPE_ARCFOUR_HMAC) {
                ktab.deleteEntries(new PrincipalName(OneKDC.USER), etype, -1);
            }
        }
        ktab.save();

        if (System.getProperty("6932525") != null) {
            // For 6932525 and 6951366, make sure the etypes sent in 2nd AS-REQ
            // is not restricted to that of preauth
            kdc.setOption(KDC.Option.ONLY_RC4_TGT, true);
        }
        if (System.getProperty("6959292") != null) {
            // For 6959292, make sure that when etype for enc-part in 2nd AS-REQ
            // is different from that of preauth, client can still decrypt it
            kdc.setOption(KDC.Option.RC4_FIRST_PREAUTH, true);
        }
        x.go();
    }
 
Example 6
Source File: KeyImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private String getAlgorithmName(int eType) {
    if (destroyed)
        throw new IllegalStateException("This key is no longer valid");

    switch (eType) {
    case EncryptedData.ETYPE_DES_CBC_CRC:
    case EncryptedData.ETYPE_DES_CBC_MD5:
        return "DES";

    case EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD:
        return "DESede";

    case EncryptedData.ETYPE_ARCFOUR_HMAC:
        return "ArcFourHmac";

    case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96:
        return "AES128";

    case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA1_96:
        return "AES256";

    case EncryptedData.ETYPE_NULL:
        return "NULL";

    default:
        throw new IllegalArgumentException(
            "Unsupported encryption type: " + eType);
    }
}
 
Example 7
Source File: KeyImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private String getAlgorithmName(int eType) {
    if (destroyed)
        throw new IllegalStateException("This key is no longer valid");

    switch (eType) {
    case EncryptedData.ETYPE_DES_CBC_CRC:
    case EncryptedData.ETYPE_DES_CBC_MD5:
        return "DES";

    case EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD:
        return "DESede";

    case EncryptedData.ETYPE_ARCFOUR_HMAC:
        return "ArcFourHmac";

    case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96:
        return "AES128";

    case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA1_96:
        return "AES256";

    case EncryptedData.ETYPE_NULL:
        return "NULL";

    default:
        throw new IllegalArgumentException(
            "Unsupported encryption type: " + eType);
    }
}
 
Example 8
Source File: W83.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        W83 x = new W83();

        // Cannot use OneKDC. kinit command cannot resolve
        // hostname kdc.rabbit.hole
        KDC kdc = new KDC(OneKDC.REALM, "127.0.0.1", 0, true);
        kdc.addPrincipal(OneKDC.USER, OneKDC.PASS);
        kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc);
        System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
        Config.refresh();

        kdc.writeKtab(OneKDC.KTAB);

        KeyTab ktab = KeyTab.getInstance(OneKDC.KTAB);
        for (int etype: EType.getBuiltInDefaults()) {
            if (etype != EncryptedData.ETYPE_ARCFOUR_HMAC) {
                ktab.deleteEntries(new PrincipalName(OneKDC.USER), etype, -1);
            }
        }
        ktab.save();

        if (System.getProperty("6932525") != null) {
            // For 6932525 and 6951366, make sure the etypes sent in 2nd AS-REQ
            // is not restricted to that of preauth
            kdc.setOption(KDC.Option.ONLY_RC4_TGT, true);
        }
        if (System.getProperty("6959292") != null) {
            // For 6959292, make sure that when etype for enc-part in 2nd AS-REQ
            // is different from that of preauth, client can still decrypt it
            kdc.setOption(KDC.Option.RC4_FIRST_PREAUTH, true);
        }
        x.go();
    }
 
Example 9
Source File: W83.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        W83 x = new W83();

        // Cannot use OneKDC. kinit command cannot resolve
        // hostname kdc.rabbit.hole
        KDC kdc = new KDC(OneKDC.REALM, "127.0.0.1", 0, true);
        kdc.addPrincipal(OneKDC.USER, OneKDC.PASS);
        kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc);
        System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
        Config.refresh();

        kdc.writeKtab(OneKDC.KTAB);

        KeyTab ktab = KeyTab.getInstance(OneKDC.KTAB);
        for (int etype: EType.getBuiltInDefaults()) {
            if (etype != EncryptedData.ETYPE_ARCFOUR_HMAC) {
                ktab.deleteEntries(new PrincipalName(OneKDC.USER), etype, -1);
            }
        }
        ktab.save();

        if (System.getProperty("6932525") != null) {
            // For 6932525 and 6951366, make sure the etypes sent in 2nd AS-REQ
            // is not restricted to that of preauth
            kdc.setOption(KDC.Option.ONLY_RC4_TGT, true);
        }
        if (System.getProperty("6959292") != null) {
            // For 6959292, make sure that when etype for enc-part in 2nd AS-REQ
            // is different from that of preauth, client can still decrypt it
            kdc.setOption(KDC.Option.RC4_FIRST_PREAUTH, true);
        }
        x.go();
    }
 
Example 10
Source File: KeyImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private String getAlgorithmName(int eType) {
    if (destroyed)
        throw new IllegalStateException("This key is no longer valid");

    switch (eType) {
    case EncryptedData.ETYPE_DES_CBC_CRC:
    case EncryptedData.ETYPE_DES_CBC_MD5:
        return "DES";

    case EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD:
        return "DESede";

    case EncryptedData.ETYPE_ARCFOUR_HMAC:
        return "ArcFourHmac";

    case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96:
        return "AES128";

    case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA1_96:
        return "AES256";

    case EncryptedData.ETYPE_NULL:
        return "NULL";

    default:
        throw new IllegalArgumentException(
            "Unsupported encryption type: " + eType);
    }
}
 
Example 11
Source File: W83.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        W83 x = new W83();

        // Cannot use OneKDC. kinit command cannot resolve
        // hostname kdc.rabbit.hole
        KDC kdc = new KDC(OneKDC.REALM, "127.0.0.1", 0, true);
        kdc.addPrincipal(OneKDC.USER, OneKDC.PASS);
        kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc);
        System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
        Config.refresh();

        kdc.writeKtab(OneKDC.KTAB);

        KeyTab ktab = KeyTab.getInstance(OneKDC.KTAB);
        for (int etype: EType.getBuiltInDefaults()) {
            if (etype != EncryptedData.ETYPE_ARCFOUR_HMAC) {
                ktab.deleteEntries(new PrincipalName(OneKDC.USER), etype, -1);
            }
        }
        ktab.save();

        if (System.getProperty("6932525") != null) {
            // For 6932525 and 6951366, make sure the etypes sent in 2nd AS-REQ
            // is not restricted to that of preauth
            kdc.setOption(KDC.Option.ONLY_RC4_TGT, true);
        }
        if (System.getProperty("6959292") != null) {
            // For 6959292, make sure that when etype for enc-part in 2nd AS-REQ
            // is different from that of preauth, client can still decrypt it
            kdc.setOption(KDC.Option.RC4_FIRST_PREAUTH, true);
        }
        x.go();
    }
 
Example 12
Source File: EType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static EType getInstance  (int eTypeConst)
    throws KdcErrException {
    EType eType = null;
    String eTypeName = null;
    switch (eTypeConst) {
    case EncryptedData.ETYPE_NULL:
        eType = new NullEType();
        eTypeName = "sun.security.krb5.internal.crypto.NullEType";
        break;
    case EncryptedData.ETYPE_DES_CBC_CRC:
        eType = new DesCbcCrcEType();
        eTypeName = "sun.security.krb5.internal.crypto.DesCbcCrcEType";
        break;
    case EncryptedData.ETYPE_DES_CBC_MD5:
        eType = new DesCbcMd5EType();
        eTypeName = "sun.security.krb5.internal.crypto.DesCbcMd5EType";
        break;

    case EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD:
        eType = new Des3CbcHmacSha1KdEType();
        eTypeName =
            "sun.security.krb5.internal.crypto.Des3CbcHmacSha1KdEType";
        break;

    case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96:
        eType = new Aes128CtsHmacSha1EType();
        eTypeName =
            "sun.security.krb5.internal.crypto.Aes128CtsHmacSha1EType";
        break;

    case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA1_96:
        eType = new Aes256CtsHmacSha1EType();
        eTypeName =
            "sun.security.krb5.internal.crypto.Aes256CtsHmacSha1EType";
        break;

    case EncryptedData.ETYPE_ARCFOUR_HMAC:
        eType = new ArcFourHmacEType();
        eTypeName = "sun.security.krb5.internal.crypto.ArcFourHmacEType";
        break;

    default:
        String msg = "encryption type = " + toString(eTypeConst)
            + " ("  + eTypeConst + ")";
        throw new KdcErrException(Krb5.KDC_ERR_ETYPE_NOSUPP, msg);
    }
    if (DEBUG) {
        System.out.println(">>> EType: " + eTypeName);
    }
    return eType;
}
 
Example 13
Source File: ArcFourHmacEType.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public int eType() {
    return EncryptedData.ETYPE_ARCFOUR_HMAC;
}
 
Example 14
Source File: ArcFourHmacEType.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public int eType() {
    return EncryptedData.ETYPE_ARCFOUR_HMAC;
}
 
Example 15
Source File: ArcFourHmacEType.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public int eType() {
    return EncryptedData.ETYPE_ARCFOUR_HMAC;
}
 
Example 16
Source File: ArcFourHmacEType.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public int eType() {
    return EncryptedData.ETYPE_ARCFOUR_HMAC;
}
 
Example 17
Source File: ArcFourHmacEType.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public int eType() {
    return EncryptedData.ETYPE_ARCFOUR_HMAC;
}
 
Example 18
Source File: EType.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static EType getInstance  (int eTypeConst)
    throws KdcErrException {
    EType eType = null;
    String eTypeName = null;
    switch (eTypeConst) {
    case EncryptedData.ETYPE_NULL:
        eType = new NullEType();
        eTypeName = "sun.security.krb5.internal.crypto.NullEType";
        break;
    case EncryptedData.ETYPE_DES_CBC_CRC:
        eType = new DesCbcCrcEType();
        eTypeName = "sun.security.krb5.internal.crypto.DesCbcCrcEType";
        break;
    case EncryptedData.ETYPE_DES_CBC_MD5:
        eType = new DesCbcMd5EType();
        eTypeName = "sun.security.krb5.internal.crypto.DesCbcMd5EType";
        break;

    case EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD:
        eType = new Des3CbcHmacSha1KdEType();
        eTypeName =
            "sun.security.krb5.internal.crypto.Des3CbcHmacSha1KdEType";
        break;

    case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96:
        eType = new Aes128CtsHmacSha1EType();
        eTypeName =
            "sun.security.krb5.internal.crypto.Aes128CtsHmacSha1EType";
        break;

    case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA1_96:
        eType = new Aes256CtsHmacSha1EType();
        eTypeName =
            "sun.security.krb5.internal.crypto.Aes256CtsHmacSha1EType";
        break;

    case EncryptedData.ETYPE_ARCFOUR_HMAC:
        eType = new ArcFourHmacEType();
        eTypeName = "sun.security.krb5.internal.crypto.ArcFourHmacEType";
        break;

    default:
        String msg = "encryption type = " + toString(eTypeConst)
            + " ("  + eTypeConst + ")";
        throw new KdcErrException(Krb5.KDC_ERR_ETYPE_NOSUPP, msg);
    }
    if (DEBUG) {
        System.out.println(">>> EType: " + eTypeName);
    }
    return eType;
}
 
Example 19
Source File: ArcFourHmacEType.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public int eType() {
    return EncryptedData.ETYPE_ARCFOUR_HMAC;
}
 
Example 20
Source File: EType.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * https://tools.ietf.org/html/rfc4120#section-3.1.3:
 *
 *                 A "newer" enctype is any enctype first officially
 * specified concurrently with or subsequent to the issue of this RFC.
 * The enctypes DES, 3DES, or RC4 and any defined in [RFC1510] are not
 * "newer" enctypes.
 *
 * @param eTypeConst the encryption type
 * @return true if "newer"
 */
public static boolean isNewer(int eTypeConst) {
    return eTypeConst != EncryptedData.ETYPE_DES_CBC_CRC &&
            eTypeConst != EncryptedData.ETYPE_DES_CBC_MD4 &&
            eTypeConst != EncryptedData.ETYPE_DES_CBC_MD5 &&
            eTypeConst != EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD &&
            eTypeConst != EncryptedData.ETYPE_ARCFOUR_HMAC &&
            eTypeConst != EncryptedData.ETYPE_ARCFOUR_HMAC_EXP;
}