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) {} } }
/** * Return the public value Y for the key. * * @return the Y value. */ public BigInteger getY() { return this.y.getPositiveValue(); }
/** * Return q, the prime factor of p - 1 * * @return q value */ public BigInteger getQ() { return this.q.getPositiveValue(); }
public BigInteger getL() { if (l == null) { return null; } return l.getPositiveValue(); }
/** * Return the generator of the multiplicative subgroup of order g. * * @return the generator g. */ public BigInteger getG() { return this.g.getPositiveValue(); }
public BigInteger getL() { if (l == null) { return null; } return l.getPositiveValue(); }
/** * Return the prime p defining the Galois field. * * @return the prime p. */ public BigInteger getP() { return this.p.getPositiveValue(); }
public BigInteger getA() { return a.getPositiveValue(); }
public BigInteger getP() { return p.getPositiveValue(); }
public BigInteger getP() { return p.getPositiveValue(); }
public BigInteger getG() { return g.getPositiveValue(); }
public BigInteger getP() { return p.getPositiveValue(); }
public BigInteger getA() { return a.getPositiveValue(); }
public BigInteger getP() { return p.getPositiveValue(); }
public BigInteger getQ() { return q.getPositiveValue(); }
public BigInteger getA() { return a.getPositiveValue(); }
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 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(); }
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 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(); }