ccrypto 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d9b4e9adddf9cbf8aca58067b846446828debe3ccb6bf628d22c710bfd21c90
4
- data.tar.gz: b18db1468580e01942f76a5774a799f8041406ea8a97a0baabe1680d08782673
3
+ metadata.gz: d78804b935e3d34f37fb6a0923bf58fd0c7eb8d23686b7da39233c7faee7fcc6
4
+ data.tar.gz: a9b72eb6dd16aceb1d0ae3dbd7171df9ae0b5113a3e45df5340f9e880331686e
5
5
  SHA512:
6
- metadata.gz: 6b155d2377681522df9e5ff54996dda2a545b890b6cbb854552d52d8f7e31d7e219399cb5fd053cfe70622616b8d32fcc9e7c2a6b436602cf055df1a71281bc9
7
- data.tar.gz: e4941b14400b7ef909095299a6f2c0e89fb931c5057c3b0d70b2eb6952f48bb7cb8b535594bc1c71c6e74de60b70281bc37047c3a45ffe9f6c1a602184fa6ff7
6
+ metadata.gz: 17e938a40eb693df83d24341c1400d59640d65e49e53535f838dd918abf5016f541b80897fcb04d3ed4b45a14bcf035cfc7405ce8dbd3c1783c4ef1472874393
7
+ data.tar.gz: f4efc3711e6886ff8ad32e846cf2db74478197e4643a1a5065e938f7f40acbe4515d46cd9d5d9473ad49ae2ef55a5b2a4a1bc2920f1532546ea9ec4c6305747a
data/.release_history.yml CHANGED
@@ -4,3 +4,5 @@ ccrypto:
4
4
  :timestamp: 1660209199.3682408
5
5
  - :version: 0.1.1
6
6
  :timestamp: 1678162760.4304333
7
+ - :version: 0.1.2
8
+ :timestamp: 1680181385.6366327
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ccrypto (0.1.1)
4
+ ccrypto (0.1.3)
5
5
  activesupport
6
6
  teLogger
7
7
  toolrack
@@ -14,11 +14,10 @@ GEM
14
14
  i18n (>= 1.6, < 2)
15
15
  minitest (>= 5.1)
16
16
  tzinfo (~> 2.0)
17
- base58 (0.2.3)
18
17
  concurrent-ruby (1.2.2)
19
- devops_assist (0.3.9)
18
+ devops_assist (0.3.11)
20
19
  git_cli
21
- git_cli_prompt
20
+ git_cli_prompt (~> 0.3.3)
22
21
  gvcs
23
22
  teLogger
24
23
  toolrack
@@ -29,7 +28,7 @@ GEM
29
28
  ptools (~> 1.4.0)
30
29
  teLogger
31
30
  toolrack
32
- git_cli_prompt (0.3.2)
31
+ git_cli_prompt (0.3.4)
33
32
  teLogger
34
33
  toolrack
35
34
  tty-prompt
@@ -50,13 +49,12 @@ GEM
50
49
  rspec-expectations (3.12.2)
51
50
  diff-lcs (>= 1.2.0, < 2.0)
52
51
  rspec-support (~> 3.12.0)
53
- rspec-mocks (3.12.4)
52
+ rspec-mocks (3.12.5)
54
53
  diff-lcs (>= 1.2.0, < 2.0)
55
54
  rspec-support (~> 3.12.0)
56
55
  rspec-support (3.12.0)
57
56
  teLogger (0.2.2)
58
- toolrack (0.20.2)
59
- base58
57
+ toolrack (0.21.0)
60
58
  tty-color (0.6.0)
61
59
  tty-cursor (0.7.1)
62
60
  tty-prompt (0.23.1)
@@ -16,7 +16,7 @@ module Ccrypto
16
16
  attr_accessor :cipherOps
17
17
 
18
18
  # required by certain mode such as CCM
19
- attr_accessor :plaintext_length, :ciphertext_length
19
+ attr_accessor :plaintext_length, :ciphertext_length, :fixed_auth_tag_length
20
20
 
21
21
  # Use cases :
22
22
  # openssl aes-128-xts only accepts input min 16 bytes
@@ -37,6 +37,7 @@ module Ccrypto
37
37
  @ciphertext_length = 0
38
38
  @min_input_length = -1
39
39
  @mandatory_Block_size = -1
40
+ @fixed_iv_length = -1
40
41
 
41
42
  if not_empty?(opts) and opts.is_a?(Hash)
42
43
  @mode = opts[:mode]
@@ -66,6 +67,8 @@ module Ccrypto
66
67
 
67
68
  @mandatory_block_size = opts[:mandatory_block_size] || -1
68
69
 
70
+ @fixed_auth_tag_length = opts[:fixed_auth_tag_length] || -1
71
+
69
72
  end
70
73
 
71
74
  #if block
@@ -107,8 +110,16 @@ module Ccrypto
107
110
  not_empty?(@key)
108
111
  end
109
112
 
113
+ def has_min_input_length?
114
+ not_empty?(@min_input_length) and @min_input_length.to_i > -1
115
+ end
116
+
117
+ def has_fixed_auth_tag_length?
118
+ not_empty?(@fixed_auth_tag_length) and @fixed_auth_tag_length.to_i > -1
119
+ end
120
+
110
121
  def is_auth_mode_cipher?
