public DecryptionMaterials decryptMaterials()

in src/main/java/com/amazonaws/encryptionsdk/DefaultCryptoMaterialsManager.java [116:147]


  public DecryptionMaterials decryptMaterials(DecryptionMaterialsRequest request) {
    DataKey<?> dataKey =
        mkp.decryptDataKey(
            request.getAlgorithm(), request.getEncryptedDataKeys(), request.getEncryptionContext());

    if (dataKey == null) {
      throw new CannotUnwrapDataKeyException("Could not decrypt any data keys");
    }

    PublicKey pubKey = null;
    if (request.getAlgorithm().getTrailingSignatureLength() > 0) {
      try {
        String serializedPubKey = request.getEncryptionContext().get(Constants.EC_PUBLIC_KEY_FIELD);

        if (serializedPubKey == null) {
          throw new AwsCryptoException("Missing trailing signature public key");
        }

        pubKey = deserializeTrailingKeyFromEc(request.getAlgorithm(), serializedPubKey);
      } catch (final IllegalStateException ex) {
        throw new AwsCryptoException(ex);
      }
    } else if (request.getEncryptionContext().containsKey(Constants.EC_PUBLIC_KEY_FIELD)) {
      throw new AwsCryptoException("Trailing signature public key found for non-signed algorithm");
    }

    return DecryptionMaterials.newBuilder()
        .setDataKey(dataKey)
        .setTrailingSignatureKey(pubKey)
        .setEncryptionContext(request.getEncryptionContext())
        .build();
  }