Class: TLSmap::App
- Inherits:
-
Object
- Object
- TLSmap::App
- Defined in:
- lib/tls_map.rb,
lib/tls_map/app/nss.rb,
lib/tls_map/app/iana.rb,
lib/tls_map/app/gnutls.rb,
lib/tls_map/app/output.rb,
lib/tls_map/app/openssl.rb,
lib/tls_map/app/cipher/cipher.rb,
lib/tls_map/app/extractor/extractor.rb,
lib/tls_map/app/extended/ciphersuiteinfo.rb
Overview
TLS mapping
Direct Known Subclasses
Defined Under Namespace
Classes: Cipher, Extended, Extractor
Constant Summary collapse
- NSS_URL =
Timeout https://hg.mozilla.org/projects/nss/raw-file/tip/lib/ssl/sslproto.h so use github RO mirror instead.
'https://raw.githubusercontent.com/nss-dev/nss/master/lib/ssl/sslproto.h'
- IANA_URL =
'https://www.iana.org/assignments/tls-parameters/tls-parameters-4.csv'
- GNUTLS_URL =
'https://gitlab.com/gnutls/gnutls/raw/master/lib/algorithms/ciphersuites.c'
- OPENSSL_URL =
'https://raw.githubusercontent.com/openssl/openssl/master/include/openssl/tls1.h'
- OPENSSL_URL2 =
'https://raw.githubusercontent.com/openssl/openssl/master/include/openssl/ssl3.h'
Instance Attribute Summary collapse
-
#tls_map ⇒ Hash
readonly
Get the mapping of all TLS cipher suites.
Class Method Summary collapse
-
.search(tls_map, criteria, term, output = :all) ⇒ Object
Stateless version of #search.
Instance Method Summary collapse
-
#bulk_search(criteria, file, output = :all) ⇒ Array<Hash>
Search for corresponding cipher algorithms in other libraries in bulk.
-
#export(filename, format) ⇒ Object
Export the mapping to a file, supporting various formats.
-
#initialize ⇒ App
constructor
Will automatically fetch source files and parse them.
-
#search(criteria, term, output = :all) ⇒ Hash
Search for corresponding cipher algorithms in other libraries.
Constructor Details
#initialize ⇒ App
Will automatically fetch source files and parse them.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tls_map.rb', line 26 def initialize @iana_file = Utils.tmpfile('iana', IANA_URL) @openssl_file = Utils.tmpfile('openssl', OPENSSL_URL) @openssl_file2 = Utils.tmpfile('openssl', OPENSSL_URL2) @gnutls_file = Utils.tmpfile('gnutls', GNUTLS_URL) @nss_file = Utils.tmpfile('nss', NSS_URL) @tls_map = [] parse end |
Instance Attribute Details
#tls_map ⇒ Hash (readonly)
Get the mapping of all TLS cipher suites
23 24 25 |
# File 'lib/tls_map.rb', line 23 def tls_map @tls_map end |
Class Method Details
.search(tls_map, criteria, term, output = :all) ⇒ Object
Stateless version of #search.
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/tls_map.rb', line 77 def self.search(tls_map, criteria, term, output = :all) tls_map.each do |alg| term = term.upcase if criteria == :codepoint next unless alg[criteria] == term return alg if output == :all return { output => alg[output] } end {} end |
Instance Method Details
#bulk_search(criteria, file, output = :all) ⇒ Array<Hash>
Search for corresponding cipher algorithms in other libraries in bulk
97 98 99 100 101 102 103 |
# File 'lib/tls_map.rb', line 97 def bulk_search(criteria, file, output = :all) res = [] File.foreach(file) do |line| res.push(search(criteria, line.chomp, output)) end res end |
#export(filename, format) ⇒ Object
Export the mapping to a file, supporting various formats.
41 42 43 44 45 46 47 48 49 |
# File 'lib/tls_map/app/output.rb', line 41 def export(filename, format) case format when :markdown then output_markdown(filename) when :json_pretty then output_json_pretty(filename) when :json_compact then output_json_compact(filename) when :marshal then output_marshal(filename) else raise "Wrong format: #{format}" end end |
#search(criteria, term, output = :all) ⇒ Hash
Search for corresponding cipher algorithms in other libraries
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/tls_map.rb', line 52 def search(criteria, term, output = :all) @tls_map.each do |alg| term = term.upcase if criteria == :codepoint next unless alg[criteria] == term return alg if output == :all return { output => alg[output] } end {} end |