Skip to content

Commit

Permalink
Update structures.go (#239)
Browse files Browse the repository at this point in the history
Add some explanatory comments to contextualize values that are combinations of algorithm-specific parameters and algorithm-specific public ID
  • Loading branch information
chrisfenner authored Apr 1, 2021
1 parent 4347b8d commit 48f82fb
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tpm2/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ type Public struct {

// Exactly one of the following fields should be set
// When encoding/decoding, one will be picked based on Type.

// RSAParameters contains both [rsa]parameters and [rsa]unique.
RSAParameters *RSAParams
// ECCParameters contains both [ecc]parameters and [ecc]unique.
ECCParameters *ECCParams
// SymCipherParameters contains both [sym]parameters and [sym]unique.
SymCipherParameters *SymCipherParams
// KeyedHashParameters contains both [keyedHash]parameters and [keyedHash]unique.
KeyedHashParameters *KeyedHashParams
}

Expand Down Expand Up @@ -189,7 +194,8 @@ func DecodePublic(buf []byte) (Public, error) {
return pub, err
}

// RSAParams represents parameters of an RSA key pair.
// RSAParams represents parameters of an RSA key pair:
// both the TPMS_RSA_PARMS and the TPM2B_PUBLIC_KEY_RSA.
//
// Symmetric and Sign may be nil, depending on key Attributes in Public.
//
Expand Down Expand Up @@ -259,7 +265,8 @@ func decodeRSAParams(in *bytes.Buffer) (*RSAParams, error) {
return &params, nil
}

// ECCParams represents parameters of an ECC key pair.
// ECCParams represents parameters of an ECC key pair:
// both the TPMS_ECC_PARMS and the TPMS_ECC_POINT.
//
// Symmetric, Sign and KDF may be nil, depending on key Attributes in Public.
type ECCParams struct {
Expand Down Expand Up @@ -340,7 +347,8 @@ func decodeECCParams(in *bytes.Buffer) (*ECCParams, error) {
return &params, nil
}

// SymCipherParams represents parameters of a symmetric block cipher TPM object.
// SymCipherParams represents parameters of a symmetric block cipher TPM object:
// both the TPMS_SYMCIPHER_PARMS and the TPM2B_DIGEST (hash of the key).
type SymCipherParams struct {
Symmetric *SymScheme
Unique tpmutil.U16Bytes
Expand Down Expand Up @@ -375,7 +383,8 @@ func decodeSymCipherParams(in *bytes.Buffer) (*SymCipherParams, error) {
return &params, nil
}

// KeyedHashParams represents parameters of a keyed hash TPM object.
// KeyedHashParams represents parameters of a keyed hash TPM object:
// both the TPMS_KEYEDHASH_PARMS and the TPM2B_DIGEST (hash of the key).
type KeyedHashParams struct {
Alg Algorithm
Hash Algorithm
Expand Down

0 comments on commit 48f82fb

Please sign in to comment.