Search in sources :

Example 21 with DERSequence

use of com.github.zhenwei.core.asn1.DERSequence in project attestation by TokenScript.

the class Ticket method makeTicket.

ASN1Sequence makeTicket() {
    ASN1EncodableVector ticket = new ASN1EncodableVector();
    ticket.add(new DERUTF8String(devconId));
    ticket.add(new ASN1Integer(ticketId));
    ticket.add(new ASN1Integer(ticketClass));
    ticket.add(new DEROctetString(commitment));
    return new DERSequence(ticket);
}
Also used : DERUTF8String(org.bouncycastle.asn1.DERUTF8String) DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) ASN1Integer(org.bouncycastle.asn1.ASN1Integer) DEROctetString(org.bouncycastle.asn1.DEROctetString)

Example 22 with DERSequence

use of com.github.zhenwei.core.asn1.DERSequence in project attestation by TokenScript.

the class Attestation method setSmartcontracts.

// TODO change to list of arrays of 20 bytes
public void setSmartcontracts(List<Long> smartcontracts) {
    ASN1EncodableVector seq = new ASN1EncodableVector();
    for (long current : smartcontracts) {
        seq.add(new ASN1Integer(current));
    }
    this.smartcontracts = new DERSequence(seq);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) ASN1Integer(org.bouncycastle.asn1.ASN1Integer)

Example 23 with DERSequence

use of com.github.zhenwei.core.asn1.DERSequence in project attestation by TokenScript.

the class AttestationRequest method getDerEncoding.

@Override
public byte[] getDerEncoding() {
    try {
        ASN1EncodableVector res = new ASN1EncodableVector();
        res.add(new ASN1Integer(type.ordinal()));
        res.add(ASN1Primitive.fromByteArray(pok.getDerEncoding()));
        return new DERSequence(res).getEncoded();
    } catch (IOException e) {
        throw ExceptionUtil.makeRuntimeException(logger, "Could not encode asn1", e);
    }
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) ASN1Integer(org.bouncycastle.asn1.ASN1Integer) IOException(java.io.IOException)

Example 24 with DERSequence

use of com.github.zhenwei.core.asn1.DERSequence in project attestation by TokenScript.

the class FullProofOfExponent method makeEncoding.

private byte[] makeEncoding(ECPoint riddle, ECPoint tPoint, BigInteger challenge, byte[] unpredictableNumber) {
    try {
        ASN1EncodableVector res = new ASN1EncodableVector();
        res.add(new DEROctetString(riddle.getEncoded(false)));
        res.add(new DEROctetString(challenge.toByteArray()));
        res.add(new DEROctetString(tPoint.getEncoded(false)));
        res.add(new DEROctetString(unpredictableNumber));
        return new DERSequence(res).getEncoded();
    } catch (IOException e) {
        throw ExceptionUtil.makeRuntimeException(logger, "Could not encode asn1", e);
    }
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) IOException(java.io.IOException) DEROctetString(org.bouncycastle.asn1.DEROctetString)

Example 25 with DERSequence

use of com.github.zhenwei.core.asn1.DERSequence in project attestation by TokenScript.

the class Cheque method encodeSignedCheque.

private byte[] encodeSignedCheque(ASN1Sequence cheque, byte[] signature, AsymmetricKeyParameter publicKey) throws IOException {
    ASN1EncodableVector signedCheque = new ASN1EncodableVector();
    signedCheque.add(cheque);
    SubjectPublicKeyInfo spki = SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(publicKey);
    signedCheque.add(spki.getPublicKeyData());
    signedCheque.add(new DERBitString(signature));
    return new DERSequence(signedCheque).getEncoded();
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DERBitString(org.bouncycastle.asn1.DERBitString) SubjectPublicKeyInfo(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo)

Aggregations

DERSequence (org.bouncycastle.asn1.DERSequence)378 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)318 DERSequence (com.github.zhenwei.core.asn1.DERSequence)288 ASN1EncodableVector (com.github.zhenwei.core.asn1.ASN1EncodableVector)286 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)89 IOException (java.io.IOException)83 DEROctetString (org.bouncycastle.asn1.DEROctetString)78 DERTaggedObject (com.github.zhenwei.core.asn1.DERTaggedObject)60 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)60 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)57 ASN1Integer (com.github.zhenwei.core.asn1.ASN1Integer)47 BigInteger (java.math.BigInteger)47 DEROctetString (com.github.zhenwei.core.asn1.DEROctetString)44 X509Certificate (java.security.cert.X509Certificate)38 DERBitString (org.bouncycastle.asn1.DERBitString)38 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)35 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)35 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)29 DERSet (org.bouncycastle.asn1.DERSet)27 GeneralName (org.bouncycastle.asn1.x509.GeneralName)26