Unify CKMLogic methods and fix PKCS12 support
Add helper functions for frequently repeated code (input parameter
checks, database selection, permission checks, hash calculation,
transaction start)
Fixed object Id is calculated from uid, pkg_id & alias. PKCS12
components are stored under common alias differing only by type. As a
result, all PKCS12 components are saved with identical object id which
may lead to conflicts.
For PKCS12 add type information as hash function input.
Change-Id: Id54c5eb4e0ad5b3521f2661df64619316cf4a9ea