coreapi: key tests
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@ed5f040416bbc6a72008cf3c9f299c47da6f42f1 This commit was moved from ipfs/boxo@6527d6e06318ce93a01a40d769225f9ad4fce6b2
Łukasz Magiera committed
Jan 1, 2018 at 18:59 UTC
89776d9be77cc98652446551a29bcce5b4aba89c
2 files changed
+7
-5
core/coreiface/interface.go
+3
-3
@@ -148,13 +148,13 @@ type KeyAPI interface {
148
// name and returns a base58 encoded multihash of it's public key
149
Generate(ctx context.Context, name string, opts ...options.KeyGenerateOption) (Key, error)
150
151
- // WithAlgorithm is an option for Generate which specifies which algorithm
151
+ // WithType is an option for Generate which specifies which algorithm
152
// should be used for the key. Default is options.RSAKey
153
//
154
- // Supported algorithms:
154
+ // Supported key types:
155
// * options.RSAKey
156
// * options.Ed25519Key
157
- WithAlgorithm(algorithm string) options.KeyGenerateOption
157
+ WithType(algorithm string) options.KeyGenerateOption
158
159
// WithSize is an option for Generate which specifies the size of the key to
160
// generated. Default is 0
core/coreiface/options/key.go
+4
-2
@@ -3,6 +3,8 @@ package options
3
const (
4
RSAKey = "rsa"
5
Ed25519Key = "ed25519"
6
+
7
+ DefaultRSALen = 2048
8
)
9
10
type KeyGenerateSettings struct {
@@ -20,7 +22,7 @@ type KeyRenameOption func(*KeyRenameSettings) error
22
func KeyGenerateOptions(opts ...KeyGenerateOption) (*KeyGenerateSettings, error) {
23
options := &KeyGenerateSettings{
24
Algorithm: RSAKey,
23
- Size: 0,
25
+ Size: -1,
26
}
27
28
for _, opt := range opts {
@@ -48,7 +50,7 @@ func KeyRenameOptions(opts ...KeyRenameOption) (*KeyRenameSettings, error) {
50
51
type KeyOptions struct{}
52
51
-func (api *KeyOptions) WithAlgorithm(algorithm string) KeyGenerateOption {
53
+func (api *KeyOptions) WithType(algorithm string) KeyGenerateOption {
54
return func(settings *KeyGenerateSettings) error {
55
settings.Algorithm = algorithm
56
return nil