-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crypto/openpgp: make it possible to set the key length
Fixes golang/go#6693. Change-Id: I7322e107bd5f7ad07062dcaadeaa3e85a101015a Reviewed-on: https://go-review.googlesource.com/12473 Reviewed-by: Adam Langley <[email protected]> Run-TryBot: Adam Langley <[email protected]>
- Loading branch information
Showing
3 changed files
with
35 additions
and
2 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
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 |
---|---|---|
|
@@ -10,6 +10,8 @@ import ( | |
"io/ioutil" | ||
"testing" | ||
"time" | ||
|
||
"golang.org/x/crypto/openpgp/packet" | ||
) | ||
|
||
func TestSignDetached(t *testing.T) { | ||
|
@@ -53,11 +55,34 @@ func TestNewEntity(t *testing.T) { | |
return | ||
} | ||
|
||
// Check bit-length with no config. | ||
e, err := NewEntity("Test User", "test", "[email protected]", nil) | ||
if err != nil { | ||
t.Errorf("failed to create entity: %s", err) | ||
return | ||
} | ||
bl, err := e.PrimaryKey.BitLength() | ||
if err != nil { | ||
t.Errorf("failed to find bit length: %s", err) | ||
} | ||
if int(bl) != defaultRSAKeyBits { | ||
t.Errorf("BitLength %v, expected %v", defaultRSAKeyBits) | ||
} | ||
|
||
// Check bit-length with a config. | ||
cfg := &packet.Config{RSABits: 1024} | ||
e, err = NewEntity("Test User", "test", "[email protected]", cfg) | ||
if err != nil { | ||
t.Errorf("failed to create entity: %s", err) | ||
return | ||
} | ||
bl, err = e.PrimaryKey.BitLength() | ||
if err != nil { | ||
t.Errorf("failed to find bit length: %s", err) | ||
} | ||
if int(bl) != cfg.RSABits { | ||
t.Errorf("BitLength %v, expected %v", bl, cfg.RSABits) | ||
} | ||
|
||
w := bytes.NewBuffer(nil) | ||
if err := e.SerializePrivate(w, nil); err != nil { | ||
|