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