Add crypto utilities for encryption feature.
Fixed bugs related to wrong assert's conditions.