lib/r509/cert/extensions/key_usage.rb in r509-0.10.0 vs lib/r509/cert/extensions/key_usage.rb in r509-1.0
- old
+ new
@@ -67,11 +67,11 @@
# R509::Cert::Extensions::KeyUsage.new(
# :critical => false,
# :value => ['digitalSignature,'keyEncipherment']
# )
def initialize(arg)
- if not R509::Cert::Extensions.is_extension?(arg)
+ unless R509::Cert::Extensions.is_extension?(arg)
arg = build_extension(arg)
end
super(arg)
parse_extension
@@ -79,12 +79,12 @@
# Returns true if the given use is allowed by this extension.
# @param [String] friendly_use_name key usage short name (e.g. digitalSignature, cRLSign, etc)
# or one of the AU_* constants in this class
# @return [Boolean]
- def allows?( friendly_use_name )
- @allowed_uses.include?( friendly_use_name )
+ def allows?(friendly_use_name)
+ @allowed_uses.include?(friendly_use_name)
end
def digital_signature?
(@digital_signature == true)
end
@@ -138,11 +138,11 @@
def build_extension(arg)
validate_usage(arg)
ef = OpenSSL::X509::ExtensionFactory.new
critical = R509::Cert::Extensions.calculate_critical(arg[:critical], false)
- return ef.create_extension("keyUsage", arg[:value].join(","),critical)
+ ef.create_extension("keyUsage", arg[:value].join(","), critical)
end
def parse_extension
@allowed_uses = []
data = R509::ASN1.get_extension_payload(self)
@@ -150,10 +150,10 @@
# There are 9 possible bits, which means we need 2 bytes
# to represent them all. When the last bit is not set
# the second byte is not encoded. let's add it back so we can
# have the full bitmask for comparison
if data.size == 1
- data = data + "\0"
+ data += "\0"
end
bit_mask = data.unpack('n')[0] # treat it as a 16-bit unsigned big endian
# KeyUsage ::= BIT STRING {
# digitalSignature (0),
# nonRepudiation (1), -- recent editions of X.509 have