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


Java DigestInfo.getDigest方法代码示例

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


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

示例1: __verifyNonRepSignature

import org.bouncycastle.asn1.x509.DigestInfo; //导入方法依赖的package包/类
private boolean __verifyNonRepSignature(final byte[] expectedDigestValue, final byte[] signatureValue,
		final X509Certificate certificate) throws NoSuchAlgorithmException, NoSuchPaddingException,
		InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException {
	final PublicKey publicKey = certificate.getPublicKey();

	final Cipher cipher = Cipher.getInstance("RSA");
	cipher.init(Cipher.DECRYPT_MODE, publicKey);
	final byte[] actualSignatureDigestInfoValue = cipher.doFinal(signatureValue);

	final ASN1InputStream asnInputStream = new ASN1InputStream(actualSignatureDigestInfoValue);
	final DigestInfo actualSignatureDigestInfo = new DigestInfo((ASN1Sequence) asnInputStream.readObject());
	asnInputStream.close();

	final byte[] actualDigestValue = actualSignatureDigestInfo.getDigest();
	return Arrays.equals(expectedDigestValue, actualDigestValue);
}
 
开发者ID:e-Contract,项目名称:commons-eid,代码行数:17,代码来源:BeIDIntegrity.java

示例2: computeProxy

import org.bouncycastle.asn1.x509.DigestInfo; //导入方法依赖的package包/类
/**
 * Compute the content proxy for a given node. This should likely move somewhere else
 * @param nodeContent the content stored at this node
 * @param isDigest is the content already digested
 * @return the proxy digest (for example, the computed root of the Merkle hash tree) for this node
 * @throws CertificateEncodingException if we cannot decode the witness
 */
public byte[] computeProxy(byte[] nodeContent, boolean isDigest) throws CertificateEncodingException {
	if (null == witness())
		return null;
	
	DigestInfo info = CCNDigestHelper.digestDecoder(witness());
	
	byte [] proxy = null;
	
	if (MerklePath.isMerklePath(info)) {
		MerklePath mp = new MerklePath(info.getDigest());
		proxy = mp.root(nodeContent, isDigest);
	} else {
		Log.warning("Unexpected witness type: " + info.getAlgorithmId().toString());
	}
	return proxy;
}
 
开发者ID:StefanoSalsano,项目名称:alien-ofelia-conet-ccnx,代码行数:24,代码来源:Signature.java

示例3: getSignedDigest

import org.bouncycastle.asn1.x509.DigestInfo; //导入方法依赖的package包/类
private byte[] getSignedDigest(byte[] signatureValue, CertificateToken signer) throws GeneralSecurityException, IOException {
	PublicKey publicKey = signer.getPublicKey();
	Cipher cipher = Cipher.getInstance(publicKey.getAlgorithm());
	cipher.init(Cipher.DECRYPT_MODE, publicKey);
	byte[] decrypted = cipher.doFinal(signatureValue);

	try (ASN1InputStream inputDecrypted = new ASN1InputStream(decrypted)) {
		ASN1Sequence seqDecrypt = (ASN1Sequence) inputDecrypted.readObject();
		DigestInfo digestInfo = new DigestInfo(seqDecrypt);
		return digestInfo.getDigest();
	}
}
 
开发者ID:esig,项目名称:dss,代码行数:13,代码来源:CRLUtilsStreamImpl.java

示例4: testTree

import org.bouncycastle.asn1.x509.DigestInfo; //导入方法依赖的package包/类
public static void testTree(byte [][] content, int count, boolean digest) {
	// Generate a merkle tree. Verify each path for the content.
	MerkleTree tree = new MerkleTree(content, digest, count, 0, 
									((count-1) >= 0) && ((count-1) < content.length) ? content[count-1].length : 0);
			
	MerklePath [] paths = new MerklePath[count];
	for (int i=0; i < count; ++i) {
		paths[i] = tree.path(i);
		//checkPath(tree, paths[i]);
		byte [] root = paths[i].root(content[i],digest);
		boolean result = Arrays.equals(root, tree.root());
		if (!result) {
			System.out.println("Constructed tree of " + count + " blocks (of " + content.length + "), numleaves: " + 
					tree.numLeaves() + " max pathlength: " + tree.maxDepth());
			System.out.println("Path " + i + " verified for leaf " + paths[i].leafNodeIndex() + "? " + result);
		}
		Assert.assertTrue("Path " + i + " failed to verify.", result);
		
		try {
			byte [] encodedPath = paths[i].derEncodedPath();
			DigestInfo info = CCNDigestHelper.digestDecoder(encodedPath);
			MerklePath decoded = new MerklePath(info.getDigest());
			if (!decoded.equals(paths[i])) {
				System.out.println("Path " + i + " failed to encode and decode.");
				Assert.fail("Path " + i + " failed to encode and decode.");
			}
		} catch (Exception e) {
			System.out.println("Exception encoding path " + i + " :" + e.getClass().getName() + ": " + e.getMessage());
			e.printStackTrace();
			Assert.fail("Exception encoding path " + i + " :" + e.getClass().getName() + ": " + e.getMessage());
		}
	}
}
 
开发者ID:StefanoSalsano,项目名称:alien-ofelia-conet-ccnx,代码行数:34,代码来源:MerkleTreeTest.java

示例5: engineVerify

import org.bouncycastle.asn1.x509.DigestInfo; //导入方法依赖的package包/类
protected boolean engineVerify(
    byte[]  sigBytes) 
    throws SignatureException
{
    byte[]  hash = new byte[digest.getDigestSize()];

    digest.doFinal(hash, 0);

    DigestInfo  digInfo;
    byte[]      sig;

    try
    {
        sig = cipher.processBlock(sigBytes, 0, sigBytes.length);
        digInfo = derDecode(sig);
    }
    catch (Exception e)
    {
        return false;
    }

    if (!digInfo.getAlgorithmId().equals(algId))
    {
        return false;
    }

    byte[]  sigHash = digInfo.getDigest();

    if (hash.length != sigHash.length)
    {
        return false;
    }

    for (int i = 0; i < hash.length; i++)
    {
        if (sigHash[i] != hash[i])
        {
            return false;
        }
    }

    return true;
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:44,代码来源:JDKDigestSignature.java


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