if (asn1Primitive instanceof ASN1Integer) { ASN1Integer asn1Integer = (ASN1Integer) asn1Primitive; BigInteger integer = asn1Integer.getValue(); if (count < 2) { sigs[count] = integer;
private KeyTransRecipientInfo computeRecipientInfo(X509Certificate x509certificate, byte[] abyte0) throws IOException, CertificateEncodingException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException { TBSCertificate certificate; try (ASN1InputStream input = new ASN1InputStream(x509certificate.getTBSCertificate())) { certificate = TBSCertificate.getInstance(input.readObject()); } AlgorithmIdentifier algorithmId = certificate.getSubjectPublicKeyInfo().getAlgorithm(); IssuerAndSerialNumber serial = new IssuerAndSerialNumber( certificate.getIssuer(), certificate.getSerialNumber().getValue()); Cipher cipher; try { cipher = Cipher.getInstance(algorithmId.getAlgorithm().getId(), SecurityProvider.getProvider()); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { // should never happen, if this happens throw IOException instead throw new RuntimeException("Could not find a suitable javax.crypto provider", e); } cipher.init(1, x509certificate.getPublicKey()); DEROctetString octets = new DEROctetString(cipher.doFinal(abyte0)); RecipientIdentifier recipientId = new RecipientIdentifier(serial); return new KeyTransRecipientInfo(recipientId, algorithmId, octets); }
public BigInteger getMinimum() { if (minimum == null) { return ZERO; } return minimum.getValue(); }
public BigInteger getMaximum() { if (maximum == null) { return null; } return maximum.getValue(); }
public BigInteger getAuthorityCertSerialNumber() { if (certserno != null) { return certserno.getValue(); } return null; }
public BigInteger getCrlNumber() { if (null == this.crlNumber) { return null; } return this.crlNumber.getValue(); }
private static BigInteger getInteger(ASN1Encodable object) throws BadAsn1ObjectException { try { return ASN1Integer.getInstance(object).getValue(); } catch (IllegalArgumentException ex) { throw new BadAsn1ObjectException("invalid object ASN1Integer: " + ex.getMessage(), ex); } }
/** * @return notYoungerThan if that's what we are, -1 otherwise */ public int notYoungerThan() { if (declaration.getTagNo() != 0) { return -1; } return ASN1Integer.getInstance(declaration, false).getValue().intValue(); }
public static BigInteger getInteger(ASN1Encodable object) throws BadAsn1ObjectException { try { return ASN1Integer.getInstance(object).getValue(); } catch (IllegalArgumentException ex) { throw new BadAsn1ObjectException("invalid object ASN1Integer: " + ex.getMessage(), ex); } }
private EncryptedData( ASN1Sequence seq) { int version = ((ASN1Integer)seq.getObjectAt(0)).getValue().intValue(); if (version != 0) { throw new IllegalArgumentException("sequence not version 0"); } this.data = ASN1Sequence.getInstance(seq.getObjectAt(1)); }
private DSAPublicKey decodeDsaPublicKeyFromBitString(DERBitString der, BigInteger p, BigInteger q, BigInteger g) throws SpkacException { try { BigInteger y = ASN1Integer.getInstance(der.getBytes()).getValue(); KeyFactory keyFact = KeyFactory.getInstance("DSA"); return (DSAPublicKey) keyFact.generatePublic(new DSAPublicKeySpec(y, p, q, g)); } catch (GeneralSecurityException ex) { throw new SpkacException(res.getString("NoGenerateDsaPublicKeyFromSpkac.exception.message"), ex); } catch (Exception ex) { throw new SpkacException(res.getString("NoGenerateDsaPublicKeyFromSpkac.exception.message"), ex); } }
public AuthEnvelopedDataParser(ASN1SequenceParser seq) throws IOException { this.seq = seq; // "It MUST be set to 0." this.version = ASN1Integer.getInstance(seq.readObject()); if (this.version.getValue().intValue() != 0) { throw new ASN1ParsingException("AuthEnvelopedData version number must be 0"); } }
public NOS(ASN1Primitive primitive) { DERIterator i = DER.asSequence(primitive); x = DER.as(ASN1Integer.class, i) .getValue() .intValue(); y = i.nextIf(ASN1Integer.class) .map(ASN1Integer::getValue) .map(BigInteger::intValue); key = DER.as(DEROctetString.class, i) .getOctets(); }
private McElieceCCA2PublicKey(ASN1Sequence seq) { BigInteger bigN = ((ASN1Integer)seq.getObjectAt(0)).getValue(); n = bigN.intValue(); BigInteger bigT = ((ASN1Integer)seq.getObjectAt(1)).getValue(); t = bigT.intValue(); g = new GF2Matrix(((ASN1OctetString)seq.getObjectAt(2)).getOctets()); digest = AlgorithmIdentifier.getInstance(seq.getObjectAt(3)); }
public SignatureInfo(ASN1Primitive primitive) { DERIterator i = DER.asSequence(primitive); DERIterator j = DER.asSequence(i); version = DER.as(ASN1Integer.class, j) .getValue() .intValue(); info = DER.as(DEROctetString.class, j) .getOctets(); }
private GetCert(ASN1Sequence seq) { if (seq.size() != 2) { throw new IllegalArgumentException("incorrect sequence size"); } this.issuerName = GeneralName.getInstance(seq.getObjectAt(0)); this.serialNumber = ASN1Integer.getInstance(seq.getObjectAt(1)).getValue(); }
private XMSSKeyParams(ASN1Sequence sequence) { this.version = ASN1Integer.getInstance(sequence.getObjectAt(0)); this.height = ASN1Integer.getInstance(sequence.getObjectAt(1)).getValue().intValue(); this.treeDigest = AlgorithmIdentifier.getInstance(sequence.getObjectAt(2)); }
AsymmetricKeyParameter getPublicKeyParameters(SubjectPublicKeyInfo keyInfo, Object defaultParams) throws IOException { DHParameter params = DHParameter.getInstance(keyInfo.getAlgorithm().getParameters()); ASN1Integer derY = (ASN1Integer)keyInfo.parsePublicKey(); BigInteger lVal = params.getL(); int l = lVal == null ? 0 : lVal.intValue(); DHParameters dhParams = new DHParameters(params.getP(), params.getG(), null, l); return new DHPublicKeyParameters(derY.getValue(), dhParams); } }
private ObjectData(ASN1Sequence seq) { this.type = ASN1Integer.getInstance(seq.getObjectAt(0)).getValue(); this.identifier = DERUTF8String.getInstance(seq.getObjectAt(1)).getString(); this.creationDate = ASN1GeneralizedTime.getInstance(seq.getObjectAt(2)); this.lastModifiedDate = ASN1GeneralizedTime.getInstance(seq.getObjectAt(3)); this.data = ASN1OctetString.getInstance(seq.getObjectAt(4)); this.comment = (seq.size() == 6) ? DERUTF8String.getInstance(seq.getObjectAt(5)).getString() : null; }