aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/test/ssh_key_cb.erl
diff options
context:
space:
mode:
authorVipin Nair <[email protected]>2015-11-13 18:51:03 +0530
committerVipin Nair <[email protected]>2015-12-01 22:56:03 +0530
commite14b301be3b5593a13e666885ca795e6bee54b5b (patch)
tree988f0b65a39d599e19bd10cf6aec9af042f4b408 /lib/ssh/test/ssh_key_cb.erl
parent417101bca30b5ae246b97485c7898c4e5c663b9c (diff)
downloadotp-e14b301be3b5593a13e666885ca795e6bee54b5b.tar.gz
otp-e14b301be3b5593a13e666885ca795e6bee54b5b.tar.bz2
otp-e14b301be3b5593a13e666885ca795e6bee54b5b.zip
Support SSH key callback module options
This patch allows extra callback options to be passed to the module implementing the SSH callback module behaviour. A module implementing the SSH key callback API is used to customize the handling of public key. This patch allows extra callback options to be passed to the module implementing the SSH callback module behaviour. The key_cb option has been changed: {key_cb, atom()} -> {key_cb, key_cb()} Where: key_cb() :: atom() | {atom(), list()} The callback options, if specified, is made available to the callback module via the options passed to it under the key 'key_cb_private'. More details and some backgorund is available here[1]. [1]: http://erlang.org/pipermail/erlang-patches/2015-November/004800.html
Diffstat (limited to 'lib/ssh/test/ssh_key_cb.erl')
-rw-r--r--lib/ssh/test/ssh_key_cb.erl45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/ssh/test/ssh_key_cb.erl b/lib/ssh/test/ssh_key_cb.erl
new file mode 100644
index 0000000000..388ec2ecc1
--- /dev/null
+++ b/lib/ssh/test/ssh_key_cb.erl
@@ -0,0 +1,45 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2015. All Rights Reserved.
+%%
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%
+%%----------------------------------------------------------------------
+
+%% Note: This module is used by ssh_basic_SUITE
+
+-module(ssh_key_cb).
+-behaviour(ssh_client_key_api).
+-compile(export_all).
+
+add_host_key(_, _, _) ->
+ ok.
+
+is_host_key(_, _, _, _) ->
+ true.
+
+user_key('ssh-dss', Opts) ->
+ UserDir = proplists:get_value(user_dir, Opts),
+ KeyFile = filename:join(filename:dirname(UserDir), "id_dsa"),
+ {ok, KeyBin} = file:read_file(KeyFile),
+ [Entry] = public_key:pem_decode(KeyBin),
+ Key = public_key:pem_entry_decode(Entry),
+ {ok, Key};
+
+user_key(_Alg, _Opt) ->
+ {error, "Not Supported"}.