@Override public boolean equals(Object o) { if(this == o) // Not necessary, but a very cheap optimization return true; else if((o == null) || (o.getClass() != this.getClass())) return false; return y.equals(((DSAPublicKey) o).y) && getGroup().equals(((DSAPublicKey) o).getGroup()); }
public boolean equals(DSAPublicKey o) { if(this == o) // Not necessary, but a very cheap optimization return true; return y.equals(o.y) && getGroup().equals(o.getGroup()); }
public static DSAGroup create(SimpleFieldSet fs) throws IllegalBase64Exception, FSParseException { String myP = fs.get("p"); String myQ = fs.get("q"); String myG = fs.get("g"); if(myP == null || myQ == null || myG == null) throw new FSParseException("The given SFS doesn't contain required fields!"); BigInteger p = new BigInteger(1, Base64.decode(myP)); BigInteger q = new BigInteger(1, Base64.decode(myQ)); BigInteger g = new BigInteger(1, Base64.decode(myG)); DSAGroup dg = new DSAGroup(p, q, g); if(dg.equals(Global.DSAgroupBigA)) return Global.DSAgroupBigA; return dg; }
/** * Parses a DSA Group from a string, where p, q, and g are in unsigned * hex-strings, separated by a commas */ // see readFromField() below //public static DSAGroup parse(String grp) { // StringTokenizer str=new StringTokenizer(grp, ","); // BigInteger p,q,g; // p = new BigInteger(str.nextToken(), 16); // q = new BigInteger(str.nextToken(), 16); // g = new BigInteger(str.nextToken(), 16); // return new DSAGroup(p,q,g); //} public static CryptoKey read(InputStream i) throws IOException, CryptFormatException { BigInteger p, q, g; p = Util.readMPI(i); q = Util.readMPI(i); g = Util.readMPI(i); try { DSAGroup group = new DSAGroup(p, q, g); if(group.equals(Global.DSAgroupBigA)) return Global.DSAgroupBigA; else return group; } catch (IllegalArgumentException e) { throw (CryptFormatException)new CryptFormatException("Invalid group: "+e).initCause(e); } }