~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to lib/ssh/src/ssh.erl

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
         stop_listener/1, stop_listener/2, stop_daemon/1, stop_daemon/2,
31
31
         shell/1, shell/2, shell/3]).
32
32
 
 
33
-export([sign_data/2, verify_data/3]).
 
34
 
33
35
%%--------------------------------------------------------------------
34
36
%% Function: start([, Type]) -> ok
35
37
%%
94
96
                    do_demonitor(MRef, Manager),
95
97
                    {error, Other};
96
98
                {'DOWN', MRef, _, Manager, Reason} when is_pid(Manager) ->
 
99
                    error_logger:warning_report([{ssh, connect},
 
100
                                                 {diagnose,
 
101
                                                  "Connection was closed before properly set up."},
 
102
                                                 {host, Host},
 
103
                                                 {port, Port},
 
104
                                                 {reason, Reason}]),
97
105
                    receive %% Clear EXIT message from queue
98
106
                        {'EXIT', Manager, _What} -> 
99
 
                            {error, Reason}
 
107
                            {error, channel_closed}
100
108
                    after 0 ->
101
 
                            {error, Reason}
 
109
                            {error, channel_closed}
102
110
                    end
103
111
            after Timeout  ->
104
112
                    do_demonitor(MRef, Manager),
239
247
            Error
240
248
    end.
241
249
 
 
250
 
 
251
%%--------------------------------------------------------------------
 
252
%% Function: sign_data(Data, Algorithm) -> binary() | 
 
253
%%                                         {error, Reason}
 
254
%%
 
255
%%   Data = binary()
 
256
%%   Algorithm = "ssh-rsa"
 
257
%%
 
258
%% Description: Use SSH key to sign data.
 
259
%%--------------------------------------------------------------------
 
260
sign_data(Data, Algorithm) when is_binary(Data) ->
 
261
    case ssh_file:private_identity_key(Algorithm,[]) of
 
262
        {ok, Key} when Algorithm == "ssh-rsa" ->
 
263
            ssh_rsa:sign(Key, Data);
 
264
        Error ->
 
265
            Error
 
266
    end.
 
267
 
 
268
%%--------------------------------------------------------------------
 
269
%% Function: verify_data(Data, Signature, Algorithm) -> ok | 
 
270
%%                                                      {error, Reason}
 
271
%%
 
272
%%   Data = binary()
 
273
%%   Signature = binary()
 
274
%%   Algorithm = "ssh-rsa"
 
275
%%
 
276
%% Description: Use SSH signature to verify data.
 
277
%%--------------------------------------------------------------------
 
278
verify_data(Data, Signature, Algorithm) when is_binary(Data), is_binary(Signature) ->
 
279
    case ssh_file:public_identity_key(Algorithm, []) of
 
280
        {ok, Key} when Algorithm == "ssh-rsa" ->
 
281
            ssh_rsa:verify(Key, Data, Signature);
 
282
        Error ->
 
283
            Error
 
284
    end.
 
285
 
 
286
 
242
287
%%--------------------------------------------------------------------
243
288
%%% Internal functions
244
289
%%--------------------------------------------------------------------