List of usage examples for org.bouncycastle.asn1 ASN1Integer ASN1Integer
public ASN1Integer(byte[] bytes)
From source file:com.github.horrorho.inflatabledonkey.data.der.ECDSASignature.java
License:Open Source License
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = DER.vector(new ASN1Integer(r), new ASN1Integer(s)); return new DERSequence(vector); }
From source file:com.github.horrorho.inflatabledonkey.data.der.EncryptedKeys.java
License:Open Source License
@Override public ASN1Primitive toASN1Primitive() { DERTaggedObject cont0Encodable = cont0().map(DEROctetString::new).map(e -> new DERTaggedObject(CONT0, e)) .orElseGet(null);/*from w w w . j a v a 2 s .c o m*/ ASN1EncodableVector vector = DER.vector(new ASN1Integer(x), DER.toSet(encryptedKeySet), cont0Encodable); return new DERSequence(vector); }
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.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.PublicKeyInfo.java
License:Open Source License
@Override public ASN1Primitive toASN1Primitive() { DERTaggedObject signatureInfoEncodable = signatureInfo.map(e -> new DERTaggedObject(SIGNATURE_INFO, e)) .orElse(null);/* w ww.j ava2 s . co 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); }
From source file:com.google.bitcoin.core.ECKey.java
License:Apache License
/** * Output this ECKey as an ASN.1 encoded private key, as understood by OpenSSL or used by the BitCoin reference * implementation in its wallet storage format. *///from w ww . java2 s. c o m public byte[] toASN1() { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(400); // ASN1_SEQUENCE(EC_PRIVATEKEY) = { // ASN1_SIMPLE(EC_PRIVATEKEY, version, LONG), // ASN1_SIMPLE(EC_PRIVATEKEY, privateKey, ASN1_OCTET_STRING), // ASN1_EXP_OPT(EC_PRIVATEKEY, parameters, ECPKPARAMETERS, 0), // ASN1_EXP_OPT(EC_PRIVATEKEY, publicKey, ASN1_BIT_STRING, 1) // } ASN1_SEQUENCE_END(EC_PRIVATEKEY) DERSequenceGenerator seq = new DERSequenceGenerator(baos); seq.addObject(new ASN1Integer(1)); // version seq.addObject(new DEROctetString(priv.toByteArray())); seq.addObject(new DERTaggedObject(0, SECNamedCurves.getByName("secp256k1").toASN1Primitive())); seq.addObject(new DERTaggedObject(1, new DERBitString(getPubKey()))); seq.close(); return baos.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); // Cannot happen, writing to memory stream. } }