-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bdfde5
commit af490d5
Showing
12 changed files
with
723 additions
and
208 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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
* Mon Nov 20 2017 cornfeedhobo 0.2.0 | ||
- Refactor key management to a struct-based approach | ||
- Drop printing to stdout and switch to writing files like OpenSSH's ssh-keygen | ||
- Refactor resource names | ||
- Style clean up | ||
- Add configurable work factor | ||
- Add tests | ||
|
||
* Sun Nov 12 2017 cornfeedhobo 0.1.0 | ||
- initial draft |
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,32 +1,52 @@ | ||
ssh-keydgen [![Travis](https://img.shields.io/travis/cornfeedhobo/ssh-keydgen.svg)]() [![Github All Releases](https://img.shields.io/github/downloads/cornfeedhobo/ssh-keydgen/total.svg)]() | ||
=========== | ||
|
||
Generate _Deterministic_ SSH keys | ||
|
||
## Usage | ||
Generate _Deterministic_ SSH keys | ||
|
||
```text | ||
NAME: | ||
ssh-keydgen - deterministic authentication key generation | ||
ssh-keydgen - Deterministic authentication key generation | ||
USAGE: | ||
ssh-keydgen [-t] [-b] [-c] [-o] [-a] | ||
ssh-keydgen [-t] [-b] [-c] [-n] [-f] [-a] | ||
AUTHOR: | ||
cornfeedhobo | ||
OPTIONS: | ||
-t type Specifies the type of key to create. The possible values are “dsa”, “ecdsa”, “ed25519”, or “rsa”. (default: "ed25519") | ||
-b bits Specifies the number of bits in the key to create. Possible values are restricted by key type. (default: 2048) | ||
-c curve Specifies the elliptic curve to use. The possible values are 256, 384, or 521. (default: 256) | ||
-o path Specifies the path to output the generated key. | ||
-a Add the generated key to the running ssh-agent. | ||
-t type Specifies the type of key to create. The possible values are "dsa", "ecdsa", "rsa", or "ed25519". (default: "ed25519") | ||
-b bits Specifies the number of bits in the key to create. Possible values are restricted by key type. (default: 2048) | ||
-c curve Specifies the elliptic curve to use. The possible values are 256, 384, or 521. (default: 256) | ||
-n factor Specifies the work factor, or "difficulty", applied to the key generation function. (default: 16384) | ||
-f filename Specifies the filename of the key file. | ||
-a Add the generated key to the running ssh-agent. | ||
COPYRIGHT: | ||
(c) 2017 cornfeedhobo | ||
``` | ||
|
||
|
||
|
||
## Usage | ||
|
||
1) Generate your keys | ||
```bash | ||
keydgen -f deterministic_key | ||
ls -lh deterministic_key* | ||
``` | ||
|
||
2) Allow time to pass, hoping an emergency does not arise when you have no access to your keys ... | ||
|
||
_If_ the time comes where you need access but can't get to your keys, you can then obtain this | ||
utility and re-generate, or even directly add your key to a running `ssh-agent`. | ||
```bash | ||
keydgen -a | ||
``` | ||
3) Profit! | ||
## Is it any good? | ||
[Yes](http://news.ycombinator.com/item?id=3067434) | ||
[Yes](http://news.ycombinator.com/item?id=3067434) |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/sha512" | ||
|
||
"golang.org/x/crypto/ripemd160" | ||
"golang.org/x/crypto/scrypt" | ||
) | ||
|
||
var WorkFactor int | ||
|
||
type Deterministic struct { | ||
seed []byte | ||
salt []byte | ||
} | ||
|
||
func (d *Deterministic) Read(p []byte) (int, error) { | ||
|
||
var sha = sha512.New() | ||
if _, err := sha.Write(d.seed); err != nil { | ||
return 0, err | ||
} | ||
d.seed = sha.Sum(nil) | ||
|
||
var ripe = ripemd160.New() | ||
if _, err := ripe.Write(d.salt); err != nil { | ||
return 0, err | ||
} | ||
d.salt = ripe.Sum(nil) | ||
|
||
dk, err := scrypt.Key(d.seed, d.salt, WorkFactor, 8, 1, len(p)) | ||
if err != nil { | ||
return 0, err | ||
} | ||
return copy(p, dk), nil | ||
|
||
} |
Oops, something went wrong.