sm: move SM common crypto procedures to the dedicated library