Class: Ccrypto::SupportedCipherList
- Inherits:
-
Object
- Object
- Ccrypto::SupportedCipherList
- Includes:
- Singleton, TR::CondUtils, TeLogger::TeLogHelper
- Defined in:
- lib/ccrypto/supported_cipher_list.rb
Instance Method Summary collapse
- #algo_count ⇒ Object
- #algos ⇒ Object
- #each(&block) ⇒ Object
- #find_algo(algo) ⇒ Object
- #find_algo_keysize(algo, keysize) ⇒ Object
- #find_algo_keysize_mode(algo, keysize, mode) ⇒ Object
- #find_algo_mode(algo, mode) ⇒ Object
- #find_keysize(keysize) ⇒ Object
- #find_keysize_modes(keysize, mode) ⇒ Object
- #find_mode(mode) ⇒ Object
-
#initialize ⇒ SupportedCipherList
constructor
A new instance of SupportedCipherList.
- #items ⇒ Object
- #keysizes ⇒ Object
- #keysizes_count ⇒ Object
- #mode_count ⇒ Object
- #modes ⇒ Object
- #register(cc) ⇒ Object
Constructor Details
#initialize ⇒ SupportedCipherList
Returns a new instance of SupportedCipherList.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 15 def initialize @algos = {} @keysizes = {} @modes = {} @algoKeysize = {} @algoKeysizeMode = {} @keysizeMode = {} @algoMode = {} @items = [] end |
Instance Method Details
#algo_count ⇒ Object
74 75 76 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 74 def algo_count @algos.length end |
#algos ⇒ Object
80 81 82 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 80 def algos @algos.keys end |
#each(&block) ⇒ Object
70 71 72 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 70 def each(&block) @items.each(&block) end |
#find_algo(algo) ⇒ Object
77 78 79 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 77 def find_algo(algo) @algos[algo.to_sym] || [] end |
#find_algo_keysize(algo, keysize) ⇒ Object
104 105 106 107 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 104 def find_algo_keysize(algo, keysize) res = @algoKeysize[algo.to_sym] || { } res[keysize.to_s] || [] end |
#find_algo_keysize_mode(algo, keysize, mode) ⇒ Object
114 115 116 117 118 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 114 def find_algo_keysize_mode(algo, keysize, mode) res = @algoKeysizeMode[algo.to_sym] || {} res = res[keysize.to_s] || {} res[mode.to_s] || [] end |
#find_algo_mode(algo, mode) ⇒ Object
109 110 111 112 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 109 def find_algo_mode(algo, mode) res = @algoMode[algo.to_sym] || {} res[mode.to_s] || [] end |
#find_keysize(keysize) ⇒ Object
90 91 92 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 90 def find_keysize(keysize) @keysizes[keysize.to_s] end |
#find_keysize_modes(keysize, mode) ⇒ Object
120 121 122 123 124 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 120 def find_keysize_modes(keysize, mode) res = @keysizeMode[keysize.to_s] || {} res[mode.to_s] || [] end |
#find_mode(mode) ⇒ Object
97 98 99 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 97 def find_mode(mode) @modes[mode.to_s] end |
#items ⇒ Object
66 67 68 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 66 def items @items end |
#keysizes ⇒ Object
87 88 89 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 87 def keysizes @keysizes.keys end |
#keysizes_count ⇒ Object
84 85 86 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 84 def keysizes_count @keysizes.length end |
#mode_count ⇒ Object
94 95 96 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 94 def mode_count @modes.length end |
#modes ⇒ Object
100 101 102 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 100 def modes @modes.keys end |
#register(cc) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ccrypto/supported_cipher_list.rb', line 27 def register(cc) raise SupportedCipherListError, "Ccrypto::CipherConfig required. Got '#{cc.class}'" if not cc.is_a?(Ccrypto::CipherConfig) @items << cc algo = cc.algo.to_sym @algos[algo] = [] if @algos[algo].nil? @algos[algo] << cc keysize = cc.keysize.to_s @keysizes[keysize] = [] if @keysizes[keysize].nil? @keysizes[keysize] << cc mode = cc.mode.nil? ? "" : cc.mode.to_s if not_empty?(mode) @modes[mode.to_s] = [] if @modes[mode.to_s].nil? @modes[mode.to_s] << cc end @algoKeysize[algo] = { } if @algoKeysize[algo].nil? @algoKeysize[algo][keysize] = [] if @algoKeysize[algo][keysize].nil? @algoKeysize[algo][keysize] << cc if not_empty?(mode) @algoMode[algo] = {} if @algoMode[algo].nil? @algoMode[algo][mode] = [] if @algoMode[algo][mode].nil? @algoMode[algo][mode] << cc @keysizeMode[keysize] = {} if @keysizeMode[keysize].nil? @keysizeMode[keysize][mode] = [] if @keysizeMode[keysize][mode].nil? @keysizeMode[keysize][mode] << cc @algoKeysizeMode[algo] = {} if @algoKeysizeMode[algo].nil? @algoKeysizeMode[algo][keysize] = {} if @algoKeysizeMode[algo][keysize].nil? @algoKeysizeMode[algo][keysize][mode] = [] if @algoKeysizeMode[algo][keysize][mode].nil? @algoKeysizeMode[algo][keysize][mode] << cc end end |