Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
interface-go-dms3-core
Commits
ed5f0404
Commit
ed5f0404
authored
Jan 01, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coreapi: key tests
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
8f7e0241
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
interface.go
interface.go
+3
-3
options/key.go
options/key.go
+4
-2
No files found.
interface.go
View file @
ed5f0404
...
...
@@ -148,13 +148,13 @@ type KeyAPI interface {
// name and returns a base58 encoded multihash of it's public key
Generate
(
ctx
context
.
Context
,
name
string
,
opts
...
options
.
KeyGenerateOption
)
(
Key
,
error
)
// With
Algorithm
is an option for Generate which specifies which algorithm
// With
Type
is an option for Generate which specifies which algorithm
// should be used for the key. Default is options.RSAKey
//
// Supported
algorithm
s:
// Supported
key type
s:
// * options.RSAKey
// * options.Ed25519Key
With
Algorithm
(
algorithm
string
)
options
.
KeyGenerateOption
With
Type
(
algorithm
string
)
options
.
KeyGenerateOption
// WithSize is an option for Generate which specifies the size of the key to
// generated. Default is 0
...
...
options/key.go
View file @
ed5f0404
...
...
@@ -3,6 +3,8 @@ package options
const
(
RSAKey
=
"rsa"
Ed25519Key
=
"ed25519"
DefaultRSALen
=
2048
)
type
KeyGenerateSettings
struct
{
...
...
@@ -20,7 +22,7 @@ type KeyRenameOption func(*KeyRenameSettings) error
func
KeyGenerateOptions
(
opts
...
KeyGenerateOption
)
(
*
KeyGenerateSettings
,
error
)
{
options
:=
&
KeyGenerateSettings
{
Algorithm
:
RSAKey
,
Size
:
0
,
Size
:
-
1
,
}
for
_
,
opt
:=
range
opts
{
...
...
@@ -48,7 +50,7 @@ func KeyRenameOptions(opts ...KeyRenameOption) (*KeyRenameSettings, error) {
type
KeyOptions
struct
{}
func
(
api
*
KeyOptions
)
With
Algorithm
(
algorithm
string
)
KeyGenerateOption
{
func
(
api
*
KeyOptions
)
With
Type
(
algorithm
string
)
KeyGenerateOption
{
return
func
(
settings
*
KeyGenerateSettings
)
error
{
settings
.
Algorithm
=
algorithm
return
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment