public static ECDSASignature decodeFromDER(byte[] bytes) { ASN1InputStream decoder = null; try { decoder = new ASN1InputStream(bytes); DLSequence seq = (DLSequence) decoder.readObject(); if (seq == null) throw new RuntimeException("Reached past end of ASN.1 stream."); ASN1Integer r, s; try { r = (ASN1Integer) seq.getObjectAt(0); s = (ASN1Integer) seq.getObjectAt(1); } catch (ClassCastException e) { throw new IllegalArgumentException(e); } // OpenSSL deviates from the DER spec by interpreting these values as unsigned, though they should not be // Thus, we always use the positive versions. See: http://r6.ca/blog/20111119T211504Z.html return new ECDSASignature(r.getPositiveValue(), s.getPositiveValue()); } catch (IOException e) { throw new RuntimeException(e); } finally { if (decoder != null) try { decoder.close(); } catch (IOException x) {} } }
public KeyAgreeRecipientInfo( OriginatorIdentifierOrKey originator, ASN1OctetString ukm, AlgorithmIdentifier keyEncryptionAlgorithm, ASN1Sequence recipientEncryptedKeys) { this.version = new ASN1Integer(3); this.originator = originator; this.ukm = ukm; this.keyEncryptionAlgorithm = keyEncryptionAlgorithm; this.recipientEncryptedKeys = recipientEncryptedKeys; }
public BigInteger getAuthorityCertSerialNumber() { if (certserno != null) { return certserno.getValue(); } return null; }
/** * @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(); }
private RSAPublicKey( ASN1Sequence seq) { if (seq.size() != 2) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } Enumeration e = seq.getObjects(); modulus = ASN1Integer.getInstance(e.nextElement()).getPositiveValue(); publicExponent = ASN1Integer.getInstance(e.nextElement()).getPositiveValue(); }
public AuthEnvelopedDataParser(ASN1SequenceParser seq) throws IOException { this.seq = seq; // TODO // "It MUST be set to 0." this.version = ASN1Integer.getInstance(seq.readObject()); }
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 RSAPublicKeyStructure( ASN1Sequence seq) { if (seq.size() != 2) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } Enumeration e = seq.getObjects(); modulus = ASN1Integer.getInstance(e.nextElement()).getPositiveValue(); publicExponent = ASN1Integer.getInstance(e.nextElement()).getPositiveValue(); }
/** * @param status */ public PKIStatusInfo(PKIStatus status) { this.status = ASN1Integer.getInstance(status.toASN1Primitive()); }
public SPHINCS256KeyParams(AlgorithmIdentifier treeDigest) { this.version = new ASN1Integer(0); this.treeDigest = treeDigest; }
/** * Return the public value Y for the key. * * @return the Y value. */ public BigInteger getY() { return this.y.getPositiveValue(); }
public BigInteger getMinimum() { if (minimum == null) { return ZERO; } return minimum.getValue(); }
private XMSSMTKeyParams(ASN1Sequence sequence) { this.version = ASN1Integer.getInstance(sequence.getObjectAt(0)); this.height = ASN1Integer.getInstance(sequence.getObjectAt(1)).getValue().intValue(); this.layers = ASN1Integer.getInstance(sequence.getObjectAt(2)).getValue().intValue(); this.treeDigest = AlgorithmIdentifier.getInstance(sequence.getObjectAt(3)); }
private RSAPublicKey( ASN1Sequence seq) { if (seq.size() != 2) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } Enumeration e = seq.getObjects(); modulus = ASN1Integer.getInstance(e.nextElement()).getPositiveValue(); publicExponent = ASN1Integer.getInstance(e.nextElement()).getPositiveValue(); }
private DSAParameter( ASN1Sequence seq) { if (seq.size() != 3) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } Enumeration e = seq.getObjects(); p = ASN1Integer.getInstance(e.nextElement()); q = ASN1Integer.getInstance(e.nextElement()); g = ASN1Integer.getInstance(e.nextElement()); }
public CertRequest( ASN1Integer certReqId, CertTemplate certTemplate, Controls controls) { this.certReqId = certReqId; this.certTemplate = certTemplate; this.controls = controls; }
/** * Return q, the prime factor of p - 1 * * @return q value */ public BigInteger getQ() { return this.q.getPositiveValue(); }
public BigInteger getAuthorityCertSerialNumber() { if (certserno != null) { return certserno.getValue(); } return null; }
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)); }
public AuthenticatedDataParser( ASN1SequenceParser seq) throws IOException { this.seq = seq; this.version = ASN1Integer.getInstance(seq.readObject()); }