Java 类org.bouncycastle.asn1.x509.DigestInfo 实例源码

项目:ipack    文件:MacData.java   
private MacData(
    ASN1Sequence seq)
{
    this.digInfo = DigestInfo.getInstance(seq.getObjectAt(0));

    this.salt = ((ASN1OctetString)seq.getObjectAt(1)).getOctets();

    if (seq.size() == 3)
    {
        this.iterationCount = ((ASN1Integer)seq.getObjectAt(2)).getValue();
    }
    else
    {
        this.iterationCount = ONE;
    }
}
项目:ipack    文件:Data.java   
public static Data getInstance(Object obj)
{
    if (obj instanceof Data)
    {
        return (Data)obj;
    }
    else if (obj instanceof ASN1OctetString)
    {
        return new Data((ASN1OctetString)obj);
    }
    else if (obj instanceof ASN1Sequence)
    {
        return new Data(DigestInfo.getInstance(obj));
    }
    else if (obj instanceof ASN1TaggedObject)
    {
        return new Data(ASN1Sequence.getInstance((ASN1TaggedObject)obj, false));
    }
    throw new IllegalArgumentException("Unknown object submitted to getInstance: " + obj.getClass().getName());
}
项目:ipack    文件:DVCSCertInfo.java   
public DVCSCertInfo(
    DVCSRequestInformation dvReqInfo,
    DigestInfo messageImprint,
    ASN1Integer serialNumber,
    DVCSTime responseTime)
{
    this.dvReqInfo = dvReqInfo;
    this.messageImprint = messageImprint;
    this.serialNumber = serialNumber;
    this.responseTime = responseTime;
}
项目:ipack    文件:OtherCertID.java   
/**
 * constructor
 */
private OtherCertID(ASN1Sequence seq)
{
    if (seq.size() < 1 || seq.size() > 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
                + seq.size());
    }

    if (seq.getObjectAt(0).toASN1Primitive() instanceof ASN1OctetString)
    {
        otherCertHash = ASN1OctetString.getInstance(seq.getObjectAt(0));
    }
    else
    {
        otherCertHash = DigestInfo.getInstance(seq.getObjectAt(0));

    }

    if (seq.size() > 1)
    {
        issuerSerial = IssuerSerial.getInstance(seq.getObjectAt(1));
    }
}
项目:ipack    文件:MessageImprintBuilder.java   
public MessageImprint build(byte[] message)
    throws DVCSException
{
    try
    {
        OutputStream dOut = digestCalculator.getOutputStream();

        dOut.write(message);

        dOut.close();

        return new MessageImprint(new DigestInfo(digestCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest()));
    }
    catch (Exception e)
    {
        throw new DVCSException("unable to build MessageImprint: " + e.getMessage(), e);
    }
}
项目:Direct-File-Downloader    文件:MacData.java   
public MacData(
    ASN1Sequence seq)
{
    this.digInfo = DigestInfo.getInstance(seq.getObjectAt(0));

    this.salt = ((ASN1OctetString)seq.getObjectAt(1)).getOctets();

    if (seq.size() == 3)
    {
        this.iterationCount = ((DERInteger)seq.getObjectAt(2)).getValue();
    }
    else
    {
        this.iterationCount = BigInteger.valueOf(1);
    }
}
项目:gwt-crypto    文件:MacData.java   
private MacData(
    ASN1Sequence seq)
{
    this.digInfo = DigestInfo.getInstance(seq.getObjectAt(0));

    this.salt = ((ASN1OctetString)seq.getObjectAt(1)).getOctets();

    if (seq.size() == 3)
    {
        this.iterationCount = ((ASN1Integer)seq.getObjectAt(2)).getValue();
    }
    else
    {
        this.iterationCount = ONE;
    }
}
项目:gwt-crypto    文件:Data.java   
public static Data getInstance(Object obj)
{
    if (obj instanceof Data)
    {
        return (Data)obj;
    }
    else if (obj instanceof ASN1OctetString)
    {
        return new Data((ASN1OctetString)obj);
    }
    else if (obj instanceof ASN1Sequence)
    {
        return new Data(DigestInfo.getInstance(obj));
    }
    else if (obj instanceof ASN1TaggedObject)
    {
        return new Data(ASN1Sequence.getInstance((ASN1TaggedObject)obj, false));
    }
    throw new IllegalArgumentException("Unknown object submitted to getInstance: " + obj.getClass().getName());
}
项目:gwt-crypto    文件:OtherCertID.java   
/**
 * constructor
 */
