rnpgp / ruby-rnp

Ruby bindings for librnp
https://www.rnpgp.org
MIT License
7 stars 3 forks source link

Add non-JSON key generation #54

Closed dewyatt closed 5 years ago

codecov[bot] commented 5 years ago

Codecov Report

Merging #54 into master will increase coverage by 0.1%. The diff coverage is 99.68%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #54     +/-   ##
=========================================
+ Coverage    99.2%   99.31%   +0.1%     
=========================================
  Files          27       35      +8     
  Lines        2266     2908    +642     
=========================================
+ Hits         2248     2888    +640     
- Misses         18       20      +2
Impacted Files Coverage Δ
lib/rnp/misc.rb 100% <ø> (ø) :arrow_up:
lib/rnp/ffi/librnp.rb 99.24% <ø> (ø) :arrow_up:
spec/generate_spec.rb 100% <100%> (ø)
spec/generate_sm2_spec.rb 100% <100%> (ø)
spec/generate_ecdsa_ecdh_spec.rb 100% <100%> (ø)
spec/generate_dsa_elg_spec.rb 100% <100%> (ø)
spec/generate_rsa_spec.rb 100% <100%> (ø)
spec/rnp_spec.rb 100% <100%> (ø) :arrow_up:
lib/rnp/rnp.rb 98.33% <100%> (+0.34%) :arrow_up:
spec/generate_eddsa_25519_spec.rb 100% <100%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5b92098...98187d3. Read the comment docs.

dewyatt commented 5 years ago

@ronaldtse @ribose-jeffreylau Any opinions on whether I should get rid of Generate#options= (and similar)? I expected codeclimate to object to it but included it as a shortcut because we have similar shortcuts for Sign, etc.

They just let you do something like:

op.options = {
  bits: 2048,
  hash: :sm3,
  usage: :sign,
  s2k_cipher: :sm4,
  preferences: {
    hashes: %i[sm3 sha512 sha256],
    ciphers: %i[sm4 cast5],
    key_server: 'hkp://pgp.mit.edu',
  }
}

Rather than:

op.bits = 2048
op.hash = :sm3
op.usage = :sign
op.s2k_hash = :sm3
op.preferences = {
  hashes: %i[sha512 sha256],
  ciphers: %i[sm4 cast5],
  key_server: 'hkp://pgp.mit.edu'
}

However, the user can always achieve something similar with:

{
  bits: 2048,
  hash: :sm3,
  usage: :sign,
  s2k_cipher: :sm4,
  preferences: {
    hashes: %i[sm3 sha512 sha256],
    ciphers: %i[sm4 cast5],
    key_server: 'hkp://pgp.mit.edu',
  }
}.each do |key, value|
  op.send("#{key}=", value)
end

So I'm not sure if it's worth it. What do you guys think?

ronaldtse commented 5 years ago

@dewyatt I think being able to set parameters via hash has its benefits, I wouldn't worry so much about CodeClimate. :wink:

dewyatt commented 5 years ago

@ronaldtse Roger that, thanks!