Module: Linzer::Key::Helper
- Included in:
- Linzer
- Defined in:
- lib/linzer/key/helper.rb
Instance Method Summary collapse
-
#generate_ecdsa_p256_sha256_key(key_id = nil) ⇒ Object
www.rfc-editor.org/rfc/rfc4492.html#appendix-A Table 6: Equivalent curves defined by SECG, ANSI, and NIST secp256r1 | prime256v1 | NIST P-256.
-
#generate_ecdsa_p384_sha384_key(key_id = nil) ⇒ Object
www.rfc-editor.org/rfc/rfc4492.html#appendix-A Table 6: Equivalent curves defined by SECG, ANSI, and NIST secp384r1 | | NIST P-384.
- #generate_ed25519_key(key_id = nil) ⇒ Object
-
#generate_hmac_sha256_key(key_id = nil) ⇒ Object
XXX: to-do Linzer::RSA::Key def new_rsa_v1_5_sha256_key def generate_rsa_v1_5_sha256_key.
- #generate_rsa_pss_sha512_key(size, key_id = nil) ⇒ Object
- #new_ecdsa_p256_sha256_key(material, key_id = nil) ⇒ Object
- #new_ecdsa_p384_sha384_key(material, key_id = nil) ⇒ Object
- #new_ed25519_key(material, key_id = nil) ⇒ Object
- #new_ed25519_public_key(material, key_id = nil) ⇒ Object
- #new_hmac_sha256_key(material, key_id = nil) ⇒ Object
- #new_rsa_pss_sha512_key(material, key_id = nil) ⇒ Object
- #new_rsa_pss_sha512_public_key(material, key_id = nil) ⇒ Object
Instance Method Details
#generate_ecdsa_p256_sha256_key(key_id = nil) ⇒ Object
www.rfc-editor.org/rfc/rfc4492.html#appendix-A Table 6: Equivalent curves defined by SECG, ANSI, and NIST secp256r1 | prime256v1 | NIST P-256
53 54 55 56 |
# File 'lib/linzer/key/helper.rb', line 53 def generate_ecdsa_p256_sha256_key(key_id = nil) material = OpenSSL::PKey::EC.generate("prime256v1") Linzer::ECDSA::Key.new(material, id: key_id, digest: "SHA256") end |
#generate_ecdsa_p384_sha384_key(key_id = nil) ⇒ Object
www.rfc-editor.org/rfc/rfc4492.html#appendix-A Table 6: Equivalent curves defined by SECG, ANSI, and NIST secp384r1 | | NIST P-384
66 67 68 69 |
# File 'lib/linzer/key/helper.rb', line 66 def generate_ecdsa_p384_sha384_key(key_id = nil) material = OpenSSL::PKey::EC.generate("secp384r1") Linzer::ECDSA::Key.new(material, id: key_id, digest: "SHA384") end |
#generate_ed25519_key(key_id = nil) ⇒ Object
35 36 37 38 |
# File 'lib/linzer/key/helper.rb', line 35 def generate_ed25519_key(key_id = nil) material = ::Ed25519::SigningKey.generate Linzer::Ed25519::Key.new(material, id: key_id) end |
#generate_hmac_sha256_key(key_id = nil) ⇒ Object
XXX: to-do Linzer::RSA::Key def new_rsa_v1_5_sha256_key def generate_rsa_v1_5_sha256_key
26 27 28 29 |
# File 'lib/linzer/key/helper.rb', line 26 def generate_hmac_sha256_key(key_id = nil) material = OpenSSL::Random.random_bytes(64) Linzer::HMAC::Key.new(material, id: key_id, digest: "SHA256") end |
#generate_rsa_pss_sha512_key(size, key_id = nil) ⇒ Object
6 7 8 9 |
# File 'lib/linzer/key/helper.rb', line 6 def generate_rsa_pss_sha512_key(size, key_id = nil) material = OpenSSL::PKey::RSA.generate(size) Linzer::RSA::Key.new(material, id: key_id, digest: "SHA512") end |
#new_ecdsa_p256_sha256_key(material, key_id = nil) ⇒ Object
58 59 60 61 |
# File 'lib/linzer/key/helper.rb', line 58 def new_ecdsa_p256_sha256_key(material, key_id = nil) key = OpenSSL::PKey::EC.new(material) Linzer::ECDSA::Key.new(key, id: key_id, digest: "SHA256") end |
#new_ecdsa_p384_sha384_key(material, key_id = nil) ⇒ Object
71 72 73 74 |
# File 'lib/linzer/key/helper.rb', line 71 def new_ecdsa_p384_sha384_key(material, key_id = nil) key = OpenSSL::PKey::EC.new(material) Linzer::ECDSA::Key.new(key, id: key_id, digest: "SHA384") end |
#new_ed25519_key(material, key_id = nil) ⇒ Object
40 41 42 43 |
# File 'lib/linzer/key/helper.rb', line 40 def new_ed25519_key(material, key_id = nil) key = ::Ed25519::SigningKey.new(material) Linzer::Ed25519::Key.new(key, id: key_id) end |
#new_ed25519_public_key(material, key_id = nil) ⇒ Object
45 46 47 48 |
# File 'lib/linzer/key/helper.rb', line 45 def new_ed25519_public_key(material, key_id = nil) key = ::Ed25519::VerifyKey.new(material) Linzer::Ed25519::Key.new(key, id: key_id) end |
#new_hmac_sha256_key(material, key_id = nil) ⇒ Object
31 32 33 |
# File 'lib/linzer/key/helper.rb', line 31 def new_hmac_sha256_key(material, key_id = nil) Linzer::HMAC::Key.new(material, id: key_id, digest: "SHA256") end |