private OtherCertID(ASN1Sequence seq)
{
    if (seq.size() < 1 || seq.size() > 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
                + seq.size());
    }

    if (seq.getObjectAt(0).toASN1Primitive() instanceof ASN1OctetString)
    {
        otherCertHash = ASN1OctetString.getInstance(seq.getObjectAt(0));
    }
    else
    {
        otherCertHash = DigestInfo.getInstance(seq.getObjectAt(0));

    }

    if (seq.size() > 1)
    {
        issuerSerial = IssuerSerial.getInstance(seq.getObjectAt(1));
    }
}
项目:gwt-crypto    文件:MessageImprintBuilder.java   
public MessageImprint build(byte[] message)
    throws DVCSException
{
    try
    {
        OutputStream dOut = digestCalculator.getOutputStream();

        dOut.write(message);

        dOut.close();

        return new MessageImprint(new DigestInfo(digestCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest()));
    }
    catch (Exception e)
    {
        throw new DVCSException("unable to build MessageImprint: " + e.getMessage(), e);
    }
}
项目:Aki-SSL    文件:MacData.java   
private MacData(
    ASN1Sequence seq)
{
    this.digInfo = DigestInfo.getInstance(seq.getObjectAt(0));

    this.salt = ((ASN1OctetString)seq.getObjectAt(1)).getOctets();

    if (seq.size() == 3)
    {
        this.iterationCount = ((ASN1Integer)seq.getObjectAt(2)).getValue();
    }
    else
    {
        this.iterationCount = ONE;
    }
}
项目:Aki-SSL    文件:Data.java   
public static Data getInstance(Object obj)
{
    if (obj instanceof Data)
    {
        return (Data)obj;
    }
    else if (obj instanceof ASN1OctetString)
    {
        return new Data((ASN1OctetString)obj);
    }
    else if (obj instanceof ASN1Sequence)
    {
        return new Data(DigestInfo.getInstance(obj));
    }
    else if (obj instanceof ASN1TaggedObject)
    {
        return new Data(ASN1Sequence.getInstance((ASN1TaggedObject)obj, false));
    }
    throw new IllegalArgumentException("Unknown object submitted to getInstance: " + obj.getClass().getName());
}
项目:Aki-SSL    文件:OtherCertID.java   
/**
 * constructor
 */
