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)


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

def ecc?
  alg_type == TPM::ALG_ECC
end

#keyObject



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

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



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

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)


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

def rsa?
  alg_type == TPM::ALG_RSA
end