File: test_ecdh_sha2_nistp521.rb

package info (click to toggle)
ruby-net-ssh 1%3A2.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,252 kB
  • sloc: ruby: 12,000; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 971 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'openssl'
require 'transport/kex/test_ecdh_sha2_nistp256'

unless defined?(OpenSSL::PKey::EC)
  puts "Skipping tests for ecdh-sha2-nistp521 key exchange"
else
  module Transport; module Kex
    class TestEcdhSHA2NistP521 < TestEcdhSHA2NistP256

      def setup
        @ecdh = @algorithms = @connection = @server_key = 
          @packet_data = @shared_secret = nil
      end

      def test_exchange_keys_should_return_expected_results_when_successful
        result = exchange!
        assert_equal session_id, result[:session_id]
        assert_equal server_host_key.to_blob, result[:server_key].to_blob
        assert_equal shared_secret, result[:shared_secret]
        assert_equal digester, result[:hashing_algorithm]
      end

      private

      def digester
        OpenSSL::Digest::SHA512
      end

      def subject
        Net::SSH::Transport::Kex::EcdhSHA2NistP521
      end

      def ecparam
        "secp521r1"
      end
    end
  end; end
end