private OtherCertID(ASN1Sequence seq)
{
    if (seq.size() < 1 || seq.size() > 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
                + seq.size());
    }

    if (seq.getObjectAt(0).toASN1Primitive() instanceof ASN1OctetString)
    {
        otherCertHash = ASN1OctetString.getInstance(seq.getObjectAt(0));
    }
    else
    {
        otherCertHash = DigestInfo.getInstance(seq.getObjectAt(0));

    }

    if (seq.size() > 1)
    {
        issuerSerial = IssuerSerial.getInstance(seq.getObjectAt(1));
    }
}
项目:Aki-SSL    文件:MessageImprintBuilder.java   
public MessageImprint build(byte[] message)
    throws DVCSException
{
    try
    {
        OutputStream dOut = digestCalculator.getOutputStream();

        dOut.write(message);

        dOut.close();

        return new MessageImprint(new DigestInfo(digestCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest()));
    }
    catch (Exception e)
    {
        throw new DVCSException("unable to build MessageImprint: " + e.getMessage(), e);
    }
}
项目:eid-applet    文件:SecurePinPadReaderTest.java   
@Test
@QualityAssurance(firmware = Firmware.V015Z, approved = true)
public void testPlainTextAuthn() throws Exception {
    // operate
    String testMessage = "Test Application @ 14/2/2012 14:48:21";
    byte[] signatureValue = this.pcscEid.sign(testMessage.getBytes(), "2.16.56.1.2.1.3.1", (byte) 0x82, false);

    // verify
    List<X509Certificate> authnCertChain = this.pcscEid.getAuthnCertificateChain();

    Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
    cipher.init(Cipher.DECRYPT_MODE, authnCertChain.get(0));
    byte[] signatureDigestInfoValue = cipher.doFinal(signatureValue);
    ASN1InputStream aIn = new ASN1InputStream(signatureDigestInfoValue);
    DigestInfo signatureDigestInfo = new DigestInfo((ASN1Sequence) aIn.readObject());
    LOG.debug("result algo Id: " + signatureDigestInfo.getAlgorithmId().getObjectId().getId());
    assertEquals("2.16.56.1.2.1.3.1", signatureDigestInfo.getAlgorithmId().getObjectId().getId());
    assertArrayEquals(testMessage.getBytes(), signatureDigestInfo.getDigest());
}
项目:TinyTravelTracker    文件:MacData.java   
private MacData(
    ASN1Sequence seq)
{
    this.digInfo = DigestInfo.getInstance(seq.getObjectAt(0));

    this.salt = ((ASN1OctetString)seq.getObjectAt(1)).getOctets();

    if (seq.size() == 3)
    {
        this.iterationCount = ((ASN1Integer)seq.getObjectAt(2)).getValue();
    }
    else
    {
        this.iterationCount = ONE;
    }
}
项目:TinyTravelTracker    文件:Data.java   
public static Data getInstance(Object obj)
{
    if (obj instanceof Data)
    {
        return (Data)obj;
    }
    else if (obj instanceof ASN1OctetString)
    {
        return new Data((ASN1OctetString)obj);
    }
    else if (obj instanceof ASN1Sequence)
    {
        return new Data(DigestInfo.getInstance(obj));
    }
    else if (obj instanceof ASN1TaggedObject)
    {
        return new Data(ASN1Sequence.getInstance((ASN1TaggedObject)obj, false));
    }
    throw new IllegalArgumentException("Unknown object submitted to getInstance: " + obj.getClass().getName());
}
项目:TinyTravelTracker    文件:OtherCertID.java   
/**
 * constructor
 */
private OtherCertID(ASN1Sequence seq)
{
    if (seq.size() < 1 || seq.size() > 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
                + seq.size());
    }

    if (seq.getObjectAt(0).toASN1Primitive() instanceof ASN1OctetString)
    {
        otherCertHash = ASN1OctetString.getInstance(seq.getObjectAt(0));
    }
    else
    {
        otherCertHash = DigestInfo.getInstance(seq.getObjectAt(0));

    }

    if (seq.size() > 1)
    {
        issuerSerial = IssuerSerial.getInstance(seq.getObjectAt(1));
    }
}
项目:commons-eid    文件:BeIDIntegrity.java   
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);
}
项目:AcademicTorrents-Downloader    文件:MacData.java   
public MacData(
    ASN1Sequence seq)
{
    this.digInfo = DigestInfo.getInstance(seq.getObjectAt(0));

    this.salt = ((ASN1OctetString)seq.getObjectAt(1)).getOctets();

    if (seq.size() == 3)
    {
        this.iterationCount = ((DERInteger)seq.getObjectAt(2)).getValue();
    }
    else
    {
        this.iterationCount = BigInteger.valueOf(1);
    }
}
项目:CryptMeme    文件:MacData.java   
private MacData(
    ASN1Sequence seq)
{
    this.digInfo = DigestInfo.getInstance(seq.getObjectAt(0));

    this.salt = ((ASN1OctetString)seq.getObjectAt(1)).getOctets();

    if (seq.size() == 3)
    {
        this.iterationCount = ((ASN1Integer)seq.getObjectAt(2)).getValue();
    }
    else
    {
        this.iterationCount = ONE;
    }
}
项目:CryptMeme    文件:Data.java   
public static Data getInstance(Object obj)
{
    if (obj instanceof Data)
    {
        return (Data)obj;
    }
    else if (obj instanceof ASN1OctetString)
    {
        return new Data((ASN1OctetString)obj);
    }
    else if (obj instanceof ASN1Sequence)
    {
        return new Data(DigestInfo.getInstance(obj));
    }
    else if (obj instanceof ASN1TaggedObject)
    {
        return new Data(ASN1Sequence.getInstance((ASN1TaggedObject)obj, false));
    }
    throw new IllegalArgumentException("Unknown object submitted to getInstance: " + obj.getClass().getName());
}
项目:CryptMeme    文件:OtherCertID.java   
/**
 * constructor
 */
