Example usage for org.bouncycastle.asn1 DEROctetString DEROctetString

List of usage examples for org.bouncycastle.asn1 DEROctetString DEROctetString

Introduction

In this page you can find the example usage for org.bouncycastle.asn1 DEROctetString DEROctetString.

Prototype

public DEROctetString(ASN1Encodable obj) throws IOException 

Source Link

Document

Constructor from the encoding of an ASN.1 object.

Usage

From source file:com.github.horrorho.inflatabledonkey.data.der.Item.java

License:Open Source License

@Override
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector vector = DER.vector(new ASN1Integer(version), new DEROctetString(octets()));

    return new DERSequence(vector);
}

From source file:com.github.horrorho.inflatabledonkey.data.der.KeySet.java

License:Open Source License

ASN1Primitive toASN1Primitive(boolean includeChecksum) {

    DEROctetString checksumEncodable = includeChecksum ? new DEROctetString(checksum()) : null;

    ASN1Integer flagsEncodable = flags.map(ASN1Integer::new).orElse(null);

    ASN1EncodableVector vector = DER.vector(new DERUTF8String(name), DER.toSet(keys), DER.toSet(serviceKeyIDs),
            checksumEncodable, flagsEncodable, signatureInfo.orElse(null));

    DERSequence sequence = new DERSequence(vector);
    return DER.toApplicationSpecific(APPLICATION_TAG, sequence);
}

From source file:com.github.horrorho.inflatabledonkey.data.der.NOS.java

License:Open Source License

@Override
public ASN1Primitive toASN1Primitive() {

    ASN1EncodableVector vector = DER.vector(new ASN1Integer(x), y.map(ASN1Integer::new).orElse(null),
            new DEROctetString(key()));

    return new DERSequence(vector);
}

From source file:com.github.horrorho.inflatabledonkey.data.der.PrivateKey.java

License:Open Source License

@Override
public ASN1Primitive toASN1Primitive() {

    ASN1EncodableVector vector = DER.vector(new DEROctetString(privateKey()), publicKeyInfo.orElse(null));

    return new DERSequence(vector);
}

From source file:com.github.horrorho.inflatabledonkey.data.der.ProtectionInfo.java

License:Open Source License

@Override
public ASN1Primitive toASN1Primitive() {

    DERTaggedObject dataEncodable = data.map(DEROctetString::new).map(e -> new DERTaggedObject(DATA, e))
            .orElseGet(null);// w  w  w .ja  va 2s. com

    DERTaggedObject signatureEncodable = signature.map(e -> new DERTaggedObject(SIGNATURE, e)).orElseGet(null);

    DERTaggedObject tagEncodable = tag.map(DEROctetString::new).map(e -> new DERTaggedObject(TAG, e))
            .orElseGet(null);

    DERTaggedObject cont3Encodable = cont3.map(DEROctetString::new).map(e -> new DERTaggedObject(CONT3, e))
            .orElseGet(null);

    DERTaggedObject cont4Encodable = cont4.map(DEROctetString::new).map(e -> new DERTaggedObject(CONT4, e))
            .orElseGet(null);

    ASN1EncodableVector vector = DER.vector(encryptedKeys, dataEncodable, signatureEncodable,
            new DEROctetString(hmac()), tagEncodable, cont3Encodable, cont4Encodable);

    DERSequence sequence = new DERSequence(vector);
    return DER.toApplicationSpecific(APPLICATION_TAG, sequence);
}

From source file:com.github.horrorho.inflatabledonkey.data.der.PublicKeyInfo.java

License:Open Source License

@Override
public ASN1Primitive toASN1Primitive() {

    DERTaggedObject signatureInfoEncodable = signatureInfo.map(e -> new DERTaggedObject(SIGNATURE_INFO, e))
            .orElse(null);/*from  w w w  .j av  a 2  s .  c o m*/

    DERTaggedObject signatureEncodable = signature.map(e -> new DERTaggedObject(SIGNATURE, e)).orElse(null);

    DERTaggedObject extendedSignatureEncodable = extendedSignature
            .map(e -> new DERTaggedObject(EXTENDED_SIGNATURE, e)).orElse(null);

    ASN1EncodableVector vector = DER.vector(new ASN1Integer(service), new ASN1Integer(type),
            new DEROctetString(key()), signatureInfoEncodable, signatureEncodable, extendedSignatureEncodable);

    DERSequence sequence = new DERSequence(vector);
    return DER.toApplicationSpecific(APPLICATION_TAG, sequence);
}

From source file:com.github.horrorho.inflatabledonkey.data.der.SECPrivateKey.java

License:Open Source License

@Override
public ASN1Primitive toASN1Primitive() {
    DERTaggedObject parametersEncodable = parameters().map(DEROctetString::new)
            .map(e -> new DERTaggedObject(PARAMETERS, e)).orElseGet(null);

    DERTaggedObject publicKeyEncodable = publicKey().map(DERBitString::new)
            .map(e -> new DERTaggedObject(PUBLIC_KEY, e)).orElseGet(null);

    ASN1EncodableVector vector = DER.vector(new ASN1Integer(version), new DEROctetString(privateKey),
            parametersEncodable, publicKeyEncodable);

    return new DERSequence(vector);
}

From source file:com.github.horrorho.inflatabledonkey.data.der.Signature.java

License:Open Source License

@Override
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector vector = DER.vector(new DEROctetString(signerKeyID()), new ASN1Integer(type),
            new DEROctetString(data()));

    return new DERSequence(vector);
}

From source file:com.github.horrorho.inflatabledonkey.data.der.SignatureInfo.java

License:Open Source License

@Override
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector inner = DER.vector(new ASN1Integer(version), new DEROctetString(info()));

    ASN1EncodableVector outer = DER.vector(new DERSequence(inner));

    return new DERSequence(outer);
}

From source file:com.github.horrorho.inflatabledonkey.data.der.TypeData.java

License:Open Source License

@Override
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector vector = DER.vector(new ASN1Integer(type), new DEROctetString(data()));

    return new DERSequence(vector);
}