Class: CcipherBox::EncKeyConfig
- Inherits:
-
Object
- Object
- CcipherBox::EncKeyConfig
- Includes:
- TR::CondUtils
- Defined in:
- lib/ccipher_box/enc_key_config.rb
Overview
link between data encryption key name with their respective key configs In a specific configurations, there might be many data encryption key and the key config to derive the data encryption key from a base key is kept here for later rebuild the same key again Only used inside SecureRing
Class Method Summary collapse
Instance Method Summary collapse
- #encoded ⇒ Object
-
#initialize ⇒ EncKeyConfig
constructor
A new instance of EncKeyConfig.
- #is_derived_key?(hash) ⇒ Boolean
- #keyConfigs ⇒ Object
- #register_config(name, keyConfig) ⇒ Object
- #register_derive_config(name, keyConfig, baseName, baseKeyConfig) ⇒ Object
Constructor Details
#initialize ⇒ EncKeyConfig
Returns a new instance of EncKeyConfig.
15 16 17 |
# File 'lib/ccipher_box/enc_key_config.rb', line 15 def initialize @keyConfigs = { } end |
Class Method Details
.from_encoded(seq) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ccipher_box/enc_key_config.rb', line 60 def self.from_encoded(seq) ekc = EncKeyConfig.new seq.each do |sst| st = BinStruct.instance.struct_from_bin(sst) case st.oid when CBTag.constant_value(:keyConfig) ekc.register_config(st.name, st.keyConfig) when CBTag.constant_value(:keyConfig_from_base) ekc.register_config(st.name, st.keyConfig, st.baseName, st.baseKeyConfig) end end ekc end |
Instance Method Details
#encoded ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ccipher_box/enc_key_config.rb', line 35 def encoded configs = [] @keyConfigs.each do |name, val| if not_empty?(val[:base]) st = BinStruct.instance.struct(:keyConfig_from_base) st.name = name st.keyConfig = val[:config] st.baseName = val[:base] st.baseKeyConfig = val[:baseConfig] else st = BinStruct.instance.struct(:keyConfig) st.name = name st.keyConfig = val[:config] end configs << st.encoded end configs end |
#is_derived_key?(hash) ⇒ Boolean
31 32 33 |
# File 'lib/ccipher_box/enc_key_config.rb', line 31 def is_derived_key?(hash) not_empty?(hash[:base]) end |
#keyConfigs ⇒ Object
27 28 29 |
# File 'lib/ccipher_box/enc_key_config.rb', line 27 def keyConfigs @keyConfigs.freeze end |
#register_config(name, keyConfig) ⇒ Object
19 20 21 |
# File 'lib/ccipher_box/enc_key_config.rb', line 19 def register_config(name, keyConfig) @keyConfigs[name] = { config: keyConfig } end |
#register_derive_config(name, keyConfig, baseName, baseKeyConfig) ⇒ Object
23 24 25 |
# File 'lib/ccipher_box/enc_key_config.rb', line 23 def register_derive_config(name, keyConfig, baseName, baseKeyConfig) @keyConfigs[name] = { config: keyConfig, base: baseName, baseConfig: baseKeyConfig } end |