class

Nanvault::Crypto

Inherits Reference / Object

Crypto class

Constants

AES_BLOCK_SIZE = 16
CIPHER_ALG_DEFAULT = "aes-256-ctr"
HMAC_ALG = OpenSSL::Algorithm::SHA256
MAX_CHAR = 126
MIN_CHAR = 33

password generation constants alphabet is made up of chars corresponding to ints between these values

PBKDF2_ALG = OpenSSL::Algorithm::SHA256
PBKDF2_ITERATIONS = 10000
PBKDF2_KEY_SIZE = 80

Class methods

check_hmac(data, key, exp_hmac)

class method to check HMAC

Source
decrypt(cipher_iv, cipher_key, ciphertext, algorithm = CIPHER_ALG_DEFAULT)

class method to decrypt ciphertext

Source
encrypt(cipher_iv, cipher_key, plaintext, algorithm = CIPHER_ALG_DEFAULT)

class method to encrypt plaintext

Source
genpass

class method to generate a random, safe password

Source
get_keys_iv(salt, password)

class method to get cipher key, HMAC key and cipher IV

Source

Macros

get_safe_pass_len(n)

get safe password length macro calculates password length to get at least n bit security NOTE: the "-1" is there because Random::Secure.rand(k) returns numbers from 0 to k-1

Source