Add ToPublic method to get a public key object from a private key (#65)
This commit is contained in:
parent
48f05401ce
commit
979fdb3f4b
3 changed files with 36 additions and 0 deletions
|
|
@ -389,3 +389,19 @@ func TestGetEntity(t *testing.T) {
|
|||
assert.True(t, entity.PrimaryIdentity().SelfSignature.FlagsValid)
|
||||
assert.IsType(t, &openpgp.Entity{}, entity)
|
||||
}
|
||||
|
||||
func TestToPublic(t *testing.T) {
|
||||
privateKey, err := NewKeyFromArmored(readTestFile("keyring_privateKey", false))
|
||||
if err != nil {
|
||||
t.Fatal("Cannot unarmor key:", err)
|
||||
}
|
||||
assert.True(t, privateKey.IsPrivate())
|
||||
|
||||
publicKey, err := privateKey.ToPublic()
|
||||
if err != nil {
|
||||
t.Fatal("Cannot make key public:", err)
|
||||
}
|
||||
|
||||
assert.False(t, publicKey.IsPrivate())
|
||||
assert.True(t, privateKey.IsPrivate())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue