key_mgmt_c

package
v0.0.0-...-aeb4a1d Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAccess

func AddAccess(stub cached_stub.CachedStubInterface, startKey data_model.Key, targetKey data_model.Key, edgeData ...map[string]string) error

AddAccess gives startKey access to targetKey.

func AddAccessWithKeys

func AddAccessWithKeys(stub cached_stub.CachedStubInterface, startKey []byte, startKeyId string, targetKey []byte, targetKeyId string, encKey []byte, edgeData ...map[string]string) error

(Deprecated, use AddAccess() function instead) AddAccessWithKeys gives startKey access to targetKey. It does this by encrypting targetKey with encKey, which can then be decrypted using startKey. If startKey is a sym key, encKey must be identical. Otherwise startKey must be a private key and encKey the matching public key. Stores an edge in the graph from startKeyId -> targetKeyId, and a reverse edge from targetKeyId -> startKeyId.

func ConvertKeyBytesToKey

func ConvertKeyBytesToKey(keyId string, keyBytes []byte) (*data_model.Key, error)

ConvertKeyBytesToKey converts a keyId + keyBytes to a Key object

func GetAccessEdge

func GetAccessEdge(stub cached_stub.CachedStubInterface, startKeyId string, targetKeyId string) ([]byte, map[string]string, error)

GetAccessEdge gets the Access key graph edge. Returns edgeValueByte, edgeDataMap, error.

func GetKey

func GetKey(stub cached_stub.CachedStubInterface, keyIdList []string, startKey []byte) ([]byte, error)

GetKey follows the path of keys in keyIdList, decrypting each key along the way. When it reaches the end of the list, it returns that final key.

func GetKeyIdForWriteOnlyAccess

func GetKeyIdForWriteOnlyAccess(assetId string, assetKeyId string, ownerId string) string

func GetLogSymKeyId

func GetLogSymKeyId(id string) string

GetLogSymKeyId returns the ID that should be assigned to a log sym key.

func GetOwnerKeys

func GetOwnerKeys(stub cached_stub.CachedStubInterface, targetKeyId string, filter ...interface{}) ([]string, error)

GetOwnerKeys returns a list of keyIds which can be used to access targetKeyId (directly or indirectly).

func GetPrivateKeyHashSymKeyId

func GetPrivateKeyHashSymKeyId(id string) string

GetPrivateKeyHashSymKeyId returns the ID that should be assigned to a sym key derived from the hash of a private key.

func GetPubPrivKeyId

func GetPubPrivKeyId(id string) string

GetPubPrivKeyId returns the ID that should be assigned to a public or private key.

func GetSymKeyId

func GetSymKeyId(id string) string

GetSymKeyId returns the ID that should be assigned to a sym key.

func GetUserKeys

func GetUserKeys(stub cached_stub.CachedStubInterface, user data_model.User, filter ...interface{}) ([]string, error)

GetUserKeys returns a list of keyIds that can be accessed by the User (directly or indirectly).

func Init

func Init(stub cached_stub.CachedStubInterface, logLevel ...shim.LoggingLevel) ([]byte, error)

Init sets up the key_mgmt package.

func KeyExists

func KeyExists(stub cached_stub.CachedStubInterface, keyId string) bool

KeyExists checks if the key already exists in the graph, It does not check the validity of the key, only its existence in the graph.

func RevokeAccess

func RevokeAccess(stub cached_stub.CachedStubInterface, startKeyId string, targetKeyId string) error

RevokeAccess revokes access from startKey to targetKey. It does this by deleting the edge from startKey -> targetKey (and the reverse edge from targetKeyId -> startKeyId).

func SlowGetMyKeys

func SlowGetMyKeys(stub cached_stub.CachedStubInterface, startKeyId string, filter ...interface{}) ([]string, error)

SlowGetMyKeys returns a list of keyIds that can be accessed starting from startKeyId (directly or indirectly).

func SlowVerifyAccess

func SlowVerifyAccess(stub cached_stub.CachedStubInterface, startKeyId string, targetKeyId string, filter ...interface{}) ([]string, error)

SlowVerifyAccess checks for a path in the graph from startKeyId to targetKeyId. Uses recursive DFS. Returns the list of keyIds in the path. If no path is found, returns nil.

func SlowVerifyAccessAndGetKey

func SlowVerifyAccessAndGetKey(stub cached_stub.CachedStubInterface, startKeyId string, startKey []byte, targetKeyId string, filter ...interface{}) ([]byte, error)

SlowVerifyAccessAndGetKey calls FindPath and passes the result to GetKey. This is a convenience function for callers who want a key but don't want to make 2 calls. If no path is found to the targetKey, (nil, nil) is returned.

func UpdateAccessEdge

func UpdateAccessEdge(stub cached_stub.CachedStubInterface, startKeyId string, targetKeyId string, edge ...interface{}) error

UpdateAccessEdge updates Access key graph edge without checking error.

func ValidateKey

func ValidateKey(stub cached_stub.CachedStubInterface, key data_model.Key, mustExist bool) (bool, error)

ValidateKey checks if key matches existing key in the graph. If key does not exist, returns !mustExist. If key does exist, returns true if valid, false otherwise.

func VerifyAccessPath

func VerifyAccessPath(stub cached_stub.CachedStubInterface, path []string) (bool, error)

VerifyAccessPath checks if all edges in the path exist.

func VerifyAccessPathAndGetKey

func VerifyAccessPathAndGetKey(stub cached_stub.CachedStubInterface, startKeyId string, startKey []byte, path []string) ([]byte, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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