hashtree

package
v0.0.0-...-edbb0c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2021 License: BSD-3-Clause Imports: 8 Imported by: 0

README

hashtree

package hashtree provides helpers for building and walking TPM2 PolicyOR trees.

Variables

var (
    ErrNodeIndexOutOfBounds = errors.New("node index out of bounds")
    ErrEmptyTree            = errors.New("tree is empty")
    ErrNodeNotAChild        = errors.New("node not a child")
)

Types

type PolicyHashTree

type PolicyHashTree [][]byte

PolicyHashTree represents a TPM2_PolicyOR tree as a complete 8-tree, where all internal nodes are hashes of PolicyOR commands, and all leaf nodes represent concrete policies used to create the tree. normalized sublist's policy.

func Build

func Build(alg crypto.Hash, leaves [][]byte) (*PolicyHashTree, error)

Build creates a PolicyHashTree holding the given leaves.

func (PolicyHashTree) ChildrenOf

func (t PolicyHashTree) ChildrenOf(index int) [][]byte

ChildrenOf returns the digests of all the children of the given internal node. If the node is a leaf node, returns nil.

func (PolicyHashTree) LeafIndex

func (t PolicyHashTree) LeafIndex(i int) (*int, error)

LeafIndex returns the index of the given leaf in the tree.

func (PolicyHashTree) Root

func (t PolicyHashTree) Root() ([]byte, error)

Root returns the root of the tree.

func (PolicyHashTree) RunOr

func (tree PolicyHashTree) RunOr(tpm io.ReadWriter, s tpmutil.Handle, index int) error

RunOr runs the PolicyOr command to go from the given node to its parent, in the given TPM session handle.


Readme created from Go doc with goreadme

Documentation

Overview

package hashtree provides helpers for building and walking TPM2 PolicyOR trees.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNodeIndexOutOfBounds = errors.New("node index out of bounds")
	ErrEmptyTree            = errors.New("tree is empty")
	ErrNodeNotAChild        = errors.New("node not a child")
)

Functions

This section is empty.

Types

type PolicyHashTree

type PolicyHashTree [][]byte

PolicyHashTree represents a TPM2_PolicyOR tree as a complete 8-tree, where all internal nodes are hashes of PolicyOR commands, and all leaf nodes represent concrete policies used to create the tree. normalized sublist's policy.

func Build

func Build(alg crypto.Hash, leaves [][]byte) (*PolicyHashTree, error)

Build creates a PolicyHashTree holding the given leaves.

func (PolicyHashTree) ChildrenOf

func (t PolicyHashTree) ChildrenOf(index int) [][]byte

ChildrenOf returns the digests of all the children of the given internal node. If the node is a leaf node, returns nil.

func (PolicyHashTree) LeafIndex

func (t PolicyHashTree) LeafIndex(i int) (*int, error)

LeafIndex returns the index of the given leaf in the tree.

func (PolicyHashTree) Root

func (t PolicyHashTree) Root() ([]byte, error)

Root returns the root of the tree.

func (PolicyHashTree) RunOr

func (tree PolicyHashTree) RunOr(tpm io.ReadWriter, s tpmutil.Handle, index int) error

RunOr runs the PolicyOr command to go from the given node to its parent, in the given TPM session handle.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL