ccipher_factory 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.release_history.yml +4 -0
- data/lib/ccipher_factory/encoding/bin_struct.rb +3 -1
- data/lib/ccipher_factory/kdf/hkdf.rb +20 -0
- data/lib/ccipher_factory/kdf/kdf.rb +3 -0
- data/lib/ccipher_factory/kdf/pbkdf2.rb +21 -0
- data/lib/ccipher_factory/kdf/scrypt.rb +20 -0
- data/lib/ccipher_factory/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a83a5b71fd4c1ed7974bd951d3ecb84b01ca18060a323a7bf76d25d9c63ca3a
|
4
|
+
data.tar.gz: b5ef665bf09048f3c2c8534beafb13e7624d0f18403292ab7122d02b7735ef3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f96c5d460d68e4a70300861d7e94e8a0abc7d0b86b207d50763caef2099470cc8e4da26ea523b3bd8a5d3224724d4a33d2043f66d6d2273c67b90dddbe3709b0
|
7
|
+
data.tar.gz: 2b2e4585e99cd7c1ecea2b07ebf4dadfa90111a3c17763c64684483d19ab6e9f476fa6ce4049ce014708ff4ae8b9fefde203debac21fe37c96f4737fee9ef8f5
|
@@ -103,6 +103,7 @@ module CcipherFactory
|
|
103
103
|
int :digest
|
104
104
|
int :outByteLength
|
105
105
|
bin :salt
|
106
|
+
bin :value
|
106
107
|
end,
|
107
108
|
|
108
109
|
kdf_scrypt: Binenc::EngineFactory.instance(:bin_struct).define do
|
@@ -114,9 +115,9 @@ module CcipherFactory
|
|
114
115
|
int :blocksize
|
115
116
|
int :parallel
|
116
117
|
int :outByteLength
|
118
|
+
bin :value
|
117
119
|
end,
|
118
120
|
|
119
|
-
|
120
121
|
kdf_pbkdf2: Binenc::EngineFactory.instance(:bin_struct).define do
|
121
122
|
oid :oid, BTag.constant_value(:kdf_pbkdf2)
|
122
123
|
int :version, 0x0100
|
@@ -124,6 +125,7 @@ module CcipherFactory
|
|
124
125
|
bin :salt
|
125
126
|
int :iterations
|
126
127
|
int :outByteLength
|
128
|
+
bin :value
|
127
129
|
end,
|
128
130
|
|
129
131
|
|
@@ -13,6 +13,7 @@ module CcipherFactory
|
|
13
13
|
|
14
14
|
attr_accessor :outByteLength, :salt
|
15
15
|
attr_accessor :digestAlgo
|
16
|
+
attr_accessor :attachedDigest, :attachedValue
|
16
17
|
attr_reader :derivedVal
|
17
18
|
def derive_init(*args, &block)
|
18
19
|
|
@@ -21,6 +22,12 @@ module CcipherFactory
|
|
21
22
|
|
22
23
|
@salt = SecureRandom.random_bytes(@outByteLength) if is_empty?(@salt)
|
23
24
|
|
25
|
+
if is_empty?(@attachedValue)
|
26
|
+
@attachedDigest = false if is_empty?(@attachedDigest)
|
27
|
+
else
|
28
|
+
@attachedDigest = true
|
29
|
+
end
|
30
|
+
|
24
31
|
if block
|
25
32
|
instance_eval(&block)
|
26
33
|
derive_final
|
@@ -96,10 +103,23 @@ module CcipherFactory
|
|
96
103
|
ts.digest = BTag.constant_value(digestId)
|
97
104
|
ts.salt = @salt
|
98
105
|
ts.outByteLength = @outByteLength
|
106
|
+
if is_bool?(@attachedDigest) and @attachedDigest
|
107
|
+
ts.value = @derivedVal
|
108
|
+
else
|
109
|
+
ts.value = ""
|
110
|
+
end
|
99
111
|
ts.encoded
|
100
112
|
|
101
113
|
end
|
102
114
|
|
115
|
+
def is_attached_mode?
|
116
|
+
if is_empty?(@attachedValue)
|
117
|
+
@attachedDigest
|
118
|
+
else
|
119
|
+
true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
103
123
|
private
|
104
124
|
def logger
|
105
125
|
if @logger.nil?
|
@@ -47,6 +47,7 @@ module CcipherFactory
|
|
47
47
|
kdf.salt = ts.salt
|
48
48
|
kdf.outByteLength = ts.outByteLength
|
49
49
|
kdf.digest = Digest.from_encoded(ts.digest)
|
50
|
+
kdf.attachedValue = ts.value
|
50
51
|
kdf.derive_init
|
51
52
|
kdf
|
52
53
|
when :kdf_hkdf
|
@@ -55,6 +56,7 @@ module CcipherFactory
|
|
55
56
|
kdf.digestAlgo = BTag.value_constant(ts.digest)
|
56
57
|
kdf.salt = ts.salt
|
57
58
|
kdf.outByteLength = ts.outByteLength
|
59
|
+
kdf.attachedValue = ts.value
|
58
60
|
kdf.derive_init
|
59
61
|
when :kdf_pbkdf2
|
60
62
|
kdf = KDFEngine.new
|
@@ -63,6 +65,7 @@ module CcipherFactory
|
|
63
65
|
kdf.salt = ts.salt
|
64
66
|
kdf.iter = ts.iterations
|
65
67
|
kdf.outByteLength = ts.outByteLength
|
68
|
+
kdf.attachedValue = ts.value
|
66
69
|
kdf.derive_init
|
67
70
|
else
|
68
71
|
raise KDFError, "Unknown KDF envelope ID '#{ts.oid}'"
|
@@ -7,6 +7,8 @@ module CcipherFactory
|
|
7
7
|
include Common
|
8
8
|
|
9
9
|
attr_accessor :salt, :iter, :outByteLength, :digestAlgo
|
10
|
+
attr_accessor :attachedDigest, :attachedValue
|
11
|
+
attr_reader :derivedVal
|
10
12
|
|
11
13
|
def derive_init(*args, &block)
|
12
14
|
|
@@ -15,6 +17,12 @@ module CcipherFactory
|
|
15
17
|
|
16
18
|
@salt = SecureRandom.random_bytes(@outByteLength) if is_empty?(@salt)
|
17
19
|
|
20
|
+
if is_empty?(@attachedValue)
|
21
|
+
@attachedDigest = false if is_empty?(@attachedDigest)
|
22
|
+
else
|
23
|
+
@attachedDigest = true
|
24
|
+
end
|
25
|
+
|
18
26
|
if block
|
19
27
|
instance_eval(&block)
|
20
28
|
derive_final
|
@@ -65,10 +73,23 @@ module CcipherFactory
|
|
65
73
|
ts.salt = @salt
|
66
74
|
ts.outByteLength = @outByteLength
|
67
75
|
ts.iterations = hconf.iter
|
76
|
+
if is_bool?(@attachedDigest) and @attachedDigest
|
77
|
+
ts.value = @derivedVal
|
78
|
+
else
|
79
|
+
ts.value = ""
|
80
|
+
end
|
68
81
|
ts.encoded
|
69
82
|
|
70
83
|
end
|
71
84
|
|
85
|
+
def is_attached_mode?
|
86
|
+
if is_empty?(@attachedValue)
|
87
|
+
@attachedDigest
|
88
|
+
else
|
89
|
+
true
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
72
93
|
def logger
|
73
94
|
if @logger.nil?
|
74
95
|
@logger = TeLogger::Tlogger.new
|
@@ -14,6 +14,7 @@ module CcipherFactory
|
|
14
14
|
##
|
15
15
|
attr_accessor :cost, :parallel, :blocksize, :salt, :outByteLength
|
16
16
|
attr_accessor :digestAlgo, :digest
|
17
|
+
attr_accessor :attachedDigest, :attachedValue
|
17
18
|
attr_reader :derivedVal
|
18
19
|
def derive_init(*args, &block)
|
19
20
|
|
@@ -44,6 +45,12 @@ module CcipherFactory
|
|
44
45
|
|
45
46
|
@digest.output(intOutputBuf)
|
46
47
|
|
48
|
+
if is_empty?(@attachedValue)
|
49
|
+
@attachedDigest = false if is_empty?(@attachedDigest)
|
50
|
+
else
|
51
|
+
@attachedDigest = true
|
52
|
+
end
|
53
|
+
|
47
54
|
if block
|
48
55
|
instance_eval(&block)
|
49
56
|
derive_final
|
@@ -85,10 +92,23 @@ module CcipherFactory
|
|
85
92
|
ts.blocksize = @blocksize
|
86
93
|
ts.parallel = @parallel
|
87
94
|
ts.outByteLength = @outByteLength
|
95
|
+
if is_bool?(@attachedDigest) and @attachedDigest
|
96
|
+
ts.value = @derivedVal
|
97
|
+
else
|
98
|
+
ts.value = ""
|
99
|
+
end
|
88
100
|
ts.encoded
|
89
101
|
|
90
102
|
end
|
91
103
|
|
104
|
+
def is_attached_mode?
|
105
|
+
if is_empty?(@attachedValue)
|
106
|
+
@attachedDigest
|
107
|
+
else
|
108
|
+
true
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
92
112
|
private
|
93
113
|
def logger
|
94
114
|
if @logger.nil?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ccipher_factory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: toolrack
|
@@ -87,6 +87,7 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
+
- ".release_history.yml"
|
90
91
|
- ".rspec"
|
91
92
|
- Gemfile
|
92
93
|
- Gemfile.lock-java
|