本文整理汇总了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;
}
}
示例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;
}
}