key.scm 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ;;; key.scm -- SSH keys management.
  2. ;; Copyright (C) 2013, 2014 Artyom V. Poptsov <poptsov.artyom@gmail.com>
  3. ;;
  4. ;; This file is a part of Guile-SSH.
  5. ;;
  6. ;; Guile-SSH is free software: you can redistribute it and/or
  7. ;; modify it under the terms of the GNU General Public License as
  8. ;; published by the Free Software Foundation, either version 3 of the
  9. ;; License, or (at your option) any later version.
  10. ;;
  11. ;; Guile-SSH is distributed in the hope that it will be useful, but
  12. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. ;; General Public License for more details.
  15. ;;
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with Guile-SSH. If not, see <http://www.gnu.org/licenses/>.
  18. ;;; Commentary:
  19. ;; This module contains API that is used for SSH key management.
  20. ;;
  21. ;; These methods are exported:
  22. ;;
  23. ;; key?
  24. ;; public-key?
  25. ;; private-key?
  26. ;; make-keypair
  27. ;; get-key-type
  28. ;; public-key->string
  29. ;; string->pubilc-key
  30. ;; public-key-from-file
  31. ;; private-key->public-key
  32. ;; private-key-from-file
  33. ;; private-key-to-file
  34. ;; get-public-key-hash
  35. ;; bytevector->hex-string
  36. ;;; Code:
  37. (define-module (ssh key)
  38. #:use-module (ice-9 format)
  39. #:use-module (rnrs bytevectors)
  40. #:use-module (ssh log)
  41. #:export (key
  42. key?
  43. public-key?
  44. private-key?
  45. make-keypair
  46. get-key-type
  47. public-key->string
  48. string->public-key
  49. public-key-from-file
  50. private-key->public-key
  51. private-key-from-file
  52. private-key-to-file
  53. get-public-key-hash
  54. bytevector->hex-string))
  55. (define (bytevector->hex-string bv)
  56. "Convert bytevector BV to a colon separated hex string."
  57. (string-join (map (lambda (e) (format #f "~2,'0x" e))
  58. (bytevector->u8-list bv))
  59. ":"))
  60. (load-extension "libguile-ssh" "init_key")
  61. ;;; key.scm ends here.