In lib/gpgme/key_common.rb, capability returns a list of the key's capabilities based on the can_{certify, sign, encrypt, authenticate} values, which are copied from the underlying GPGME gpgme_subkey_t and can be either 0 or 1, indicating false or true as is the convention in C.
Unfortunately, the conditionals in capability look like this: caps << :encrypt if @can_encrypt.
Since @can_encrypt is either 0 or 1, this always returns true because every value in Ruby is "true" except for false and nil. As a result, capability incorrectly reports that every subkey has all capabilities.
A pull request that fixes this issue was filed in 2013, #29, but it appears to have been accidentally closed and was never merged. It has the correct fix and looks like it's still merge-able, so hopefully this should be exceptionally easy to resolve!
In
lib/gpgme/key_common.rb
,capability
returns a list of the key's capabilities based on thecan_{certify, sign, encrypt, authenticate}
values, which are copied from the underlying GPGMEgpgme_subkey_t
and can be either 0 or 1, indicating false or true as is the convention in C.Unfortunately, the conditionals in
capability
look like this:caps << :encrypt if @can_encrypt
.Since
@can_encrypt
is either 0 or 1, this always returns true because every value in Ruby is "true" except forfalse
andnil
. As a result,capability
incorrectly reports that every subkey has all capabilities.A pull request that fixes this issue was filed in 2013, #29, but it appears to have been accidentally closed and was never merged. It has the correct fix and looks like it's still merge-able, so hopefully this should be exceptionally easy to resolve!