File: decrypted_part.rb

package info (click to toggle)
ruby-mail-gpg 0.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 328 kB
  • sloc: ruby: 2,289; makefile: 6
file content (20 lines) | stat: -rw-r--r-- 597 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'mail/gpg/verified_part'
module Mail
  module Gpg
    class DecryptedPart < VerifiedPart

      # options are:
      #
      # :verify: decrypt and verify
      def initialize(cipher_part, options = {})
        if cipher_part.mime_type != EncryptedPart::CONTENT_TYPE
          raise EncodingError, "RFC 3156 incorrect mime type for encrypted part '#{cipher_part.mime_type}'"
        end

        decrypted = GpgmeHelper.decrypt(cipher_part.body.decoded, options)
        self.verify_result = decrypted.verify_result if options[:verify]
        super(decrypted)
      end
    end
  end
end