当前位置: 首页>>代码示例>>Java>>正文


Java ArcFourHmac.encryptRaw方法代码示例

本文整理汇总了Java中sun.security.krb5.internal.crypto.ArcFourHmac.encryptRaw方法的典型用法代码示例。如果您正苦于以下问题:Java ArcFourHmac.encryptRaw方法的具体用法?Java ArcFourHmac.encryptRaw怎么用?Java ArcFourHmac.encryptRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.security.krb5.internal.crypto.ArcFourHmac的用法示例。


在下文中一共展示了ArcFourHmac.encryptRaw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: arcFourEncrypt

import sun.security.krb5.internal.crypto.ArcFourHmac; //导入方法依赖的package包/类
private byte[] arcFourEncrypt(WrapToken token, byte[] confounder,
    byte[] plaintext, int start, int len, byte[] padding)
    throws GSSException {

    // [confounder | plaintext | padding]
    byte[] all = new byte[confounder.length + len + padding.length];
    System.arraycopy(confounder, 0, all, 0, confounder.length);
    System.arraycopy(plaintext, start, all, confounder.length, len);
    System.arraycopy(padding, 0, all, confounder.length + len,
        padding.length);

    // get the token Sequence Number required for encryption
    // Note: When using this RC4 based encryption type, the sequence number
    // is always sent in big-endian rather than little-endian order.
    byte[] seqNum = new byte[4];
    WrapToken.writeBigEndian(token.getSequenceNumber(), seqNum);

    // Krb5Token.debug("\narcFourEncrypt:" + Krb5Token.getHexBytes(all));

    // Encrypt
    try {
        byte[] answer = ArcFourHmac.encryptRaw(keybytes, KG_USAGE_SEAL,
                                    seqNum, all, 0, all.length);
        // Krb5Token.debug("\narcFourEncrypt encrypted:" +
        //  Krb5Token.getHexBytes(answer));
        return answer;
    } catch (Exception e) {
        // GeneralSecurityException, KrbCryptoException
        GSSException ge = new GSSException(GSSException.FAILURE, -1,
            "Could not use ArcFour Cipher - " + e.getMessage());
        ge.initCause(e);
        throw ge;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:CipherHelper.java

示例2: arcFourEncrypt

import sun.security.krb5.internal.crypto.ArcFourHmac; //导入方法依赖的package包/类
private byte[] arcFourEncrypt(WrapToken token, byte[] confounder,
    byte[] plaintext, int start, int len, byte[] padding)
    throws GSSException {

    // [confounder | plaintext | padding]
    byte[] all = new byte[confounder.length + len + padding.length];
    System.arraycopy(confounder, 0, all, 0, confounder.length);
    System.arraycopy(plaintext, start, all, confounder.length, len);
    System.arraycopy(padding, 0, all, confounder.length + len,
        padding.length);

    // get the token Sequence Number required for encryption
    // Note: When using this RC4 based encryption type, the sequence number
    // is always sent in big-endian rather than little-endian order.
    byte[] seqNum = new byte[4];
    token.writeBigEndian(token.getSequenceNumber(), seqNum);

    // Krb5Token.debug("\narcFourEncrypt:" + Krb5Token.getHexBytes(all));

    // Encrypt
    try {
        byte[] answer = ArcFourHmac.encryptRaw(keybytes, KG_USAGE_SEAL,
                                    seqNum, all, 0, all.length);
        // Krb5Token.debug("\narcFourEncrypt encrypted:" +
        //  Krb5Token.getHexBytes(answer));
        return answer;
    } catch (Exception e) {
        // GeneralSecurityException, KrbCryptoException
        GSSException ge = new GSSException(GSSException.FAILURE, -1,
            "Could not use ArcFour Cipher - " + e.getMessage());
        ge.initCause(e);
        throw ge;
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:35,代码来源:CipherHelper.java


注:本文中的sun.security.krb5.internal.crypto.ArcFourHmac.encryptRaw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。