From 1f283401008fdbed795cf21929cceab42ba0c2fa Mon Sep 17 00:00:00 2001 From: "Artyom V. Poptsov" Date: Thu, 24 Nov 2016 21:33:43 +0300 Subject: key.scm (get-key-type, get-public-key-hash): Deprecate * modules/ssh/key.scm (get-key-type, get-public-key-hash): Deprecate. * libguile-ssh/key-func.c (guile_ssh_key_get_type): Rename to 'gssh_key_type'. (guile_ssh_get_public_key_hash): Rename to 'gssh_public_key_hash'. (print_key): Update. * doc/api-keys.texi: Update. * NEWS: Update. * tests/key.scm ("public-key-hash"): New TC. --- NEWS | 6 ++++++ doc/api-keys.texi | 4 ++-- libguile-ssh/key-func.c | 11 +++-------- libguile-ssh/key-type.c | 9 ++------- libguile-ssh/key-type.h | 2 +- modules/ssh/key.scm | 33 +++++++++++++++++++++++++++++---- tests/key.scm | 3 +++ 7 files changed, 46 insertions(+), 22 deletions(-) diff --git a/NEWS b/NEWS index 9035441..c471768 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,12 @@ Copyright (C) Artyom V. Poptsov are permitted in any medium without royalty provided the copyright notice and this notice are preserved. +* Unreleased +** Deprecation +*** In (ssh key) + - 'get-key-type' (use 'key-type' instead) + - 'get-public-key-hash' (use 'public-key-hash' instead) + * Changes in version 0.10.2 (2016-11-25) ** New procedures *** New procedure 'channel-send-eof' in (ssh channel) diff --git a/doc/api-keys.texi b/doc/api-keys.texi index c718dbd..722e012 100644 --- a/doc/api-keys.texi +++ b/doc/api-keys.texi @@ -77,12 +77,12 @@ Read public key from a @var{file}. Return a public key or @code{#f} on error. @end deffn -@deffn {Scheme Procedure} get-key-type key +@deffn {Scheme Procedure} key-type key Get a symbol that represents the type of the Guile-SSH @var{key}. Possible types are: @code{dss}, @code{rsa}, @code{rsa1}, @code{unknown}. @end deffn -@deffn {Scheme Procedure} get-public-key-hash public-key type +@deffn {Scheme Procedure} public-key-hash public-key type @cindex fingerprint @tindex fingerprint Get a @var{public-key} hash of @var{type} as a bytevector. Return the diff --git a/libguile-ssh/key-func.c b/libguile-ssh/key-func.c index cfb3026..0a00c21 100644 --- a/libguile-ssh/key-func.c +++ b/libguile-ssh/key-func.c @@ -242,14 +242,9 @@ static struct symbol_mapping hash_types[] = { { NULL, -1 } }; -SCM_DEFINE (guile_ssh_get_public_key_hash, "get-public-key-hash", 2, 0, 0, - (SCM key, SCM type), - "\ -Get hash of the public KEY as a bytevector.\n\ -Possible types are: 'sha1, 'md5\n\ -Return a bytevector on success, #f on error.\ -") -#define FUNC_NAME s_guile_ssh_get_public_key_hash +SCM_GSSH_DEFINE (gssh_public_key_hash, "%gssh-public-key-hash", 2, + (SCM key, SCM type)) +#define FUNC_NAME s_gssh_public_key_hash { struct key_data *kd = _scm_to_key_data (key); unsigned char *hash = NULL; diff --git a/libguile-ssh/key-type.c b/libguile-ssh/key-type.c index 058ed06..acbec59 100644 --- a/libguile-ssh/key-type.c +++ b/libguile-ssh/key-type.c @@ -75,7 +75,7 @@ static int print_key (SCM smob, SCM port, scm_print_state *pstate) { struct key_data *key_data = _scm_to_key_data (smob); - SCM type = guile_ssh_key_get_type (smob); + SCM type = gssh_key_type (smob); scm_puts ("#ssh_key); diff --git a/libguile-ssh/key-type.h b/libguile-ssh/key-type.h index b3e1f68..46d0c33 100644 --- a/libguile-ssh/key-type.h +++ b/libguile-ssh/key-type.h @@ -41,7 +41,7 @@ extern SCM guile_ssh_is_key_p (SCM arg1); extern SCM guile_ssh_is_public_key_p (SCM arg1); extern SCM guile_ssh_is_private_key_p (SCM arg1); -extern SCM guile_ssh_key_get_type (SCM arg1); +extern SCM gssh_key_type (SCM arg1); extern void init_key_type (void); diff --git a/modules/ssh/key.scm b/modules/ssh/key.scm index 450c4ce..7146488 100644 --- a/modules/ssh/key.scm +++ b/modules/ssh/key.scm @@ -28,14 +28,14 @@ ;; public-key? ;; private-key? ;; make-keypair -;; get-key-type +;; key-type ;; public-key->string ;; string->pubilc-key ;; public-key-from-file ;; private-key->public-key ;; private-key-from-file ;; private-key-to-file -;; get-public-key-hash +;; public-key-hash ;; bytevector->hex-string @@ -50,14 +50,16 @@ public-key? private-key? make-keypair - get-key-type + key-type + get-key-type ; deprecated public-key->string string->public-key public-key-from-file private-key->public-key private-key-from-file private-key-to-file - get-public-key-hash + public-key-hash + get-public-key-hash ; deprecated bytevector->hex-string)) (define (bytevector->hex-string bv) @@ -66,6 +68,29 @@ (bytevector->u8-list bv)) ":")) + +(define (key-type key) + "Get a symbol that represents the type of the SSH key KEY. +Possible types are: 'dss, 'rsa, 'rsa1, 'ecdsa, 'unknown" + (%gssh-key-type key)) + +(define (get-key-type key) + (issue-deprecation-warning "'get-key-type' is deprecated. " + "Use 'key-type' instead.'") + (%gssh-key-type key)) + + +(define (public-key-hash key type) + "Get hash of the public KEY as a bytevector. Possible types are: 'sha1, +'md5. Return a bytevector on success, #f on error." + (%gssh-public-key-hash key type)) + +(define (get-public-key-hash key type) + (issue-deprecation-warning "'get-public-key-hash' is deprecated. " + "Use 'public-key-hash' instead.'") + (%gssh-public-key-hash key type)) + + (load-extension "libguile-ssh" "init_key") ;;; key.scm ends here. diff --git a/tests/key.scm b/tests/key.scm index c4394b1..4c91a2c 100644 --- a/tests/key.scm +++ b/tests/key.scm @@ -164,6 +164,9 @@ (and (key? key) (eq? (get-key-type key) 'ecdsa)))))) +(test-assert-with-log "public-key-hash" + (public-key-hash (make-keypair 'rsa 128) 'sha1)) + ;;; (test-end "key") -- cgit v1.2.3