Example #1
0
  void init() throws KeyczarException {
    BigInteger yVal = new BigInteger(Base64Coder.decodeWebSafe(y));
    BigInteger pVal = new BigInteger(Base64Coder.decodeWebSafe(p));
    BigInteger qVal = new BigInteger(Base64Coder.decodeWebSafe(q));
    BigInteger gVal = new BigInteger(Base64Coder.decodeWebSafe(g));
    DSAPublicKeySpec spec = new DSAPublicKeySpec(yVal, pVal, qVal, gVal);

    try {
      KeyFactory kf = KeyFactory.getInstance(KEY_GEN_ALGORITHM);
      jcePublicKey = kf.generatePublic(spec);
    } catch (GeneralSecurityException e) {
      throw new KeyczarException(e);
    }

    byte[] fullHash =
        Util.prefixHash(
            Util.stripLeadingZeros(pVal.toByteArray()),
            Util.stripLeadingZeros(qVal.toByteArray()),
            Util.stripLeadingZeros(gVal.toByteArray()),
            Util.stripLeadingZeros(yVal.toByteArray()));
    System.arraycopy(fullHash, 0, hash, 0, hash.length);
  }