forked from jsipprell/keyctl
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jiacfan/dev
Create slim version of keyctl with basic keyring operations for session keyring.
- Loading branch information
Showing
17 changed files
with
13 additions
and
1,176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,7 @@ | ||
branches: | ||
only: | ||
- master | ||
language: go | ||
go: | ||
- 1.4 | ||
- 1.5 | ||
- 1.6 | ||
- tip | ||
- 1.10 | ||
install: | ||
- go get golang.org/x/crypto/openpgp | ||
- go get golang.org/x/crypto/cast5 | ||
- go get golang.org/x/crypto/ssh/terminal | ||
- go get golang.org/x/tools/cmd/cover | ||
- go build -v ./... | ||
script: | ||
- go test -v -cover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,3 @@ | ||
[![GoDoc](https://godoc.org/github.com/jsipprell/keyctl?status.svg)](https://godoc.org/github.com/jsipprell/keyctl) | ||
[![Build Status](https://travis-ci.org/jsipprell/keyctl.svg?branch=master)](https://travis-ci.org/jsipprell/keyctl) | ||
|
||
# keyctl | ||
|
||
A native Go API for the security key management system (aka "keyrings") found in Linux 2.6+ | ||
|
||
The keyctl interface is nominally provided by three or so Linux-specific syscalls, however it is almost always wrapped | ||
in a library named `libkeyutils.so`. | ||
|
||
This package interacts directly with the syscall interface and does not require CGO for linkage to the helper library | ||
provided on most systems. | ||
|
||
## Example Usages | ||
|
||
To access the default session keyring (and create it if it doesn't exist) | ||
|
||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"log" | ||
"github.com/jsipprell/keyctl" | ||
) | ||
|
||
func main() { | ||
keyring, err := keyctl.SessionKeyring() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// default timeout of 10 seconds for new or updated keys | ||
keyring.SetDefaultTimeout(10) | ||
secureData := []byte{1,2,3,4} | ||
id, err := keyring.Add("some-data", secureData) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Printf("created session key id %v", id) | ||
} | ||
``` | ||
|
||
To search for an existing key by name: | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"log" | ||
"github.com/jsipprell/keyctl" | ||
) | ||
|
||
func main() { | ||
keyring, err := keyctl.SessionKeyring() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
key, err := keyring.Search("some-data") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
data, err := key.Get() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Printf("secure data: %v\n", data) | ||
} | ||
``` | ||
Slim version of `github.com/jsipprell/keyctl` with basic keyring operations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.