Sha256: 9f5f2b9ec3c701049bcd845b1cc3f58d9c1b237400ccae7bbe0dd689db3ac8e7

Contents?: true

Size: 757 Bytes

Versions: 4

Compression:

Stored size: 757 Bytes

Contents

# frozen_string_literal: true

require "openssl"
require "tpm/t_public"

module TPM
  TPM_TO_OPENSSL_HASH_ALG = {
    TPM::ALG_SHA1 => "SHA1",
    TPM::ALG_SHA256 => "SHA256"
  }.freeze

  class PublicArea
    attr_reader :object

    def initialize(object)
      @object = object
    end

    def name
      [name_alg].pack("n") + name_digest
    end

    def key
      t_public.key
    end

    def ecc?
      t_public.ecc?
    end

    def openssl_curve_name
      t_public.openssl_curve_name
    end

    private

    def name_digest
      OpenSSL::Digest.digest(TPM_TO_OPENSSL_HASH_ALG[name_alg], object)
    end

    def name_alg
      t_public.name_alg
    end

    def t_public
      @t_public ||= TPM::TPublic.deserialize(object)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tpm-key_attestation-0.12.1 lib/tpm/public_area.rb
tpm-key_attestation-0.12.0 lib/tpm/public_area.rb
tpm-key_attestation-0.11.0 lib/tpm/public_area.rb
tpm-key_attestation-0.10.0 lib/tpm/public_area.rb