Ejemplo n.º 1
0
 public static KeyMetadata read(String jsonString) {
   KeyMetadata kmd = (KeyMetadata) Util.gson().fromJson(jsonString, KeyMetadata.class);
   for (KeyVersion version : kmd.getVersions()) {
     kmd.versionMap.put(Integer.valueOf(version.getVersionNumber()), version);
   }
   return kmd;
 }
Ejemplo n.º 2
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);
  }
Ejemplo n.º 3
0
 static DsaPublicKey read(String input) throws KeyczarException {
   DsaPublicKey key = Util.gson().fromJson(input, DsaPublicKey.class);
   key.init();
   return key;
 }
Ejemplo n.º 4
0
 public String toString() {
   return Util.gson().toJson((Object) this);
 }