Package org.keyczar

Examples of org.keyczar.Crypter.decrypt()


    @Override
    public byte[] getBytes() {
        Crypter crypter = parent.getCrypter();
        byte[] plaintext;
        try {
            plaintext = crypter.decrypt(data.getCiphertext().toByteArray());
        } catch (KeyczarException e) {
            throw new IllegalStateException("Error decrypting secret", e);
        }
        return plaintext;
    }
View Full Code Here


    public BackendSecretData getSecretData(BackendData backendData) {
        try {
            Crypter crypter = sharedKeystore.buildCrypter(KEY);

            byte[] plaintext = crypter.decrypt(backendData.getSecretData().getCiphertext().toByteArray());
            BackendSecretData secretData = BackendSecretData.parseFrom(plaintext);

            return secretData;
        } catch (Exception e) {
            throw new IllegalArgumentException("Error decrypting backend secret", e);
View Full Code Here

    public HostGroupSecretData getSecretData(HostGroupData backendData) {
        try {
            Crypter crypter = sharedKeystore.buildCrypter(KEY);

            byte[] plaintext = crypter.decrypt(backendData.getSecretData().getCiphertext().toByteArray());
            HostGroupSecretData secretData = HostGroupSecretData.parseFrom(plaintext);

            return secretData;
        } catch (Exception e) {
            throw new IllegalArgumentException("Error decrypting backend secret", e);
View Full Code Here

            if (version == 1) {
                Crypter crypter = new Crypter(recoveryKey);

                byte[] plaintext;
                try {
                    plaintext = crypter.decrypt(entry.getCiphertext().toByteArray());
                } catch (KeyczarException e) {
                    throw new IllegalStateException("Error decrypting token", e);
                }

                aesKey = KeyczarUtils.unpack(plaintext);
View Full Code Here

        return KeyczarUtils.buildCrypter(cryptoKey);
    }

    byte[] decrypt(byte[] ciphertext) throws KeyczarException {
        Crypter crypter = getCrypter();
        return crypter.decrypt(ciphertext);
    }

    @Deprecated
    CryptoKey getDeprecatedKey() {
        if (deprecatedKey != null) {
View Full Code Here

      Map<String, String> output, String algorithm, Map<String, String> generateParams,
      Map<String, String> testParams) throws KeyczarException {
    Crypter crypter = new Crypter(
        getReader(algorithm, generateParams.get("cryptedKeySet"), ""));
    if (generateParams.get("encoding").equals("encoded")) {
      String plaintext = crypter.decrypt(new String(readOutput(output)));
      assert(plaintext.equals(testData));
    } else if (generateParams.get("encoding").equals("unencoded")) {
      byte[] plaintext = crypter.decrypt(readOutput(output));
      assert((new String(plaintext)).equals(testData));
    } else {
View Full Code Here

        getReader(algorithm, generateParams.get("cryptedKeySet"), ""));
    if (generateParams.get("encoding").equals("encoded")) {
      String plaintext = crypter.decrypt(new String(readOutput(output)));
      assert(plaintext.equals(testData));
    } else if (generateParams.get("encoding").equals("unencoded")) {
      byte[] plaintext = crypter.decrypt(readOutput(output));
      assert((new String(plaintext)).equals(testData));
    } else {
      throw new KeyczarException("Expects encoded or unencoded in parameters");
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.