class Nanvault::Crypto

Overview

Crypto class

Defined in:

nanvault.cr

Constant Summary

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 Method Summary

Macro Summary

Class Method Detail

def self.check_hmac(data, key, exp_hmac) #

class method to check HMAC


[View source]
def self.decrypt(cipher_iv, cipher_key, ciphertext, algorithm = CIPHER_ALG_DEFAULT) #

class method to decrypt ciphertext


[View source]
def self.encrypt(cipher_iv, cipher_key, plaintext, algorithm = CIPHER_ALG_DEFAULT) #

class method to encrypt plaintext


[View source]
def self.genpass #

class method to generate a random, safe password


[View source]
def self.get_keys_iv(salt, password) #

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


[View source]

Macro Detail

macro 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


[View source]