List of usage examples for org.bouncycastle.asn1 ASN1Integer getPositiveValue
public BigInteger getPositiveValue()
From source file:be.fedict.trust.crl.CrlTrustLinker.java
License:Open Source License
private static BigInteger getCrlNumber(X509CRL crl) { byte[] crlNumberExtensionValue = crl.getExtensionValue(Extension.cRLNumber.getId()); if (null == crlNumberExtensionValue) { return null; }//from w ww. j a va 2 s . c o m try { ASN1OctetString octetString = (ASN1OctetString) (new ASN1InputStream( new ByteArrayInputStream(crlNumberExtensionValue)).readObject()); byte[] octets = octetString.getOctets(); ASN1Integer integer = (ASN1Integer) new ASN1InputStream(octets).readObject(); BigInteger crlNumber = integer.getPositiveValue(); return crlNumber; } catch (IOException e) { throw new RuntimeException("IO error: " + e.getMessage(), e); } }
From source file:de.thiemann.ssl.report.model.CertificateV3.java
License:Open Source License
private PubKeyInfo transferPublicKeyInfo(byte[] encodedPublicKey) { PubKeyInfo info = new PubKeyInfo(); try {/*from ww w. j a v a2s.c o m*/ SubjectPublicKeyInfo subPubKeyInfo = new SubjectPublicKeyInfo( (ASN1Sequence) ASN1Object.fromByteArray(encodedPublicKey)); String asn1PubKeyId = subPubKeyInfo.getAlgorithmId().getAlgorithm().getId(); if (asn1PubKeyId.equals(ASN1PublicKeyIds.RSA.getOid())) { DERSequence seq = (DERSequence) subPubKeyInfo.getPublicKey(); ASN1Integer iModulus = (ASN1Integer) seq.getObjectAt(0); BigInteger modulus = iModulus.getPositiveValue(); info.pubKeyAlgorithm = ASN1PublicKeyIds.RSA.name(); info.pubKeySize = modulus.bitLength(); } else if (asn1PubKeyId.equals(ASN1PublicKeyIds.DSA.getOid())) { info.pubKeyAlgorithm = ASN1PublicKeyIds.DSA.name(); } else if (asn1PubKeyId.equals(ASN1PublicKeyIds.Diffie_Hellman.getOid())) { info.pubKeyAlgorithm = ASN1PublicKeyIds.Diffie_Hellman.name(); } else if (asn1PubKeyId.equals(ASN1PublicKeyIds.KEA.getOid())) { info.pubKeyAlgorithm = ASN1PublicKeyIds.KEA.name(); } else if (asn1PubKeyId.equals(ASN1PublicKeyIds.ECDH.getOid())) { info.pubKeyAlgorithm = ASN1PublicKeyIds.ECDH.name(); } else info.pubKeyAlgorithm = "Unknown public key! OID: " + asn1PubKeyId; } catch (IOException e) { e.printStackTrace(); } return info; }
From source file:de.tsenger.animamea.asn1.AmDHPublicKey.java
License:Open Source License
/** Returns prime modulus p * @return/*from w ww . ja va2 s. com*/ */ public BigInteger getP() { if (p == null) return null; ASN1Integer derInt = (ASN1Integer) p.getObjectParser(BERTags.INTEGER, false); return derInt.getPositiveValue(); }
From source file:de.tsenger.animamea.asn1.AmDHPublicKey.java
License:Open Source License
/** Returns generator g * @return/* ww w .j a v a 2 s . c om*/ */ public BigInteger getG() { if (g == null) return null; ASN1Integer derInt = (ASN1Integer) g.getObjectParser(BERTags.INTEGER, false); return derInt.getPositiveValue(); }
From source file:de.tsenger.animamea.asn1.AmDHPublicKey.java
License:Open Source License
/** Returns oder of the subgroup q * @return/*from www . j a va 2s. c om*/ */ public BigInteger getQ() { if (q == null) return null; ASN1Integer derInt = (ASN1Integer) q.getObjectParser(BERTags.INTEGER, false); return derInt.getPositiveValue(); }
From source file:de.tsenger.animamea.asn1.AmDHPublicKey.java
License:Open Source License
@Override public BigInteger getY() { if (y == null) return null; ASN1Integer derInt = (ASN1Integer) y.getObjectParser(BERTags.INTEGER, false); return derInt.getPositiveValue(); }
From source file:de.tsenger.animamea.asn1.AmECPublicKey.java
License:Open Source License
/** Returns prime modulus p * @return/* w ww. j a v a 2s . co m*/ */ public BigInteger getP() { if (p == null) return null; ASN1Integer derInt = ASN1Integer.getInstance(p, false); return derInt.getPositiveValue(); }
From source file:de.tsenger.animamea.asn1.AmECPublicKey.java
License:Open Source License
/** Returns first coefficient a * @return//from w w w. j a v a 2s.com */ public BigInteger getA() { if (a == null) return null; ASN1Integer derInt = ASN1Integer.getInstance(a, false); return derInt.getPositiveValue(); }
From source file:de.tsenger.animamea.asn1.AmECPublicKey.java
License:Open Source License
/** Returns second coefficient b * @return/* w w w . j a v a 2 s.co m*/ */ public BigInteger getB() { if (b == null) return null; ASN1Integer derInt = ASN1Integer.getInstance(b, false); return derInt.getPositiveValue(); }
From source file:de.tsenger.animamea.asn1.AmECPublicKey.java
License:Open Source License
/** Returns order of the base point r * @return//from w w w.j av a 2 s .c om */ public BigInteger getR() { if (r == null) return null; ASN1Integer derInt = ASN1Integer.getInstance(r, false); return derInt.getPositiveValue(); }