Documentation ¶
Index ¶
- Constants
- func CoPath(root *PublicNode, idx int, copathNodes []*ecdh.PublicKey) []*ecdh.PublicKey
- func DHKeyGen() (*ecdh.PrivateKey, error)
- func DeriveLeafKey(ekPath string, suk *ecdh.PublicKey) (*ecdh.PrivateKey, error)
- func DeriveLeafKeyOrFail(privKeyFile string, setupKey *ecdh.PublicKey) *ecdh.PrivateKey
- func DeriveStageKey(skInfo *StageKeyInfo) ([]byte, error)
- func GetPublicKeys(pathKeys []*ecdh.PrivateKey) []*ecdh.PublicKey
- func KeyExchange(sk *ecdh.PrivateKey, pk *ecdh.PublicKey) ([]byte, error)
- func KeyExchangeKeyGen() (*ecdh.PrivateKey, error)
- func MarshalPrivateEKToDER(key *ecdh.PrivateKey) ([]byte, error)
- func MarshalPrivateEKToPEM(key *ecdh.PrivateKey) ([]byte, error)
- func MarshalPrivateEKToRaw(key *ecdh.PrivateKey) ([]byte, error)
- func MarshalPrivateIKToDER(key ed25519.PrivateKey) ([]byte, error)
- func MarshalPrivateIKToPEM(key ed25519.PrivateKey) ([]byte, error)
- func MarshalPrivateIKToRaw(key ed25519.PrivateKey) ([]byte, error)
- func MarshalPublicEKToDER(key *ecdh.PublicKey) ([]byte, error)
- func MarshalPublicEKToPEM(key *ecdh.PublicKey) ([]byte, error)
- func MarshalPublicEKToRaw(key *ecdh.PublicKey) ([]byte, error)
- func MarshalPublicIKToDER(key ed25519.PublicKey) ([]byte, error)
- func MarshalPublicIKToPEM(key ed25519.PublicKey) ([]byte, error)
- func MarshalPublicIKToRaw(key ed25519.PublicKey) ([]byte, error)
- func MarshallTreeState(state *TreeState) *treeJson
- func NewHMAC(key []byte) hash.Hash
- func PathNodeKeys(leafKey *ecdh.PrivateKey, copathKeys []*ecdh.PublicKey) ([]*ecdh.PrivateKey, error)
- func ReadPrivateEKFromFile(path string, encoding KeyEncoding) (*ecdh.PrivateKey, error)
- func ReadPrivateIKFromFile(path string, encoding KeyEncoding) (ed25519.PrivateKey, error)
- func ReadPublicEKFromFile(path string, encoding KeyEncoding) (*ecdh.PublicKey, error)
- func ReadPublicIKFromFile(path string, encoding KeyEncoding) (ed25519.PublicKey, error)
- func SetupGroup(configFile, initiator string) (*TreeState, *SetupMessage)
- func SignFile(privIKFile string, msgFile string) ([]byte, error)
- func UnmarshalPrivateEKFromDER(derData []byte) (*ecdh.PrivateKey, error)
- func UnmarshalPrivateEKFromPEM(pemData []byte) (*ecdh.PrivateKey, error)
- func UnmarshalPrivateEKFromRaw(data []byte) (*ecdh.PrivateKey, error)
- func UnmarshalPrivateIKFromDER(derData []byte) (ed25519.PrivateKey, error)
- func UnmarshalPrivateIKFromPEM(pemData []byte) (ed25519.PrivateKey, error)
- func UnmarshalPrivateIKFromRaw(data []byte) (ed25519.PrivateKey, error)
- func UnmarshalPrivateX25519FromRaw(data []byte) (*ecdh.PrivateKey, error)
- func UnmarshalPublicEKFromDER(derData []byte) (*ecdh.PublicKey, error)
- func UnmarshalPublicEKFromPEM(pemData []byte) (*ecdh.PublicKey, error)
- func UnmarshalPublicEKFromRaw(data []byte) (*ecdh.PublicKey, error)
- func UnmarshalPublicIKFromDER(derData []byte) (ed25519.PublicKey, error)
- func UnmarshalPublicIKFromPEM(pemData []byte) (ed25519.PublicKey, error)
- func UnmarshalPublicIKFromRaw(data []byte) (ed25519.PublicKey, error)
- func UnmarshallPublicKeys(pathKeys [][]byte) []*ecdh.PublicKey
- func UpdateCoPathNodes(index int, state *TreeState) []*ecdh.PrivateKey
- func UpdateKey(index int, treeStateFile string) (*UpdateMessage, *TreeState, *ed25519.PrivateKey)
- func VerifyMessageSignature(publicKeyPath, msgFile, sigFile string)
- func VerifySignature(pkPath, msgFile, sigFile string) (bool, error)
- func WritePrivateEKToFile(key *ecdh.PrivateKey, path string, encoding KeyEncoding) error
- func WritePrivateIKToFile(key ed25519.PrivateKey, path string, encoding KeyEncoding) error
- func WritePublicEKToFile(key *ecdh.PublicKey, path string, encoding KeyEncoding) error
- func WritePublicIKToFile(key ed25519.PublicKey, path string, encoding KeyEncoding) error
- type Group
- type KeyEncoding
- type Member
- type Node
- type PublicNode
- type SetupMessage
- func (sm *SetupMessage) Decode(file *os.File)
- func (sm *SetupMessage) DeriveStageKey(treeSecret *ecdh.PrivateKey) []byte
- func (sm *SetupMessage) GetPublicTree() *PublicNode
- func (sm *SetupMessage) GetSetupKey() *ecdh.PublicKey
- func (sm *SetupMessage) Read(msgFilePath string)
- func (sm *SetupMessage) Save(fileName string)
- func (sm *SetupMessage) SaveSign(sigFile, msgFile, privIKFile string)
- type StageKeyInfo
- type TreeState
- func ProcessSetupMessage(index int, privEKFile, setupMsgFile, initiatorPubIKFile, sigFile string) *TreeState
- func ProcessUpdateMessage(index int, treeStateFile, updateMsgFile, macFile string) *TreeState
- func ReadTreeState(treeStateFile string) *TreeState
- func UnMarshallTreeState(tree *treeJson) *TreeState
- func (state *TreeState) DeriveStageKey(treeSecret *ecdh.PrivateKey)
- func (treeState *TreeState) DeriveTreeKey(index int) *ecdh.PrivateKey
- func (treeState *TreeState) Read(treeStateFile string)
- func (treeState *TreeState) Save(fileName string)
- func (treeState *TreeState) SaveStageKey(fileName string)
- func (treeState *TreeState) StageKey() ed25519.PrivateKey
- func (treeState *TreeState) UnMarshallTreeState(tree *treeJson)
- type UpdateMessage
Constants ¶
View Source
const ( PublicIKPEMTypeString = "ED25519 PUBLIC KEY" PrivateIKPEMTypeString = "ED25519 PRIVATE KEY" PublicEKPEMTypeString = "X25519 PUBLIC KEY" PrivateEKPEMTypeString = "X25519 PRIVATE KEY" )
View Source
const ( PublicKeyFileMode = 0440 PrivateKeyFileMode = 0400 )
View Source
const StageKeySize = 32
Variables ¶
This section is empty.
Functions ¶
func DHKeyGen ¶
func DHKeyGen() (*ecdh.PrivateKey, error)
func DeriveLeafKey ¶
func DeriveLeafKeyOrFail ¶
func DeriveLeafKeyOrFail(privKeyFile string, setupKey *ecdh.PublicKey) *ecdh.PrivateKey
func DeriveStageKey ¶
func DeriveStageKey(skInfo *StageKeyInfo) ([]byte, error)
prev sk, current tk, IDs, Public Tree
func GetPublicKeys ¶
func GetPublicKeys(pathKeys []*ecdh.PrivateKey) []*ecdh.PublicKey
func KeyExchange ¶
the unauthenticated KeyExchange is just SUK^ek or EK^suk
func KeyExchangeKeyGen ¶
func KeyExchangeKeyGen() (*ecdh.PrivateKey, error)
func MarshalPrivateEKToDER ¶
func MarshalPrivateEKToDER(key *ecdh.PrivateKey) ([]byte, error)
func MarshalPrivateEKToPEM ¶
func MarshalPrivateEKToPEM(key *ecdh.PrivateKey) ([]byte, error)
func MarshalPrivateEKToRaw ¶
func MarshalPrivateEKToRaw(key *ecdh.PrivateKey) ([]byte, error)
func MarshalPrivateIKToDER ¶
func MarshalPrivateIKToDER(key ed25519.PrivateKey) ([]byte, error)
func MarshalPrivateIKToPEM ¶
func MarshalPrivateIKToPEM(key ed25519.PrivateKey) ([]byte, error)
func MarshalPrivateIKToRaw ¶
func MarshalPrivateIKToRaw(key ed25519.PrivateKey) ([]byte, error)
func MarshallTreeState ¶
func MarshallTreeState(state *TreeState) *treeJson
func PathNodeKeys ¶
func PathNodeKeys(leafKey *ecdh.PrivateKey, copathKeys []*ecdh.PublicKey) ( []*ecdh.PrivateKey, error)
func ReadPrivateEKFromFile ¶
func ReadPrivateEKFromFile(path string, encoding KeyEncoding) (*ecdh.PrivateKey, error)
func ReadPrivateIKFromFile ¶
func ReadPrivateIKFromFile(path string, encoding KeyEncoding) (ed25519.PrivateKey, error)
func ReadPublicEKFromFile ¶
func ReadPublicEKFromFile(path string, encoding KeyEncoding) (*ecdh.PublicKey, error)
func ReadPublicIKFromFile ¶
func ReadPublicIKFromFile(path string, encoding KeyEncoding) (ed25519.PublicKey, error)
func SetupGroup ¶
func SetupGroup(configFile, initiator string) (*TreeState, *SetupMessage)
func UnmarshalPrivateEKFromDER ¶
func UnmarshalPrivateEKFromDER(derData []byte) (*ecdh.PrivateKey, error)
func UnmarshalPrivateEKFromPEM ¶
func UnmarshalPrivateEKFromPEM(pemData []byte) (*ecdh.PrivateKey, error)
func UnmarshalPrivateEKFromRaw ¶
func UnmarshalPrivateEKFromRaw(data []byte) (*ecdh.PrivateKey, error)
func UnmarshalPrivateIKFromDER ¶
func UnmarshalPrivateIKFromDER(derData []byte) (ed25519.PrivateKey, error)
func UnmarshalPrivateIKFromPEM ¶
func UnmarshalPrivateIKFromPEM(pemData []byte) (ed25519.PrivateKey, error)
func UnmarshalPrivateIKFromRaw ¶
func UnmarshalPrivateIKFromRaw(data []byte) (ed25519.PrivateKey, error)
func UnmarshalPrivateX25519FromRaw ¶
func UnmarshalPrivateX25519FromRaw(data []byte) (*ecdh.PrivateKey, error)
func UnmarshallPublicKeys ¶
func UpdateCoPathNodes ¶
func UpdateCoPathNodes(index int, state *TreeState) []*ecdh.PrivateKey
func UpdateKey ¶
func UpdateKey(index int, treeStateFile string) (*UpdateMessage, *TreeState, *ed25519.PrivateKey)
func VerifyMessageSignature ¶
func VerifyMessageSignature(publicKeyPath, msgFile, sigFile string)
func VerifySignature ¶
func WritePrivateEKToFile ¶
func WritePrivateEKToFile(key *ecdh.PrivateKey, path string, encoding KeyEncoding) error
func WritePrivateIKToFile ¶
func WritePrivateIKToFile(key ed25519.PrivateKey, path string, encoding KeyEncoding) error
func WritePublicEKToFile ¶
func WritePublicEKToFile(key *ecdh.PublicKey, path string, encoding KeyEncoding) error
func WritePublicIKToFile ¶
func WritePublicIKToFile(key ed25519.PublicKey, path string, encoding KeyEncoding) error
Types ¶
type KeyEncoding ¶
type KeyEncoding int
const ( EncodingUnknown KeyEncoding = iota EncodingRaw EncodingDER EncodingPEM )
func StringToKeyEncoding ¶
func StringToKeyEncoding(keyform string) (KeyEncoding, error)
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func CreateTree ¶
func CreateTree(leafKeys []*ecdh.PrivateKey) (*Node, error)
func UnmarshalKeysToPrivateTree ¶
constructing a private tree from a level-order list of marshalled keys
func (*Node) GetSk ¶
func (Node *Node) GetSk() *ecdh.PrivateKey
func (*Node) MarshalKeys ¶
*** *** Helper functions for private trees *** ***
func (*Node) PublicKeys ¶
func (node *Node) PublicKeys() *PublicNode
type PublicNode ¶
type PublicNode struct { Left *PublicNode Right *PublicNode Height int // a height of zero indicates a leaf node // contains filtered or unexported fields }
func UnmarshalKeysToPublicTree ¶
func UnmarshalKeysToPublicTree(marshalledKeys [][]byte) (*PublicNode, error)
constructing a public tree from a level-order list of marshalled keys
func UpdatePublicTree ¶
func UpdatePublicTree(pathKeys []*ecdh.PublicKey, root *PublicNode, idx int) *PublicNode
update the full tree with the new leaf and path keys
func (*PublicNode) GetPk ¶
func (publicNode *PublicNode) GetPk() *ecdh.PublicKey
func (*PublicNode) MarshalKeys ¶
func (publicNode *PublicNode) MarshalKeys() ([][]byte, error)
MarshalKeys marshals the public keys level-by-level, starting at the root.
func (*PublicNode) UpdatePk ¶
func (publicNode *PublicNode) UpdatePk(newPK *ecdh.PublicKey)
type SetupMessage ¶
type SetupMessage struct { IKeys [][]byte `json:"iKeys"` EKeys [][]byte `json:"eKeys"` Suk []byte `json:"suk"` TreeKeys [][]byte `json:"treeKeys"` }
func (*SetupMessage) Decode ¶
func (sm *SetupMessage) Decode(file *os.File)
func (*SetupMessage) DeriveStageKey ¶
func (sm *SetupMessage) DeriveStageKey(treeSecret *ecdh.PrivateKey) []byte
func (*SetupMessage) GetPublicTree ¶
func (sm *SetupMessage) GetPublicTree() *PublicNode
func (*SetupMessage) GetSetupKey ¶
func (sm *SetupMessage) GetSetupKey() *ecdh.PublicKey
func (*SetupMessage) Read ¶
func (sm *SetupMessage) Read(msgFilePath string)
func (*SetupMessage) Save ¶
func (sm *SetupMessage) Save(fileName string)
func (*SetupMessage) SaveSign ¶
func (sm *SetupMessage) SaveSign(sigFile, msgFile, privIKFile string)
TODO: why is this part of the SetupMessage struct?
type StageKeyInfo ¶
type StageKeyInfo struct { PrevStageKey []byte TreeSecretKey []byte TreeKeys [][]byte IKeys [][]byte }
func (*StageKeyInfo) GetIKM ¶
func (skInfo *StageKeyInfo) GetIKM() []byte
func (*StageKeyInfo) GetInfo ¶
func (skInfo *StageKeyInfo) GetInfo() []byte
type TreeState ¶
type TreeState struct { // TODO: maybe add a tracker for the stage number to ensure updates // are processed in the correct order PublicTree *PublicNode Sk ed25519.PrivateKey Lk *ecdh.PrivateKey IKeys [][]byte }
func ProcessSetupMessage ¶
func ProcessUpdateMessage ¶
func ReadTreeState ¶
func UnMarshallTreeState ¶
func UnMarshallTreeState(tree *treeJson) *TreeState
func (*TreeState) DeriveStageKey ¶
func (state *TreeState) DeriveStageKey(treeSecret *ecdh.PrivateKey)
func (*TreeState) DeriveTreeKey ¶
func (treeState *TreeState) DeriveTreeKey(index int) *ecdh.PrivateKey
func (*TreeState) SaveStageKey ¶
func (*TreeState) StageKey ¶
func (treeState *TreeState) StageKey() ed25519.PrivateKey
func (*TreeState) UnMarshallTreeState ¶
func (treeState *TreeState) UnMarshallTreeState(tree *treeJson)
type UpdateMessage ¶
func CreateUpdateMessage ¶
func CreateUpdateMessage(index int, pathKeys []*ecdh.PrivateKey) UpdateMessage
func (*UpdateMessage) Decode ¶
func (um *UpdateMessage) Decode(file *os.File)
func (*UpdateMessage) Read ¶
func (um *UpdateMessage) Read(msgFilePath string)
func (*UpdateMessage) Save ¶
func (um *UpdateMessage) Save(fileName string)
func (*UpdateMessage) SaveMac ¶
func (um *UpdateMessage) SaveMac(sk ed25519.PrivateKey, macFile string)
func (*UpdateMessage) VerifyUpdateMessage ¶
func (um *UpdateMessage) VerifyUpdateMessage(sk ed25519.PrivateKey, macFile string)
verify the message signature with the current stage key
Click to show internal directories.
Click to hide internal directories.