本文整理汇总了Java中org.bouncycastle.operator.RuntimeOperatorException类的典型用法代码示例。如果您正苦于以下问题:Java RuntimeOperatorException类的具体用法?Java RuntimeOperatorException怎么用?Java RuntimeOperatorException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeOperatorException类属于org.bouncycastle.operator包,在下文中一共展示了RuntimeOperatorException类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: verify
import org.bouncycastle.operator.RuntimeOperatorException; //导入依赖的package包/类
public boolean verify(byte[] expected)
{
try
{
return stream.verify(expected);
}
catch (SignatureException e)
{
throw new RuntimeOperatorException("exception obtaining signature: " + e.getMessage(), e);
}
}
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:JcaContentVerifierProviderBuilder.java
示例2: getOutputStream
import org.bouncycastle.operator.RuntimeOperatorException; //导入依赖的package包/类
@Override
public OutputStream getOutputStream() {
try {
signer.initSign(key);
} catch (InvalidKeyException ex) {
throw new RuntimeOperatorException("could not initSign", ex);
}
return stream;
}
开发者ID:xipki,项目名称:xitk,代码行数:10,代码来源:SignatureSigner.java
示例3: getSignature
import org.bouncycastle.operator.RuntimeOperatorException; //导入依赖的package包/类
@Override
public byte[] getSignature() {
try {
return stream.getSignature();
} catch (SignatureException ex) {
throw new RuntimeOperatorException("exception obtaining signature: " + ex.getMessage(),
ex);
}
}
开发者ID:xipki,项目名称:xitk,代码行数:10,代码来源:SignatureSigner.java
示例4: hash
import org.bouncycastle.operator.RuntimeOperatorException; //导入依赖的package包/类
public static byte[] hash(HashAlgoType hashAlgoType, byte[] data) {
ParamUtil.requireNonNull("hashAlgoType", hashAlgoType);
ParamUtil.requireNonNull("data", data);
if (!MDS_MAP.containsKey(hashAlgoType)) {
throw new IllegalArgumentException("unknown hash algo " + hashAlgoType);
}
ConcurrentBag<ConcurrentBagEntry<Digest>> mds = MDS_MAP.get(hashAlgoType);
ConcurrentBagEntry<Digest> md0 = null;
for (int i = 0; i < 3; i++) {
try {
md0 = mds.borrow(10, TimeUnit.SECONDS);
break;
} catch (InterruptedException ex) { // CHECKSTYLE:SKIP
}
}
if (md0 == null) {
throw new RuntimeOperatorException("could not get idle MessageDigest");
}
try {
Digest md = md0.value();
md.reset();
md.update(data, 0, data.length);
byte[] bytes = new byte[md.getDigestSize()];
md.doFinal(bytes, 0);
return bytes;
} finally {
mds.requite(md0);
}
}
开发者ID:xipki,项目名称:xitk,代码行数:34,代码来源:HashCalculator.java
示例5: hash
import org.bouncycastle.operator.RuntimeOperatorException; //导入依赖的package包/类
/**
* Hash the data and returns the first 8 bytes of the hash value.
* @param data data over which the hash value is calculated.
* @return long represented of the first 8 bytes
*/
public static long hash(byte[] data) {
ParamUtil.requireNonNull("data", data);
ConcurrentBagEntry<Digest> md0 = null;
for (int i = 0; i < 3; i++) {
try {
md0 = MDS.borrow(10, TimeUnit.SECONDS);
break;
} catch (InterruptedException ex) { // CHECKSTYLE:SKIP
}
}
if (md0 == null) {
throw new RuntimeOperatorException("could not get idle MessageDigest");
}
try {
Digest md = md0.value();
md.reset();
md.update(data, 0, data.length);
byte[] bytes = new byte[md.getDigestSize()];
md.doFinal(bytes, 0);
return bytesToLong(bytes);
} finally {
MDS.requite(md0);
}
}
开发者ID:xipki,项目名称:xitk,代码行数:34,代码来源:FpIdCalculator.java
示例6: genCalculator
import org.bouncycastle.operator.RuntimeOperatorException; //导入依赖的package包/类
private MacCalculator genCalculator(final PBMParameter params, char[] password)
throws CRMFException
{
// From RFC 4211
//
// 1. Generate a random salt value S
//
// 2. Append the salt to the pw. K = pw || salt.
//
// 3. Hash the value of K. K = HASH(K)
//
// 4. Iter = Iter - 1. If Iter is greater than zero. Goto step 3.
//
// 5. Compute an HMAC as documented in [HMAC].
//
// MAC = HASH( K XOR opad, HASH( K XOR ipad, data) )
//
// Where opad and ipad are defined in [HMAC].
byte[] pw = Strings.toUTF8ByteArray(password);
byte[] salt = params.getSalt().getOctets();
byte[] K = new byte[pw.length + salt.length];
System.arraycopy(pw, 0, K, 0, pw.length);
System.arraycopy(salt, 0, K, pw.length, salt.length);
calculator.setup(params.getOwf(), params.getMac());
int iter = params.getIterationCount().getValue().intValue();
do
{
K = calculator.calculateDigest(K);
}
while (--iter > 0);
final byte[] key = K;
return new MacCalculator()
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
public AlgorithmIdentifier getAlgorithmIdentifier()
{
return new AlgorithmIdentifier(CMPObjectIdentifiers.passwordBasedMac, params);
}
public GenericKey getKey()
{
return new GenericKey(getAlgorithmIdentifier(), key);
}
public OutputStream getOutputStream()
{
return bOut;
}
public byte[] getMac()
{
try
{
return calculator.calculateMac(key, bOut.toByteArray());
}
catch (CRMFException e)
{
throw new RuntimeOperatorException("exception calculating mac: " + e.getMessage(), e);
}
}
};
}
开发者ID:Appdome,项目名称:ipack,代码行数:69,代码来源:PKMACBuilder.java
示例7: build
import org.bouncycastle.operator.RuntimeOperatorException; //导入依赖的package包/类
public ContentSigner build(AsymmetricKeyParameter privateKey)
throws OperatorCreationException
{
final Signer sig = createSigner(sigAlgId, digAlgId);
if (random != null)
{
sig.init(true, new ParametersWithRandom(privateKey, random));
}
else
{
sig.init(true, privateKey);
}
return new ContentSigner()
{
private BcSignerOutputStream stream = new BcSignerOutputStream(sig);
public AlgorithmIdentifier getAlgorithmIdentifier()
{
return sigAlgId;
}
public OutputStream getOutputStream()
{
return stream;
}
public byte[] getSignature()
{
try
{
return stream.getSignature();
}
catch (CryptoException e)
{
throw new RuntimeOperatorException("exception obtaining signature: " + e.getMessage(), e);
}
}
};
}
开发者ID:Appdome,项目名称:ipack,代码行数:42,代码来源:BcContentSignerBuilder.java
注:本文中的org.bouncycastle.operator.RuntimeOperatorException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论