private OtherCertID(ASN1Sequence seq)
{
    if (seq.size() < 1 || seq.size() > 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
                + seq.size());
    }

    if (seq.getObjectAt(0).toASN1Primitive() instanceof ASN1OctetString)
    {
        otherCertHash = ASN1OctetString.getInstance(seq.getObjectAt(0));
    }
    else
    {
        otherCertHash = DigestInfo.getInstance(seq.getObjectAt(0));

    }

    if (seq.size() > 1)
    {
        issuerSerial = IssuerSerial.getInstance(seq.getObjectAt(1));
    }
}
项目:alien-ofelia-conet-ccnx    文件:Signature.java   
/**
 * 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;
}
项目:irma_future_id    文件:MessageImprintBuilder.java   
public MessageImprint build(byte[] message)
    throws DVCSException
{
    try
    {
        OutputStream dOut = digestCalculator.getOutputStream();

        dOut.write(message);

        dOut.close();

        return new MessageImprint(new DigestInfo(digestCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest()));
    }
    catch (Exception e)
    {
        throw new DVCSException("unable to build MessageImprint: " + e.getMessage(), e);
    }
}
项目:irma_future_id    文件:MacData.java   
private MacData(
    ASN1Sequence seq)
{
    this.digInfo = DigestInfo.getInstance(seq.getObjectAt(0));

    this.salt = ((ASN1OctetString)seq.getObjectAt(1)).getOctets();

    if (seq.size() == 3)
    {
        this.iterationCount = ((ASN1Integer)seq.getObjectAt(2)).getValue();
    }
    else
    {
        this.iterationCount = ONE;
    }
}
项目:irma_future_id    文件:Data.java   
public static Data getInstance(Object obj)
{
    if (obj instanceof Data)
    {
        return (Data)obj;
    }
    else if (obj instanceof ASN1OctetString)
    {
        return new Data((ASN1OctetString)obj);
    }
    else if (obj instanceof ASN1Sequence)
    {
        return new Data(DigestInfo.getInstance(obj));
    }
    else if (obj instanceof ASN1TaggedObject)
    {
        return new Data(ASN1Sequence.getInstance((ASN1TaggedObject)obj, false));
    }
    throw new IllegalArgumentException("Unknown object submitted to getInstance: " + obj.getClass().getName());
}
项目:irma_future_id    文件:OtherCertID.java   
/**
 * constructor
 */
private OtherCertID(ASN1Sequence seq)
{
    if (seq.size() < 1 || seq.size() > 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
                + seq.size());
    }

    if (seq.getObjectAt(0).toASN1Primitive() instanceof ASN1OctetString)
    {
        otherCertHash = ASN1OctetString.getInstance(seq.getObjectAt(0));
    }
    else
    {
        otherCertHash = DigestInfo.getInstance(seq.getObjectAt(0));

    }

    if (seq.size() > 1)
    {
        issuerSerial = IssuerSerial.getInstance(seq.getObjectAt(1));
    }
}
项目:bc-java    文件:MessageImprintBuilder.java   
public MessageImprint build(byte[] message)
    throws DVCSException
{
    try
    {
        OutputStream dOut = digestCalculator.getOutputStream();

        dOut.write(message);

        dOut.close();

        return new MessageImprint(new DigestInfo(digestCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest()));
    }
    catch (Exception e)
    {
        throw new DVCSException("unable to build MessageImprint: " + e.getMessage(), e);
    }
}
项目:bc-java    文件:MacData.java   
private MacData(
    ASN1Sequence seq)
{
    this.digInfo = DigestInfo.getInstance(seq.getObjectAt(0));

    this.salt = ((ASN1OctetString)seq.getObjectAt(1)).getOctets();

    if (seq.size() == 3)
    {
        this.iterationCount = ((ASN1Integer)seq.getObjectAt(2)).getValue();
    }
    else
    {
        this.iterationCount = ONE;
    }
}
项目:bc-java    文件:Data.java   
public static Data getInstance(Object obj)
{
    if (obj instanceof Data)
    {
        return (Data)obj;
    }
    else if (obj instanceof ASN1OctetString)
    {
        return new Data((ASN1OctetString)obj);
    }
    else if (obj instanceof ASN1Sequence)
    {
        return new Data(DigestInfo.getInstance(obj));
    }
    else if (obj instanceof ASN1TaggedObject)
    {
        return new Data(ASN1Sequence.getInstance((ASN1TaggedObject)obj, false));
    }
    throw new IllegalArgumentException("Unknown object submitted to getInstance: " + obj.getClass().getName());
}
项目:bc-java    文件:OtherCertID.java   
/**
 * constructor
 */
