summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRyosuke Yamazaki <ryosuke.yamazaki@mac.com>2011-12-15 11:28:16 +0900
committerRyosuke Yamazaki <ryosuke.yamazaki@mac.com>2011-12-15 11:28:16 +0900
commit881d6217cc0a4093d815ac9ab0252733afd9eecc (patch)
tree5b68446bb74f3b72372ed26f649f1ce38a6b6d5c /lib
parent613a7e1b55614b0f38535da6596796be9361f50b (diff)
downloadnet-ssh-881d6217cc0a4093d815ac9ab0252733afd9eecc.tar.gz
support hmac-sha2-256, hmac-sha2-512, hmac-sha2-256-96, hmac-sha2-512-96
Diffstat (limited to 'lib')
-rw-r--r--lib/net/ssh/transport/hmac/sha2_256.rb15
-rw-r--r--lib/net/ssh/transport/hmac/sha2_256_96.rb13
-rw-r--r--lib/net/ssh/transport/hmac/sha2_512.rb14
-rw-r--r--lib/net/ssh/transport/hmac/sha2_512_96.rb13
4 files changed, 55 insertions, 0 deletions
diff --git a/lib/net/ssh/transport/hmac/sha2_256.rb b/lib/net/ssh/transport/hmac/sha2_256.rb
new file mode 100644
index 0000000..8191a90
--- /dev/null
+++ b/lib/net/ssh/transport/hmac/sha2_256.rb
@@ -0,0 +1,15 @@
+require 'net/ssh/transport/hmac/abstract'
+
+if defined?(OpenSSL::Digest::SHA256) # need openssl support
+ module Net::SSH::Transport::HMAC
+
+ # The SHA-256 HMAC algorithm. This has a mac and key length of 32, and
+ # uses the SHA-256 digest algorithm.
+ class SHA2_256 < Abstract
+ mac_length 32
+ key_length 32
+ digest_class OpenSSL::Digest::SHA256
+ end
+
+ end
+end
diff --git a/lib/net/ssh/transport/hmac/sha2_256_96.rb b/lib/net/ssh/transport/hmac/sha2_256_96.rb
new file mode 100644
index 0000000..15e36ff
--- /dev/null
+++ b/lib/net/ssh/transport/hmac/sha2_256_96.rb
@@ -0,0 +1,13 @@
+require 'net/ssh/transport/hmac/abstract'
+
+module Net::SSH::Transport::HMAC
+
+ if defined?(SHA2_256) # need openssl support
+ # The SHA256-96 HMAC algorithm. This returns only the first 12 bytes of
+ # the digest.
+ class SHA2_256_96 < SHA2_256
+ mac_length 12
+ end
+ end
+
+end
diff --git a/lib/net/ssh/transport/hmac/sha2_512.rb b/lib/net/ssh/transport/hmac/sha2_512.rb
new file mode 100644
index 0000000..e68df19
--- /dev/null
+++ b/lib/net/ssh/transport/hmac/sha2_512.rb
@@ -0,0 +1,14 @@
+require 'net/ssh/transport/hmac/abstract'
+
+module Net::SSH::Transport::HMAC
+
+ if defined?(OpenSSL::Digest::SHA512) # need openssl support
+ # The SHA-512 HMAC algorithm. This has a mac and key length of 64, and
+ # uses the SHA-512 digest algorithm.
+ class SHA2_512 < Abstract
+ mac_length 64
+ key_length 64
+ digest_class OpenSSL::Digest::SHA512
+ end
+ end
+end
diff --git a/lib/net/ssh/transport/hmac/sha2_512_96.rb b/lib/net/ssh/transport/hmac/sha2_512_96.rb
new file mode 100644
index 0000000..5cc7aed
--- /dev/null
+++ b/lib/net/ssh/transport/hmac/sha2_512_96.rb
@@ -0,0 +1,13 @@
+require 'net/ssh/transport/hmac/abstract'
+
+module Net::SSH::Transport::HMAC
+
+ if defined?(SHA2_512) # need openssl support
+ # The SHA2-512-96 HMAC algorithm. This returns only the first 12 bytes of
+ # the digest.
+ class SHA2_512_96 < SHA2_512
+ mac_length 12
+ end
+ end
+
+end