111
- @authMode
122
+ @authMode == true
112
123
  end
113
124
 
114
125
  def is_algo?(algo)
@@ -123,10 +134,18 @@ module Ccrypto
123
134
  if @mode.nil? or is_empty?(@mode)
124
135
  false
125
136
  else
126
- (@mode.to_s.downcase =~ /#{mode.to_s}/) != nil
137
+ (@mode.to_s.downcase =~ /#{mode.to_s.downcase}/) != nil
127
138
  end
128
139
  end
129
140
 
141
+ def needs_plaintext_length?
142
+ is_mode?(:ccm)
143
+ end
144
+
145
+ def needs_ciphertext_length?
146
+ is_mode?(:ccm)
147
+ end
148
+
130
149
  def encrypt_cipher_mode
131
150
  @cipherOps = :encrypt
132
151
  end
@@ -17,6 +17,8 @@ module Ccrypto
17
17
 
18
18
  attr_reader :default
19
19
 
20
+ attr_accessor :native_config
21
+
20
22
  def initialize(status = Algo_Active, default = false)
21
23
  @algo_status = status
22
24
  @default = default
@@ -38,8 +38,8 @@ module Ccrypto
38
38
 
39
39
  mode = cc.mode.nil? ? "" : cc.mode.to_s
40
40
  if not_empty?(mode)
41
- @modes[mode.to_s] = [] if @modes[mode.to_s].nil?
42
- @modes[mode.to_s] << cc
41
+ @modes[mode] = [] if @modes[mode].nil?
42
+ @modes[mode] << cc
43
43
  end
44
44
 
45
45
  @algoKeysize[algo] = { } if @algoKeysize[algo].nil?
@@ -64,7 +64,7 @@ module Ccrypto
64
64
  end
65
65
 
66
66
  def items
67
- @items
67
+ @items.freeze
68
68
  end
69
69
 
70
70
  def each(&block)
@@ -75,52 +75,66 @@ module Ccrypto
75
75
  @algos.length
76
76
  end
77
77
  def find_algo(algo)
78
- @algos[algo.to_sym] || []
78
+ res = @algos[algo.to_sym] || []
79
+ res.freeze
79
80
  end
81
+
82
+ # Problem with this is the algo is in symbol
83
+ # and external app need to remember to conver it to
84
+ # symbol in order to compare.
85
+ # therefore the new method is_algo_supported? created
86
+ # to solve this issue
80
87
  def algos
81
- @algos.keys
88
+ @algos.keys.freeze
89
+ end
90
+
91
+ def is_algo_supported?(algo)
92
+ @algos.keys.include?(algo.to_sym)
82
93
  end
83
94
 
84
95
  def keysizes_count
85
96
  @keysizes.length
86
97
  end
87
98
  def keysizes
88
- @keysizes.keys
99
+ @keysizes.keys.freeze
89
100
  end
90
- def find_keysize(keysize)
91
- @keysizes[keysize.to_s]
101
+ def find_config_by_keysize(keysize)
102
+ @keysizes[keysize.to_s].freeze
92
103
  end
93
104
 
94
105
  def mode_count
95
106
  @modes.length
96
107
  end
97
- def find_mode(mode)
98
- @modes[mode.to_s]
108
+ def find_config_by_mode(mode)
109
+ @modes[mode.to_s].freeze
99
110
  end
100
111
  def modes
101
- @modes.keys
112
+ @modes.keys.freeze
102
113
  end
103
114
 
104
115
  def find_algo_keysize(algo, keysize)
105
116
  res = @algoKeysize[algo.to_sym] || { }
106
- res[keysize.to_s] || []
117
+ res = res[keysize.to_s] || []
118
+ res.freeze
107
119
  end
108
120
 
109
121
  def find_algo_mode(algo, mode)
110
122
  res = @algoMode[algo.to_sym] || {}
111
- res[mode.to_s] || []
123
+ res = res[mode.to_s] || []
124
+ res.freeze
112
125
  end
113
126
 
114
127
  def find_algo_keysize_mode(algo, keysize, mode)
115
128
  res = @algoKeysizeMode[algo.to_sym] || {}
116
129
  res = res[keysize.to_s] || {}
117
- res[mode.to_s] || []
130
+ res = res[mode.to_s] || []
131
+ res.freeze
118
132
  end
119
133
 
120
134
  def find_keysize_modes(keysize, mode)
121
-
122
135
  res = @keysizeMode[keysize.to_s] || {}
123
- res[mode.to_s] || []
136
+ res = res[mode.to_s] || []
137
+ res.freeze
124
138
  end
125
139
 
126
140
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ccrypto
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/ccrypto.rb CHANGED
@@ -56,4 +56,7 @@ module Ccrypto
56
56
 
57
57
  class KeyBundleStorageException < StandardError; end
58
58
  # Your code goes here...
59
+
60
+ Root_OID = ["2","0","18"]
61
+
59
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ccrypto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-30 00:00:00.000000000 Z
11
+ date: 2023-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: teLogger
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubygems_version: 3.4.6
131
+ rubygems_version: 3.4.10
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Crypto API normalization for Ruby and Java