public boolean equals(final Object obj) {
      if (obj == null) {
         return false;
      }
      if (obj instanceof RSAPrivateKey) {
         final RSAPrivateKey that = (RSAPrivateKey) obj;
         return super.equals(that) && d.equals(that.getPrivateExponent());
      }
      if (obj instanceof RSAPrivateCrtKey) {
         final RSAPrivateCrtKey that = (RSAPrivateCrtKey) obj;
         return   super.equals(that)
               && p.equals(that.getPrimeP())
               && q.equals(that.getPrimeQ())
               && dP.equals(that.getPrimeExponentP())
               && dQ.equals(that.getPrimeExponentQ())
               && qInv.equals(that.getCrtCoefficient());
      }
      return false;
   }