def decrypt(cipher, options = {})
      options = @default_options.merge options

      plain_data   = Data.new(options[:output])
      cipher_data  = Data.new(cipher)

      GPGME::Ctx.new(options) do |ctx|
        begin
          ctx.decrypt_verify(cipher_data, plain_data)
        rescue GPGME::Error::UnsupportedAlgorithm => exc
          exc.algorithm = ctx.decrypt_result.unsupported_algorithm
          raise exc
        rescue GPGME::Error::WrongKeyUsage => exc
          exc.key_usage = ctx.decrypt_result.wrong_key_usage
          raise exc
        end

        verify_result = ctx.verify_result
        if verify_result && block_given?
          verify_result.signatures.each do |signature|
            yield signature
          end
        end

      end

      plain_data.seek(0)
      plain_data
    end
def decrypt(cipher, options = {})
      options = @default_options.merge options

      plain_data   = Data.new(options[:output])
      cipher_data  = Data.new(cipher)

      GPGME::Ctx.new(options) do |ctx|
        begin
          ctx.decrypt_verify(cipher_data, plain_data)
        rescue GPGME::Error::UnsupportedAlgorithm => exc
          exc.algorithm = ctx.decrypt_result.unsupported_algorithm
          raise exc
        rescue GPGME::Error::WrongKeyUsage => exc
          exc.key_usage = ctx.decrypt_result.wrong_key_usage
          raise exc
        end

        verify_result = ctx.verify_result
        if verify_result && block_given?
          verify_result.signatures.each do |signature|
            yield signature
          end
        end

      end

      plain_data.seek(0)
      plain_data
    end
Decrypts a previously encrypted element

   crypto.decrypt cipher, options, &block

 Must have the appropiate key to be able to decrypt, of course. Returns
 a {GPGME::Data} object which can then be read.

 @param cipher
   Must be something that can be converted into a {GPGME::Data} object,
   or a {GPGME::Data} object itself. It is the element that will be
   decrypted.

 @param [Hash] options
   The optional parameters:
   * +:output+ if specified, it will write the output into it. It will
     me converted to a {GPGME::Data} object, so it can also be a file,
     for example.
   * If the file was encrypted with symmentric encryption, must provide
     a :password option.
   * Any other option accepted by {GPGME::Ctx.new}

 @param &block
   In the block all the signatures are yielded, so one could verify them.
   See examples.

 @return [GPGME::Data] a {GPGME::Data} that can be read.

 @example Simple decrypt
   crypto.decrypt encrypted_data

 @example symmetric encryption, or passwored key
   crypto.decrypt encrypted_data, :password => "gpgme"

 @example Output to file
   file = File.open("decrypted.txt", "w+")
   crypto.decrypt encrypted_data, :output => file

 @example Verifying signatures
   crypto.decrypt encrypted_data do |signature|
     raise "Signature could not be verified" unless signature.valid?
   end

 @raise [GPGME::Error::UnsupportedAlgorithm] when the cipher was encrypted
   using an algorithm that's not supported currently.

 @raise [GPGME::Error::WrongKeyUsage] TODO Don't know when

 @raise [GPGME::Error::DecryptFailed] when the cipher was encrypted
   for a key that's not available currently.