本文整理汇总了Java中sun.security.krb5.internal.crypto.ArcFourHmac类的典型用法代码示例。如果您正苦于以下问题:Java ArcFourHmac类的具体用法?Java ArcFourHmac怎么用?Java ArcFourHmac使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArcFourHmac类属于sun.security.krb5.internal.crypto包,在下文中一共展示了ArcFourHmac类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例3: arcFourDecrypt
import sun.security.krb5.internal.crypto.ArcFourHmac; //导入依赖的package包/类
private void arcFourDecrypt(WrapToken token, byte[] ciphertext,
int cStart, int cLen, byte[] plaintext, int pStart)
throws GSSException {
// obtain Sequence number needed for decryption
// first decrypt the Sequence Number using checksum
byte[] seqNum = decryptSeq(token.getChecksum(),
token.getEncSeqNumber(), 0, 8);
byte[] ptext;
try {
ptext = ArcFourHmac.decryptRaw(keybytes, KG_USAGE_SEAL, ZERO_IV,
ciphertext, cStart, cLen, seqNum);
} catch (GeneralSecurityException e) {
GSSException ge = new GSSException(GSSException.FAILURE, -1,
"Could not use ArcFour Cipher - " + e.getMessage());
ge.initCause(e);
throw ge;
}
/*
Krb5Token.debug("\narcFourDecrypt in: " +
Krb5Token.getHexBytes(ciphertext, cStart, cLen));
Krb5Token.debug("\narcFourDecrypt plain: " +
Krb5Token.getHexBytes(ptext));
*/
// Strip out confounder and padding
/*
* There is always at least one padding byte. The padding bytes
* are all the value of the number of padding bytes.
*/
int padSize = ptext[ptext.length - 1];
if (padSize < 1)
throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
"Invalid padding on Wrap Token");
token.padding = WrapToken.pads[padSize];
int len = ptext.length - WrapToken.CONFOUNDER_SIZE - padSize;
System.arraycopy(ptext, WrapToken.CONFOUNDER_SIZE,
plaintext, pStart, len);
// Krb5Token.debug("\narcFourDecrypt plaintext: " +
// Krb5Token.getHexBytes(plaintext));
// Needed to calculate checksum
System.arraycopy(ptext, 0, token.confounder,
0, WrapToken.CONFOUNDER_SIZE);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:CipherHelper.java
注:本文中的sun.security.krb5.internal.crypto.ArcFourHmac类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论