diff options
author | Hans Nilsson <[email protected]> | 2017-10-31 23:12:52 +0100 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2017-11-10 12:27:47 +0100 |
commit | 8f8582a0cf347f5c87a02004d981cb2e26027a6d (patch) | |
tree | 004540862d89d41fea47e7855abbce5f629e03d1 /lib/ssh/test/ssh_key_cb_engine_keys.erl | |
parent | aa8b4b31e2b31766f8aba4e1bca19d3ed006e272 (diff) | |
download | otp-8f8582a0cf347f5c87a02004d981cb2e26027a6d.tar.gz otp-8f8582a0cf347f5c87a02004d981cb2e26027a6d.tar.bz2 otp-8f8582a0cf347f5c87a02004d981cb2e26027a6d.zip |
ssh: New test suite for engine-stored keys
Diffstat (limited to 'lib/ssh/test/ssh_key_cb_engine_keys.erl')
-rw-r--r-- | lib/ssh/test/ssh_key_cb_engine_keys.erl | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/ssh/test/ssh_key_cb_engine_keys.erl b/lib/ssh/test/ssh_key_cb_engine_keys.erl new file mode 100644 index 0000000000..fc9cbfd49b --- /dev/null +++ b/lib/ssh/test/ssh_key_cb_engine_keys.erl @@ -0,0 +1,62 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2015-2017. 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_engine_keys). +-behaviour(ssh_server_key_api). +-compile(export_all). + +host_key(SshAlg, Options) -> + KBopts = proplists:get_value(key_cb_private, Options, []), + Engine = proplists:get_value(engine, KBopts), + case proplists:get_value(SshAlg, KBopts) of + undefined -> + {error, {unknown_alg,SshAlg}}; + KeyId -> + case crypto_alg(SshAlg) of + undefined -> + {error, {unsupported_alg,SshAlg}}; + CryptoAlg -> + PrivKey = #{engine => Engine, + key_id => KeyId, + algorithm => CryptoAlg}, + %% Is there a key with this reference ? + case crypto:privkey_to_pubkey(CryptoAlg, PrivKey) of + [_|_] -> + {ok, PrivKey}; + _ -> + {error, {no_hostkey,SshAlg}} + end + end + end. + +is_auth_key(_PublicUserKey, _User, _Options) -> + false. + + + +crypto_alg('ssh-rsa') -> rsa; +crypto_alg('ssh-dss') -> dss; +crypto_alg(_) -> undefined. + |