/** * convert a vector of octet strings into a single byte string */ static private byte[] toBytes( Vector octs) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); for (int i = 0; i != octs.size(); i++) { try { DEROctetString o = (DEROctetString)octs.elementAt(i); bOut.write(o.getOctets()); } catch (ClassCastException e) { throw new IllegalArgumentException(octs.elementAt(i).getClass().getName() + " found in input should only contain DEROctetString"); } catch (IOException e) { throw new IllegalArgumentException("exception converting octets " + e.toString()); } } return bOut.toByteArray(); }
/** * Convert a vector of octet strings into a single byte string */ static private byte[] toBytes( ASN1OctetString[] octs) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); for (int i = 0; i != octs.length; i++) { try { DEROctetString o = (DEROctetString)octs[i]; bOut.write(o.getOctets()); } catch (ClassCastException e) { throw new IllegalArgumentException(octs[i].getClass().getName() + " found in input should only contain DEROctetString"); } catch (IOException e) { throw new IllegalArgumentException("exception converting octets " + e.toString()); } } return bOut.toByteArray(); }
/** * convert a vector of octet strings into a single byte string */ static private byte[] toBytes( ASN1OctetString[] octs) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); for (int i = 0; i != octs.length; i++) { try { DEROctetString o = (DEROctetString)octs[i]; bOut.write(o.getOctets()); } catch (ClassCastException e) { throw new IllegalArgumentException(octs[i].getClass().getName() + " found in input should only contain DEROctetString"); } catch (IOException e) { throw new IllegalArgumentException("exception converting octets " + e.toString()); } } return bOut.toByteArray(); }
/** * convert a vector of octet strings into a single byte string */ static private byte[] toBytes( Vector octs) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); for (int i = 0; i != octs.size(); i++) { try { DEROctetString o = (DEROctetString)octs.elementAt(i); bOut.write(o.getOctets()); } catch (ClassCastException e) { throw new IllegalArgumentException(octs.elementAt(i).getClass().getName() + " found in input should only contain DEROctetString"); } catch (IOException e) { throw new IllegalArgumentException("exception converting octets " + e.toString()); } } return bOut.toByteArray(); }
BCGOST3410PublicKey( SubjectPublicKeyInfo info) { GOST3410PublicKeyAlgParameters params = new GOST3410PublicKeyAlgParameters((ASN1Sequence)info.getAlgorithmId().getParameters()); DEROctetString derY; try { derY = (DEROctetString)info.parsePublicKey(); byte[] keyEnc = derY.getOctets(); byte[] keyBytes = new byte[keyEnc.length]; for (int i = 0; i != keyEnc.length; i++) { keyBytes[i] = keyEnc[keyEnc.length - 1 - i]; // was little endian } this.y = new BigInteger(1, keyBytes); } catch (IOException e) { throw new IllegalArgumentException("invalid info structure in GOST3410 public key"); } this.gost3410Spec = GOST3410ParameterSpec.fromPublicKeyAlg(params); }
void fromByteArray(final byte[] encodedData) throws SecureMessagingException { try ( final ASN1InputStream asn1in = new ASN1InputStream(encodedData); ) { this.to = (DERTaggedObject)asn1in.readObject(); } catch (final IOException e) { throw new SecureMessagingException(e); } final DEROctetString ocs = (DEROctetString) this.to.getObject(); this.data = ocs.getOctets(); }
BCGOST3410PublicKey( SubjectPublicKeyInfo info) { GOST3410PublicKeyAlgParameters params = new GOST3410PublicKeyAlgParameters((ASN1Sequence)info.getAlgorithmId().getParameters()); DEROctetString derY; try { derY = (DEROctetString)info.parsePublicKey(); byte[] keyEnc = derY.getOctets(); byte[] keyBytes = new byte[keyEnc.length]; for (int i = 0; i != keyEnc.length; i++) { keyBytes[i] = keyEnc[keyEnc.length - 1 - i]; // was little endian } this.y = new BigInteger(1, keyBytes); } catch (IOException e) { throw new IllegalArgumentException("invalid info structure in GOST3410 public key"); } this.gost3410Spec = GOST3410ParameterSpec.fromPublicKeyAlg(params); }
void fromByteArray(final byte[] encodedData) throws SecureMessagingException { try ( final ASN1InputStream asn1in = new ASN1InputStream(encodedData); ) { this.to = (DERTaggedObject)asn1in.readObject(); } catch (final IOException e) { throw new SecureMessagingException(e); } final DEROctetString ocs = (DEROctetString) this.to.getObject(); this.data = ocs.getOctets(); }
/** Método que extrae el contenido de un tipo CompressedData. * @param data El tipo CompressedData. * @return El contenido del envoltorio. * @throws IOException Cuando hay un error de lectura de datos. * @throws DataFormatException Si los datos no estaban comprimidos. */ static byte[] getContentCompressedData(final byte[] data) throws IOException, DataFormatException { final ASN1Sequence contentEnvelopedData = Utils.fetchWrappedData(data); final CompressedData compressed = CompressedData.getInstance(contentEnvelopedData); final DEROctetString dos = (DEROctetString) compressed.getEncapContentInfo().getContent(); return BinaryUtils.uncompress(dos.getOctets()); } }
void fromByteArray(final byte[] encodedData) throws SecureMessagingException { try ( final ASN1InputStream asn1in = new ASN1InputStream(encodedData); ) { this.to = (DERTaggedObject) asn1in.readObject(); asn1in.close(); } catch (final IOException e) { throw new SecureMessagingException(e); } final DEROctetString ocs = (DEROctetString) this.to.getObject(); this.data = ocs.getOctets(); }
void fromByteArray(final byte[] encodedData) throws SecureMessagingException { try ( final ASN1InputStream asn1in = new ASN1InputStream(encodedData); ) { this.to = (DERTaggedObject)asn1in.readObject(); } catch (final IOException e) { throw new SecureMessagingException(e); } final DEROctetString ocs = (DEROctetString) this.to.getObject(); this.value_ = ocs.getOctets(); this.data = removeOne(this.value_); }
contenido = ((DEROctetString) ci.getContent()).getOctets();
/** * Gets the URL of the TSA if it's available on the certificate * @param certificate a certificate * @return a TSA URL * @throws IOException */ public static String getTSAURL(X509Certificate certificate) { byte der[] = certificate.getExtensionValue(SecurityIDs.ID_TSA); if(der == null) return null; ASN1Primitive asn1obj; try { asn1obj = ASN1Primitive.fromByteArray(der); DEROctetString octets = (DEROctetString)asn1obj; asn1obj = ASN1Primitive.fromByteArray(octets.getOctets()); ASN1Sequence asn1seq = ASN1Sequence.getInstance(asn1obj); return getStringFromGeneralName(asn1seq.getObjectAt(1).toASN1Primitive()); } catch (IOException e) { return null; } }
.getInstance(new ASN1InputStream( ((DEROctetString) DEROctetString .fromByteArray(targetInfoExt)).getOctets()) .readObject());
final DEROctetString qcsRaw = (DEROctetString) ASN1Primitive.fromByteArray(qcStatementsValue); final ASN1Sequence seq = (ASN1Sequence) ASN1Primitive.fromByteArray( qcsRaw.getOctets() ); qcs = QCStatements.getInstance(seq);
.getInstance(new ASN1InputStream( ((DEROctetString) DEROctetString .fromByteArray(targetInfoExt)).getOctets()) .readObject());
final DERSet derSetHash = (DERSet) elemento.getObjectAt(1); final DEROctetString derHash = (DEROctetString) derSetHash.getObjectAt(0); messageDigest = derHash.getOctets(); break;
for (int i = 0; i < curSeeds.length; i++) curSeeds[i] = ((DEROctetString)curSeedsPart.getObjectAt(i)).getOctets(); for (int i = 0; i < nextNextSeeds.length; i++) nextNextSeeds[i] = ((DEROctetString)nextNextSeedsPart.getObjectAt(i)).getOctets(); for (int j = 0; j < curAuth[i].length; j++) curAuth[i][j] = ((DEROctetString)curAuthPart1.getObjectAt(j)).getOctets(); for (int j = 0; j < nextAuth[i].length; j++) nextAuth[i][j] = ((DEROctetString)nextAuthPart1.getObjectAt(j)).getOctets();
return ((DEROctetString) authenticated.getEncapsulatedContentInfo().getContent()).getOctets();
final DERSet derSetHash = (DERSet) elemento.getObjectAt(1); final DEROctetString derHash = (DEROctetString) derSetHash.getObjectAt(0); md = derHash.getOctets();