コード例 #1
0
 public boolean isPublicKeyBlackListed(PublicKey publicKey) {
   byte[] encoded = publicKey.getEncoded();
   Digest digest = AndroidDigestFactory.getSHA1();
   digest.update(encoded, 0, encoded.length);
   byte[] out = new byte[digest.getDigestSize()];
   digest.doFinal(out, 0);
   for (byte[] blacklisted : pubkeyBlacklist) {
     if (Arrays.equals(blacklisted, Hex.encode(out))) {
       return true;
     }
   }
   return false;
 }
コード例 #2
0
    private static PBEParametersGenerator makePBEGenerator(int type, int hash) {
      PBEParametersGenerator generator;

      if (type == PKCS5S1) {
        switch (hash) {
            // BEGIN android-removed
            // case MD2:
            //     generator = new PKCS5S1ParametersGenerator(new MD2Digest());
            //     break;
            // END android-removed
          case MD5:
            // BEGIN android-changed
            generator = new PKCS5S1ParametersGenerator(AndroidDigestFactory.getMD5());
            // END android-changed
            break;
          case SHA1:
            // BEGIN android-changed
            generator = new PKCS5S1ParametersGenerator(AndroidDigestFactory.getSHA1());
            // END android-changed
            break;
          default:
            throw new IllegalStateException("PKCS5 scheme 1 only supports MD2, MD5 and SHA1.");
        }
      } else if (type == PKCS5S2) {
        generator = new PKCS5S2ParametersGenerator();
      } else if (type == PKCS12) {
        switch (hash) {
            // BEGIN android-removed
            // case MD2:
            //     generator = new PKCS12ParametersGenerator(new MD2Digest());
            //     break;
            // END android-removed
          case MD5:
            // BEGIN android-changed
            generator = new PKCS12ParametersGenerator(AndroidDigestFactory.getMD5());
            // END android-changed
            break;
          case SHA1:
            // BEGIN android-changed
            generator = new PKCS12ParametersGenerator(AndroidDigestFactory.getSHA1());
            // END android-changed
            break;
            // BEGIN android-removed
            // case RIPEMD160:
            //     generator = new PKCS12ParametersGenerator(new RIPEMD160Digest());
            //     break;
            // case TIGER:
            //     generator = new PKCS12ParametersGenerator(new TigerDigest());
            //     break;
            // END android-removed
          case SHA256:
            // BEGIN android-changed
            generator = new PKCS12ParametersGenerator(AndroidDigestFactory.getSHA256());
            // END android-changed
            break;
          default:
            throw new IllegalStateException("unknown digest scheme for PBE encryption.");
        }
      } else {
        generator = new OpenSSLPBEParametersGenerator();
      }

      return generator;
    }
コード例 #3
0
 public DSAParametersGenerator() {
   // BEGIN android-changed
   this(AndroidDigestFactory.getSHA1());
   // END android-changed
 }