id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
141,800 | ipsn/go-ipfs | exchange/reprovide/reprovide.go | Reprovide | func (rp *Reprovider) Reprovide() error {
keychan, err := rp.keyProvider(rp.ctx)
if err != nil {
return fmt.Errorf("failed to get key chan: %s", err)
}
for c := range keychan {
// hash security
if err := verifcid.ValidateCid(c); err != nil {
log.Errorf("insecure hash in reprovider, %s (%s)", c, err)
con... | go | func (rp *Reprovider) Reprovide() error {
keychan, err := rp.keyProvider(rp.ctx)
if err != nil {
return fmt.Errorf("failed to get key chan: %s", err)
}
for c := range keychan {
// hash security
if err := verifcid.ValidateCid(c); err != nil {
log.Errorf("insecure hash in reprovider, %s (%s)", c, err)
con... | [
"func",
"(",
"rp",
"*",
"Reprovider",
")",
"Reprovide",
"(",
")",
"error",
"{",
"keychan",
",",
"err",
":=",
"rp",
".",
"keyProvider",
"(",
"rp",
".",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"... | // Reprovide registers all keys given by rp.keyProvider to libp2p content routing | [
"Reprovide",
"registers",
"all",
"keys",
"given",
"by",
"rp",
".",
"keyProvider",
"to",
"libp2p",
"content",
"routing"
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/exchange/reprovide/reprovide.go#L81-L109 |
141,801 | ipsn/go-ipfs | cmd/ipfs/daemon.go | printSwarmAddrs | func printSwarmAddrs(node *core.IpfsNode) {
if !node.IsOnline {
fmt.Println("Swarm not listening, running in offline mode.")
return
}
var lisAddrs []string
ifaceAddrs, err := node.PeerHost.Network().InterfaceListenAddresses()
if err != nil {
log.Errorf("failed to read listening addresses: %s", err)
}
for ... | go | func printSwarmAddrs(node *core.IpfsNode) {
if !node.IsOnline {
fmt.Println("Swarm not listening, running in offline mode.")
return
}
var lisAddrs []string
ifaceAddrs, err := node.PeerHost.Network().InterfaceListenAddresses()
if err != nil {
log.Errorf("failed to read listening addresses: %s", err)
}
for ... | [
"func",
"printSwarmAddrs",
"(",
"node",
"*",
"core",
".",
"IpfsNode",
")",
"{",
"if",
"!",
"node",
".",
"IsOnline",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"var",
"lisAddrs",
"[",
"]",
"string",
"\n",
"i... | // printSwarmAddrs prints the addresses of the host | [
"printSwarmAddrs",
"prints",
"the",
"addresses",
"of",
"the",
"host"
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/cmd/ipfs/daemon.go#L519-L547 |
141,802 | ipsn/go-ipfs | provider/queue.go | nextEntry | func (q *Queue) nextEntry() (datastore.Key, cid.Cid) {
for {
if q.head >= q.tail {
return datastore.Key{}, cid.Undef
}
key := q.queueKey(q.head)
value, err := q.ds.Get(key)
if err == datastore.ErrNotFound {
log.Warningf("Error missing entry in queue: %s", key)
q.head++ // move on
continue
} e... | go | func (q *Queue) nextEntry() (datastore.Key, cid.Cid) {
for {
if q.head >= q.tail {
return datastore.Key{}, cid.Undef
}
key := q.queueKey(q.head)
value, err := q.ds.Get(key)
if err == datastore.ErrNotFound {
log.Warningf("Error missing entry in queue: %s", key)
q.head++ // move on
continue
} e... | [
"func",
"(",
"q",
"*",
"Queue",
")",
"nextEntry",
"(",
")",
"(",
"datastore",
".",
"Key",
",",
"cid",
".",
"Cid",
")",
"{",
"for",
"{",
"if",
"q",
".",
"head",
">=",
"q",
".",
"tail",
"{",
"return",
"datastore",
".",
"Key",
"{",
"}",
",",
"ci... | // Look for next Cid in the queue and return it. Skip over gaps and mangled data | [
"Look",
"for",
"next",
"Cid",
"in",
"the",
"queue",
"and",
"return",
"it",
".",
"Skip",
"over",
"gaps",
"and",
"mangled",
"data"
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/provider/queue.go#L71-L99 |
141,803 | ipsn/go-ipfs | provider/queue.go | work | func (q *Queue) work() {
go func() {
var k datastore.Key = datastore.Key{}
var c cid.Cid = cid.Undef
for {
if c == cid.Undef {
k, c = q.nextEntry()
}
// If c != cid.Undef set dequeue and attempt write, otherwise wait for enqueue
var dequeue chan cid.Cid
if c != cid.Undef {
dequeue = q.de... | go | func (q *Queue) work() {
go func() {
var k datastore.Key = datastore.Key{}
var c cid.Cid = cid.Undef
for {
if c == cid.Undef {
k, c = q.nextEntry()
}
// If c != cid.Undef set dequeue and attempt write, otherwise wait for enqueue
var dequeue chan cid.Cid
if c != cid.Undef {
dequeue = q.de... | [
"func",
"(",
"q",
"*",
"Queue",
")",
"work",
"(",
")",
"{",
"go",
"func",
"(",
")",
"{",
"var",
"k",
"datastore",
".",
"Key",
"=",
"datastore",
".",
"Key",
"{",
"}",
"\n",
"var",
"c",
"cid",
".",
"Cid",
"=",
"cid",
".",
"Undef",
"\n\n",
"for"... | // Run dequeues and enqueues when available. | [
"Run",
"dequeues",
"and",
"enqueues",
"when",
"available",
"."
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/provider/queue.go#L102-L142 |
141,804 | ipsn/go-ipfs | provider/queue.go | getQueueHeadTail | func getQueueHeadTail(ctx context.Context, name string, datastore datastore.Datastore) (uint64, uint64, error) {
q := query.Query{}
results, err := datastore.Query(q)
if err != nil {
return 0, 0, err
}
var tail uint64
var head uint64 = math.MaxUint64
for entry := range results.Next() {
trimmed := strings.Tr... | go | func getQueueHeadTail(ctx context.Context, name string, datastore datastore.Datastore) (uint64, uint64, error) {
q := query.Query{}
results, err := datastore.Query(q)
if err != nil {
return 0, 0, err
}
var tail uint64
var head uint64 = math.MaxUint64
for entry := range results.Next() {
trimmed := strings.Tr... | [
"func",
"getQueueHeadTail",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"datastore",
"datastore",
".",
"Datastore",
")",
"(",
"uint64",
",",
"uint64",
",",
"error",
")",
"{",
"q",
":=",
"query",
".",
"Query",
"{",
"}",
"\n",
"res... | // crawl over the queue entries to find the head and tail | [
"crawl",
"over",
"the",
"queue",
"entries",
"to",
"find",
"the",
"head",
"and",
"tail"
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/provider/queue.go#L149-L181 |
141,805 | ipsn/go-ipfs | plugin/loader/loader.go | Start | func (loader *PluginLoader) Start(iface coreiface.CoreAPI) error {
for i, pl := range loader.plugins {
if pl, ok := pl.(plugin.PluginDaemon); ok {
err := pl.Start(iface)
if err != nil {
closePlugins(loader.plugins[i:])
return err
}
}
}
return nil
} | go | func (loader *PluginLoader) Start(iface coreiface.CoreAPI) error {
for i, pl := range loader.plugins {
if pl, ok := pl.(plugin.PluginDaemon); ok {
err := pl.Start(iface)
if err != nil {
closePlugins(loader.plugins[i:])
return err
}
}
}
return nil
} | [
"func",
"(",
"loader",
"*",
"PluginLoader",
")",
"Start",
"(",
"iface",
"coreiface",
".",
"CoreAPI",
")",
"error",
"{",
"for",
"i",
",",
"pl",
":=",
"range",
"loader",
".",
"plugins",
"{",
"if",
"pl",
",",
"ok",
":=",
"pl",
".",
"(",
"plugin",
".",... | // Start starts all long-running plugins. | [
"Start",
"starts",
"all",
"long",
"-",
"running",
"plugins",
"."
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/plugin/loader/loader.go#L113-L124 |
141,806 | ipsn/go-ipfs | core/core.go | HandlePeerFound | func (n *IpfsNode) HandlePeerFound(p pstore.PeerInfo) {
log.Warning("trying peer info: ", p)
ctx, cancel := context.WithTimeout(n.Context(), discoveryConnTimeout)
defer cancel()
if err := n.PeerHost.Connect(ctx, p); err != nil {
log.Warning("Failed to connect to peer found by discovery: ", err)
}
} | go | func (n *IpfsNode) HandlePeerFound(p pstore.PeerInfo) {
log.Warning("trying peer info: ", p)
ctx, cancel := context.WithTimeout(n.Context(), discoveryConnTimeout)
defer cancel()
if err := n.PeerHost.Connect(ctx, p); err != nil {
log.Warning("Failed to connect to peer found by discovery: ", err)
}
} | [
"func",
"(",
"n",
"*",
"IpfsNode",
")",
"HandlePeerFound",
"(",
"p",
"pstore",
".",
"PeerInfo",
")",
"{",
"log",
".",
"Warning",
"(",
"\"",
"\"",
",",
"p",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"n",
".",
"Contex... | // HandlePeerFound attempts to connect to peer from `PeerInfo`, if it fails
// logs a warning log. | [
"HandlePeerFound",
"attempts",
"to",
"connect",
"to",
"peer",
"from",
"PeerInfo",
"if",
"it",
"fails",
"logs",
"a",
"warning",
"log",
"."
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/core/core.go#L468-L475 |
141,807 | ipsn/go-ipfs | core/core.go | getCacheSize | func (n *IpfsNode) getCacheSize() (int, error) {
cfg, err := n.Repo.Config()
if err != nil {
return 0, err
}
cs := cfg.Ipns.ResolveCacheSize
if cs == 0 {
cs = DefaultIpnsCacheSize
}
if cs < 0 {
return 0, fmt.Errorf("cannot specify negative resolve cache size")
}
return cs, nil
} | go | func (n *IpfsNode) getCacheSize() (int, error) {
cfg, err := n.Repo.Config()
if err != nil {
return 0, err
}
cs := cfg.Ipns.ResolveCacheSize
if cs == 0 {
cs = DefaultIpnsCacheSize
}
if cs < 0 {
return 0, fmt.Errorf("cannot specify negative resolve cache size")
}
return cs, nil
} | [
"func",
"(",
"n",
"*",
"IpfsNode",
")",
"getCacheSize",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"n",
".",
"Repo",
".",
"Config",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}... | // getCacheSize returns cache life and cache size | [
"getCacheSize",
"returns",
"cache",
"life",
"and",
"cache",
"size"
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/core/core.go#L597-L611 |
141,808 | ipsn/go-ipfs | core/core.go | teardown | func (n *IpfsNode) teardown() error {
log.Debug("core is shutting down...")
// owned objects are closed in this teardown to ensure that they're closed
// regardless of which constructor was used to add them to the node.
var closers []io.Closer
// NOTE: The order that objects are added(closed) matters, if an objec... | go | func (n *IpfsNode) teardown() error {
log.Debug("core is shutting down...")
// owned objects are closed in this teardown to ensure that they're closed
// regardless of which constructor was used to add them to the node.
var closers []io.Closer
// NOTE: The order that objects are added(closed) matters, if an objec... | [
"func",
"(",
"n",
"*",
"IpfsNode",
")",
"teardown",
"(",
")",
"error",
"{",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"// owned objects are closed in this teardown to ensure that they're closed",
"// regardless of which constructor was used to add them to the node.",
... | // teardown closes owned children. If any errors occur, this function returns
// the first error. | [
"teardown",
"closes",
"owned",
"children",
".",
"If",
"any",
"errors",
"occur",
"this",
"function",
"returns",
"the",
"first",
"error",
"."
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/core/core.go#L668-L722 |
141,809 | ipsn/go-ipfs | core/core.go | Bootstrap | func (n *IpfsNode) Bootstrap(cfg BootstrapConfig) error {
// TODO what should return value be when in offlineMode?
if n.Routing == nil {
return nil
}
if n.Bootstrapper != nil {
n.Bootstrapper.Close() // stop previous bootstrap process.
}
// if the caller did not specify a bootstrap peer function, get the
/... | go | func (n *IpfsNode) Bootstrap(cfg BootstrapConfig) error {
// TODO what should return value be when in offlineMode?
if n.Routing == nil {
return nil
}
if n.Bootstrapper != nil {
n.Bootstrapper.Close() // stop previous bootstrap process.
}
// if the caller did not specify a bootstrap peer function, get the
/... | [
"func",
"(",
"n",
"*",
"IpfsNode",
")",
"Bootstrap",
"(",
"cfg",
"BootstrapConfig",
")",
"error",
"{",
"// TODO what should return value be when in offlineMode?",
"if",
"n",
".",
"Routing",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"n",
".",
... | // Bootstrap will set and call the IpfsNodes bootstrap function. | [
"Bootstrap",
"will",
"set",
"and",
"call",
"the",
"IpfsNodes",
"bootstrap",
"function",
"."
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/core/core.go#L725-L751 |
141,810 | ipsn/go-ipfs | core/core.go | GetKey | func (n *IpfsNode) GetKey(name string) (ic.PrivKey, error) {
if name == "self" {
if n.PrivateKey == nil {
return nil, fmt.Errorf("private key not available")
}
return n.PrivateKey, nil
} else {
return n.Repo.Keystore().Get(name)
}
} | go | func (n *IpfsNode) GetKey(name string) (ic.PrivKey, error) {
if name == "self" {
if n.PrivateKey == nil {
return nil, fmt.Errorf("private key not available")
}
return n.PrivateKey, nil
} else {
return n.Repo.Keystore().Get(name)
}
} | [
"func",
"(",
"n",
"*",
"IpfsNode",
")",
"GetKey",
"(",
"name",
"string",
")",
"(",
"ic",
".",
"PrivKey",
",",
"error",
")",
"{",
"if",
"name",
"==",
"\"",
"\"",
"{",
"if",
"n",
".",
"PrivateKey",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
"... | // GetKey will return a key from the Keystore with name `name`. | [
"GetKey",
"will",
"return",
"a",
"key",
"from",
"the",
"Keystore",
"with",
"name",
"name",
"."
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/core/core.go#L781-L790 |
141,811 | ipsn/go-ipfs | core/core.go | constructPeerHost | func constructPeerHost(ctx context.Context, id peer.ID, ps pstore.Peerstore, options ...libp2p.Option) (p2phost.Host, error) {
pkey := ps.PrivKey(id)
if pkey == nil {
return nil, fmt.Errorf("missing private key for node ID: %s", id.Pretty())
}
options = append([]libp2p.Option{libp2p.Identity(pkey), libp2p.Peersto... | go | func constructPeerHost(ctx context.Context, id peer.ID, ps pstore.Peerstore, options ...libp2p.Option) (p2phost.Host, error) {
pkey := ps.PrivKey(id)
if pkey == nil {
return nil, fmt.Errorf("missing private key for node ID: %s", id.Pretty())
}
options = append([]libp2p.Option{libp2p.Identity(pkey), libp2p.Peersto... | [
"func",
"constructPeerHost",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"peer",
".",
"ID",
",",
"ps",
"pstore",
".",
"Peerstore",
",",
"options",
"...",
"libp2p",
".",
"Option",
")",
"(",
"p2phost",
".",
"Host",
",",
"error",
")",
"{",
"pkey",
... | // isolates the complex initialization steps | [
"isolates",
"the",
"complex",
"initialization",
"steps"
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/core/core.go#L926-L933 |
141,812 | ipsn/go-ipfs | core/core.go | startListening | func startListening(host p2phost.Host, cfg *config.Config) error {
listenAddrs, err := listenAddresses(cfg)
if err != nil {
return err
}
// Actually start listening:
if err := host.Network().Listen(listenAddrs...); err != nil {
return err
}
// list out our addresses
addrs, err := host.Network().InterfaceL... | go | func startListening(host p2phost.Host, cfg *config.Config) error {
listenAddrs, err := listenAddresses(cfg)
if err != nil {
return err
}
// Actually start listening:
if err := host.Network().Listen(listenAddrs...); err != nil {
return err
}
// list out our addresses
addrs, err := host.Network().InterfaceL... | [
"func",
"startListening",
"(",
"host",
"p2phost",
".",
"Host",
",",
"cfg",
"*",
"config",
".",
"Config",
")",
"error",
"{",
"listenAddrs",
",",
"err",
":=",
"listenAddresses",
"(",
"cfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",... | // startListening on the network addresses | [
"startListening",
"on",
"the",
"network",
"addresses"
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/core/core.go#L954-L972 |
141,813 | ipsn/go-ipfs | core/coreapi/name.go | Resolve | func (api *NameAPI) Resolve(ctx context.Context, name string, opts ...caopts.NameResolveOption) (coreiface.Path, error) {
results, err := api.Search(ctx, name, opts...)
if err != nil {
return nil, err
}
err = coreiface.ErrResolveFailed
var p coreiface.Path
for res := range results {
p, err = res.Path, res.E... | go | func (api *NameAPI) Resolve(ctx context.Context, name string, opts ...caopts.NameResolveOption) (coreiface.Path, error) {
results, err := api.Search(ctx, name, opts...)
if err != nil {
return nil, err
}
err = coreiface.ErrResolveFailed
var p coreiface.Path
for res := range results {
p, err = res.Path, res.E... | [
"func",
"(",
"api",
"*",
"NameAPI",
")",
"Resolve",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"opts",
"...",
"caopts",
".",
"NameResolveOption",
")",
"(",
"coreiface",
".",
"Path",
",",
"error",
")",
"{",
"results",
",",
"err",... | // Resolve attempts to resolve the newest version of the specified name and
// returns its path. | [
"Resolve",
"attempts",
"to",
"resolve",
"the",
"newest",
"version",
"of",
"the",
"specified",
"name",
"and",
"returns",
"its",
"path",
"."
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/core/coreapi/name.go#L124-L141 |
141,814 | ipsn/go-ipfs | fuse/ipns/mount_unix.go | Mount | func Mount(ipfs *core.IpfsNode, ipnsmp, ipfsmp string) (mount.Mount, error) {
cfg, err := ipfs.Repo.Config()
if err != nil {
return nil, err
}
allow_other := cfg.Mounts.FuseAllowOther
fsys, err := NewFileSystem(ipfs, ipfs.PrivateKey, ipfsmp, ipnsmp)
if err != nil {
return nil, err
}
return mount.NewMount... | go | func Mount(ipfs *core.IpfsNode, ipnsmp, ipfsmp string) (mount.Mount, error) {
cfg, err := ipfs.Repo.Config()
if err != nil {
return nil, err
}
allow_other := cfg.Mounts.FuseAllowOther
fsys, err := NewFileSystem(ipfs, ipfs.PrivateKey, ipfsmp, ipnsmp)
if err != nil {
return nil, err
}
return mount.NewMount... | [
"func",
"Mount",
"(",
"ipfs",
"*",
"core",
".",
"IpfsNode",
",",
"ipnsmp",
",",
"ipfsmp",
"string",
")",
"(",
"mount",
".",
"Mount",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"ipfs",
".",
"Repo",
".",
"Config",
"(",
")",
"\n",
"if",
"err",... | // Mount mounts ipns at a given location, and returns a mount.Mount instance. | [
"Mount",
"mounts",
"ipns",
"at",
"a",
"given",
"location",
"and",
"returns",
"a",
"mount",
".",
"Mount",
"instance",
"."
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/fuse/ipns/mount_unix.go#L12-L26 |
141,815 | ipsn/go-ipfs | core/corehttp/mutex_profile.go | MutexFractionOption | func MutexFractionOption(path string) ServeOption {
return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
if ... | go | func MutexFractionOption(path string) ServeOption {
return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
if ... | [
"func",
"MutexFractionOption",
"(",
"path",
"string",
")",
"ServeOption",
"{",
"return",
"func",
"(",
"_",
"*",
"core",
".",
"IpfsNode",
",",
"_",
"net",
".",
"Listener",
",",
"mux",
"*",
"http",
".",
"ServeMux",
")",
"(",
"*",
"http",
".",
"ServeMux",... | // MutexFractionOption allows to set runtime.SetMutexProfileFraction via HTTP
// using POST request with parameter 'fraction'. | [
"MutexFractionOption",
"allows",
"to",
"set",
"runtime",
".",
"SetMutexProfileFraction",
"via",
"HTTP",
"using",
"POST",
"request",
"with",
"parameter",
"fraction",
"."
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/core/corehttp/mutex_profile.go#L14-L45 |
141,816 | ipsn/go-ipfs | core/coreapi/pin.go | Rm | func (api *PinAPI) Rm(ctx context.Context, p coreiface.Path, opts ...caopts.PinRmOption) error {
rp, err := api.core().ResolvePath(ctx, p)
if err != nil {
return err
}
settings, err := caopts.PinRmOptions(opts...)
if err != nil {
return err
}
if err = api.pinning.Unpin(ctx, rp.Cid(), settings.Recursive); e... | go | func (api *PinAPI) Rm(ctx context.Context, p coreiface.Path, opts ...caopts.PinRmOption) error {
rp, err := api.core().ResolvePath(ctx, p)
if err != nil {
return err
}
settings, err := caopts.PinRmOptions(opts...)
if err != nil {
return err
}
if err = api.pinning.Unpin(ctx, rp.Cid(), settings.Recursive); e... | [
"func",
"(",
"api",
"*",
"PinAPI",
")",
"Rm",
"(",
"ctx",
"context",
".",
"Context",
",",
"p",
"coreiface",
".",
"Path",
",",
"opts",
"...",
"caopts",
".",
"PinRmOption",
")",
"error",
"{",
"rp",
",",
"err",
":=",
"api",
".",
"core",
"(",
")",
".... | // Rm pin rm api | [
"Rm",
"pin",
"rm",
"api"
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/core/coreapi/pin.go#L58-L74 |
141,817 | ipsn/go-ipfs | core/coreunix/add.go | Finalize | func (adder *Adder) Finalize() (ipld.Node, error) {
mr, err := adder.mfsRoot()
if err != nil {
return nil, err
}
var root mfs.FSNode
rootdir := mr.GetDirectory()
root = rootdir
err = root.Flush()
if err != nil {
return nil, err
}
var name string
if !adder.Wrap {
children, err := rootdir.ListNames(add... | go | func (adder *Adder) Finalize() (ipld.Node, error) {
mr, err := adder.mfsRoot()
if err != nil {
return nil, err
}
var root mfs.FSNode
rootdir := mr.GetDirectory()
root = rootdir
err = root.Flush()
if err != nil {
return nil, err
}
var name string
if !adder.Wrap {
children, err := rootdir.ListNames(add... | [
"func",
"(",
"adder",
"*",
"Adder",
")",
"Finalize",
"(",
")",
"(",
"ipld",
".",
"Node",
",",
"error",
")",
"{",
"mr",
",",
"err",
":=",
"adder",
".",
"mfsRoot",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
... | // Finalize flushes the mfs root directory and returns the mfs root node. | [
"Finalize",
"flushes",
"the",
"mfs",
"root",
"directory",
"and",
"returns",
"the",
"mfs",
"root",
"node",
"."
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/core/coreunix/add.go#L196-L240 |
141,818 | ipsn/go-ipfs | core/commands/p2p.go | parseIpfsAddr | func parseIpfsAddr(addr string) ([]ipfsaddr.IPFSAddr, error) {
mutiladdr, err := ma.NewMultiaddr(addr)
if err != nil {
return nil, err
}
if _, err := mutiladdr.ValueForProtocol(ma.P_IPFS); err == nil {
iaddrs := make([]ipfsaddr.IPFSAddr, 1)
iaddrs[0], err = ipfsaddr.ParseMultiaddr(mutiladdr)
if err != nil {... | go | func parseIpfsAddr(addr string) ([]ipfsaddr.IPFSAddr, error) {
mutiladdr, err := ma.NewMultiaddr(addr)
if err != nil {
return nil, err
}
if _, err := mutiladdr.ValueForProtocol(ma.P_IPFS); err == nil {
iaddrs := make([]ipfsaddr.IPFSAddr, 1)
iaddrs[0], err = ipfsaddr.ParseMultiaddr(mutiladdr)
if err != nil {... | [
"func",
"parseIpfsAddr",
"(",
"addr",
"string",
")",
"(",
"[",
"]",
"ipfsaddr",
".",
"IPFSAddr",
",",
"error",
")",
"{",
"mutiladdr",
",",
"err",
":=",
"ma",
".",
"NewMultiaddr",
"(",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",... | // parseIpfsAddr is a function that takes in addr string and return ipfsAddrs | [
"parseIpfsAddr",
"is",
"a",
"function",
"that",
"takes",
"in",
"addr",
"string",
"and",
"return",
"ipfsAddrs"
] | 8b9b72514244155bc38ab21eac7f4d950ea97c28 | https://github.com/ipsn/go-ipfs/blob/8b9b72514244155bc38ab21eac7f4d950ea97c28/core/commands/p2p.go#L137-L165 |
141,819 | xdg-go/scram | server_conv.go | Step | func (sc *ServerConversation) Step(challenge string) (response string, err error) {
switch sc.state {
case serverFirst:
sc.state = serverFinal
response, err = sc.firstMsg(challenge)
case serverFinal:
sc.state = serverDone
response, err = sc.finalMsg(challenge)
default:
response, err = "", errors.New("Conv... | go | func (sc *ServerConversation) Step(challenge string) (response string, err error) {
switch sc.state {
case serverFirst:
sc.state = serverFinal
response, err = sc.firstMsg(challenge)
case serverFinal:
sc.state = serverDone
response, err = sc.finalMsg(challenge)
default:
response, err = "", errors.New("Conv... | [
"func",
"(",
"sc",
"*",
"ServerConversation",
")",
"Step",
"(",
"challenge",
"string",
")",
"(",
"response",
"string",
",",
"err",
"error",
")",
"{",
"switch",
"sc",
".",
"state",
"{",
"case",
"serverFirst",
":",
"sc",
".",
"state",
"=",
"serverFinal",
... | // Step takes a string provided from a client and attempts to move the
// authentication conversation forward. It returns a string to be sent to the
// client or an error if the client message is invalid. Calling Step after a
// conversation completes is also an error. | [
"Step",
"takes",
"a",
"string",
"provided",
"from",
"a",
"client",
"and",
"attempts",
"to",
"move",
"the",
"authentication",
"conversation",
"forward",
".",
"It",
"returns",
"a",
"string",
"to",
"be",
"sent",
"to",
"the",
"client",
"or",
"an",
"error",
"if... | 7eeb5667e42c09cb51bf7b7c28aea8c56767da90 | https://github.com/xdg-go/scram/blob/7eeb5667e42c09cb51bf7b7c28aea8c56767da90/server_conv.go#L46-L58 |
141,820 | xdg-go/scram | server_conv.go | finalMsg | func (sc *ServerConversation) finalMsg(c2 string) (string, error) {
msg, err := parseClientFinal(c2)
if err != nil {
return "", err
}
// Check channel binding matches what we expect; in this case, we expect
// just the gs2 header we received as we don't support channel binding
// with a data payload. If we ad... | go | func (sc *ServerConversation) finalMsg(c2 string) (string, error) {
msg, err := parseClientFinal(c2)
if err != nil {
return "", err
}
// Check channel binding matches what we expect; in this case, we expect
// just the gs2 header we received as we don't support channel binding
// with a data payload. If we ad... | [
"func",
"(",
"sc",
"*",
"ServerConversation",
")",
"finalMsg",
"(",
"c2",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"msg",
",",
"err",
":=",
"parseClientFinal",
"(",
"c2",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
... | // For errors, returns server error message as well as non-nil error. Callers
// can choose whether to send server error or not. | [
"For",
"errors",
"returns",
"server",
"error",
"message",
"as",
"well",
"as",
"non",
"-",
"nil",
"error",
".",
"Callers",
"can",
"choose",
"whether",
"to",
"send",
"server",
"error",
"or",
"not",
"."
] | 7eeb5667e42c09cb51bf7b7c28aea8c56767da90 | https://github.com/xdg-go/scram/blob/7eeb5667e42c09cb51bf7b7c28aea8c56767da90/server_conv.go#L114-L151 |
141,821 | xdg-go/scram | server.go | NewConversation | func (s *Server) NewConversation() *ServerConversation {
s.RLock()
defer s.RUnlock()
return &ServerConversation{
nonceGen: s.nonceGen,
hashGen: s.hashGen,
credentialCB: s.credentialCB,
}
} | go | func (s *Server) NewConversation() *ServerConversation {
s.RLock()
defer s.RUnlock()
return &ServerConversation{
nonceGen: s.nonceGen,
hashGen: s.hashGen,
credentialCB: s.credentialCB,
}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"NewConversation",
"(",
")",
"*",
"ServerConversation",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"&",
"ServerConversation",
"{",
"nonceGen",
":",
"s",
".",
"... | // NewConversation constructs a server-side authentication conversation.
// Conversations cannot be reused, so this must be called for each new
// authentication attempt. | [
"NewConversation",
"constructs",
"a",
"server",
"-",
"side",
"authentication",
"conversation",
".",
"Conversations",
"cannot",
"be",
"reused",
"so",
"this",
"must",
"be",
"called",
"for",
"each",
"new",
"authentication",
"attempt",
"."
] | 7eeb5667e42c09cb51bf7b7c28aea8c56767da90 | https://github.com/xdg-go/scram/blob/7eeb5667e42c09cb51bf7b7c28aea8c56767da90/server.go#L42-L50 |
141,822 | xdg-go/scram | scram.go | NewClient | func (f HashGeneratorFcn) NewClient(username, password, authzID string) (*Client, error) {
var userprep, passprep, authprep string
var err error
if userprep, err = stringprep.SASLprep.Prepare(username); err != nil {
return nil, fmt.Errorf("Error SASLprepping username '%s': %v", username, err)
}
if passprep, err... | go | func (f HashGeneratorFcn) NewClient(username, password, authzID string) (*Client, error) {
var userprep, passprep, authprep string
var err error
if userprep, err = stringprep.SASLprep.Prepare(username); err != nil {
return nil, fmt.Errorf("Error SASLprepping username '%s': %v", username, err)
}
if passprep, err... | [
"func",
"(",
"f",
"HashGeneratorFcn",
")",
"NewClient",
"(",
"username",
",",
"password",
",",
"authzID",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"var",
"userprep",
",",
"passprep",
",",
"authprep",
"string",
"\n",
"var",
"err",
"error... | // NewClient constructs a SCRAM client component based on a given hash.Hash
// factory receiver. This constructor will normalize the username, password
// and authzID via the SASLprep algorithm, as recommended by RFC-5802. If
// SASLprep fails, the method returns an error. | [
"NewClient",
"constructs",
"a",
"SCRAM",
"client",
"component",
"based",
"on",
"a",
"given",
"hash",
".",
"Hash",
"factory",
"receiver",
".",
"This",
"constructor",
"will",
"normalize",
"the",
"username",
"password",
"and",
"authzID",
"via",
"the",
"SASLprep",
... | 7eeb5667e42c09cb51bf7b7c28aea8c56767da90 | https://github.com/xdg-go/scram/blob/7eeb5667e42c09cb51bf7b7c28aea8c56767da90/scram.go#L36-L51 |
141,823 | xdg-go/scram | scram.go | NewClientUnprepped | func (f HashGeneratorFcn) NewClientUnprepped(username, password, authzID string) (*Client, error) {
return newClient(username, password, authzID, f), nil
} | go | func (f HashGeneratorFcn) NewClientUnprepped(username, password, authzID string) (*Client, error) {
return newClient(username, password, authzID, f), nil
} | [
"func",
"(",
"f",
"HashGeneratorFcn",
")",
"NewClientUnprepped",
"(",
"username",
",",
"password",
",",
"authzID",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"return",
"newClient",
"(",
"username",
",",
"password",
",",
"authzID",
",",
"f",... | // NewClientUnprepped acts like NewClient, except none of the arguments will
// be normalized via SASLprep. This is not generally recommended, but is
// provided for users that may have custom normalization needs. | [
"NewClientUnprepped",
"acts",
"like",
"NewClient",
"except",
"none",
"of",
"the",
"arguments",
"will",
"be",
"normalized",
"via",
"SASLprep",
".",
"This",
"is",
"not",
"generally",
"recommended",
"but",
"is",
"provided",
"for",
"users",
"that",
"may",
"have",
... | 7eeb5667e42c09cb51bf7b7c28aea8c56767da90 | https://github.com/xdg-go/scram/blob/7eeb5667e42c09cb51bf7b7c28aea8c56767da90/scram.go#L56-L58 |
141,824 | xdg-go/scram | scram.go | NewServer | func (f HashGeneratorFcn) NewServer(cl CredentialLookup) (*Server, error) {
return newServer(cl, f)
} | go | func (f HashGeneratorFcn) NewServer(cl CredentialLookup) (*Server, error) {
return newServer(cl, f)
} | [
"func",
"(",
"f",
"HashGeneratorFcn",
")",
"NewServer",
"(",
"cl",
"CredentialLookup",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"return",
"newServer",
"(",
"cl",
",",
"f",
")",
"\n",
"}"
] | // NewServer constructs a SCRAM server component based on a given hash.Hash
// factory receiver. To be maximally generic, it uses dependency injection to
// handle credential lookup, which is the process of turning a username string
// into a struct with stored credentials for authentication. | [
"NewServer",
"constructs",
"a",
"SCRAM",
"server",
"component",
"based",
"on",
"a",
"given",
"hash",
".",
"Hash",
"factory",
"receiver",
".",
"To",
"be",
"maximally",
"generic",
"it",
"uses",
"dependency",
"injection",
"to",
"handle",
"credential",
"lookup",
"... | 7eeb5667e42c09cb51bf7b7c28aea8c56767da90 | https://github.com/xdg-go/scram/blob/7eeb5667e42c09cb51bf7b7c28aea8c56767da90/scram.go#L64-L66 |
141,825 | xdg-go/scram | client.go | WithMinIterations | func (c *Client) WithMinIterations(n int) *Client {
c.Lock()
defer c.Unlock()
c.minIters = n
return c
} | go | func (c *Client) WithMinIterations(n int) *Client {
c.Lock()
defer c.Unlock()
c.minIters = n
return c
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"WithMinIterations",
"(",
"n",
"int",
")",
"*",
"Client",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"minIters",
"=",
"n",
"\n",
"return",
"c",
"\n",
"}"
] | // WithMinIterations changes minimum required PBKDF2 iteration count. | [
"WithMinIterations",
"changes",
"minimum",
"required",
"PBKDF2",
"iteration",
"count",
"."
] | 7eeb5667e42c09cb51bf7b7c28aea8c56767da90 | https://github.com/xdg-go/scram/blob/7eeb5667e42c09cb51bf7b7c28aea8c56767da90/client.go#L53-L58 |
141,826 | xdg-go/scram | client.go | NewConversation | func (c *Client) NewConversation() *ClientConversation {
c.RLock()
defer c.RUnlock()
return &ClientConversation{
client: c,
nonceGen: c.nonceGen,
hashGen: c.hashGen,
minIters: c.minIters,
}
} | go | func (c *Client) NewConversation() *ClientConversation {
c.RLock()
defer c.RUnlock()
return &ClientConversation{
client: c,
nonceGen: c.nonceGen,
hashGen: c.hashGen,
minIters: c.minIters,
}
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"NewConversation",
"(",
")",
"*",
"ClientConversation",
"{",
"c",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"&",
"ClientConversation",
"{",
"client",
":",
"c",
",",
"no... | // NewConversation constructs a client-side authentication conversation.
// Conversations cannot be reused, so this must be called for each new
// authentication attempt. | [
"NewConversation",
"constructs",
"a",
"client",
"-",
"side",
"authentication",
"conversation",
".",
"Conversations",
"cannot",
"be",
"reused",
"so",
"this",
"must",
"be",
"called",
"for",
"each",
"new",
"authentication",
"attempt",
"."
] | 7eeb5667e42c09cb51bf7b7c28aea8c56767da90 | https://github.com/xdg-go/scram/blob/7eeb5667e42c09cb51bf7b7c28aea8c56767da90/client.go#L73-L82 |
141,827 | xdg-go/scram | client.go | GetStoredCredentials | func (c *Client) GetStoredCredentials(kf KeyFactors) StoredCredentials {
dk := c.getDerivedKeys(kf)
return StoredCredentials{
KeyFactors: kf,
StoredKey: dk.StoredKey,
ServerKey: dk.ServerKey,
}
} | go | func (c *Client) GetStoredCredentials(kf KeyFactors) StoredCredentials {
dk := c.getDerivedKeys(kf)
return StoredCredentials{
KeyFactors: kf,
StoredKey: dk.StoredKey,
ServerKey: dk.ServerKey,
}
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetStoredCredentials",
"(",
"kf",
"KeyFactors",
")",
"StoredCredentials",
"{",
"dk",
":=",
"c",
".",
"getDerivedKeys",
"(",
"kf",
")",
"\n",
"return",
"StoredCredentials",
"{",
"KeyFactors",
":",
"kf",
",",
"StoredKey",... | // GetStoredCredentials takes a salt and iteration count structure and
// provides the values that must be stored by a server to authentication a
// user. These values are what the Server credential lookup function must
// return for a given username. | [
"GetStoredCredentials",
"takes",
"a",
"salt",
"and",
"iteration",
"count",
"structure",
"and",
"provides",
"the",
"values",
"that",
"must",
"be",
"stored",
"by",
"a",
"server",
"to",
"authentication",
"a",
"user",
".",
"These",
"values",
"are",
"what",
"the",
... | 7eeb5667e42c09cb51bf7b7c28aea8c56767da90 | https://github.com/xdg-go/scram/blob/7eeb5667e42c09cb51bf7b7c28aea8c56767da90/client.go#L97-L104 |
141,828 | qor/exchange | backends/csv/csv.go | New | func New(value interface{}, config ...Config) *CSV {
csv := &CSV{}
if f, ok := value.(string); ok {
csv.filename = f
} else {
if r, ok := value.(io.ReadCloser); ok {
csv.reader = r
}
if w, ok := value.(io.WriteCloser); ok {
csv.writer = w
}
}
for _, cfg := range config {
csv.config = cfg
}
r... | go | func New(value interface{}, config ...Config) *CSV {
csv := &CSV{}
if f, ok := value.(string); ok {
csv.filename = f
} else {
if r, ok := value.(io.ReadCloser); ok {
csv.reader = r
}
if w, ok := value.(io.WriteCloser); ok {
csv.writer = w
}
}
for _, cfg := range config {
csv.config = cfg
}
r... | [
"func",
"New",
"(",
"value",
"interface",
"{",
"}",
",",
"config",
"...",
"Config",
")",
"*",
"CSV",
"{",
"csv",
":=",
"&",
"CSV",
"{",
"}",
"\n\n",
"if",
"f",
",",
"ok",
":=",
"value",
".",
"(",
"string",
")",
";",
"ok",
"{",
"csv",
".",
"fi... | // New initialize CSV backend, config is option, the last one will be used if there are more than one configs | [
"New",
"initialize",
"CSV",
"backend",
"config",
"is",
"option",
"the",
"last",
"one",
"will",
"be",
"used",
"if",
"there",
"are",
"more",
"than",
"one",
"configs"
] | 59574e5febf08e8844bc4391dd942d4ea8a8f4e9 | https://github.com/qor/exchange/blob/59574e5febf08e8844bc4391dd942d4ea8a8f4e9/backends/csv/csv.go#L11-L30 |
141,829 | qor/exchange | backends/excel/reader.go | Header | func (rows Rows) Header() (results []string) {
if rows.total > 0 {
if rows.Resource.Config.WithoutHeader {
for i := 0; i <= len(rows.records[0]); i++ {
results = append(results, strconv.Itoa(i))
}
} else {
return rows.records[0]
}
}
return
} | go | func (rows Rows) Header() (results []string) {
if rows.total > 0 {
if rows.Resource.Config.WithoutHeader {
for i := 0; i <= len(rows.records[0]); i++ {
results = append(results, strconv.Itoa(i))
}
} else {
return rows.records[0]
}
}
return
} | [
"func",
"(",
"rows",
"Rows",
")",
"Header",
"(",
")",
"(",
"results",
"[",
"]",
"string",
")",
"{",
"if",
"rows",
".",
"total",
">",
"0",
"{",
"if",
"rows",
".",
"Resource",
".",
"Config",
".",
"WithoutHeader",
"{",
"for",
"i",
":=",
"0",
";",
... | // Header CSV header column | [
"Header",
"CSV",
"header",
"column"
] | 59574e5febf08e8844bc4391dd942d4ea8a8f4e9 | https://github.com/qor/exchange/blob/59574e5febf08e8844bc4391dd942d4ea8a8f4e9/backends/excel/reader.go#L67-L78 |
141,830 | qor/exchange | backends/excel/reader.go | Next | func (rows *Rows) Next() bool {
if rows.total >= rows.current+1 {
rows.current++
return true
}
return false
} | go | func (rows *Rows) Next() bool {
if rows.total >= rows.current+1 {
rows.current++
return true
}
return false
} | [
"func",
"(",
"rows",
"*",
"Rows",
")",
"Next",
"(",
")",
"bool",
"{",
"if",
"rows",
".",
"total",
">=",
"rows",
".",
"current",
"+",
"1",
"{",
"rows",
".",
"current",
"++",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // Next read next rows from CSV | [
"Next",
"read",
"next",
"rows",
"from",
"CSV"
] | 59574e5febf08e8844bc4391dd942d4ea8a8f4e9 | https://github.com/qor/exchange/blob/59574e5febf08e8844bc4391dd942d4ea8a8f4e9/backends/excel/reader.go#L86-L92 |
141,831 | qor/exchange | backends/excel/reader.go | ReadRow | func (rows Rows) ReadRow() (*resource.MetaValues, error) {
var metaValues resource.MetaValues
columns := rows.Header()
for index, column := range columns {
metaValue := resource.MetaValue{
Name: column,
Value: rows.records[rows.current][index],
}
if meta := rows.Resource.GetMeta(column); meta != nil {
... | go | func (rows Rows) ReadRow() (*resource.MetaValues, error) {
var metaValues resource.MetaValues
columns := rows.Header()
for index, column := range columns {
metaValue := resource.MetaValue{
Name: column,
Value: rows.records[rows.current][index],
}
if meta := rows.Resource.GetMeta(column); meta != nil {
... | [
"func",
"(",
"rows",
"Rows",
")",
"ReadRow",
"(",
")",
"(",
"*",
"resource",
".",
"MetaValues",
",",
"error",
")",
"{",
"var",
"metaValues",
"resource",
".",
"MetaValues",
"\n",
"columns",
":=",
"rows",
".",
"Header",
"(",
")",
"\n\n",
"for",
"index",
... | // ReadRow read row from CSV | [
"ReadRow",
"read",
"row",
"from",
"CSV"
] | 59574e5febf08e8844bc4391dd942d4ea8a8f4e9 | https://github.com/qor/exchange/blob/59574e5febf08e8844bc4391dd942d4ea8a8f4e9/backends/excel/reader.go#L95-L112 |
141,832 | qor/exchange | backends/excel/excel.go | New | func New(value interface{}, config ...*Config) *Excel {
excel := &Excel{}
if f, ok := value.(string); ok {
excel.filename = f
} else {
if r, ok := value.(io.ReadCloser); ok {
excel.reader = r
}
if w, ok := value.(io.WriteCloser); ok {
excel.writer = w
}
}
for _, cfg := range config {
excel.con... | go | func New(value interface{}, config ...*Config) *Excel {
excel := &Excel{}
if f, ok := value.(string); ok {
excel.filename = f
} else {
if r, ok := value.(io.ReadCloser); ok {
excel.reader = r
}
if w, ok := value.(io.WriteCloser); ok {
excel.writer = w
}
}
for _, cfg := range config {
excel.con... | [
"func",
"New",
"(",
"value",
"interface",
"{",
"}",
",",
"config",
"...",
"*",
"Config",
")",
"*",
"Excel",
"{",
"excel",
":=",
"&",
"Excel",
"{",
"}",
"\n\n",
"if",
"f",
",",
"ok",
":=",
"value",
".",
"(",
"string",
")",
";",
"ok",
"{",
"excel... | // New new excel backend | [
"New",
"new",
"excel",
"backend"
] | 59574e5febf08e8844bc4391dd942d4ea8a8f4e9 | https://github.com/qor/exchange/blob/59574e5febf08e8844bc4391dd942d4ea8a8f4e9/backends/excel/excel.go#L13-L37 |
141,833 | qor/exchange | backends/excel/writer.go | Flush | func (writer *Writer) Flush() error {
if writer.Excel.writer != nil {
defer writer.Excel.writer.Close()
return writer.Writer.Write(writer.Excel.writer)
}
return writer.Writer.SaveAs(writer.Excel.filename)
} | go | func (writer *Writer) Flush() error {
if writer.Excel.writer != nil {
defer writer.Excel.writer.Close()
return writer.Writer.Write(writer.Excel.writer)
}
return writer.Writer.SaveAs(writer.Excel.filename)
} | [
"func",
"(",
"writer",
"*",
"Writer",
")",
"Flush",
"(",
")",
"error",
"{",
"if",
"writer",
".",
"Excel",
".",
"writer",
"!=",
"nil",
"{",
"defer",
"writer",
".",
"Excel",
".",
"writer",
".",
"Close",
"(",
")",
"\n",
"return",
"writer",
".",
"Write... | // Flush flush all changes | [
"Flush",
"flush",
"all",
"changes"
] | 59574e5febf08e8844bc4391dd942d4ea8a8f4e9 | https://github.com/qor/exchange/blob/59574e5febf08e8844bc4391dd942d4ea8a8f4e9/backends/excel/writer.go#L100-L107 |
141,834 | qor/exchange | exchange.go | NewResource | func NewResource(value interface{}, config ...Config) *Resource {
res := Resource{Resource: resource.New(value)}
if len(config) > 0 {
res.Config = &config[0]
} else {
res.Config = &Config{}
}
res.Permission = res.Config.Permission
if res.Config.PrimaryField != "" {
if err := res.SetPrimaryFields(res.Config... | go | func NewResource(value interface{}, config ...Config) *Resource {
res := Resource{Resource: resource.New(value)}
if len(config) > 0 {
res.Config = &config[0]
} else {
res.Config = &Config{}
}
res.Permission = res.Config.Permission
if res.Config.PrimaryField != "" {
if err := res.SetPrimaryFields(res.Config... | [
"func",
"NewResource",
"(",
"value",
"interface",
"{",
"}",
",",
"config",
"...",
"Config",
")",
"*",
"Resource",
"{",
"res",
":=",
"Resource",
"{",
"Resource",
":",
"resource",
".",
"New",
"(",
"value",
")",
"}",
"\n",
"if",
"len",
"(",
"config",
")... | // NewResource new exchange Resource | [
"NewResource",
"new",
"exchange",
"Resource"
] | 59574e5febf08e8844bc4391dd942d4ea8a8f4e9 | https://github.com/qor/exchange/blob/59574e5febf08e8844bc4391dd942d4ea8a8f4e9/exchange.go#L33-L48 |
141,835 | qor/exchange | exchange.go | GetMeta | func (res *Resource) GetMeta(name string) *Meta {
for _, meta := range res.Metas {
if meta.Header == name {
return meta
}
}
return nil
} | go | func (res *Resource) GetMeta(name string) *Meta {
for _, meta := range res.Metas {
if meta.Header == name {
return meta
}
}
return nil
} | [
"func",
"(",
"res",
"*",
"Resource",
")",
"GetMeta",
"(",
"name",
"string",
")",
"*",
"Meta",
"{",
"for",
"_",
",",
"meta",
":=",
"range",
"res",
".",
"Metas",
"{",
"if",
"meta",
".",
"Header",
"==",
"name",
"{",
"return",
"meta",
"\n",
"}",
"\n"... | // GetMeta get defined Meta from exchange Resource | [
"GetMeta",
"get",
"defined",
"Meta",
"from",
"exchange",
"Resource"
] | 59574e5febf08e8844bc4391dd942d4ea8a8f4e9 | https://github.com/qor/exchange/blob/59574e5febf08e8844bc4391dd942d4ea8a8f4e9/exchange.go#L63-L70 |
141,836 | qor/exchange | exchange.go | GetMetas | func (res *Resource) GetMetas([]string) []resource.Metaor {
metas := []resource.Metaor{}
for _, meta := range res.Metas {
metas = append(metas, meta)
}
return metas
} | go | func (res *Resource) GetMetas([]string) []resource.Metaor {
metas := []resource.Metaor{}
for _, meta := range res.Metas {
metas = append(metas, meta)
}
return metas
} | [
"func",
"(",
"res",
"*",
"Resource",
")",
"GetMetas",
"(",
"[",
"]",
"string",
")",
"[",
"]",
"resource",
".",
"Metaor",
"{",
"metas",
":=",
"[",
"]",
"resource",
".",
"Metaor",
"{",
"}",
"\n",
"for",
"_",
",",
"meta",
":=",
"range",
"res",
".",
... | // GetMetas get all defined Metas from exchange Resource | [
"GetMetas",
"get",
"all",
"defined",
"Metas",
"from",
"exchange",
"Resource"
] | 59574e5febf08e8844bc4391dd942d4ea8a8f4e9 | https://github.com/qor/exchange/blob/59574e5febf08e8844bc4391dd942d4ea8a8f4e9/exchange.go#L73-L79 |
141,837 | mattbaird/gochimp | mandrill_messages.go | MessageSendRaw | func (a *MandrillAPI) MessageSendRaw(rawMessage string, to []string, from Recipient, async bool) ([]SendResponse, error) {
var response []SendResponse
if rawMessage == "" {
return response, errors.New("rawMessage cannot be blank")
}
if len(to) <= 0 {
return response, errors.New("You need at least one recipient ... | go | func (a *MandrillAPI) MessageSendRaw(rawMessage string, to []string, from Recipient, async bool) ([]SendResponse, error) {
var response []SendResponse
if rawMessage == "" {
return response, errors.New("rawMessage cannot be blank")
}
if len(to) <= 0 {
return response, errors.New("You need at least one recipient ... | [
"func",
"(",
"a",
"*",
"MandrillAPI",
")",
"MessageSendRaw",
"(",
"rawMessage",
"string",
",",
"to",
"[",
"]",
"string",
",",
"from",
"Recipient",
",",
"async",
"bool",
")",
"(",
"[",
"]",
"SendResponse",
",",
"error",
")",
"{",
"var",
"response",
"[",... | // Can return oneof Invalid_Key, ValidationError or GeneralError | [
"Can",
"return",
"oneof",
"Invalid_Key",
"ValidationError",
"or",
"GeneralError"
] | a267553896d1cbd0ccfc259ad5442e62bdc3d30d | https://github.com/mattbaird/gochimp/blob/a267553896d1cbd0ccfc259ad5442e62bdc3d30d/mandrill_messages.go#L109-L126 |
141,838 | docker/go | canonical/json/encode.go | newTypeEncoder | func (e *encodeState) newTypeEncoder(t reflect.Type, allowAddr bool) encoderFunc {
if t.Implements(marshalerType) {
return marshalerEncoder
}
if t.Kind() != reflect.Ptr && allowAddr {
if reflect.PtrTo(t).Implements(marshalerType) {
return newCondAddrEncoder(addrMarshalerEncoder, e.newTypeEncoder(t, false))
... | go | func (e *encodeState) newTypeEncoder(t reflect.Type, allowAddr bool) encoderFunc {
if t.Implements(marshalerType) {
return marshalerEncoder
}
if t.Kind() != reflect.Ptr && allowAddr {
if reflect.PtrTo(t).Implements(marshalerType) {
return newCondAddrEncoder(addrMarshalerEncoder, e.newTypeEncoder(t, false))
... | [
"func",
"(",
"e",
"*",
"encodeState",
")",
"newTypeEncoder",
"(",
"t",
"reflect",
".",
"Type",
",",
"allowAddr",
"bool",
")",
"encoderFunc",
"{",
"if",
"t",
".",
"Implements",
"(",
"marshalerType",
")",
"{",
"return",
"marshalerEncoder",
"\n",
"}",
"\n",
... | // newTypeEncoder constructs an encoderFunc for a type.
// The returned encoder only checks CanAddr when allowAddr is true. | [
"newTypeEncoder",
"constructs",
"an",
"encoderFunc",
"for",
"a",
"type",
".",
"The",
"returned",
"encoder",
"only",
"checks",
"CanAddr",
"when",
"allowAddr",
"is",
"true",
"."
] | d30aec9fd63c35133f8f79c3412ad91a3b08be06 | https://github.com/docker/go/blob/d30aec9fd63c35133f8f79c3412ad91a3b08be06/canonical/json/encode.go#L371-L418 |
141,839 | clbanning/x2j | xml.go | cast | func cast(s string, r bool) interface{} {
if r {
// handle nan and inf
if !castNanInf {
switch strings.ToLower(s) {
case "nan", "inf", "-inf":
return interface{}(s)
}
}
// handle numeric strings ahead of boolean
if f, err := strconv.ParseFloat(s, 64); err == nil {
return interface{}(f)
}
... | go | func cast(s string, r bool) interface{} {
if r {
// handle nan and inf
if !castNanInf {
switch strings.ToLower(s) {
case "nan", "inf", "-inf":
return interface{}(s)
}
}
// handle numeric strings ahead of boolean
if f, err := strconv.ParseFloat(s, 64); err == nil {
return interface{}(f)
}
... | [
"func",
"cast",
"(",
"s",
"string",
",",
"r",
"bool",
")",
"interface",
"{",
"}",
"{",
"if",
"r",
"{",
"// handle nan and inf",
"if",
"!",
"castNanInf",
"{",
"switch",
"strings",
".",
"ToLower",
"(",
"s",
")",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\... | // cast - try to cast string values to bool or float64 | [
"cast",
"-",
"try",
"to",
"cast",
"string",
"values",
"to",
"bool",
"or",
"float64"
] | 5e605d46809c441eb0e565867b63f7d80c9140c2 | https://github.com/clbanning/x2j/blob/5e605d46809c441eb0e565867b63f7d80c9140c2/xml.go#L146-L169 |
141,840 | clbanning/x2j | x2j.go | DocToJson | func DocToJson(doc string, recast ...bool) (string, error) {
var r bool
if len(recast) == 1 {
r = recast[0]
}
m, merr := xmlToMap([]byte(doc), r)
if m == nil || merr != nil {
return "", merr
}
b, berr := json.Marshal(m)
if berr != nil {
return "", berr
}
// NOTE: don't have to worry about safe JSON ma... | go | func DocToJson(doc string, recast ...bool) (string, error) {
var r bool
if len(recast) == 1 {
r = recast[0]
}
m, merr := xmlToMap([]byte(doc), r)
if m == nil || merr != nil {
return "", merr
}
b, berr := json.Marshal(m)
if berr != nil {
return "", berr
}
// NOTE: don't have to worry about safe JSON ma... | [
"func",
"DocToJson",
"(",
"doc",
"string",
",",
"recast",
"...",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"r",
"bool",
"\n",
"if",
"len",
"(",
"recast",
")",
"==",
"1",
"{",
"r",
"=",
"recast",
"[",
"0",
"]",
"\n",
"}",
"\n",
... | // DocToJson - return an XML doc as a JSON string.
// If the optional argument 'recast' is 'true', then values will be converted to boolean or float64 if possible. | [
"DocToJson",
"-",
"return",
"an",
"XML",
"doc",
"as",
"a",
"JSON",
"string",
".",
"If",
"the",
"optional",
"argument",
"recast",
"is",
"true",
"then",
"values",
"will",
"be",
"converted",
"to",
"boolean",
"or",
"float64",
"if",
"possible",
"."
] | 5e605d46809c441eb0e565867b63f7d80c9140c2 | https://github.com/clbanning/x2j/blob/5e605d46809c441eb0e565867b63f7d80c9140c2/x2j.go#L102-L119 |
141,841 | clbanning/x2j | x2j.go | DocToTree | func DocToTree(doc string) (*Node, error) {
// xml.Decoder doesn't properly handle whitespace in some doc
// see songTextString.xml test case ...
reg, _ := regexp.Compile("[ \t\n\r]*<")
doc = reg.ReplaceAllString(doc, "<")
b := bytes.NewBufferString(doc)
p := xml.NewDecoder(b)
p.CharsetReader = X2jCharsetReader... | go | func DocToTree(doc string) (*Node, error) {
// xml.Decoder doesn't properly handle whitespace in some doc
// see songTextString.xml test case ...
reg, _ := regexp.Compile("[ \t\n\r]*<")
doc = reg.ReplaceAllString(doc, "<")
b := bytes.NewBufferString(doc)
p := xml.NewDecoder(b)
p.CharsetReader = X2jCharsetReader... | [
"func",
"DocToTree",
"(",
"doc",
"string",
")",
"(",
"*",
"Node",
",",
"error",
")",
"{",
"// xml.Decoder doesn't properly handle whitespace in some doc",
"// see songTextString.xml test case ...",
"reg",
",",
"_",
":=",
"regexp",
".",
"Compile",
"(",
"\"",
"\\t",
"... | // DocToTree - convert an XML doc into a tree of nodes. | [
"DocToTree",
"-",
"convert",
"an",
"XML",
"doc",
"into",
"a",
"tree",
"of",
"nodes",
"."
] | 5e605d46809c441eb0e565867b63f7d80c9140c2 | https://github.com/clbanning/x2j/blob/5e605d46809c441eb0e565867b63f7d80c9140c2/x2j.go#L156-L171 |
141,842 | clbanning/x2j | x2j.go | recast | func recast(s string, r bool) interface{} {
if r {
// handle numeric strings ahead of boolean
if f, err := strconv.ParseFloat(s, 64); err == nil {
return interface{}(f)
}
// ParseBool treats "1"==true & "0"==false
if b, err := strconv.ParseBool(s); err == nil {
return interface{}(b)
}
}
return inte... | go | func recast(s string, r bool) interface{} {
if r {
// handle numeric strings ahead of boolean
if f, err := strconv.ParseFloat(s, 64); err == nil {
return interface{}(f)
}
// ParseBool treats "1"==true & "0"==false
if b, err := strconv.ParseBool(s); err == nil {
return interface{}(b)
}
}
return inte... | [
"func",
"recast",
"(",
"s",
"string",
",",
"r",
"bool",
")",
"interface",
"{",
"}",
"{",
"if",
"r",
"{",
"// handle numeric strings ahead of boolean",
"if",
"f",
",",
"err",
":=",
"strconv",
".",
"ParseFloat",
"(",
"s",
",",
"64",
")",
";",
"err",
"=="... | // recast - try to cast string values to bool or float64 | [
"recast",
"-",
"try",
"to",
"cast",
"string",
"values",
"to",
"bool",
"or",
"float64"
] | 5e605d46809c441eb0e565867b63f7d80c9140c2 | https://github.com/clbanning/x2j/blob/5e605d46809c441eb0e565867b63f7d80c9140c2/x2j.go#L320-L332 |
141,843 | clbanning/x2j | x2j.go | ValuesForKey | func ValuesForKey(m map[string]interface{}, key string) []interface{} {
ret := make([]interface{}, 0)
hasKey(m, key, &ret)
if len(ret) > 0 {
return ret
}
return nil
} | go | func ValuesForKey(m map[string]interface{}, key string) []interface{} {
ret := make([]interface{}, 0)
hasKey(m, key, &ret)
if len(ret) > 0 {
return ret
}
return nil
} | [
"func",
"ValuesForKey",
"(",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"key",
"string",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"0",
")",
"\n\n",
"hasKey",
"(",
... | // ValuesForKey - return all values in map associated with 'key'
// Returns nil if the 'key' does not occur in the map | [
"ValuesForKey",
"-",
"return",
"all",
"values",
"in",
"map",
"associated",
"with",
"key",
"Returns",
"nil",
"if",
"the",
"key",
"does",
"not",
"occur",
"in",
"the",
"map"
] | 5e605d46809c441eb0e565867b63f7d80c9140c2 | https://github.com/clbanning/x2j/blob/5e605d46809c441eb0e565867b63f7d80c9140c2/x2j.go#L533-L541 |
141,844 | clbanning/x2j | x2j.go | hasKey | func hasKey(iv interface{}, key string, ret *[]interface{}) {
switch iv.(type) {
case map[string]interface{}:
vv := iv.(map[string]interface{})
if v, ok := vv[key]; ok {
*ret = append(*ret, v)
}
for _, v := range iv.(map[string]interface{}) {
hasKey(v, key, ret)
}
case []interface{}:
for _, v := ra... | go | func hasKey(iv interface{}, key string, ret *[]interface{}) {
switch iv.(type) {
case map[string]interface{}:
vv := iv.(map[string]interface{})
if v, ok := vv[key]; ok {
*ret = append(*ret, v)
}
for _, v := range iv.(map[string]interface{}) {
hasKey(v, key, ret)
}
case []interface{}:
for _, v := ra... | [
"func",
"hasKey",
"(",
"iv",
"interface",
"{",
"}",
",",
"key",
"string",
",",
"ret",
"*",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"switch",
"iv",
".",
"(",
"type",
")",
"{",
"case",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
":",
"vv... | // hasKey - if the map 'key' exists append it to array
// if it doesn't do nothing except scan array and map values | [
"hasKey",
"-",
"if",
"the",
"map",
"key",
"exists",
"append",
"it",
"to",
"array",
"if",
"it",
"doesn",
"t",
"do",
"nothing",
"except",
"scan",
"array",
"and",
"map",
"values"
] | 5e605d46809c441eb0e565867b63f7d80c9140c2 | https://github.com/clbanning/x2j/blob/5e605d46809c441eb0e565867b63f7d80c9140c2/x2j.go#L545-L560 |
141,845 | clbanning/x2j | x2j.go | ByteDocToJson | func ByteDocToJson(doc []byte, recast ...bool) (string, error) {
var r bool
if len(recast) == 1 {
r = recast[0]
}
m, merr := ByteDocToMap(doc, r)
if m == nil || merr != nil {
return "", merr
}
b, berr := json.Marshal(m)
if berr != nil {
return "", berr
}
// NOTE: don't have to worry about safe JSON ma... | go | func ByteDocToJson(doc []byte, recast ...bool) (string, error) {
var r bool
if len(recast) == 1 {
r = recast[0]
}
m, merr := ByteDocToMap(doc, r)
if m == nil || merr != nil {
return "", merr
}
b, berr := json.Marshal(m)
if berr != nil {
return "", berr
}
// NOTE: don't have to worry about safe JSON ma... | [
"func",
"ByteDocToJson",
"(",
"doc",
"[",
"]",
"byte",
",",
"recast",
"...",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"r",
"bool",
"\n",
"if",
"len",
"(",
"recast",
")",
"==",
"1",
"{",
"r",
"=",
"recast",
"[",
"0",
"]",
"\n",... | // ByteDocToJson - return an XML doc as a JSON string.
// If the optional argument 'recast' is 'true', then values will be converted to boolean or float64 if possible. | [
"ByteDocToJson",
"-",
"return",
"an",
"XML",
"doc",
"as",
"a",
"JSON",
"string",
".",
"If",
"the",
"optional",
"argument",
"recast",
"is",
"true",
"then",
"values",
"will",
"be",
"converted",
"to",
"boolean",
"or",
"float64",
"if",
"possible",
"."
] | 5e605d46809c441eb0e565867b63f7d80c9140c2 | https://github.com/clbanning/x2j/blob/5e605d46809c441eb0e565867b63f7d80c9140c2/x2j.go#L595-L612 |
141,846 | clbanning/x2j | x2j.go | ByteDocToTree | func ByteDocToTree(doc []byte) (*Node, error) {
// xml.Decoder doesn't properly handle whitespace in some doc
// see songTextString.xml test case ...
reg, _ := regexp.Compile("[ \t\n\r]*<")
doc = reg.ReplaceAll(doc, []byte("<"))
b := bytes.NewBuffer(doc)
p := xml.NewDecoder(b)
p.CharsetReader = X2jCharsetReader... | go | func ByteDocToTree(doc []byte) (*Node, error) {
// xml.Decoder doesn't properly handle whitespace in some doc
// see songTextString.xml test case ...
reg, _ := regexp.Compile("[ \t\n\r]*<")
doc = reg.ReplaceAll(doc, []byte("<"))
b := bytes.NewBuffer(doc)
p := xml.NewDecoder(b)
p.CharsetReader = X2jCharsetReader... | [
"func",
"ByteDocToTree",
"(",
"doc",
"[",
"]",
"byte",
")",
"(",
"*",
"Node",
",",
"error",
")",
"{",
"// xml.Decoder doesn't properly handle whitespace in some doc",
"// see songTextString.xml test case ...",
"reg",
",",
"_",
":=",
"regexp",
".",
"Compile",
"(",
"\... | // ByteDocToTree - convert an XML doc into a tree of nodes. | [
"ByteDocToTree",
"-",
"convert",
"an",
"XML",
"doc",
"into",
"a",
"tree",
"of",
"nodes",
"."
] | 5e605d46809c441eb0e565867b63f7d80c9140c2 | https://github.com/clbanning/x2j/blob/5e605d46809c441eb0e565867b63f7d80c9140c2/x2j.go#L627-L642 |
141,847 | clbanning/x2j | x2j_findPath.go | hasKeyPath | func hasKeyPath(crumb string, iv interface{}, key string, basket *map[string]bool) {
switch iv.(type) {
case map[string]interface{}:
vv := iv.(map[string]interface{})
if _, ok := vv[key]; ok {
if crumb == "" {
crumb = key
} else {
crumb += "." + key
}
// *basket = append(*basket, crumb)
(*b... | go | func hasKeyPath(crumb string, iv interface{}, key string, basket *map[string]bool) {
switch iv.(type) {
case map[string]interface{}:
vv := iv.(map[string]interface{})
if _, ok := vv[key]; ok {
if crumb == "" {
crumb = key
} else {
crumb += "." + key
}
// *basket = append(*basket, crumb)
(*b... | [
"func",
"hasKeyPath",
"(",
"crumb",
"string",
",",
"iv",
"interface",
"{",
"}",
",",
"key",
"string",
",",
"basket",
"*",
"map",
"[",
"string",
"]",
"bool",
")",
"{",
"switch",
"iv",
".",
"(",
"type",
")",
"{",
"case",
"map",
"[",
"string",
"]",
... | // hasKeyPath - if the map 'key' exists append it to KeyPath.path and increment KeyPath.depth
// This is really just a breadcrumber that saves all trails that hit the prescribed 'key'. | [
"hasKeyPath",
"-",
"if",
"the",
"map",
"key",
"exists",
"append",
"it",
"to",
"KeyPath",
".",
"path",
"and",
"increment",
"KeyPath",
".",
"depth",
"This",
"is",
"really",
"just",
"a",
"breadcrumber",
"that",
"saves",
"all",
"trails",
"that",
"hit",
"the",
... | 5e605d46809c441eb0e565867b63f7d80c9140c2 | https://github.com/clbanning/x2j/blob/5e605d46809c441eb0e565867b63f7d80c9140c2/x2j_findPath.go#L112-L142 |
141,848 | clbanning/x2j | x2m_bulk.go | XmlBufferToMap | func XmlBufferToMap(b *bytes.Buffer,recast ...bool) (map[string]interface{},error) {
var r bool
if len(recast) == 1 {
r = recast[0]
}
n,err := XmlBufferToTree(b)
if err != nil {
return nil, err
}
m := make(map[string]interface{})
m[n.key] = n.treeToMap(r)
return m,nil
} | go | func XmlBufferToMap(b *bytes.Buffer,recast ...bool) (map[string]interface{},error) {
var r bool
if len(recast) == 1 {
r = recast[0]
}
n,err := XmlBufferToTree(b)
if err != nil {
return nil, err
}
m := make(map[string]interface{})
m[n.key] = n.treeToMap(r)
return m,nil
} | [
"func",
"XmlBufferToMap",
"(",
"b",
"*",
"bytes",
".",
"Buffer",
",",
"recast",
"...",
"bool",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"var",
"r",
"bool",
"\n",
"if",
"len",
"(",
"recast",
")",
"==",
"1... | // XmlBufferToMap - process XML message from a bytes.Buffer
// 'b' is the buffer
// Optional argument 'recast' coerces map values to float64 or bool where possible. | [
"XmlBufferToMap",
"-",
"process",
"XML",
"message",
"from",
"a",
"bytes",
".",
"Buffer",
"b",
"is",
"the",
"buffer",
"Optional",
"argument",
"recast",
"coerces",
"map",
"values",
"to",
"float64",
"or",
"bool",
"where",
"possible",
"."
] | 5e605d46809c441eb0e565867b63f7d80c9140c2 | https://github.com/clbanning/x2j/blob/5e605d46809c441eb0e565867b63f7d80c9140c2/x2m_bulk.go#L76-L91 |
141,849 | clbanning/x2j | x2j_bulk.go | XmlBufferToJson | func XmlBufferToJson(b *bytes.Buffer,recast ...bool) (string,error) {
var r bool
if len(recast) == 1 {
r = recast[0]
}
n,err := XmlBufferToTree(b)
if err != nil {
return "", err
}
m := make(map[string]interface{})
m[n.key] = n.treeToMap(r)
j, jerr := json.Marshal(m)
return string(j), jerr
} | go | func XmlBufferToJson(b *bytes.Buffer,recast ...bool) (string,error) {
var r bool
if len(recast) == 1 {
r = recast[0]
}
n,err := XmlBufferToTree(b)
if err != nil {
return "", err
}
m := make(map[string]interface{})
m[n.key] = n.treeToMap(r)
j, jerr := json.Marshal(m)
return string(j), jerr
} | [
"func",
"XmlBufferToJson",
"(",
"b",
"*",
"bytes",
".",
"Buffer",
",",
"recast",
"...",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"r",
"bool",
"\n",
"if",
"len",
"(",
"recast",
")",
"==",
"1",
"{",
"r",
"=",
"recast",
"[",
"0",
... | // XmlBufferToJson - process XML message from a bytes.Buffer
// 'b' is the buffer
// Optional argument 'recast' coerces values to float64 or bool where possible. | [
"XmlBufferToJson",
"-",
"process",
"XML",
"message",
"from",
"a",
"bytes",
".",
"Buffer",
"b",
"is",
"the",
"buffer",
"Optional",
"argument",
"recast",
"coerces",
"values",
"to",
"float64",
"or",
"bool",
"where",
"possible",
"."
] | 5e605d46809c441eb0e565867b63f7d80c9140c2 | https://github.com/clbanning/x2j/blob/5e605d46809c441eb0e565867b63f7d80c9140c2/x2j_bulk.go#L75-L91 |
141,850 | google/go-tspi | verification/verification.go | GenerateChallenge | func GenerateChallenge(ekcert []byte, aikpub []byte, secret []byte) (asymenc []byte, symenc []byte, err error) {
/*
* Some EK certificates use RSAES-OAEP public keys.
* This is currently not supported by crypto/x509 but
* we are working with them to find a solution.
* https://github.com/golang/go/issues/30416
... | go | func GenerateChallenge(ekcert []byte, aikpub []byte, secret []byte) (asymenc []byte, symenc []byte, err error) {
/*
* Some EK certificates use RSAES-OAEP public keys.
* This is currently not supported by crypto/x509 but
* we are working with them to find a solution.
* https://github.com/golang/go/issues/30416
... | [
"func",
"GenerateChallenge",
"(",
"ekcert",
"[",
"]",
"byte",
",",
"aikpub",
"[",
"]",
"byte",
",",
"secret",
"[",
"]",
"byte",
")",
"(",
"asymenc",
"[",
"]",
"byte",
",",
"symenc",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"/*\n\t * Some EK c... | // GenerateChallenge takes a copy of the EK certificate, the public half of
// the AIK to be challenged and a secret. It then symmetrically encrypts the
// secret with a randomly generated AES key and Asymmetrically encrypts the
// AES key with the public half of the EK. These can then be provided to the
// TPM in orde... | [
"GenerateChallenge",
"takes",
"a",
"copy",
"of",
"the",
"EK",
"certificate",
"the",
"public",
"half",
"of",
"the",
"AIK",
"to",
"be",
"challenged",
"and",
"a",
"secret",
".",
"It",
"then",
"symmetrically",
"encrypts",
"the",
"secret",
"with",
"a",
"randomly"... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/verification/verification.go#L138-L151 |
141,851 | google/go-tspi | verification/verification.go | VerifyEKCert | func VerifyEKCert(ekcert []byte) error {
trustedCerts := map[string]string{
"STM1": `-----BEGIN CERTIFICATE-----
MIIDzDCCArSgAwIBAgIEAAAAATANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQGEwJD
SDEeMBwGA1UEChMVU1RNaWNyb2VsZWN0cm9uaWNzIE5WMRswGQYDVQQDExJTVE0g
VFBNIEVLIFJvb3QgQ0EwHhcNMDkwNzI4MDAwMDAwWhcNMjkxMjMxMDAwMDAwWjBV
MQswCQYDV... | go | func VerifyEKCert(ekcert []byte) error {
trustedCerts := map[string]string{
"STM1": `-----BEGIN CERTIFICATE-----
MIIDzDCCArSgAwIBAgIEAAAAATANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQGEwJD
SDEeMBwGA1UEChMVU1RNaWNyb2VsZWN0cm9uaWNzIE5WMRswGQYDVQQDExJTVE0g
VFBNIEVLIFJvb3QgQ0EwHhcNMDkwNzI4MDAwMDAwWhcNMjkxMjMxMDAwMDAwWjBV
MQswCQYDV... | [
"func",
"VerifyEKCert",
"(",
"ekcert",
"[",
"]",
"byte",
")",
"error",
"{",
"trustedCerts",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"`-----BEGIN CERTIFICATE-----\nMIIDzDCCArSgAwIBAgIEAAAAATANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQGEwJD\nSDEeMBwGA1UEChMVU1RN... | // VerifyEKCert verifies that the provided EK certificate is signed by a
// trusted manufacturer. | [
"VerifyEKCert",
"verifies",
"that",
"the",
"provided",
"EK",
"certificate",
"is",
"signed",
"by",
"a",
"trusted",
"manufacturer",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/verification/verification.go#L155-L585 |
141,852 | google/go-tspi | tspi/nv.go | ReadValue | func (nv *NV) ReadValue(offset uint, length uint) ([]byte, error) {
var cdata *C.BYTE
defer C.Tspi_Context_FreeMemory(nv.context, cdata)
err := tspiError(C.Tspi_NV_ReadValue(nv.handle, (C.UINT32)(offset), (*C.UINT32)(unsafe.Pointer(&length)), &cdata))
if err != nil {
return nil, err
}
data := C.GoBytes(unsafe.P... | go | func (nv *NV) ReadValue(offset uint, length uint) ([]byte, error) {
var cdata *C.BYTE
defer C.Tspi_Context_FreeMemory(nv.context, cdata)
err := tspiError(C.Tspi_NV_ReadValue(nv.handle, (C.UINT32)(offset), (*C.UINT32)(unsafe.Pointer(&length)), &cdata))
if err != nil {
return nil, err
}
data := C.GoBytes(unsafe.P... | [
"func",
"(",
"nv",
"*",
"NV",
")",
"ReadValue",
"(",
"offset",
"uint",
",",
"length",
"uint",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"cdata",
"*",
"C",
".",
"BYTE",
"\n",
"defer",
"C",
".",
"Tspi_Context_FreeMemory",
"(",
"nv",
... | // ReadValue reads length bytes from offset in the TPM NVRAM space | [
"ReadValue",
"reads",
"length",
"bytes",
"from",
"offset",
"in",
"the",
"TPM",
"NVRAM",
"space"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/nv.go#L28-L37 |
141,853 | google/go-tspi | tspi/nv.go | AssignPolicy | func (nv *NV) AssignPolicy(policy *Policy) error {
err := tspiError(C.Tspi_Policy_AssignToObject(policy.handle, (C.TSS_HOBJECT)(nv.handle)))
return err
} | go | func (nv *NV) AssignPolicy(policy *Policy) error {
err := tspiError(C.Tspi_Policy_AssignToObject(policy.handle, (C.TSS_HOBJECT)(nv.handle)))
return err
} | [
"func",
"(",
"nv",
"*",
"NV",
")",
"AssignPolicy",
"(",
"policy",
"*",
"Policy",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Policy_AssignToObject",
"(",
"policy",
".",
"handle",
",",
"(",
"C",
".",
"TSS_HOBJECT",
")",
"(",
"nv",
... | // AssignPolicy assigns a policy to the TPM NVRAM region | [
"AssignPolicy",
"assigns",
"a",
"policy",
"to",
"the",
"TPM",
"NVRAM",
"region"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/nv.go#L46-L49 |
141,854 | google/go-tspi | tspi/nv.go | Close | func (nv *NV) Close() error {
err := tspiError(C.Tspi_Context_CloseObject(nv.context, nv.handle))
return err
} | go | func (nv *NV) Close() error {
err := tspiError(C.Tspi_Context_CloseObject(nv.context, nv.handle))
return err
} | [
"func",
"(",
"nv",
"*",
"NV",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_CloseObject",
"(",
"nv",
".",
"context",
",",
"nv",
".",
"handle",
")",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Close closes the NV object. | [
"Close",
"closes",
"the",
"NV",
"object",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/nv.go#L52-L55 |
141,855 | google/go-tspi | tspi/pcrs.go | SetPCRs | func (pcrs *PCRs) SetPCRs(pcrset []int) error {
for pcr := range pcrs.pcrset {
pcrs.pcrset[pcr] = false
}
for _, pcr := range pcrset {
err := tspiError(C.Tspi_PcrComposite_SelectPcrIndex(pcrs.handle, (C.UINT32)(pcr)))
if err != nil {
return err
}
pcrs.pcrset[pcr] = true
}
return nil
} | go | func (pcrs *PCRs) SetPCRs(pcrset []int) error {
for pcr := range pcrs.pcrset {
pcrs.pcrset[pcr] = false
}
for _, pcr := range pcrset {
err := tspiError(C.Tspi_PcrComposite_SelectPcrIndex(pcrs.handle, (C.UINT32)(pcr)))
if err != nil {
return err
}
pcrs.pcrset[pcr] = true
}
return nil
} | [
"func",
"(",
"pcrs",
"*",
"PCRs",
")",
"SetPCRs",
"(",
"pcrset",
"[",
"]",
"int",
")",
"error",
"{",
"for",
"pcr",
":=",
"range",
"pcrs",
".",
"pcrset",
"{",
"pcrs",
".",
"pcrset",
"[",
"pcr",
"]",
"=",
"false",
"\n",
"}",
"\n",
"for",
"_",
","... | // SetPCRs takes an array of integers referring to PCRs. Any queries performed
// with this PCR object will then query these PCRs. | [
"SetPCRs",
"takes",
"an",
"array",
"of",
"integers",
"referring",
"to",
"PCRs",
".",
"Any",
"queries",
"performed",
"with",
"this",
"PCR",
"object",
"will",
"then",
"query",
"these",
"PCRs",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/pcrs.go#L31-L43 |
141,856 | google/go-tspi | tspi/pcrs.go | GetPCRValues | func (pcrs *PCRs) GetPCRValues() ([][]byte, error) {
var buflen C.UINT32
var buf *C.BYTE
for pcr := range pcrs.pcrs {
if pcrs.pcrset[pcr] == false {
continue
}
err := tspiError(C.Tspi_PcrComposite_GetPcrValue(pcrs.handle, (C.UINT32)(pcr), &buflen, &buf))
if err != nil {
return nil, err
}
pcrs.pcrs[... | go | func (pcrs *PCRs) GetPCRValues() ([][]byte, error) {
var buflen C.UINT32
var buf *C.BYTE
for pcr := range pcrs.pcrs {
if pcrs.pcrset[pcr] == false {
continue
}
err := tspiError(C.Tspi_PcrComposite_GetPcrValue(pcrs.handle, (C.UINT32)(pcr), &buflen, &buf))
if err != nil {
return nil, err
}
pcrs.pcrs[... | [
"func",
"(",
"pcrs",
"*",
"PCRs",
")",
"GetPCRValues",
"(",
")",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"buflen",
"C",
".",
"UINT32",
"\n",
"var",
"buf",
"*",
"C",
".",
"BYTE",
"\n",
"for",
"pcr",
":=",
"range",
"pcrs",... | // GetPCRValues obtains the PCR values for any PCRs that have been set. | [
"GetPCRValues",
"obtains",
"the",
"PCR",
"values",
"for",
"any",
"PCRs",
"that",
"have",
"been",
"set",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/pcrs.go#L46-L61 |
141,857 | google/go-tspi | tspi/pcrs.go | Close | func (pcrs *PCRs) Close() error {
err := tspiError(C.Tspi_Context_CloseObject(pcrs.context, pcrs.handle))
return err
} | go | func (pcrs *PCRs) Close() error {
err := tspiError(C.Tspi_Context_CloseObject(pcrs.context, pcrs.handle))
return err
} | [
"func",
"(",
"pcrs",
"*",
"PCRs",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_CloseObject",
"(",
"pcrs",
".",
"context",
",",
"pcrs",
".",
"handle",
")",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Close closes the PCRs object. | [
"Close",
"closes",
"the",
"PCRs",
"object",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/pcrs.go#L64-L67 |
141,858 | google/go-tspi | tspi/policy.go | SetSecret | func (policy *Policy) SetSecret(sectype int, secret []byte) error {
err := tspiError(C.Tspi_Policy_SetSecret(policy.handle, (C.TSS_FLAG)(sectype), (C.UINT32)(len(secret)), (*C.BYTE)(&secret[0])))
return err
} | go | func (policy *Policy) SetSecret(sectype int, secret []byte) error {
err := tspiError(C.Tspi_Policy_SetSecret(policy.handle, (C.TSS_FLAG)(sectype), (C.UINT32)(len(secret)), (*C.BYTE)(&secret[0])))
return err
} | [
"func",
"(",
"policy",
"*",
"Policy",
")",
"SetSecret",
"(",
"sectype",
"int",
",",
"secret",
"[",
"]",
"byte",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Policy_SetSecret",
"(",
"policy",
".",
"handle",
",",
"(",
"C",
".",
"TS... | // SetSecret sets the secret for a policy. This policy may then be applied to
// another object. | [
"SetSecret",
"sets",
"the",
"secret",
"for",
"a",
"policy",
".",
"This",
"policy",
"may",
"then",
"be",
"applied",
"to",
"another",
"object",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/policy.go#L28-L31 |
141,859 | google/go-tspi | tspi/policy.go | Close | func (policy *Policy) Close() error {
err := tspiError(C.Tspi_Context_CloseObject(policy.context, policy.handle))
return err
} | go | func (policy *Policy) Close() error {
err := tspiError(C.Tspi_Context_CloseObject(policy.context, policy.handle))
return err
} | [
"func",
"(",
"policy",
"*",
"Policy",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_CloseObject",
"(",
"policy",
".",
"context",
",",
"policy",
".",
"handle",
")",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Close closes the Policy object. | [
"Close",
"closes",
"the",
"Policy",
"object",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/policy.go#L34-L37 |
141,860 | google/go-tspi | tspi/tpm.go | ExtendPCR | func (tpm *TPM) ExtendPCR(pcr int, data []byte, eventtype int, event []byte) error {
var outlen C.UINT32
var pcrval *C.BYTE
var eventstruct C.TSS_PCR_EVENT
var err error
shasum := sha1.Sum(data)
if event != nil {
var pcrdata *C.BYTE
var pcrdatalen C.UINT32
eventstruct.versionInfo.bMajor = 1
eventstruct... | go | func (tpm *TPM) ExtendPCR(pcr int, data []byte, eventtype int, event []byte) error {
var outlen C.UINT32
var pcrval *C.BYTE
var eventstruct C.TSS_PCR_EVENT
var err error
shasum := sha1.Sum(data)
if event != nil {
var pcrdata *C.BYTE
var pcrdatalen C.UINT32
eventstruct.versionInfo.bMajor = 1
eventstruct... | [
"func",
"(",
"tpm",
"*",
"TPM",
")",
"ExtendPCR",
"(",
"pcr",
"int",
",",
"data",
"[",
"]",
"byte",
",",
"eventtype",
"int",
",",
"event",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"outlen",
"C",
".",
"UINT32",
"\n",
"var",
"pcrval",
"*",
"C",
... | // ExtendPCR extends a pcr. If event is nil, data must be pre-hashed with
// SHA1. If event is not nil, event is used to populate the TSS event
// log. If both data and event are provided, both will be used to create the
// extend hash. | [
"ExtendPCR",
"extends",
"a",
"pcr",
".",
"If",
"event",
"is",
"nil",
"data",
"must",
"be",
"pre",
"-",
"hashed",
"with",
"SHA1",
".",
"If",
"event",
"is",
"not",
"nil",
"event",
"is",
"used",
"to",
"populate",
"the",
"TSS",
"event",
"log",
".",
"If",... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/tpm.go#L110-L148 |
141,861 | google/go-tspi | tspi/tpm.go | GetPCRValues | func (tpm *TPM) GetPCRValues() ([][]byte, error) {
var (
buflen C.UINT32
buf *C.BYTE
pcrs [24][]byte
)
for pcr := 0; pcr < 24; pcr++ {
err := tspiError(C.Tspi_TPM_PcrRead(tpm.handle, (C.UINT32)(pcr), &buflen, &buf))
if err != nil {
return nil, err
}
pcrs[pcr] = C.GoBytes(unsafe.Pointer(buf), (C... | go | func (tpm *TPM) GetPCRValues() ([][]byte, error) {
var (
buflen C.UINT32
buf *C.BYTE
pcrs [24][]byte
)
for pcr := 0; pcr < 24; pcr++ {
err := tspiError(C.Tspi_TPM_PcrRead(tpm.handle, (C.UINT32)(pcr), &buflen, &buf))
if err != nil {
return nil, err
}
pcrs[pcr] = C.GoBytes(unsafe.Pointer(buf), (C... | [
"func",
"(",
"tpm",
"*",
"TPM",
")",
"GetPCRValues",
"(",
")",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"(",
"buflen",
"C",
".",
"UINT32",
"\n",
"buf",
"*",
"C",
".",
"BYTE",
"\n",
"pcrs",
"[",
"24",
"]",
"[",
"]",
"b... | // GetPCRValues obtains the PCR values from the TPM. | [
"GetPCRValues",
"obtains",
"the",
"PCR",
"values",
"from",
"the",
"TPM",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/tpm.go#L151-L166 |
141,862 | google/go-tspi | tspi/tpm.go | GetQuote | func (tpm *TPM) GetQuote(aik *Key, pcrs *PCRs, challenge []byte) ([]byte, []byte, error) {
var validation C.TSS_VALIDATION
challangeHash := sha1.Sum(challenge[:])
validation.ulExternalDataLength = sha1.Size
validation.rgbExternalData = (*C.BYTE)(C.CBytes(challangeHash[:]))
defer C.free(unsafe.Pointer(validation.r... | go | func (tpm *TPM) GetQuote(aik *Key, pcrs *PCRs, challenge []byte) ([]byte, []byte, error) {
var validation C.TSS_VALIDATION
challangeHash := sha1.Sum(challenge[:])
validation.ulExternalDataLength = sha1.Size
validation.rgbExternalData = (*C.BYTE)(C.CBytes(challangeHash[:]))
defer C.free(unsafe.Pointer(validation.r... | [
"func",
"(",
"tpm",
"*",
"TPM",
")",
"GetQuote",
"(",
"aik",
"*",
"Key",
",",
"pcrs",
"*",
"PCRs",
",",
"challenge",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"validation",
"C",
".",
"... | //GetQuote takes an encrypted key blob representing the AIK, a set of PCRs
//and a challenge and returns a blob containing a hash of the PCR hashes and
//the challenge, and a validation blob signed by the AIK. | [
"GetQuote",
"takes",
"an",
"encrypted",
"key",
"blob",
"representing",
"the",
"AIK",
"a",
"set",
"of",
"PCRs",
"and",
"a",
"challenge",
"and",
"returns",
"a",
"blob",
"containing",
"a",
"hash",
"of",
"the",
"PCR",
"hashes",
"and",
"the",
"challenge",
"and"... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/tpm.go#L171-L191 |
141,863 | google/go-tspi | tspi/tpm.go | ActivateIdentity | func (tpm *TPM) ActivateIdentity(aik *Key, asymblob []byte, symblob []byte) (secret []byte, err error) {
var creds *C.BYTE
var credlen C.UINT32
err = tspiError(C.Tspi_TPM_ActivateIdentity(tpm.handle, aik.handle, (C.UINT32)(len(asymblob)), (*C.BYTE)(&asymblob[0]), (C.UINT32)(len(symblob)), (*C.BYTE)(&symblob[0]), &c... | go | func (tpm *TPM) ActivateIdentity(aik *Key, asymblob []byte, symblob []byte) (secret []byte, err error) {
var creds *C.BYTE
var credlen C.UINT32
err = tspiError(C.Tspi_TPM_ActivateIdentity(tpm.handle, aik.handle, (C.UINT32)(len(asymblob)), (*C.BYTE)(&asymblob[0]), (C.UINT32)(len(symblob)), (*C.BYTE)(&symblob[0]), &c... | [
"func",
"(",
"tpm",
"*",
"TPM",
")",
"ActivateIdentity",
"(",
"aik",
"*",
"Key",
",",
"asymblob",
"[",
"]",
"byte",
",",
"symblob",
"[",
"]",
"byte",
")",
"(",
"secret",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"creds",
"*",
"C",
... | // ActivateIdentity accepts an encrypted key blob representing the AIK and
// two blobs representing the asymmetric and symmetric challenges associated
// with the AIK. If the TPM is able to decrypt the challenges and the
// challenges correspond to the AIK, the TPM will return the original
// challenge secret. | [
"ActivateIdentity",
"accepts",
"an",
"encrypted",
"key",
"blob",
"representing",
"the",
"AIK",
"and",
"two",
"blobs",
"representing",
"the",
"asymmetric",
"and",
"symmetric",
"challenges",
"associated",
"with",
"the",
"AIK",
".",
"If",
"the",
"TPM",
"is",
"able"... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/tpm.go#L198-L213 |
141,864 | google/go-tspi | tspi/tpm.go | GetPolicy | func (tpm *TPM) GetPolicy(poltype int) (*Policy, error) {
var policyHandle C.TSS_HPOLICY
err := tspiError(C.Tspi_GetPolicyObject((C.TSS_HOBJECT)(tpm.handle), (C.TSS_FLAG)(poltype), &policyHandle))
return &Policy{handle: policyHandle, context: tpm.context}, err
} | go | func (tpm *TPM) GetPolicy(poltype int) (*Policy, error) {
var policyHandle C.TSS_HPOLICY
err := tspiError(C.Tspi_GetPolicyObject((C.TSS_HOBJECT)(tpm.handle), (C.TSS_FLAG)(poltype), &policyHandle))
return &Policy{handle: policyHandle, context: tpm.context}, err
} | [
"func",
"(",
"tpm",
"*",
"TPM",
")",
"GetPolicy",
"(",
"poltype",
"int",
")",
"(",
"*",
"Policy",
",",
"error",
")",
"{",
"var",
"policyHandle",
"C",
".",
"TSS_HPOLICY",
"\n",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_GetPolicyObject",
"(",
"(",
... | // GetPolicy returns the TSS policy associated with the TPM. | [
"GetPolicy",
"returns",
"the",
"TSS",
"policy",
"associated",
"with",
"the",
"TPM",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/tpm.go#L216-L220 |
141,865 | google/go-tspi | tspi/tpm.go | TakeOwnership | func (tpm *TPM) TakeOwnership(srk *Key) error {
err := tspiError(C.Tspi_TPM_TakeOwnership(tpm.handle, srk.handle, 0))
return err
} | go | func (tpm *TPM) TakeOwnership(srk *Key) error {
err := tspiError(C.Tspi_TPM_TakeOwnership(tpm.handle, srk.handle, 0))
return err
} | [
"func",
"(",
"tpm",
"*",
"TPM",
")",
"TakeOwnership",
"(",
"srk",
"*",
"Key",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_TPM_TakeOwnership",
"(",
"tpm",
".",
"handle",
",",
"srk",
".",
"handle",
",",
"0",
")",
")",
"\n",
"ret... | // TakeOwnership transitions a TPM from unowned state to owned, installing the
// encrypted key blob as the SRK. | [
"TakeOwnership",
"transitions",
"a",
"TPM",
"from",
"unowned",
"state",
"to",
"owned",
"installing",
"the",
"encrypted",
"key",
"blob",
"as",
"the",
"SRK",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/tpm.go#L224-L227 |
141,866 | google/go-tspi | tspi/tpm.go | AssignPolicy | func (tpm *TPM) AssignPolicy(policy *Policy) error {
err := tspiError(C.Tspi_Policy_AssignToObject(policy.handle, (C.TSS_HOBJECT)(tpm.handle)))
return err
} | go | func (tpm *TPM) AssignPolicy(policy *Policy) error {
err := tspiError(C.Tspi_Policy_AssignToObject(policy.handle, (C.TSS_HOBJECT)(tpm.handle)))
return err
} | [
"func",
"(",
"tpm",
"*",
"TPM",
")",
"AssignPolicy",
"(",
"policy",
"*",
"Policy",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Policy_AssignToObject",
"(",
"policy",
".",
"handle",
",",
"(",
"C",
".",
"TSS_HOBJECT",
")",
"(",
"tpm... | // AssignPolicy assigns a TSS policy to the TPM. | [
"AssignPolicy",
"assigns",
"a",
"TSS",
"policy",
"to",
"the",
"TPM",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/tpm.go#L230-L233 |
141,867 | google/go-tspi | tspi/tpm.go | CollateIdentityRequest | func (tpm *TPM) CollateIdentityRequest(srk *Key, pubkey *Key, aik *Key) ([]byte, error) {
var certLen C.UINT32
var cCertReq *C.BYTE
err := tspiError(C.Tspi_TPM_CollateIdentityRequest(tpm.handle, srk.handle, pubkey.handle, 0, nil, aik.handle, C.TSS_ALG_AES, &certLen, &cCertReq))
certReq := C.GoBytes(unsafe.Pointer(c... | go | func (tpm *TPM) CollateIdentityRequest(srk *Key, pubkey *Key, aik *Key) ([]byte, error) {
var certLen C.UINT32
var cCertReq *C.BYTE
err := tspiError(C.Tspi_TPM_CollateIdentityRequest(tpm.handle, srk.handle, pubkey.handle, 0, nil, aik.handle, C.TSS_ALG_AES, &certLen, &cCertReq))
certReq := C.GoBytes(unsafe.Pointer(c... | [
"func",
"(",
"tpm",
"*",
"TPM",
")",
"CollateIdentityRequest",
"(",
"srk",
"*",
"Key",
",",
"pubkey",
"*",
"Key",
",",
"aik",
"*",
"Key",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"certLen",
"C",
".",
"UINT32",
"\n",
"var",
"cCer... | // CollateIdentityRequest creates a signing request for the provided AIKq | [
"CollateIdentityRequest",
"creates",
"a",
"signing",
"request",
"for",
"the",
"provided",
"AIKq"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/tpm.go#L236-L243 |
141,868 | google/go-tspi | tspi/tpm.go | Close | func (tpm *TPM) Close() error {
err := tspiError(C.Tspi_Context_CloseObject(tpm.context, tpm.handle))
return err
} | go | func (tpm *TPM) Close() error {
err := tspiError(C.Tspi_Context_CloseObject(tpm.context, tpm.handle))
return err
} | [
"func",
"(",
"tpm",
"*",
"TPM",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_CloseObject",
"(",
"tpm",
".",
"context",
",",
"tpm",
".",
"handle",
")",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Close closes the TPM object. | [
"Close",
"closes",
"the",
"TPM",
"object",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/tpm.go#L246-L249 |
141,869 | google/go-tspi | tspi/context.go | NewContext | func NewContext() (*Context, error) {
context := new(Context)
err := tspiError(C.Tspi_Context_Create(&context.context))
return context, err
} | go | func NewContext() (*Context, error) {
context := new(Context)
err := tspiError(C.Tspi_Context_Create(&context.context))
return context, err
} | [
"func",
"NewContext",
"(",
")",
"(",
"*",
"Context",
",",
"error",
")",
"{",
"context",
":=",
"new",
"(",
"Context",
")",
"\n",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_Create",
"(",
"&",
"context",
".",
"context",
")",
")",
"\n",
"retu... | // NewContext returns a TSS daemon context | [
"NewContext",
"returns",
"a",
"TSS",
"daemon",
"context"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/context.go#L32-L36 |
141,870 | google/go-tspi | tspi/context.go | Connect | func (context *Context) Connect() error {
var tpmhandle C.TSS_HTPM
err := tspiError(C.Tspi_Context_Connect(context.context, nil))
if err != nil {
return err
}
C.Tspi_Context_GetTpmObject(context.context, &tpmhandle)
context.tpm = TPM{handle: tpmhandle, context: context.context}
return nil
} | go | func (context *Context) Connect() error {
var tpmhandle C.TSS_HTPM
err := tspiError(C.Tspi_Context_Connect(context.context, nil))
if err != nil {
return err
}
C.Tspi_Context_GetTpmObject(context.context, &tpmhandle)
context.tpm = TPM{handle: tpmhandle, context: context.context}
return nil
} | [
"func",
"(",
"context",
"*",
"Context",
")",
"Connect",
"(",
")",
"error",
"{",
"var",
"tpmhandle",
"C",
".",
"TSS_HTPM",
"\n",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_Connect",
"(",
"context",
".",
"context",
",",
"nil",
")",
")",
"\n",... | // Connect opens a connection between the context and the TSS daemon. It
// returns an error on failure. | [
"Connect",
"opens",
"a",
"connection",
"between",
"the",
"context",
"and",
"the",
"TSS",
"daemon",
".",
"It",
"returns",
"an",
"error",
"on",
"failure",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/context.go#L40-L49 |
141,871 | google/go-tspi | tspi/context.go | Close | func (context *Context) Close() error {
err := tspiError(C.Tspi_Context_Close(context.context))
return err
} | go | func (context *Context) Close() error {
err := tspiError(C.Tspi_Context_Close(context.context))
return err
} | [
"func",
"(",
"context",
"*",
"Context",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_Close",
"(",
"context",
".",
"context",
")",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Close closes the connection between the context and the TSS daemon. It
// returns an error on failure. | [
"Close",
"closes",
"the",
"connection",
"between",
"the",
"context",
"and",
"the",
"TSS",
"daemon",
".",
"It",
"returns",
"an",
"error",
"on",
"failure",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/context.go#L53-L56 |
141,872 | google/go-tspi | tspi/context.go | CreateNV | func (context *Context) CreateNV() (*NV, error) {
var handle C.TSS_HNVSTORE
err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_NV, 0, (*C.TSS_HOBJECT)(&handle)))
return &NV{handle: handle, context: context.context}, err
} | go | func (context *Context) CreateNV() (*NV, error) {
var handle C.TSS_HNVSTORE
err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_NV, 0, (*C.TSS_HOBJECT)(&handle)))
return &NV{handle: handle, context: context.context}, err
} | [
"func",
"(",
"context",
"*",
"Context",
")",
"CreateNV",
"(",
")",
"(",
"*",
"NV",
",",
"error",
")",
"{",
"var",
"handle",
"C",
".",
"TSS_HNVSTORE",
"\n",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_CreateObject",
"(",
"context",
".",
"cont... | // CreateNV creates a TSS object referring to a TPM NVRAM area. It returns a
// reference to the object and any error. | [
"CreateNV",
"creates",
"a",
"TSS",
"object",
"referring",
"to",
"a",
"TPM",
"NVRAM",
"area",
".",
"It",
"returns",
"a",
"reference",
"to",
"the",
"object",
"and",
"any",
"error",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/context.go#L60-L64 |
141,873 | google/go-tspi | tspi/context.go | CreateKey | func (context *Context) CreateKey(flags int) (*Key, error) {
var handle C.TSS_HKEY
err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_RSAKEY, (C.TSS_FLAG)(flags), (*C.TSS_HOBJECT)(&handle)))
return &Key{handle: handle, context: context.context}, err
} | go | func (context *Context) CreateKey(flags int) (*Key, error) {
var handle C.TSS_HKEY
err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_RSAKEY, (C.TSS_FLAG)(flags), (*C.TSS_HOBJECT)(&handle)))
return &Key{handle: handle, context: context.context}, err
} | [
"func",
"(",
"context",
"*",
"Context",
")",
"CreateKey",
"(",
"flags",
"int",
")",
"(",
"*",
"Key",
",",
"error",
")",
"{",
"var",
"handle",
"C",
".",
"TSS_HKEY",
"\n",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_CreateObject",
"(",
"contex... | // CreateKey creates a TSS object referring to a TPM key. It returns a
// reference to the object and any error. | [
"CreateKey",
"creates",
"a",
"TSS",
"object",
"referring",
"to",
"a",
"TPM",
"key",
".",
"It",
"returns",
"a",
"reference",
"to",
"the",
"object",
"and",
"any",
"error",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/context.go#L68-L72 |
141,874 | google/go-tspi | tspi/context.go | LoadKeyByUUID | func (context *Context) LoadKeyByUUID(storetype int, uuid C.TSS_UUID) (*Key, error) {
var handle C.TSS_HKEY
err := tspiError(C.Tspi_Context_LoadKeyByUUID(context.context, (C.TSS_FLAG)(storetype), uuid, &handle))
return &Key{handle: handle, context: context.context}, err
} | go | func (context *Context) LoadKeyByUUID(storetype int, uuid C.TSS_UUID) (*Key, error) {
var handle C.TSS_HKEY
err := tspiError(C.Tspi_Context_LoadKeyByUUID(context.context, (C.TSS_FLAG)(storetype), uuid, &handle))
return &Key{handle: handle, context: context.context}, err
} | [
"func",
"(",
"context",
"*",
"Context",
")",
"LoadKeyByUUID",
"(",
"storetype",
"int",
",",
"uuid",
"C",
".",
"TSS_UUID",
")",
"(",
"*",
"Key",
",",
"error",
")",
"{",
"var",
"handle",
"C",
".",
"TSS_HKEY",
"\n",
"err",
":=",
"tspiError",
"(",
"C",
... | // LoadKeyByUUID loads the key referenced by UUID. The storetype argument
// indicates whether the key should be obtained from the system or user
// stores. It returns a reference to the key and any error. | [
"LoadKeyByUUID",
"loads",
"the",
"key",
"referenced",
"by",
"UUID",
".",
"The",
"storetype",
"argument",
"indicates",
"whether",
"the",
"key",
"should",
"be",
"obtained",
"from",
"the",
"system",
"or",
"user",
"stores",
".",
"It",
"returns",
"a",
"reference",
... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/context.go#L77-L81 |
141,875 | google/go-tspi | tspi/context.go | LoadKeyByBlob | func (context *Context) LoadKeyByBlob(parent *Key, blob []byte) (*Key, error) {
var handle C.TSS_HKEY
err := tspiError(C.Tspi_Context_LoadKeyByBlob(context.context, parent.handle, (C.UINT32)(len(blob)), (*C.BYTE)(unsafe.Pointer(&blob[0])), &handle))
return &Key{handle: handle, context: context.context}, err
} | go | func (context *Context) LoadKeyByBlob(parent *Key, blob []byte) (*Key, error) {
var handle C.TSS_HKEY
err := tspiError(C.Tspi_Context_LoadKeyByBlob(context.context, parent.handle, (C.UINT32)(len(blob)), (*C.BYTE)(unsafe.Pointer(&blob[0])), &handle))
return &Key{handle: handle, context: context.context}, err
} | [
"func",
"(",
"context",
"*",
"Context",
")",
"LoadKeyByBlob",
"(",
"parent",
"*",
"Key",
",",
"blob",
"[",
"]",
"byte",
")",
"(",
"*",
"Key",
",",
"error",
")",
"{",
"var",
"handle",
"C",
".",
"TSS_HKEY",
"\n",
"err",
":=",
"tspiError",
"(",
"C",
... | // LoadKeyByBlob takes an encrypted key blob and reads it into the TPM. It
// takes a reference to the parent key and the key blob, and returns a
// reference to the key and any error. | [
"LoadKeyByBlob",
"takes",
"an",
"encrypted",
"key",
"blob",
"and",
"reads",
"it",
"into",
"the",
"TPM",
".",
"It",
"takes",
"a",
"reference",
"to",
"the",
"parent",
"key",
"and",
"the",
"key",
"blob",
"and",
"returns",
"a",
"reference",
"to",
"the",
"key... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/context.go#L86-L90 |
141,876 | google/go-tspi | tspi/context.go | CreatePolicy | func (context *Context) CreatePolicy(flags int) (*Policy, error) {
var handle C.TSS_HPOLICY
err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_POLICY, (C.TSS_FLAG)(flags), (*C.TSS_HOBJECT)(&handle)))
return &Policy{handle: handle, context: context.context}, err
} | go | func (context *Context) CreatePolicy(flags int) (*Policy, error) {
var handle C.TSS_HPOLICY
err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_POLICY, (C.TSS_FLAG)(flags), (*C.TSS_HOBJECT)(&handle)))
return &Policy{handle: handle, context: context.context}, err
} | [
"func",
"(",
"context",
"*",
"Context",
")",
"CreatePolicy",
"(",
"flags",
"int",
")",
"(",
"*",
"Policy",
",",
"error",
")",
"{",
"var",
"handle",
"C",
".",
"TSS_HPOLICY",
"\n",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_CreateObject",
"(",
... | // CreatePolicy creates an object referring to a TSS policy. It returns a
// reference to the object plus any error. | [
"CreatePolicy",
"creates",
"an",
"object",
"referring",
"to",
"a",
"TSS",
"policy",
".",
"It",
"returns",
"a",
"reference",
"to",
"the",
"object",
"plus",
"any",
"error",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/context.go#L99-L103 |
141,877 | google/go-tspi | tspi/context.go | CreatePCRs | func (context *Context) CreatePCRs(flags int) (*PCRs, error) {
var handle C.TSS_HPCRS
err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_PCRS, (C.TSS_FLAG)(flags), (*C.TSS_HOBJECT)(&handle)))
return &PCRs{handle: handle, context: context.context}, err
} | go | func (context *Context) CreatePCRs(flags int) (*PCRs, error) {
var handle C.TSS_HPCRS
err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_PCRS, (C.TSS_FLAG)(flags), (*C.TSS_HOBJECT)(&handle)))
return &PCRs{handle: handle, context: context.context}, err
} | [
"func",
"(",
"context",
"*",
"Context",
")",
"CreatePCRs",
"(",
"flags",
"int",
")",
"(",
"*",
"PCRs",
",",
"error",
")",
"{",
"var",
"handle",
"C",
".",
"TSS_HPCRS",
"\n",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_CreateObject",
"(",
"con... | // CreatePCRs creates an object referring to a TSS PCR composite. It returns
// a reference to the object plus any error. | [
"CreatePCRs",
"creates",
"an",
"object",
"referring",
"to",
"a",
"TSS",
"PCR",
"composite",
".",
"It",
"returns",
"a",
"reference",
"to",
"the",
"object",
"plus",
"any",
"error",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/context.go#L107-L111 |
141,878 | google/go-tspi | tspi/context.go | CreateHash | func (context *Context) CreateHash(hash crypto.Hash) (*Hash, error) {
var hashAlg C.TSS_FLAG
if hash == crypto.SHA1 {
hashAlg = C.TSS_HASH_SHA1
} else {
hashAlg = C.TSS_HASH_OTHER
}
var handle C.TSS_HHASH
err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_HASH, hashAlg, (*C.TSS_H... | go | func (context *Context) CreateHash(hash crypto.Hash) (*Hash, error) {
var hashAlg C.TSS_FLAG
if hash == crypto.SHA1 {
hashAlg = C.TSS_HASH_SHA1
} else {
hashAlg = C.TSS_HASH_OTHER
}
var handle C.TSS_HHASH
err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_HASH, hashAlg, (*C.TSS_H... | [
"func",
"(",
"context",
"*",
"Context",
")",
"CreateHash",
"(",
"hash",
"crypto",
".",
"Hash",
")",
"(",
"*",
"Hash",
",",
"error",
")",
"{",
"var",
"hashAlg",
"C",
".",
"TSS_FLAG",
"\n",
"if",
"hash",
"==",
"crypto",
".",
"SHA1",
"{",
"hashAlg",
"... | // CreateHash creates a Hash object for the given hash algorithm. If using an algorithm other than crypto.SHA1 and
// if you are signing with this hash then make sure the key is created with signing algorithm TSS_SS_RSASSAPKCS1V15_DER. | [
"CreateHash",
"creates",
"a",
"Hash",
"object",
"for",
"the",
"given",
"hash",
"algorithm",
".",
"If",
"using",
"an",
"algorithm",
"other",
"than",
"crypto",
".",
"SHA1",
"and",
"if",
"you",
"are",
"signing",
"with",
"this",
"hash",
"then",
"make",
"sure",... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/context.go#L115-L134 |
141,879 | google/go-tspi | tspi/key.go | GetPolicy | func (key *Key) GetPolicy(poltype int) (*Policy, error) {
var policyHandle C.TSS_HPOLICY
err := tspiError(C.Tspi_GetPolicyObject((C.TSS_HOBJECT)(key.handle), (C.TSS_FLAG)(poltype), &policyHandle))
return &Policy{handle: policyHandle, context: key.context}, err
} | go | func (key *Key) GetPolicy(poltype int) (*Policy, error) {
var policyHandle C.TSS_HPOLICY
err := tspiError(C.Tspi_GetPolicyObject((C.TSS_HOBJECT)(key.handle), (C.TSS_FLAG)(poltype), &policyHandle))
return &Policy{handle: policyHandle, context: key.context}, err
} | [
"func",
"(",
"key",
"*",
"Key",
")",
"GetPolicy",
"(",
"poltype",
"int",
")",
"(",
"*",
"Policy",
",",
"error",
")",
"{",
"var",
"policyHandle",
"C",
".",
"TSS_HPOLICY",
"\n",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_GetPolicyObject",
"(",
"(",
... | // GetPolicy returns the policy associated with the key | [
"GetPolicy",
"returns",
"the",
"policy",
"associated",
"with",
"the",
"key"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/key.go#L39-L43 |
141,880 | google/go-tspi | tspi/key.go | SetModulus | func (key *Key) SetModulus(n []byte) error {
err := tspiError(C.Tspi_SetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_RSAKEY_INFO, C.TSS_TSPATTRIB_KEYINFO_RSA_MODULUS, (C.UINT32)(len(n)), (*C.BYTE)(unsafe.Pointer(&n[0]))))
return err
} | go | func (key *Key) SetModulus(n []byte) error {
err := tspiError(C.Tspi_SetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_RSAKEY_INFO, C.TSS_TSPATTRIB_KEYINFO_RSA_MODULUS, (C.UINT32)(len(n)), (*C.BYTE)(unsafe.Pointer(&n[0]))))
return err
} | [
"func",
"(",
"key",
"*",
"Key",
")",
"SetModulus",
"(",
"n",
"[",
"]",
"byte",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_SetAttribData",
"(",
"(",
"C",
".",
"TSS_HOBJECT",
")",
"(",
"key",
".",
"handle",
")",
",",
"C",
"."... | // SetModulus sets the modulus of a public key to the provided value | [
"SetModulus",
"sets",
"the",
"modulus",
"of",
"a",
"public",
"key",
"to",
"the",
"provided",
"value"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/key.go#L46-L49 |
141,881 | google/go-tspi | tspi/key.go | GetExponent | func (key *Key) GetExponent() (uint32, error) {
var dataLen C.UINT32
var cData *C.BYTE
err := tspiError(C.Tspi_GetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_RSAKEY_INFO, C.TSS_TSPATTRIB_KEYINFO_RSA_EXPONENT, &dataLen, &cData))
data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen))
C.Tspi_Context_F... | go | func (key *Key) GetExponent() (uint32, error) {
var dataLen C.UINT32
var cData *C.BYTE
err := tspiError(C.Tspi_GetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_RSAKEY_INFO, C.TSS_TSPATTRIB_KEYINFO_RSA_EXPONENT, &dataLen, &cData))
data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen))
C.Tspi_Context_F... | [
"func",
"(",
"key",
"*",
"Key",
")",
"GetExponent",
"(",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"var",
"dataLen",
"C",
".",
"UINT32",
"\n",
"var",
"cData",
"*",
"C",
".",
"BYTE",
"\n",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_GetAttribDa... | // GetExponent returns the exponent of the public key | [
"GetExponent",
"returns",
"the",
"exponent",
"of",
"the",
"public",
"key"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/key.go#L52-L69 |
141,882 | google/go-tspi | tspi/key.go | GetModulus | func (key *Key) GetModulus() (modulus []byte, err error) {
var dataLen C.UINT32
var cData *C.BYTE
err = tspiError(C.Tspi_GetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_RSAKEY_INFO, C.TSS_TSPATTRIB_KEYINFO_RSA_MODULUS, &dataLen, &cData))
data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen))
C.Tspi_... | go | func (key *Key) GetModulus() (modulus []byte, err error) {
var dataLen C.UINT32
var cData *C.BYTE
err = tspiError(C.Tspi_GetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_RSAKEY_INFO, C.TSS_TSPATTRIB_KEYINFO_RSA_MODULUS, &dataLen, &cData))
data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen))
C.Tspi_... | [
"func",
"(",
"key",
"*",
"Key",
")",
"GetModulus",
"(",
")",
"(",
"modulus",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"dataLen",
"C",
".",
"UINT32",
"\n",
"var",
"cData",
"*",
"C",
".",
"BYTE",
"\n",
"err",
"=",
"tspiError",
"(",
... | // GetModulus returns the modulus of the public key | [
"GetModulus",
"returns",
"the",
"modulus",
"of",
"the",
"public",
"key"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/key.go#L89-L96 |
141,883 | google/go-tspi | tspi/key.go | GetPubKeyBlob | func (key *Key) GetPubKeyBlob() (pubkey []byte, err error) {
var dataLen C.UINT32
var cData *C.BYTE
err = tspiError(C.Tspi_GetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_KEY_BLOB, C.TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY, &dataLen, &cData))
data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen))
C.Tspi_Co... | go | func (key *Key) GetPubKeyBlob() (pubkey []byte, err error) {
var dataLen C.UINT32
var cData *C.BYTE
err = tspiError(C.Tspi_GetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_KEY_BLOB, C.TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY, &dataLen, &cData))
data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen))
C.Tspi_Co... | [
"func",
"(",
"key",
"*",
"Key",
")",
"GetPubKeyBlob",
"(",
")",
"(",
"pubkey",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"dataLen",
"C",
".",
"UINT32",
"\n",
"var",
"cData",
"*",
"C",
".",
"BYTE",
"\n",
"err",
"=",
"tspiError",
"(",... | // GetPubKeyBlob returns the public half of the key in TPM blob format | [
"GetPubKeyBlob",
"returns",
"the",
"public",
"half",
"of",
"the",
"key",
"in",
"TPM",
"blob",
"format"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/key.go#L99-L106 |
141,884 | google/go-tspi | tspi/key.go | Unbind | func (key *Key) Unbind(data []byte) ([]byte, error) {
var encdata C.TSS_HENCDATA
var dataLen C.UINT32
var cData *C.BYTE
err := tspiError(C.Tspi_Context_CreateObject(key.context, C.TSS_OBJECT_TYPE_ENCDATA, C.TSS_ENCDATA_BIND, (*C.TSS_HOBJECT)(&encdata)))
if err != nil {
return nil, err
}
err = tspiError(C.Tsp... | go | func (key *Key) Unbind(data []byte) ([]byte, error) {
var encdata C.TSS_HENCDATA
var dataLen C.UINT32
var cData *C.BYTE
err := tspiError(C.Tspi_Context_CreateObject(key.context, C.TSS_OBJECT_TYPE_ENCDATA, C.TSS_ENCDATA_BIND, (*C.TSS_HOBJECT)(&encdata)))
if err != nil {
return nil, err
}
err = tspiError(C.Tsp... | [
"func",
"(",
"key",
"*",
"Key",
")",
"Unbind",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"encdata",
"C",
".",
"TSS_HENCDATA",
"\n",
"var",
"dataLen",
"C",
".",
"UINT32",
"\n",
"var",
"cData",
"*",
... | // Unbind decrypts data previously encrypted with this key | [
"Unbind",
"decrypts",
"data",
"previously",
"encrypted",
"with",
"this",
"key"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/key.go#L146-L169 |
141,885 | google/go-tspi | tspi/key.go | Seal | func (key *Key) Seal(data []byte, pcrs *PCRs) ([]byte, error) {
var encdata C.TSS_HENCDATA
var dataLen C.UINT32
var cData *C.BYTE
var pcrhandle C.TSS_HPCRS
if pcrs != nil {
pcrhandle = pcrs.handle
}
err := tspiError(C.Tspi_Context_CreateObject(key.context, C.TSS_OBJECT_TYPE_ENCDATA, C.TSS_ENCDATA_SEAL, (*C.T... | go | func (key *Key) Seal(data []byte, pcrs *PCRs) ([]byte, error) {
var encdata C.TSS_HENCDATA
var dataLen C.UINT32
var cData *C.BYTE
var pcrhandle C.TSS_HPCRS
if pcrs != nil {
pcrhandle = pcrs.handle
}
err := tspiError(C.Tspi_Context_CreateObject(key.context, C.TSS_OBJECT_TYPE_ENCDATA, C.TSS_ENCDATA_SEAL, (*C.T... | [
"func",
"(",
"key",
"*",
"Key",
")",
"Seal",
"(",
"data",
"[",
"]",
"byte",
",",
"pcrs",
"*",
"PCRs",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"encdata",
"C",
".",
"TSS_HENCDATA",
"\n",
"var",
"dataLen",
"C",
".",
"UINT32",
"\... | // Seal encrypts the data using the TPM such that it can only be decrypted
// when the TPM's PCR values match the values set on the provided PCRs
// object. If pcrs is nil, the data will be sealed to the TPM but may be
// decrypted regardless of platform state. | [
"Seal",
"encrypts",
"the",
"data",
"using",
"the",
"TPM",
"such",
"that",
"it",
"can",
"only",
"be",
"decrypted",
"when",
"the",
"TPM",
"s",
"PCR",
"values",
"match",
"the",
"values",
"set",
"on",
"the",
"provided",
"PCRs",
"object",
".",
"If",
"pcrs",
... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/key.go#L175-L203 |
141,886 | google/go-tspi | tspi/key.go | SetSignatureScheme | func (key *Key) SetSignatureScheme(scheme int) error {
return tspiError(C.Tspi_SetAttribUint32((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_KEY_INFO, C.TSS_TSPATTRIB_KEYINFO_SIGSCHEME, (C.UINT32)(scheme)))
} | go | func (key *Key) SetSignatureScheme(scheme int) error {
return tspiError(C.Tspi_SetAttribUint32((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_KEY_INFO, C.TSS_TSPATTRIB_KEYINFO_SIGSCHEME, (C.UINT32)(scheme)))
} | [
"func",
"(",
"key",
"*",
"Key",
")",
"SetSignatureScheme",
"(",
"scheme",
"int",
")",
"error",
"{",
"return",
"tspiError",
"(",
"C",
".",
"Tspi_SetAttribUint32",
"(",
"(",
"C",
".",
"TSS_HOBJECT",
")",
"(",
"key",
".",
"handle",
")",
",",
"C",
".",
"... | // SetSignatureScheme sets the signature scheme on a newly created key. The scheme parameter should be one of tspiconst.TSS_SS_RSASSAPKCS1V15_SHA1
// or tspiconst.TSS_SS_RSASSAPKCS1V15_DER | [
"SetSignatureScheme",
"sets",
"the",
"signature",
"scheme",
"on",
"a",
"newly",
"created",
"key",
".",
"The",
"scheme",
"parameter",
"should",
"be",
"one",
"of",
"tspiconst",
".",
"TSS_SS_RSASSAPKCS1V15_SHA1",
"or",
"tspiconst",
".",
"TSS_SS_RSASSAPKCS1V15_DER"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/key.go#L234-L236 |
141,887 | google/go-tspi | tspi/key.go | GenerateKey | func (key *Key) GenerateKey(wrapkey *Key) (err error) {
err = tspiError(C.Tspi_Key_CreateKey((C.TSS_HKEY)(key.handle), (C.TSS_HKEY)(wrapkey.handle), 0))
return err
} | go | func (key *Key) GenerateKey(wrapkey *Key) (err error) {
err = tspiError(C.Tspi_Key_CreateKey((C.TSS_HKEY)(key.handle), (C.TSS_HKEY)(wrapkey.handle), 0))
return err
} | [
"func",
"(",
"key",
"*",
"Key",
")",
"GenerateKey",
"(",
"wrapkey",
"*",
"Key",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"tspiError",
"(",
"C",
".",
"Tspi_Key_CreateKey",
"(",
"(",
"C",
".",
"TSS_HKEY",
")",
"(",
"key",
".",
"handle",
")",
... | // GenerateKey generates a key pair on the TPM, wrapping it with the provided
// key | [
"GenerateKey",
"generates",
"a",
"key",
"pair",
"on",
"the",
"TPM",
"wrapping",
"it",
"with",
"the",
"provided",
"key"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/key.go#L240-L243 |
141,888 | google/go-tspi | tspi/key.go | Certify | func (key *Key) Certify(certifykey *Key, challenge []byte) ([]byte, []byte, error) {
var validation C.TSS_VALIDATION
challengeHash := sha1.Sum(challenge[:])
validation.ulExternalDataLength = sha1.Size
validation.rgbExternalData = (*C.BYTE)(&challengeHash[0])
err := tspiError(C.Tspi_Key_CertifyKey((C.TSS_HKEY)(ke... | go | func (key *Key) Certify(certifykey *Key, challenge []byte) ([]byte, []byte, error) {
var validation C.TSS_VALIDATION
challengeHash := sha1.Sum(challenge[:])
validation.ulExternalDataLength = sha1.Size
validation.rgbExternalData = (*C.BYTE)(&challengeHash[0])
err := tspiError(C.Tspi_Key_CertifyKey((C.TSS_HKEY)(ke... | [
"func",
"(",
"key",
"*",
"Key",
")",
"Certify",
"(",
"certifykey",
"*",
"Key",
",",
"challenge",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"validation",
"C",
".",
"TSS_VALIDATION",
"\n\n",
... | // Certify signs the public key with another key held by the TPM | [
"Certify",
"signs",
"the",
"public",
"key",
"with",
"another",
"key",
"held",
"by",
"the",
"TPM"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/key.go#L246-L265 |
141,889 | google/go-tspi | tspi/key.go | AssignPolicy | func (key *Key) AssignPolicy(policy *Policy) error {
err := tspiError(C.Tspi_Policy_AssignToObject(policy.handle, (C.TSS_HOBJECT)(key.handle)))
return err
} | go | func (key *Key) AssignPolicy(policy *Policy) error {
err := tspiError(C.Tspi_Policy_AssignToObject(policy.handle, (C.TSS_HOBJECT)(key.handle)))
return err
} | [
"func",
"(",
"key",
"*",
"Key",
")",
"AssignPolicy",
"(",
"policy",
"*",
"Policy",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Policy_AssignToObject",
"(",
"policy",
".",
"handle",
",",
"(",
"C",
".",
"TSS_HOBJECT",
")",
"(",
"key... | // AssignPolicy assigns a TSS policy to the key. | [
"AssignPolicy",
"assigns",
"a",
"TSS",
"policy",
"to",
"the",
"key",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/key.go#L268-L271 |
141,890 | google/go-tspi | tspi/key.go | Close | func (key *Key) Close() error {
err := tspiError(C.Tspi_Context_CloseObject(key.context, key.handle))
return err
} | go | func (key *Key) Close() error {
err := tspiError(C.Tspi_Context_CloseObject(key.context, key.handle))
return err
} | [
"func",
"(",
"key",
"*",
"Key",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_CloseObject",
"(",
"key",
".",
"context",
",",
"key",
".",
"handle",
")",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Close closes the Key object. | [
"Close",
"closes",
"the",
"Key",
"object",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/key.go#L274-L277 |
141,891 | google/go-tspi | tspi/hash.go | Update | func (hash *Hash) Update(data []byte) error {
err := tspiError(C.Tspi_Hash_UpdateHashValue(hash.handle, (C.UINT32)(len(data)), (*C.BYTE)(&data[0])))
return err
} | go | func (hash *Hash) Update(data []byte) error {
err := tspiError(C.Tspi_Hash_UpdateHashValue(hash.handle, (C.UINT32)(len(data)), (*C.BYTE)(&data[0])))
return err
} | [
"func",
"(",
"hash",
"*",
"Hash",
")",
"Update",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Hash_UpdateHashValue",
"(",
"hash",
".",
"handle",
",",
"(",
"C",
".",
"UINT32",
")",
"(",
"len",
"(",... | // Update updates a TSS hash with the data provided. It returns an error on
// failure. | [
"Update",
"updates",
"a",
"TSS",
"hash",
"with",
"the",
"data",
"provided",
".",
"It",
"returns",
"an",
"error",
"on",
"failure",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/hash.go#L35-L38 |
141,892 | google/go-tspi | tspi/hash.go | Verify | func (hash *Hash) Verify(key *Key, signature []byte) error {
err := tspiError(C.Tspi_Hash_VerifySignature(hash.handle, key.handle, (C.UINT32)(len(signature)), (*C.BYTE)(&signature[0])))
return err
} | go | func (hash *Hash) Verify(key *Key, signature []byte) error {
err := tspiError(C.Tspi_Hash_VerifySignature(hash.handle, key.handle, (C.UINT32)(len(signature)), (*C.BYTE)(&signature[0])))
return err
} | [
"func",
"(",
"hash",
"*",
"Hash",
")",
"Verify",
"(",
"key",
"*",
"Key",
",",
"signature",
"[",
"]",
"byte",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Hash_VerifySignature",
"(",
"hash",
".",
"handle",
",",
"key",
".",
"handle... | // Verify checks whether a hash matches the signature signed with the
// provided key. It returns an error on failure. | [
"Verify",
"checks",
"whether",
"a",
"hash",
"matches",
"the",
"signature",
"signed",
"with",
"the",
"provided",
"key",
".",
"It",
"returns",
"an",
"error",
"on",
"failure",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/hash.go#L42-L45 |
141,893 | google/go-tspi | tspi/hash.go | SetValue | func (hash *Hash) SetValue(hashed []byte) error {
var data []byte
if hash.hashAlg == crypto.SHA1 {
data = hashed
} else {
prefix, ok := hashPrefixes[hash.hashAlg]
if !ok {
return errors.New("unsupported hash algorithm")
}
data = append(prefix, hashed...)
}
return tspiError(C.Tspi_Hash_SetHashValue(ha... | go | func (hash *Hash) SetValue(hashed []byte) error {
var data []byte
if hash.hashAlg == crypto.SHA1 {
data = hashed
} else {
prefix, ok := hashPrefixes[hash.hashAlg]
if !ok {
return errors.New("unsupported hash algorithm")
}
data = append(prefix, hashed...)
}
return tspiError(C.Tspi_Hash_SetHashValue(ha... | [
"func",
"(",
"hash",
"*",
"Hash",
")",
"SetValue",
"(",
"hashed",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"data",
"[",
"]",
"byte",
"\n",
"if",
"hash",
".",
"hashAlg",
"==",
"crypto",
".",
"SHA1",
"{",
"data",
"=",
"hashed",
"\n",
"}",
"else"... | // SetValue sets the value of the hash to the given bytes | [
"SetValue",
"sets",
"the",
"value",
"of",
"the",
"hash",
"to",
"the",
"given",
"bytes"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/hash.go#L60-L73 |
141,894 | google/go-tspi | tspi/hash.go | Sign | func (hash *Hash) Sign(key *Key) ([]byte, error) {
var dataLen C.UINT32
var cData *C.BYTE
err := tspiError(C.Tspi_Hash_Sign(hash.handle, key.handle, &dataLen, &cData))
data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen))
C.Tspi_Context_FreeMemory(hash.context, cData)
if err != nil {
return nil, err
}
... | go | func (hash *Hash) Sign(key *Key) ([]byte, error) {
var dataLen C.UINT32
var cData *C.BYTE
err := tspiError(C.Tspi_Hash_Sign(hash.handle, key.handle, &dataLen, &cData))
data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen))
C.Tspi_Context_FreeMemory(hash.context, cData)
if err != nil {
return nil, err
}
... | [
"func",
"(",
"hash",
"*",
"Hash",
")",
"Sign",
"(",
"key",
"*",
"Key",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"dataLen",
"C",
".",
"UINT32",
"\n",
"var",
"cData",
"*",
"C",
".",
"BYTE",
"\n",
"err",
":=",
"tspiError",
"(",
... | // Sign uses the provided key to create a signature. | [
"Sign",
"uses",
"the",
"provided",
"key",
"to",
"create",
"a",
"signature",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/hash.go#L76-L88 |
141,895 | google/go-tspi | tspi/hash.go | Close | func (hash *Hash) Close() error {
err := tspiError(C.Tspi_Context_CloseObject(hash.context, hash.handle))
return err
} | go | func (hash *Hash) Close() error {
err := tspiError(C.Tspi_Context_CloseObject(hash.context, hash.handle))
return err
} | [
"func",
"(",
"hash",
"*",
"Hash",
")",
"Close",
"(",
")",
"error",
"{",
"err",
":=",
"tspiError",
"(",
"C",
".",
"Tspi_Context_CloseObject",
"(",
"hash",
".",
"context",
",",
"hash",
".",
"handle",
")",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Close closes the Hash object. | [
"Close",
"closes",
"the",
"Hash",
"object",
"."
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tspi/hash.go#L91-L94 |
141,896 | google/go-tspi | tpmclient/tpmclient.go | GetEKCert | func (client *TPMClient) GetEKCert() (ekcert []byte, err error) {
var ekcertData EkcertResponse
ekresp, err := client.get(GetEKCertURL)
if err != nil {
return nil, fmt.Errorf("Can't obtain ekcert: %s", err)
}
defer ekresp.Body.Close()
body, err := ioutil.ReadAll(ekresp.Body)
if err != nil {
return nil, fmt.... | go | func (client *TPMClient) GetEKCert() (ekcert []byte, err error) {
var ekcertData EkcertResponse
ekresp, err := client.get(GetEKCertURL)
if err != nil {
return nil, fmt.Errorf("Can't obtain ekcert: %s", err)
}
defer ekresp.Body.Close()
body, err := ioutil.ReadAll(ekresp.Body)
if err != nil {
return nil, fmt.... | [
"func",
"(",
"client",
"*",
"TPMClient",
")",
"GetEKCert",
"(",
")",
"(",
"ekcert",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"ekcertData",
"EkcertResponse",
"\n\n",
"ekresp",
",",
"err",
":=",
"client",
".",
"get",
"(",
"GetEKCertURL",
"... | // GetEKCert obtains the Endorsement Key certificate from the client TPM. This
// is an X509 certificate containing the public half of the Endorsement Key
// and a signature chain chaining back to a vendor-issued signing certificate. | [
"GetEKCert",
"obtains",
"the",
"Endorsement",
"Key",
"certificate",
"from",
"the",
"client",
"TPM",
".",
"This",
"is",
"an",
"X509",
"certificate",
"containing",
"the",
"public",
"half",
"of",
"the",
"Endorsement",
"Key",
"and",
"a",
"signature",
"chain",
"cha... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tpmclient/tpmclient.go#L72-L91 |
141,897 | google/go-tspi | tpmclient/tpmclient.go | GenerateAIK | func (client *TPMClient) GenerateAIK() (aikpub []byte, aikblob []byte, err error) {
var aikData AikResponse
aikresp, err := client.post(GenerateAikURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("Can't generate AIK: %s", err)
}
defer aikresp.Body.Close()
body, err := ioutil.ReadAll(aikresp.Body)
if err ... | go | func (client *TPMClient) GenerateAIK() (aikpub []byte, aikblob []byte, err error) {
var aikData AikResponse
aikresp, err := client.post(GenerateAikURL, nil)
if err != nil {
return nil, nil, fmt.Errorf("Can't generate AIK: %s", err)
}
defer aikresp.Body.Close()
body, err := ioutil.ReadAll(aikresp.Body)
if err ... | [
"func",
"(",
"client",
"*",
"TPMClient",
")",
"GenerateAIK",
"(",
")",
"(",
"aikpub",
"[",
"]",
"byte",
",",
"aikblob",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"aikData",
"AikResponse",
"\n\n",
"aikresp",
",",
"err",
":=",
"client",
"... | // GenerateAIK requests that the TPM generate a new Attestation Identity Key.
// It returns an unencrypted copy of the public half of the AIK, along with
// a TSPI key blob encrypted by the TPM. | [
"GenerateAIK",
"requests",
"that",
"the",
"TPM",
"generate",
"a",
"new",
"Attestation",
"Identity",
"Key",
".",
"It",
"returns",
"an",
"unencrypted",
"copy",
"of",
"the",
"public",
"half",
"of",
"the",
"AIK",
"along",
"with",
"a",
"TSPI",
"key",
"blob",
"e... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tpmclient/tpmclient.go#L101-L123 |
141,898 | google/go-tspi | tpmclient/tpmclient.go | GenerateKey | func (client *TPMClient) GenerateKey(flags int) (keypub []byte, keyblob []byte, err error) {
var keyData KeyData
var keyResponse KeyResponse
keyData.KeyFlags = flags
request, err := json.Marshal(keyData)
if err != nil {
return nil, nil, fmt.Errorf("Can't construct request JSON: %s", err)
}
keyresp, err := cl... | go | func (client *TPMClient) GenerateKey(flags int) (keypub []byte, keyblob []byte, err error) {
var keyData KeyData
var keyResponse KeyResponse
keyData.KeyFlags = flags
request, err := json.Marshal(keyData)
if err != nil {
return nil, nil, fmt.Errorf("Can't construct request JSON: %s", err)
}
keyresp, err := cl... | [
"func",
"(",
"client",
"*",
"TPMClient",
")",
"GenerateKey",
"(",
"flags",
"int",
")",
"(",
"keypub",
"[",
"]",
"byte",
",",
"keyblob",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"keyData",
"KeyData",
"\n",
"var",
"keyResponse",
"KeyRespon... | // GenerateKey requests that the TPM generate a new keypair | [
"GenerateKey",
"requests",
"that",
"the",
"TPM",
"generate",
"a",
"new",
"keypair"
] | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tpmclient/tpmclient.go#L135-L164 |
141,899 | google/go-tspi | tpmclient/tpmclient.go | ValidateAIK | func (client *TPMClient) ValidateAIK(aikblob []byte, asymenc []byte, symenc []byte) (secret []byte, err error) {
var challenge ChallengeData
var response ChallengeResponse
challenge.AIK = aikblob
challenge.Asymenc = asymenc
challenge.Symenc = symenc
request, err := json.Marshal(challenge)
if err != nil {
ret... | go | func (client *TPMClient) ValidateAIK(aikblob []byte, asymenc []byte, symenc []byte) (secret []byte, err error) {
var challenge ChallengeData
var response ChallengeResponse
challenge.AIK = aikblob
challenge.Asymenc = asymenc
challenge.Symenc = symenc
request, err := json.Marshal(challenge)
if err != nil {
ret... | [
"func",
"(",
"client",
"*",
"TPMClient",
")",
"ValidateAIK",
"(",
"aikblob",
"[",
"]",
"byte",
",",
"asymenc",
"[",
"]",
"byte",
",",
"symenc",
"[",
"]",
"byte",
")",
"(",
"secret",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"challenge... | // ValidateAIK challenges the TPM to validate an AIK by using the provided
// key blob to decrypt a secret encrypted with the public half of the
// AIK. This will only be possible if the TPM is able to decrypt the
// encrypted key blob. The AIK is used to decrypt asymenc, which then
// provides the AES key used to enc... | [
"ValidateAIK",
"challenges",
"the",
"TPM",
"to",
"validate",
"an",
"AIK",
"by",
"using",
"the",
"provided",
"key",
"blob",
"to",
"decrypt",
"a",
"secret",
"encrypted",
"with",
"the",
"public",
"half",
"of",
"the",
"AIK",
".",
"This",
"will",
"only",
"be",
... | 115dea689aad055993e26f6423bf3cf800e732d7 | https://github.com/google/go-tspi/blob/115dea689aad055993e26f6423bf3cf800e732d7/tpmclient/tpmclient.go#L182-L209 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.