/** * Creates an object on the base of its encoded form. */ public InhibitAnyPolicy(byte[] encoding) throws IOException { super(encoding); this.skipCerts = new BigInteger((byte[]) ASN1Integer.getInstance().decode(encoding)).intValue(); }
/** * Returns ASN.1 encoded form of the object. */ @Override public byte[] getEncoded() { if (encoding == null) { encoding = ASN1Integer.getInstance() .encode(ASN1Integer.fromIntValue(skipCerts)); } return encoding; }
public Object decode(BerInputStream in) throws IOException { in.readInteger(); if (in.isVerify) { return null; } return getDecodedObject(in); }
/** * Creates object from DSAPublicKeySpec. * * @param keySpec - a DSAPublicKeySpec object */ public DSAPublicKeyImpl(DSAPublicKeySpec keySpec) { super("DSA"); SubjectPublicKeyInfo spki; p = keySpec.getP(); q = keySpec.getQ(); g = keySpec.getG(); ThreeIntegerSequence threeInts = new ThreeIntegerSequence(p .toByteArray(), q.toByteArray(), g.toByteArray()); AlgorithmIdentifier ai = new AlgorithmIdentifier(AlgNameMapper .map2OID("DSA"), threeInts.getEncoded()); y = keySpec.getY(); spki = new SubjectPublicKeyInfo(ai, ASN1Integer.getInstance().encode( y.toByteArray())); setEncoding(spki.getEncoded()); params = (DSAParams) (new DSAParameterSpec(p, q, g)); }
protected Object getDecodedObject(BerInputStream in) { Object[] values = (Object[]) in.content; int [] accuracy = new int [3]; for (int i = 0; i < 3; i++) { if (values[i] != null) { accuracy[i] = ASN1Integer.toIntValue(values[i]); if (i > 0 && (accuracy[i] < 0 || accuracy[i] > 999)) { throw new RuntimeException("Time-stamp accuracy value is incorrect: " + accuracy[i]); } } } return accuracy; }
@Override protected void getValues(Object object, Object[] values) { GeneralSubtree gs = (GeneralSubtree) object; values[0] = gs.base; values[1] = ASN1Integer.fromIntValue(gs.minimum); if (gs.maximum > -1) { values[2] = ASN1Integer.fromIntValue(gs.maximum); } } };
private SignerInfo(int version, Object[] issuerAndSerialNumber, AlgorithmIdentifier digestAlgorithm, AuthenticatedAttributes authenticatedAttributes, AlgorithmIdentifier digestEncryptionAlgorithm, byte[] encryptedDigest, List<?> unauthenticatedAttributes) { this.version = version; this.issuer = ((Name)issuerAndSerialNumber[0]).getX500Principal(); this.serialNumber = ASN1Integer.toBigIntegerValue(issuerAndSerialNumber[1]); this.digestAlgorithm = digestAlgorithm; this.authenticatedAttributes = authenticatedAttributes; this.digestEncryptionAlgorithm = digestEncryptionAlgorithm; this.encryptedDigest = encryptedDigest; this.unauthenticatedAttributes = unauthenticatedAttributes; }
/** * Creates object from DSAPrivateKeySpec. * * @param keySpec - a DSAPrivateKeySpec object */ public DSAPrivateKeyImpl(DSAPrivateKeySpec keySpec) { super("DSA"); PrivateKeyInfo pki; g = keySpec.getG(); p = keySpec.getP(); q = keySpec.getQ(); ThreeIntegerSequence threeInts = new ThreeIntegerSequence(p .toByteArray(), q.toByteArray(), g.toByteArray()); AlgorithmIdentifier ai = new AlgorithmIdentifier(AlgNameMapper .map2OID("DSA"), threeInts.getEncoded()); x = keySpec.getX(); pki = new PrivateKeyInfo(0, ai, ASN1Integer.getInstance().encode( x.toByteArray()), null); setEncoding(pki.getEncoded()); params = new DSAParameterSpec(p, q, g); }
@Override protected Object getDecodedObject(BerInputStream in) { Object[] values = (Object[]) in.content; int maximum = -1; // is optional maximum missing? if (values[2] != null) { maximum = ASN1Integer.toIntValue(values[2]); // no! } return new GeneralSubtree((GeneralName) values[0], ASN1Integer.toIntValue(values[1]), maximum); }
@Override protected void getValues(Object object, Object[] values) { TBSCertList tbs = (TBSCertList) object; values[0] = (tbs.version > 1) ? ASN1Integer.fromIntValue(tbs.version - 1) : null; values[1] = tbs.signature; values[2] = tbs.issuer; values[3] = tbs.thisUpdate; values[4] = tbs.nextUpdate; values[5] = tbs.revokedCertificates; values[6] = tbs.crlExtensions; } };
private SignerInfo(int version, Object[] issuerAndSerialNumber, AlgorithmIdentifier digestAlgorithm, AuthenticatedAttributes authenticatedAttributes, AlgorithmIdentifier digestEncryptionAlgorithm, byte[] encryptedDigest, List<?> unauthenticatedAttributes) { this.version = version; this.issuer = ((Name)issuerAndSerialNumber[0]).getX500Principal(); this.serialNumber = ASN1Integer.toBigIntegerValue(issuerAndSerialNumber[1]); this.digestAlgorithm = digestAlgorithm; this.authenticatedAttributes = authenticatedAttributes; this.digestEncryptionAlgorithm = digestEncryptionAlgorithm; this.encryptedDigest = encryptedDigest; this.unauthenticatedAttributes = unauthenticatedAttributes; }
bytes = (byte[]) ASN1OctetString.getInstance().decode(bytes); BigInteger crlNumber = new BigInteger((byte[]) ASN1Integer.getInstance().decode(bytes)); if ((minCRL != null) && (crlNumber.compareTo(minCRL) < 0)) { return false;
/** * Returns ASN.1 encoded form of the object. */ @Override public byte[] getEncoded() { if (encoding == null) { encoding = ASN1Integer.getInstance() .encode(ASN1Integer.fromIntValue(skipCerts)); } return encoding; }
/** * Creates object from DSAPublicKeySpec. * * @param keySpec - a DSAPublicKeySpec object */ public DSAPublicKeyImpl(DSAPublicKeySpec keySpec) { super("DSA"); SubjectPublicKeyInfo spki; p = keySpec.getP(); q = keySpec.getQ(); g = keySpec.getG(); ThreeIntegerSequence threeInts = new ThreeIntegerSequence(p .toByteArray(), q.toByteArray(), g.toByteArray()); AlgorithmIdentifier ai = new AlgorithmIdentifier(AlgNameMapper .map2OID("DSA"), threeInts.getEncoded()); y = keySpec.getY(); spki = new SubjectPublicKeyInfo(ai, ASN1Integer.getInstance().encode( y.toByteArray())); setEncoding(spki.getEncoded()); params = (DSAParams) (new DSAParameterSpec(p, q, g)); }
@Override protected Object getDecodedObject(BerInputStream in) { Object[] values = (Object[]) in.content; return new SignedData( ASN1Integer.toIntValue(values[0]), (List<?>) values[1], (ContentInfo) values[2], (List<Certificate>) values[3], (List<CertificateList>) values[4], (List<SignerInfo>) values[5] ); } };
protected void getValues(Object object, Object[] values) { PrivateKeyInfo privateKeyInfo = (PrivateKeyInfo) object; values[0] = ASN1Integer.fromIntValue(privateKeyInfo.version); values[1] = privateKeyInfo.privateKeyAlgorithm; values[2] = privateKeyInfo.privateKey; values[3] = privateKeyInfo.attributes; } };
public Object decode(BerInputStream in) throws IOException { in.readInteger(); if (in.isVerify) { return null; } return getDecodedObject(in); }
private SignerInfo(int version, Object[] issuerAndSerialNumber, AlgorithmIdentifier digestAlgorithm, AuthenticatedAttributes authenticatedAttributes, AlgorithmIdentifier digestEncryptionAlgorithm, byte[] encryptedDigest, List<?> unauthenticatedAttributes) { this.version = version; this.issuer = ((Name)issuerAndSerialNumber[0]).getX500Principal(); this.serialNumber = ASN1Integer.toBigIntegerValue(issuerAndSerialNumber[1]); this.digestAlgorithm = digestAlgorithm; this.authenticatedAttributes = authenticatedAttributes; this.digestEncryptionAlgorithm = digestEncryptionAlgorithm; this.encryptedDigest = encryptedDigest; this.unauthenticatedAttributes = unauthenticatedAttributes; }
x = new BigInteger((byte[]) ASN1Integer.getInstance().decode( privateKeyInfo.getPrivateKey())); } catch (IOException e) {
/** * Returns ASN.1 encoded form of the object. */ @Override public byte[] getEncoded() { if (encoding == null) { encoding = ASN1Integer.getInstance() .encode(ASN1Integer.fromIntValue(skipCerts)); } return encoding; }