ccrypto-ruby 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.release_history.yml +6 -0
- data/Dockerfile.dockerun +29 -0
- data/Gemfile.lock +60 -33
- data/ccrypto-ruby.gemspec +4 -1
- data/gen_ecc_const.rb +13 -0
- data/lib/ccrypto/provider.rb +52 -44
- data/lib/ccrypto/ruby/ecc_const.rb +82 -0
- data/lib/ccrypto/ruby/engines/cipher_engine.rb +214 -55
- data/lib/ccrypto/ruby/engines/digest_engine.rb +39 -17
- data/lib/ccrypto/ruby/engines/ecc_engine.rb +89 -14
- data/lib/ccrypto/ruby/engines/ed25519_engine.rb +84 -0
- data/lib/ccrypto/ruby/engines/pkcs7_engine.rb +1 -0
- data/lib/ccrypto/ruby/engines/rsa_engine.rb +9 -0
- data/lib/ccrypto/ruby/engines/x25519_engine.rb +65 -0
- data/lib/ccrypto/ruby/engines/x509_csr_engine.rb +128 -0
- data/lib/ccrypto/ruby/engines/x509_engine.rb +208 -8
- data/lib/ccrypto/ruby/ext/x509_csr.rb +153 -0
- data/lib/ccrypto/ruby/keybundle_store/pem_store.rb +3 -3
- data/lib/ccrypto/ruby/keybundle_store/pkcs12.rb +6 -5
- data/lib/ccrypto/ruby/version.rb +1 -1
- data/lib/ccrypto/ruby.rb +1 -0
- metadata +39 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ffc07a1990117b5d797ed47227cd903b257a74d34f19e9a17f6f5504111e356
|
4
|
+
data.tar.gz: eb85f4b547303e36c5834c4798373b908b050728c748e1742647560a964970ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c3459bd55f014a7d5bbb62851d39130c61522abd450ebf62f65bd059b540297b3d1911faf0b7f4db8c41f2c30857092cfd344d451b79c47e53bd27c3b9c79c3
|
7
|
+
data.tar.gz: a460a153c8888bf4c219c8d9f8e71b5b1f09d5ad83f8e722ad991f852a744ce426b68ec7f6d8085e1c4fb012e2ee26e61e62af2679f06919fb97a5d801861a0f
|
data/Dockerfile.dockerun
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
FROM ruby:3.2.1
|
3
|
+
LABEL version="0.1"
|
4
|
+
LABEL maintainer="chris"
|
5
|
+
LABEL description="Dockerfile generated by dockerun"
|
6
|
+
LABEL dockerun-info="https://github.com/chrisliaw/dockerun"
|
7
|
+
|
8
|
+
|
9
|
+
RUN apt-get update && apt-get install -y sudo git curl build-essential
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
RUN groupadd -f -g 1000 chris && \
|
15
|
+
useradd -u 1000 -g 1000 -m chris && \
|
16
|
+
usermod -aG sudo chris && \
|
17
|
+
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
18
|
+
|
19
|
+
USER chris
|
20
|
+
|
21
|
+
# from this point onwards, sudo is required for privileaged operation
|
22
|
+
#RUN sudo apt-get install -y curl build-essential
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
# other Dockerfile entries starts here
|
27
|
+
|
28
|
+
CMD [ "/bin/bash", "--login" ]
|
29
|
+
|
data/Gemfile.lock
CHANGED
@@ -1,62 +1,89 @@
|
|
1
|
-
GIT
|
2
|
-
remote: ccrypto
|
3
|
-
revision: 0d1c446d77fb781857f5ac087de9326bc3dafca9
|
4
|
-
branch: main
|
5
|
-
specs:
|
6
|
-
ccrypto (0.1.0)
|
7
|
-
activesupport
|
8
|
-
teLogger
|
9
|
-
toolrack
|
10
|
-
|
11
1
|
PATH
|
12
2
|
remote: .
|
13
3
|
specs:
|
14
|
-
ccrypto-ruby (0.1.
|
4
|
+
ccrypto-ruby (0.1.2)
|
5
|
+
ccrypto (~> 0.1.3)
|
6
|
+
ed25519
|
15
7
|
teLogger
|
16
8
|
toolrack
|
9
|
+
x25519
|
17
10
|
|
18
11
|
GEM
|
19
12
|
remote: https://rubygems.org/
|
20
13
|
specs:
|
21
|
-
activesupport (7.0.3
|
14
|
+
activesupport (7.0.4.3)
|
22
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
23
16
|
i18n (>= 1.6, < 2)
|
24
17
|
minitest (>= 5.1)
|
25
18
|
tzinfo (~> 2.0)
|
26
|
-
|
27
|
-
|
19
|
+
ccrypto (0.1.3)
|
20
|
+
activesupport
|
21
|
+
teLogger
|
22
|
+
toolrack
|
23
|
+
concurrent-ruby (1.2.2)
|
24
|
+
devops_assist (0.3.11)
|
25
|
+
git_cli
|
26
|
+
git_cli_prompt (~> 0.3.3)
|
27
|
+
gvcs
|
28
|
+
teLogger
|
29
|
+
toolrack
|
30
|
+
tty-prompt
|
28
31
|
diff-lcs (1.5.0)
|
32
|
+
ed25519 (1.3.0)
|
33
|
+
git_cli (0.11.2)
|
34
|
+
gvcs
|
35
|
+
ptools (~> 1.4.0)
|
36
|
+
teLogger
|
37
|
+
toolrack
|
38
|
+
git_cli_prompt (0.3.4)
|
39
|
+
teLogger
|
40
|
+
toolrack
|
41
|
+
tty-prompt
|
42
|
+
gvcs (0.1.1)
|
29
43
|
i18n (1.12.0)
|
30
44
|
concurrent-ruby (~> 1.0)
|
31
|
-
minitest (5.
|
45
|
+
minitest (5.18.0)
|
46
|
+
pastel (0.8.0)
|
47
|
+
tty-color (~> 0.5)
|
48
|
+
ptools (1.4.3)
|
32
49
|
rake (13.0.6)
|
33
|
-
rspec (3.
|
34
|
-
rspec-core (~> 3.
|
35
|
-
rspec-expectations (~> 3.
|
36
|
-
rspec-mocks (~> 3.
|
37
|
-
rspec-core (3.
|
38
|
-
rspec-support (~> 3.
|
39
|
-
rspec-expectations (3.
|
50
|
+
rspec (3.12.0)
|
51
|
+
rspec-core (~> 3.12.0)
|
52
|
+
rspec-expectations (~> 3.12.0)
|
53
|
+
rspec-mocks (~> 3.12.0)
|
54
|
+
rspec-core (3.12.1)
|
55
|
+
rspec-support (~> 3.12.0)
|
56
|
+
rspec-expectations (3.12.2)
|
40
57
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
-
rspec-support (~> 3.
|
42
|
-
rspec-mocks (3.
|
58
|
+
rspec-support (~> 3.12.0)
|
59
|
+
rspec-mocks (3.12.5)
|
43
60
|
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
-
rspec-support (~> 3.
|
45
|
-
rspec-support (3.
|
46
|
-
teLogger (0.
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
61
|
+
rspec-support (~> 3.12.0)
|
62
|
+
rspec-support (3.12.0)
|
63
|
+
teLogger (0.2.2)
|
64
|
+
toolrack (0.21.0)
|
65
|
+
tty-color (0.6.0)
|
66
|
+
tty-cursor (0.7.1)
|
67
|
+
tty-prompt (0.23.1)
|
68
|
+
pastel (~> 0.8)
|
69
|
+
tty-reader (~> 0.8)
|
70
|
+
tty-reader (0.9.0)
|
71
|
+
tty-cursor (~> 0.7)
|
72
|
+
tty-screen (~> 0.8)
|
73
|
+
wisper (~> 2.0)
|
74
|
+
tty-screen (0.8.1)
|
75
|
+
tzinfo (2.0.6)
|
52
76
|
concurrent-ruby (~> 1.0)
|
77
|
+
wisper (2.0.1)
|
78
|
+
x25519 (1.0.10)
|
53
79
|
|
54
80
|
PLATFORMS
|
81
|
+
ruby
|
55
82
|
x86_64-linux
|
56
83
|
|
57
84
|
DEPENDENCIES
|
58
|
-
ccrypto!
|
59
85
|
ccrypto-ruby!
|
86
|
+
devops_assist
|
60
87
|
rake (~> 13.0)
|
61
88
|
rspec (~> 3.0)
|
62
89
|
|
data/ccrypto-ruby.gemspec
CHANGED
@@ -33,7 +33,10 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_dependency 'teLogger'
|
34
34
|
spec.add_dependency 'toolrack'
|
35
35
|
|
36
|
-
spec.add_dependency 'ccrypto'
|
36
|
+
spec.add_dependency 'ccrypto' , "~> 0.1.3"
|
37
|
+
|
38
|
+
spec.add_dependency 'ed25519'
|
39
|
+
spec.add_dependency 'x25519'
|
37
40
|
|
38
41
|
spec.add_development_dependency 'devops_assist'
|
39
42
|
|
data/gen_ecc_const.rb
ADDED
data/lib/ccrypto/provider.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
require_relative 'ruby/engines/ecc_engine'
|
3
3
|
require_relative 'ruby/engines/digest_engine'
|
4
4
|
require_relative 'ruby/engines/x509_engine'
|
5
|
+
require_relative 'ruby/engines/x509_csr_engine'
|
6
|
+
|
7
|
+
require_relative 'ruby/engines/ed25519_engine'
|
8
|
+
require_relative 'ruby/engines/x25519_engine'
|
5
9
|
|
6
10
|
require_relative 'ruby/engines/scrypt_engine'
|
7
11
|
require_relative 'ruby/engines/hkdf_engine'
|
@@ -31,12 +35,50 @@ require_relative 'ruby/engines/rsa_engine'
|
|
31
35
|
|
32
36
|
module Ccrypto
|
33
37
|
module Ruby
|
38
|
+
|
39
|
+
class KSPemStore
|
40
|
+
include TR::CondUtils
|
41
|
+
include PEMStore
|
42
|
+
end
|
43
|
+
|
44
|
+
class KSP12Store
|
45
|
+
include TR::CondUtils
|
46
|
+
include DataConversion
|
47
|
+
include PKCS12Store
|
48
|
+
end
|
49
|
+
|
34
50
|
class Provider
|
35
51
|
|
36
52
|
def self.provider_name
|
37
53
|
"ruby"
|
38
54
|
end
|
39
55
|
|
56
|
+
def self.supported_keypair_config(purpose = :signing, &block)
|
57
|
+
case purpose
|
58
|
+
when :signing, :sign, :identity
|
59
|
+
[Ccrypto::ECCConfig, Ccrypto::RSAConfig, Ccrypto::ED25519Config]
|
60
|
+
when :cipher, :encryption, :enc
|
61
|
+
[Ccrypto::ECCConfig, Ccrypto::RSAConfig, Ccrypto::X25519Config]
|
62
|
+
when :sign_and_encrypt, :sign_and_enc, :sign_and_cipher
|
63
|
+
[Ccrypto::ECCConfig, Ccrypto::RSAConfig]
|
64
|
+
else
|
65
|
+
raise KeypairEngineException, "Unknown key purpose '#{purpose}'. Supported including :signing, :cipher or :both"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.supported_secret_key_config(&block)
|
70
|
+
CipherEngine.supported_cipher_list
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.keybundle_from_storage(*args, &block)
|
74
|
+
input = args.first
|
75
|
+
if KSPemStore.is_pem?(input)
|
76
|
+
KSPemStore.from_pem(input, &block)
|
77
|
+
else
|
78
|
+
KSP12Store.from_pkcs12(input, &block)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
40
82
|
def self.algo_instance(*args, &block)
|
41
83
|
config = args.first
|
42
84
|
|
@@ -61,6 +103,10 @@ module Ccrypto
|
|
61
103
|
Ccrypto::Ruby::SecretKeyEngine
|
62
104
|
elsif config == Ccrypto::SecretSharingConfig
|
63
105
|
SecretSharingEngine
|
106
|
+
elsif config == Ccrypto::X509::CSRProfile
|
107
|
+
X509CSREngine
|
108
|
+
elsif config == Ccrypto::ED25519Config
|
109
|
+
ED25519Engine
|
64
110
|
else
|
65
111
|
raise CcryptoProviderException, "Config class '#{config}' is not supported for provider '#{self.provider_name}'"
|
66
112
|
end
|
@@ -74,6 +120,8 @@ module Ccrypto
|
|
74
120
|
DigestEngine.instance(*args, &block)
|
75
121
|
when Ccrypto::X509::CertProfile
|
76
122
|
X509Engine.new(*args,&block)
|
123
|
+
when Ccrypto::X509::CSRProfile
|
124
|
+
X509CSREngine.new(*args,&block)
|
77
125
|
when Ccrypto::ScryptConfig
|
78
126
|
ScryptEngine.new(*args,&block)
|
79
127
|
when Ccrypto::HKDFConfig
|
@@ -88,55 +136,15 @@ module Ccrypto
|
|
88
136
|
SecretSharingEngine.new(*args,&block)
|
89
137
|
when Ccrypto::PKCS7Config
|
90
138
|
PKCS7Engine.new(*args, &block)
|
139
|
+
when Ccrypto::ED25519Config
|
140
|
+
ED25519Engine.new(*args, &block)
|
141
|
+
when Ccrypto::X25519Config
|
142
|
+
X25519Engine.new(*args, &block)
|
91
143
|
else
|
92
144
|
raise CcryptoProviderException, "Config instance '#{config}' is not supported for provider '#{self.provider_name}'"
|
93
145
|
end
|
94
146
|
end
|
95
147
|
|
96
|
-
#case config
|
97
|
-
#when Ccrypto::ECCConfig.class
|
98
|
-
# puts "ecc config class"
|
99
|
-
# ECCEngine
|
100
|
-
#when Ccrypto::ECCConfig
|
101
|
-
# puts "ecc config"
|
102
|
-
# ECCEngine.new(*args, &block)
|
103
|
-
#when Ccrypto::DigestConfig.class
|
104
|
-
# puts "digest config class"
|
105
|
-
# DigestEngine
|
106
|
-
#when Ccrypto::DigestConfig
|
107
|
-
# puts "digest config"
|
108
|
-
# DigestEngine.instance(*args,&block)
|
109
|
-
#else
|
110
|
-
# raise CcryptoProviderException, "Config '#{config}' is not supported for provider '#{self.provider_name}'"
|
111
|
-
#end
|
112
|
-
|
113
|
-
#case algo
|
114
|
-
#when :ecc
|
115
|
-
# ECCEngine
|
116
|
-
#when :x509
|
117
|
-
# if args.length > 1
|
118
|
-
# X509Engine.new(*args[1..-1])
|
119
|
-
# else
|
120
|
-
# X509Engine
|
121
|
-
# end
|
122
|
-
#when :scrypt
|
123
|
-
# ScryptEngine.new
|
124
|
-
#when :secure_random
|
125
|
-
# SecureRandomEngine
|
126
|
-
#else
|
127
|
-
# if DigestEngine.is_supported?(algo)
|
128
|
-
# DigestEngine.instance(algo)
|
129
|
-
# elsif CipherEngine.is_supported_cipher?(algo.to_s)
|
130
|
-
# if args.length > 1 or args[0].is_a?(String)
|
131
|
-
# CipherEngine.new(*args)
|
132
|
-
# else
|
133
|
-
# CipherEngine
|
134
|
-
# end
|
135
|
-
# else
|
136
|
-
# raise CcryptoProviderException, "Algo '#{algo}' is not supported for provider '#{self.provider_name}'"
|
137
|
-
# end
|
138
|
-
#end
|
139
|
-
|
140
148
|
end
|
141
149
|
|
142
150
|
def self.asn1_engine(*args, &block)
|
@@ -0,0 +1,82 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
module Ccrypto
|
5
|
+
module Ruby
|
6
|
+
module ECCConst
|
7
|
+
Const = {
|
8
|
+
"Oakley-EC2N-3"=>0x0300,
|
9
|
+
"Oakley-EC2N-4"=>0x0301,
|
10
|
+
"SM2"=>0x0302,
|
11
|
+
"brainpoolP160r1"=>0x0303,
|
12
|
+
"brainpoolP160t1"=>0x0304,
|
13
|
+
"brainpoolP192r1"=>0x0305,
|
14
|
+
"brainpoolP192t1"=>0x0306,
|
15
|
+
"brainpoolP224r1"=>0x0307,
|
16
|
+
"brainpoolP224t1"=>0x0308,
|
17
|
+
"brainpoolP256r1"=>0x0309,
|
18
|
+
"brainpoolP256t1"=>0x030a,
|
19
|
+
"brainpoolP320r1"=>0x030b,
|
20
|
+
"brainpoolP320t1"=>0x030c,
|
21
|
+
"brainpoolP384r1"=>0x030d,
|
22
|
+
"brainpoolP384t1"=>0x030e,
|
23
|
+
"brainpoolP512r1"=>0x030f,
|
24
|
+
"brainpoolP512t1"=>0x0310,
|
25
|
+
"c2pnb163v1"=>0x0311,
|
26
|
+
"c2pnb163v2"=>0x0312,
|
27
|
+
"c2pnb163v3"=>0x0313,
|
28
|
+
"c2pnb176v1"=>0x0314,
|
29
|
+
"c2pnb208w1"=>0x0315,
|
30
|
+
"c2pnb272w1"=>0x0316,
|
31
|
+
"c2pnb304w1"=>0x0317,
|
32
|
+
"c2pnb368w1"=>0x0318,
|
33
|
+
"c2tnb191v1"=>0x0319,
|
34
|
+
"c2tnb191v2"=>0x031a,
|
35
|
+
"c2tnb191v3"=>0x031b,
|
36
|
+
"c2tnb239v1"=>0x031c,
|
37
|
+
"c2tnb239v2"=>0x031d,
|
38
|
+
"c2tnb239v3"=>0x031e,
|
39
|
+
"c2tnb359v1"=>0x031f,
|
40
|
+
"c2tnb431r1"=>0x0320,
|
41
|
+
"prime192v1"=>0x0321,
|
42
|
+
"prime192v2"=>0x0322,
|
43
|
+
"prime192v3"=>0x0323,
|
44
|
+
"prime239v1"=>0x0324,
|
45
|
+
"prime239v2"=>0x0325,
|
46
|
+
"prime239v3"=>0x0326,
|
47
|
+
"prime256v1"=>0x0327,
|
48
|
+
"secp112r1"=>0x0328,
|
49
|
+
"secp112r2"=>0x0329,
|
50
|
+
"secp128r1"=>0x032a,
|
51
|
+
"secp128r2"=>0x032b,
|
52
|
+
"secp160k1"=>0x032c,
|
53
|
+
"secp160r1"=>0x032d,
|
54
|
+
"secp160r2"=>0x032e,
|
55
|
+
"secp192k1"=>0x032f,
|
56
|
+
"secp224k1"=>0x0330,
|
57
|
+
"secp224r1"=>0x0331,
|
58
|
+
"secp256k1"=>0x0332,
|
59
|
+
"secp384r1"=>0x0333,
|
60
|
+
"secp521r1"=>0x0334,
|
61
|
+
"sect113r1"=>0x0335,
|
62
|
+
"sect113r2"=>0x0336,
|
63
|
+
"sect131r1"=>0x0337,
|
64
|
+
"sect131r2"=>0x0338,
|
65
|
+
"sect163k1"=>0x0339,
|
66
|
+
"sect163r1"=>0x033a,
|
67
|
+
"sect163r2"=>0x033b,
|
68
|
+
"sect193r1"=>0x033c,
|
69
|
+
"sect193r2"=>0x033d,
|
70
|
+
"sect233k1"=>0x033e,
|
71
|
+
"sect233r1"=>0x033f,
|
72
|
+
"sect239k1"=>0x0340,
|
73
|
+
"sect283k1"=>0x0341,
|
74
|
+
"sect283r1"=>0x0342,
|
75
|
+
"sect409k1"=>0x0343,
|
76
|
+
"sect409r1"=>0x0344,
|
77
|
+
"sect571k1"=>0x0345,
|
78
|
+
"sect571r1"=>0x0346
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|