def pbkdf2_hmac(space, name, password, salt, rounds, w_dklen): digest = ropenssl.EVP_get_digestbyname(name) if not digest: raise oefmt(space.w_ValueError, "unknown hash function") if space.is_w(w_dklen, space.w_None): dklen = ropenssl.EVP_MD_size(digest) else: dklen = space.int_w(w_dklen) if dklen < 1: raise oefmt(space.w_ValueError, "key length must be greater than 0.") with rffi.scoped_alloc_buffer(dklen) as buf: r = ropenssl.PKCS5_PBKDF2_HMAC(password, len(password), salt, len(salt), rounds, digest, dklen, buf.raw) if not r: raise ValueError return space.newbytes(buf.str(dklen))
def digest_type_by_name(self, space): digest_type = ropenssl.EVP_get_digestbyname(self.name) if not digest_type: raise oefmt(space.w_ValueError, "unknown hash function") return digest_type
def digest_type_by_name(self, space): digest_type = ropenssl.EVP_get_digestbyname(self.name) if not digest_type: raise OperationError(space.w_ValueError, space.wrap("unknown hash function")) return digest_type