/** * Generates a new ProxyACExtension object form the byte array * * @param bytes bytes * @throws IOException IO exception */ public ProxyACExtension(byte[] bytes) throws IOException { ac = (DLSequence) ASN1Primitive.fromByteArray(bytes); }
/** * @deprecated use org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils.parseExtensionValue() */ public static ASN1Primitive fromExtensionValue( byte[] encodedValue) throws IOException { ASN1OctetString octs = (ASN1OctetString)ASN1Primitive.fromByteArray(encodedValue); return ASN1Primitive.fromByteArray(octs.getOctets()); }
ASN1ObjectIdentifier oid = PKCSObjectIdentifiers.id_aa_signatureTimeStampToken; ASN1Encodable signatureTimeStamp = new Attribute(oid, new DERSet(ASN1Primitive.fromByteArray(token)));
private ASN1Primitive rebuildASN1Primitive(int tagNo, byte[] array) throws IOException { try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { baos.write(tagNo); DERUtil.writeLength(baos, array.length); baos.write(array); return ASN1Primitive.fromByteArray(baos.toByteArray()); } }
/** * Return the enclosed object assuming explicit tagging. * * @return the resulting object * @throws IOException if reconstruction fails. */ public ASN1Primitive getObject() throws IOException { return ASN1Primitive.fromByteArray(getContents()); }
private ASN1Primitive decodeObject(String oValue) { try { return ASN1Primitive.fromByteArray(Hex.decode(oValue.substring(1))); } catch (IOException e) { throw new IllegalStateException("unknown encoding in name: " + e); } }
private static ASN1Primitive asn1PrimitivefromByteArray(final byte[] encoded) throws CertprofileException { try { return ASN1Primitive.fromByteArray(encoded); } catch (IOException ex) { throw new CertprofileException(ex.getMessage(), ex); } }
private ASN1Primitive decodeObject(String oValue) { try { return ASN1Primitive.fromByteArray(Hex.decode(oValue.substring(1))); } catch (IOException e) { throw new IllegalStateException("unknown encoding in name: " + e); } }
public ASN1Encodable parsePrivateKey() throws IOException { return ASN1Primitive.fromByteArray(privateKey.getOctets()); }
private void readObject( ObjectInputStream in) throws IOException, ClassNotFoundException { byte[] enc = (byte[])in.readObject(); populateFromPubKeyInfo(SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(enc))); this.algorithm = (String)in.readObject(); this.withCompression = in.readBoolean(); }
private String getBitString(byte[] octets) throws IOException { if (octets == null) { return ""; } DERBitString derBitString = DERBitString.getInstance(ASN1Primitive.fromByteArray(octets)); byte[] bitStringBytes = derBitString.getBytes(); return new BigInteger(1, bitStringBytes).toString(2); }
/** * Create a private key parameter from a PKCS8 PrivateKeyInfo encoding. * * @param privateKeyInfoData the PrivateKeyInfo encoding * @return a suitable private key parameter * @throws IOException on an error decoding the key */ public static AsymmetricKeyParameter createKey(byte[] privateKeyInfoData) throws IOException { return createKey(PrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(privateKeyInfoData))); }
private String getRestrictionStringValue(byte[] octets) throws IOException { /* RestrictionSyntax ::= DirectoryString (SIZE(1..1024)) */ return DirectoryString.getInstance(ASN1Primitive.fromByteArray(octets)).toString(); }
/** * Create a public key from a SubjectPublicKeyInfo encoding * * @param keyInfoData the SubjectPublicKeyInfo encoding * @return the appropriate key parameter * @throws IOException on an error decoding the key */ public static AsymmetricKeyParameter createKey(byte[] keyInfoData) throws IOException { return createKey(SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(keyInfoData))); }
/** * Create a private key parameter from a PKCS8 PrivateKeyInfo encoding. * * @param privateKeyInfoData the PrivateKeyInfo encoding * @return a suitable private key parameter * @throws IOException on an error decoding the key */ public static AsymmetricKeyParameter createKey(byte[] privateKeyInfoData) throws IOException { return createKey(PrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(privateKeyInfoData))); }
/** * Create a public key from a SubjectPublicKeyInfo encoding * * @param keyInfoData the SubjectPublicKeyInfo encoding * @return the appropriate key parameter * @throws IOException on an error decoding the key */ public static AsymmetricKeyParameter createKey(byte[] keyInfoData) throws IOException { return createKey(SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(keyInfoData))); }
/** * Create a public key from a SubjectPublicKeyInfo encoding * * @param keyInfoData the SubjectPublicKeyInfo encoding * @return the appropriate key parameter * @throws IOException on an error decoding the key */ public static AsymmetricKeyParameter createKey(byte[] keyInfoData) throws IOException { return createKey(SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(keyInfoData))); }
protected void engineInit( byte[] params, String format) throws IOException { if (this.isASN1FormatString(format)) { engineInit(params); return; } throw new IOException("Unknown parameters format in PBKDF2 parameters object"); }
private DERBitString getPublicKeyDetails(JCEECPublicKey pub) { try { SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(ASN1Primitive.fromByteArray(pub.getEncoded())); return info.getPublicKeyData(); } catch (IOException e) { // should never happen return null; } }
private BigInteger[] derDecode( byte[] encoding) throws IOException { ASN1Sequence s = (ASN1Sequence)ASN1Primitive.fromByteArray(encoding); return new BigInteger[] { ((ASN1Integer)s.getObjectAt(0)).getValue(), ((ASN1Integer)s.getObjectAt(1)).getValue() }; } }