/** * Encodes the signature as a DER sequence (ASN.1 format). */ private byte[] asnEncode(byte[] sigBlob) throws IOException { byte[] r = new BigInteger(1, Arrays.copyOfRange(sigBlob, 0, 20)).toByteArray(); byte[] s = new BigInteger(1, Arrays.copyOfRange(sigBlob, 20, 40)).toByteArray(); ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new ASN1Integer(r)); vector.add(new ASN1Integer(s)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ASN1OutputStream asnOS = new ASN1OutputStream(baos); asnOS.writeObject(new DERSequence(vector)); asnOS.flush(); return baos.toByteArray(); } }
/** * Encodes the signature as a DER sequence (ASN.1 format). */ private byte[] asnEncode(byte[] sigBlob) throws IOException { Buffer.PlainBuffer sigbuf = new Buffer.PlainBuffer(sigBlob); byte[] r = sigbuf.readBytes(); byte[] s = sigbuf.readBytes(); ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new ASN1Integer(r)); vector.add(new ASN1Integer(s)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ASN1OutputStream asnOS = new ASN1OutputStream(baos); asnOS.writeObject(new DERSequence(vector)); asnOS.flush(); return baos.toByteArray(); } }
seq.addObject(new ASN1Integer(sigs[0])); seq.addObject(new ASN1Integer(sigs[1])); seq.close(); return s.toByteArray();
@Override public ASN1Primitive toASN1Primitive() { return new ASN1Integer(skipCerts); } }
public DSAParameter( BigInteger p, BigInteger q, BigInteger g) { this.p = new ASN1Integer(p); this.q = new ASN1Integer(q); this.g = new ASN1Integer(g); }
seq.addObject(new ASN1Integer(blockNumber)); seq.addObject(new DEROctetString(previousHash)); seq.addObject(new DEROctetString(dataHash));
public ValidationParams(byte[] seed, int pgenCounter) { if (seed == null) { throw new IllegalArgumentException("'seed' cannot be null"); } this.seed = new DERBitString(seed); this.pgenCounter = new ASN1Integer(pgenCounter); }
public RC2CBCParameter( int parameterVersion, byte[] iv) { this.version = new ASN1Integer(parameterVersion); this.iv = new DEROctetString(iv); }
public IssuerSerial( GeneralNames issuer, BigInteger serial) { this(issuer, new ASN1Integer(serial)); }
private byte[] encodeRsaPublicKeyAsBitString(RSAPublicKey rsaPublicKey) throws IOException { ASN1EncodableVector vec = new ASN1EncodableVector(); vec.add(new ASN1Integer(rsaPublicKey.getModulus())); vec.add(new ASN1Integer(rsaPublicKey.getPublicExponent())); DERSequence derSequence = new DERSequence(vec); return derSequence.getEncoded(); }
private byte[] encodeDsaPublicKeyAsBitString(DSAPublicKey dsaPublicKey) throws IOException { ASN1Integer publicKey = new ASN1Integer(dsaPublicKey.getY()); return publicKey.getEncoded(ASN1Encoding.DER); } }
private byte[] encodeRsaPublicKeyAsBitString(RSAPublicKey rsaPublicKey) throws SpkacException { try { ASN1EncodableVector vec = new ASN1EncodableVector (); vec.add(new ASN1Integer(rsaPublicKey.getModulus())); vec.add(new ASN1Integer(rsaPublicKey.getPublicExponent())); DERSequence derSequence = new DERSequence(vec); return derSequence.getEncoded(ASN1Encoding.DER); } catch (Exception ex) { throw new SpkacException(res.getString("NoEncodeRsaPublicKey.exception.message"), ex); } }
private byte[] encodeDsaPublicKeyAsBitString(DSAPublicKey dsaPublicKey) throws SpkacException { try { ASN1Integer publicKey = new ASN1Integer(dsaPublicKey.getY()); return publicKey.getEncoded(ASN1Encoding.DER); } catch (Exception ex) { throw new SpkacException(res.getString("NoEncodeDsaPublicKey.exception.message"), ex); } }
@Override public ASN1Primitive toASN1Primitive() { DERTaggedObject cont0Encodable = cont0() .map(DEROctetString::new) .map(e -> new DERTaggedObject(CONT0, e)) .orElseGet(null); ASN1EncodableVector vector = DER.vector( new ASN1Integer(x), DER.toSet(encryptedKeySet), cont0Encodable); return new DERSequence(vector); }
private static RSASSAPSSparams createPSSRSAParams(HashAlgo digestAlg) throws NoSuchAlgorithmException { int saltSize = Args.notNull(digestAlg, "digestAlg").getLength(); AlgorithmIdentifier digAlgId = new AlgorithmIdentifier(digestAlg.getOid(), DERNull.INSTANCE); return new RSASSAPSSparams(digAlgId, new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, digAlgId), new ASN1Integer(saltSize), RSASSAPSSparams.DEFAULT_TRAILER_FIELD); } // method createPSSRSAParams
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = DER.vector(new ASN1Integer(type), new DEROctetString(data())); return new DERSequence(vector); }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new ASN1Integer(mechanism)); if (params != null) { vector.add(params); } return new DERSequence(vector); }
public PublishTrustAnchors(BigInteger seqNumber, AlgorithmIdentifier hashAlgorithm, byte[][] anchorHashes) { this.seqNumber = new ASN1Integer(seqNumber); this.hashAlgorithm = hashAlgorithm; ASN1EncodableVector v = new ASN1EncodableVector(); for (int i = 0; i != anchorHashes.length; i++) { v.add(new DEROctetString(Arrays.clone(anchorHashes[i]))); } this.anchorHashes = new DERSequence(v); }
public byte[] getEncoded() { if (dsaSpec == null) { return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new ASN1Integer(y)); } return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).toASN1Primitive()), new ASN1Integer(y)); }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new Asn1P11SlotIdentifier(slotId)); vector.add(new DERUTF8String(label)); vector.add(new ASN1Integer(keyType)); vector.add(new DEROctetString(keyValue)); return new DERSequence(vector); }