本文整理匯總了Java中org.bouncycastle.crypto.Digest.getDigestSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Digest.getDigestSize方法的具體用法?Java Digest.getDigestSize怎麽用?Java Digest.getDigestSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bouncycastle.crypto.Digest
的用法示例。
在下文中一共展示了Digest.getDigestSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: OAEPEncoding
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
public OAEPEncoding(
AsymmetricBlockCipher cipher,
Digest hash,
Digest mgf1Hash,
byte[] encodingParams)
{
this.engine = cipher;
this.mgf1Hash = mgf1Hash;
this.defHash = new byte[hash.getDigestSize()];
hash.reset();
if (encodingParams != null)
{
hash.update(encodingParams, 0, encodingParams.length);
}
hash.doFinal(defHash, 0);
}
示例2: AuthorityKeyIdentifier
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
/**
* create an AuthorityKeyIdentifier with the GeneralNames tag and
* the serial number provided as well.
*/
public AuthorityKeyIdentifier(
SubjectPublicKeyInfo spki,
GeneralNames name,
BigInteger serialNumber)
{
Digest digest = new SHA1Digest();
byte[] resBuf = new byte[digest.getDigestSize()];
byte[] bytes = spki.getPublicKeyData().getBytes();
digest.update(bytes, 0, bytes.length);
digest.doFinal(resBuf, 0);
this.keyidentifier = new DEROctetString(resBuf);
this.certissuer = GeneralNames.getInstance(name.toASN1Primitive());
this.certserno = new ASN1Integer(serialNumber);
}
示例3: calculateHashForZeroKnowledgeProof
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
private static BigInteger calculateHashForZeroKnowledgeProof(
BigInteger g,
BigInteger gr,
BigInteger gx,
String participantId,
Digest digest)
{
digest.reset();
updateDigestIncludingSize(digest, g);
updateDigestIncludingSize(digest, gr);
updateDigestIncludingSize(digest, gx);
updateDigestIncludingSize(digest, participantId);
byte[] output = new byte[digest.getDigestSize()];
digest.doFinal(output, 0);
return new BigInteger(output);
}
示例4: HMac
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
private HMac(
Digest digest,
int byteLength)
{
this.digest = digest;
digestSize = digest.getDigestSize();
this.blockLength = byteLength;
inputPad = new byte[blockLength];
outputPad = new byte[blockLength];
}
示例5: PKCS12ParametersGenerator
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
/**
* Construct a PKCS 12 Parameters generator. This constructor will
* accept any digest which also implements ExtendedDigest.
*
* @param digest the digest to be used as the source of derived keys.
* @exception IllegalArgumentException if an unknown digest is passed in.
*/
public PKCS12ParametersGenerator(
Digest digest)
{
this.digest = digest;
if (digest instanceof ExtendedDigest)
{
u = digest.getDigestSize();
v = ((ExtendedDigest)digest).getByteLength();
}
else
{
throw new IllegalArgumentException("Digest " + digest.getAlgorithmName() + " unsupported");
}
}
示例6: OldHMac
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
/**
* @deprecated uses incorrect pad for SHA-512 and SHA-384 use HMac.
*/
public OldHMac(
Digest digest)
{
this.digest = digest;
digestSize = digest.getDigestSize();
}
示例7: hash
import org.bouncycastle.crypto.Digest; //導入方法依賴的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);
}
}
示例8: SSL3Mac
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
/**
* Base constructor for one of the standard digest algorithms that the byteLength of
* the algorithm is know for. Behaviour is undefined for digests other than MD5 or SHA1.
*
* @param digest the digest.
*/
public SSL3Mac(Digest digest)
{
this.digest = digest;
if (digest.getDigestSize() == 20)
{
this.padLength = 40;
}
else
{
this.padLength = 48;
}
}
示例9: generateServerKeyExchange
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
public byte[] generateServerKeyExchange()
throws IOException
{
if (this.dhParameters == null)
{
throw new TlsFatalAlert(AlertDescription.internal_error);
}
ByteArrayOutputStream buf = new ByteArrayOutputStream();
DHKeyPairGenerator kpg = new DHKeyPairGenerator();
kpg.init(new DHKeyGenerationParameters(context.getSecureRandom(), this.dhParameters));
AsymmetricCipherKeyPair kp = kpg.generateKeyPair();
BigInteger Ys = ((DHPublicKeyParameters)kp.getPublic()).getY();
TlsDHUtils.writeDHParameter(dhParameters.getP(), buf);
TlsDHUtils.writeDHParameter(dhParameters.getG(), buf);
TlsDHUtils.writeDHParameter(Ys, buf);
byte[] digestInput = buf.toByteArray();
Digest d = new CombinedHash();
SecurityParameters securityParameters = context.getSecurityParameters();
d.update(securityParameters.clientRandom, 0, securityParameters.clientRandom.length);
d.update(securityParameters.serverRandom, 0, securityParameters.serverRandom.length);
d.update(digestInput, 0, digestInput.length);
byte[] hash = new byte[d.getDigestSize()];
d.doFinal(hash, 0);
byte[] sigBytes = serverCredentials.generateCertificateSignature(hash);
/*
* TODO RFC 5246 4.7. digitally-signed element needs SignatureAndHashAlgorithm prepended from TLS 1.2
*/
TlsUtils.writeOpaque16(sigBytes, buf);
return buf.toByteArray();
}
示例10: ISO9796d2PSSSigner
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
/**
* Generate a signer for the with either implicit or explicit trailers
* for ISO9796-2, scheme 2 or 3.
*
* @param cipher base cipher to use for signature creation/verification
* @param digest digest to use.
* @param saltLength length of salt in bytes.
* @param implicit whether or not the trailer is implicit or gives the hash.
*/
public ISO9796d2PSSSigner(
AsymmetricBlockCipher cipher,
Digest digest,
int saltLength,
boolean implicit)
{
this.cipher = cipher;
this.digest = digest;
this.hLen = digest.getDigestSize();
this.saltLength = saltLength;
if (implicit)
{
trailer = TRAILER_IMPLICIT;
}
else
{
Integer trailerObj = (Integer)trailerMap.get(digest.getAlgorithmName());
if (trailerObj != null)
{
trailer = trailerObj.intValue();
}
else
{
throw new IllegalArgumentException("no valid trailer for digest");
}
}
}
示例11: calculateKeyBlock_SSL
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
static byte[] calculateKeyBlock_SSL(byte[] master_secret, byte[] random, int size)
{
Digest md5 = new MD5Digest();
Digest sha1 = new SHA1Digest();
int md5Size = md5.getDigestSize();
byte[] shatmp = new byte[sha1.getDigestSize()];
byte[] tmp = new byte[size + md5Size];
int i = 0, pos = 0;
while (pos < size)
{
byte[] ssl3Const = SSL3_CONST[i];
sha1.update(ssl3Const, 0, ssl3Const.length);
sha1.update(master_secret, 0, master_secret.length);
sha1.update(random, 0, random.length);
sha1.doFinal(shatmp, 0);
md5.update(master_secret, 0, master_secret.length);
md5.update(shatmp, 0, shatmp.length);
md5.doFinal(tmp, pos);
pos += md5Size;
++i;
}
byte rval[] = new byte[size];
System.arraycopy(tmp, 0, rval, 0, size);
return rval;
}
示例12: calculateMasterSecret_SSL
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
static byte[] calculateMasterSecret_SSL(byte[] pre_master_secret, byte[] random)
{
Digest md5 = new MD5Digest();
Digest sha1 = new SHA1Digest();
int md5Size = md5.getDigestSize();
byte[] shatmp = new byte[sha1.getDigestSize()];
byte[] rval = new byte[md5Size * 3];
int pos = 0;
for (int i = 0; i < 3; ++i)
{
byte[] ssl3Const = SSL3_CONST[i];
sha1.update(ssl3Const, 0, ssl3Const.length);
sha1.update(pre_master_secret, 0, pre_master_secret.length);
sha1.update(random, 0, random.length);
sha1.doFinal(shatmp, 0);
md5.update(pre_master_secret, 0, pre_master_secret.length);
md5.update(shatmp, 0, shatmp.length);
md5.doFinal(rval, pos);
pos += md5Size;
}
return rval;
}
示例13: ssl3Complete
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
protected void ssl3Complete(Digest d, byte[] ipad, byte[] opad, int padLength)
{
byte[] secret = context.getSecurityParameters().masterSecret;
d.update(secret, 0, secret.length);
d.update(ipad, 0, padLength);
byte[] tmp = new byte[d.getDigestSize()];
d.doFinal(tmp, 0);
d.update(secret, 0, secret.length);
d.update(opad, 0, padLength);
d.update(tmp, 0, tmp.length);
}
示例14: hash
import org.bouncycastle.crypto.Digest; //導入方法依賴的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);
}
}
示例15: getDigest
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
private static byte[] getDigest(SubjectPublicKeyInfo spki)
{
Digest digest = new SHA1Digest();
byte[] resBuf = new byte[digest.getDigestSize()];
byte[] bytes = spki.getPublicKeyData().getBytes();
digest.update(bytes, 0, bytes.length);
digest.doFinal(resBuf, 0);
return resBuf;
}