Class: TPM::TPublic

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/tpm/t_public.rb,
lib/tpm/t_public/s_ecc_parms.rb,
lib/tpm/t_public/s_rsa_parms.rb

Overview

Defined Under Namespace

Classes: SEccParms, SRsaParms

Constant Summary collapse

BYTE_LENGTH =
8
CURVE_TPM_TO_OPENSSL =
{
  TPM::ECC_NIST_P256 => "prime256v1",
  TPM::ECC_NIST_P384 => "secp384r1",
  TPM::ECC_NIST_P521 => "secp521r1",
}.freeze
BN_BASE =
2
RSA_KEY_DEFAULT_PUBLIC_EXPONENT =
2**16 + 1
ECC_UNCOMPRESSED_POINT_INDICATOR =
"\x04"

Instance Method Summary collapse

Instance Method Details

#ecc?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/tpm/t_public.rb', line 54

def ecc?
  alg_type == TPM::ALG_ECC
end

#keyObject



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/tpm/t_public.rb', line 58

def key
  if parameters.symmetric == TPM::ALG_NULL
    if ecc?
      ecc_key
    elsif rsa?
      rsa_key
    else
      raise "Type #{alg_type} not supported"
    end
  end
end

#openssl_curve_nameObject



70
71
72
73
74
# File 'lib/tpm/t_public.rb', line 70

def openssl_curve_name
  if ecc?
    CURVE_TPM_TO_OPENSSL[parameters.curve_id] || raise("Unknown curve #{parameters.curve_id}")
  end
end

#rsa?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/tpm/t_public.rb', line 50

def rsa?
  alg_type == TPM::ALG_RSA
end