private OtherCertID(ASN1Sequence seq)
{
    if (seq.size() < 1 || seq.size() > 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
                + seq.size());
    }

    if (seq.getObjectAt(0).toASN1Primitive() instanceof ASN1OctetString)
    {
        otherCertHash = ASN1OctetString.getInstance(seq.getObjectAt(0));
    }
    else
    {
        otherCertHash = DigestInfo.getInstance(seq.getObjectAt(0));

    }

    if (seq.size() > 1)
    {
        issuerSerial = IssuerSerial.getInstance(seq.getObjectAt(1));
    }
}
项目:ipack    文件:MacDataGenerator.java   
public MacData build(char[] password, byte[] data)
    throws PKCSException
{
    MacCalculator     macCalculator;

    try
    {
        macCalculator = builder.build(password);

        OutputStream out = macCalculator.getOutputStream();

        out.write(data);

        out.close();
    }
    catch (Exception e)
    {
        throw new PKCSException("unable to process data: " + e.getMessage(), e);
    }

    AlgorithmIdentifier algId = macCalculator.getAlgorithmIdentifier();

    DigestInfo dInfo = new DigestInfo(builder.getDigestAlgorithmIdentifier(), macCalculator.getMac());
    PKCS12PBEParams params = PKCS12PBEParams.getInstance(algId.getParameters());

    return new MacData(dInfo, params.getIV(), params.getIterations().intValue());
}
项目:ipack    文件:RSADigestSigner.java   
private byte[] derEncode(
    byte[] hash)
    throws IOException
{
    DigestInfo dInfo = new DigestInfo(algId, hash);

    return dInfo.getEncoded(ASN1Encoding.DER);
}
项目:ipack    文件:MacData.java   
public MacData(
    DigestInfo  digInfo,
    byte[]      salt,
    int         iterationCount)
{
    this.digInfo = digInfo;
    this.salt = salt;
    this.iterationCount = BigInteger.valueOf(iterationCount);
}
项目:ipack    文件:DVCSCertInfoBuilder.java   
public DVCSCertInfoBuilder(
    DVCSRequestInformation dvReqInfo,
    DigestInfo messageImprint,
    ASN1Integer serialNumber,
    DVCSTime responseTime)
{
    this.dvReqInfo = dvReqInfo;
    this.messageImprint = messageImprint;
    this.serialNumber = serialNumber;
    this.responseTime = responseTime;
}
项目:ipack    文件:OtherCertID.java   
public OtherCertID(
    AlgorithmIdentifier  algId,
    byte[]               digest,
    IssuerSerial    issuerSerial)
{
    this.otherCertHash = new DigestInfo(algId, digest);
    this.issuerSerial = issuerSerial;
}
项目:ipack    文件:OtherCertID.java   
public AlgorithmIdentifier getAlgorithmHash()
{
    if (otherCertHash.toASN1Primitive() instanceof ASN1OctetString)
    {
        // SHA-1
        return new AlgorithmIdentifier("1.3.14.3.2.26");
    }
    else
    {
        return DigestInfo.getInstance(otherCertHash).getAlgorithmId();
    }
}
项目:ipack    文件:OtherCertID.java   
public byte[] getCertHash()
{
    if (otherCertHash.toASN1Primitive() instanceof ASN1OctetString)
    {
        // SHA-1
        return ((ASN1OctetString)otherCertHash.toASN1Primitive()).getOctets();
    }
    else
    {
        return DigestInfo.getInstance(otherCertHash).getDigest();
    }
}
项目:ipack    文件:DigestSignatureSpi.java   
private byte[] derEncode(
    byte[]  hash)
    throws IOException
{
    if (algId == null)
    {
        // For raw RSA, the DigestInfo must be prepared externally
        return hash;
    }

    DigestInfo dInfo = new DigestInfo(algId, hash);

    return dInfo.getEncoded(ASN1Encoding.DER);
}