aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-06-02 17:41:35 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-06-02 17:41:35 +0200
commit76415c40ddb0487983dc655524db214e067e8d79 (patch)
tree39c08f9055e284d40bce09d8b76db2212391a5dc
parent1f8fbd0ad96393b3f07f360423d43ac8875a2a60 (diff)
Default keysize 2048
-rw-r--r--crypto.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto.go b/crypto.go
index c3771da..b42f147 100644
--- a/crypto.go
+++ b/crypto.go
@@ -80,6 +80,10 @@ func LoadCerts(r io.Reader) ([]*x509.Certificate, error) {
return x509.ParseCertificates(block.Bytes)
}
+// NewKey generates a new private key, supported keysizes are:
+// EC keys: 224, 256, 384, 521
+// RSA keys: 1024, 1536, 2048, 4096, 8192
+// Default key: 2048 RSA (when size of 0 is provided)
func NewKey(size int) (crypto.PrivateKey, error) {
switch size {
case 224:
@@ -92,6 +96,8 @@ func NewKey(size int) (crypto.PrivateKey, error) {
return ecdsa.GenerateKey(elliptic.P521(), rand.Reader)
case 1024, 1536, 2048, 4096, 8192:
return rsa.GenerateKey(rand.Reader, size)
+ case 0:
+ return rsa.GenerateKey(rand.Reader, 2048)
default:
return nil, ErrKeySize
}