[PATCH v8 13/27] x509: move common functions to x509 helper