Exemple #1
0
 def unwrapkey(self, password, wrapped ):
     """decrypt the key encrypted by the password-derived key 
     """
     salt = wrapped[:SALT_SIZE]
     payload = wrapped[SALT_SIZE:]
     kek = derive_key(password,salt,self.box.KEY_SIZE)
     sbox = self.box(kek)
     return sbox.decrypt(payload)
Exemple #2
0
 def wrapkey(self, password, key ):
     """encrypt a key using a password-derived key
     """
     salt = self.random(SALT_SIZE)
     kek = derive_key(password,salt,self.box.KEY_SIZE)
     sbox = self.box(kek)
     nonce = self.random(sbox.NONCE_SIZE)
     payload = sbox.encrypt(key,nonce)
     return salt+payload
Exemple #3
0
def check_badalgorithm(pw):
    try:
        k = derive_key(pw, SALT, 16)
        assert False, "{} should not be valid".format(pw)
    except RuntimeError:
        pass
Exemple #4
0
def test_bcrypt():
    k = derive_key("@aaa", SALT, 16)
Exemple #5
0
def test_scrypt():
    k = derive_key("`aaa", SALT, 16)
Exemple #6
0
def test_pbkdf2():
    k = derive_key(" aaa", SALT, 16)
Exemple #7
0
def check_badalgorithm(pw):
    try:
        k = derive_key(pw, SALT, 16)
        assert False, "{} should not be valid".format(pw)
    except RuntimeError:
        pass
Exemple #8
0
def test_scrypt():
    k = derive_key("`aaa", SALT, 16)
Exemple #9
0
def test_bcrypt():
    k = derive_key("@aaa", SALT, 16)
Exemple #10
0
def test_pbkdf2():
    k = derive_key(" aaa", SALT, 16)