Merge pull request #698 from Chilledheart/remove_duplcated_code

[lib] remove duplicated code in rsa.c
[server] correct usage of g_strndup

  - g_strndup will always allocate a n+1 bytes string, and terminate it by NULL.
  - there is no need for manually doing this.
  - see more at glib's source (glib/gstrfuncs.c)
  - see more at glib's document
    https://developer.gnome.org/glib/2.28/glib-String-Utility-Functions.html
Merge pull request #703 from Chilledheart/correct_usage_of_g_strndup

[server] correct usage of g_strndup
[server] Add cache support for repo