Class: Keybase::Crypto
- Inherits:
-
Object
- Object
- Keybase::Crypto
- Defined in:
- lib/keybase/crypto.rb
Constant Summary collapse
- SCRYPT_VARS =
{'N' => 2**15, 'r' => 8, 'p' => 1, 'key_length' => 224, 'chunk' => 192..-1}
Class Method Summary collapse
Class Method Details
.hex2bin(hex) ⇒ Object
16 17 18 |
# File 'lib/keybase/crypto.rb', line 16 def self.hex2bin(hex) [hex].pack("H*") end |
.hmac_sha512(key, data) ⇒ Object
12 13 14 |
# File 'lib/keybase/crypto.rb', line 12 def self.hmac_sha512(key, data) OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA512.new, key, Base64.decode64(data)) end |
.scrypt(passphrase, salt) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/keybase/crypto.rb', line 5 def self.scrypt(passphrase, salt) SCrypt::Engine.scrypt(passphrase, hex2bin(salt), SCRYPT_VARS['N'], SCRYPT_VARS['r'], SCRYPT_VARS['p'], SCRYPT_VARS['key_length'] )[SCRYPT_VARS['chunk']] end |