Add methods to get key capabilities (#125)
* Add methods to get key capabilities Signed-off-by: Aditya Wasan <adityawasan55@gmail.com> * Use correct indetity to check for flags Signed-off-by: Aditya Wasan <adityawasan55@gmail.com> * Fix lint Signed-off-by: Aditya Wasan <adityawasan55@gmail.com> * Remove CanCertify and update CanSign to use SigningKey Signed-off-by: GitHub <noreply@github.com> * keyring: implement CanSign and CanEncrypt Signed-off-by: GitHub <noreply@github.com> * key/keyring: add tests for key capabilities Signed-off-by: GitHub <noreply@github.com> * Apply suggestions from code review Renames CanSign to CanVerify and adds an extended test for public-only keys to confirm CanVerify is true for them. Co-authored-by: wussler <aron@wussler.it> Co-authored-by: Harsh Shandilya <me@msfjarvis.dev> Co-authored-by: wussler <aron@wussler.it>
This commit is contained in:
parent
80b9a7aca2
commit
3dd1711707
4 changed files with 58 additions and 0 deletions
|
|
@ -251,6 +251,18 @@ func (key *Key) GetPublicKey() (b []byte, err error) {
|
|||
|
||||
// --- Key object properties
|
||||
|
||||
// CanVerify returns true if any of the subkeys can be used for verification.
|
||||
func (key *Key) CanVerify() bool {
|
||||
_, canVerify := key.entity.SigningKey(getNow())
|
||||
return canVerify
|
||||
}
|
||||
|
||||
// CanEncrypt returns true if any of the subkeys can be used for encryption.
|
||||
func (key *Key) CanEncrypt() bool {
|
||||
_, canEncrypt := key.entity.EncryptionKey(getNow())
|
||||
return canEncrypt
|
||||
}
|
||||
|
||||
// IsExpired checks whether the key is expired.
|
||||
func (key *Key) IsExpired() bool {
|
||||
_, ok := key.entity.EncryptionKey(getNow())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue