c7decrypt 0.3.1 → 0.3.2
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
- checksums.yaml.gz.sig +0 -0
- data/README.md +4 -3
- data/c7decrypt.gemspec +4 -3
- data/lib/c7decrypt/version.rb +1 -1
- data.tar.gz.sig +1 -0
- metadata +27 -10
- metadata.gz.sig +0 -0
- data/spec/example_configs/bad_canned_example.txt +0 -13
- data/spec/example_configs/empty_example.txt +0 -0
- data/spec/example_configs/simple_canned_example.txt +0 -8
- data/spec/type5_spec.rb +0 -31
- data/spec/type7_spec.rb +0 -243
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0d2e026d0d8dbb9c18117d95a5d6e502d049115
|
|
4
|
+
data.tar.gz: 756739dad11c52d14cc47ecb37f45583854371c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 64626b838586f3c7906aa0675b2c8d983a3b036852ac08b60bd9bd1dd6cf967de8bcc79c927ad5dadb84b1ed6b1fcec1ddf6d37f78c1d0243edf4c81386157b5
|
|
7
|
+
data.tar.gz: ddb9052c8ad3584ce7261d0dbd26f6cdfd68560ccce755159b43aa2137f200fe51e7f7dd4d53d93b2521bd3b5d9800815a900e87d1d08cdd166abd1e0642542e
|
checksums.yaml.gz.sig
ADDED
|
Binary file
|
data/README.md
CHANGED
|
@@ -44,20 +44,20 @@ To use, just require
|
|
|
44
44
|
require 'c7decrypt'
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
Decrypt
|
|
47
|
+
Decrypt Cisco Type-7 Password
|
|
48
48
|
|
|
49
49
|
```ruby
|
|
50
50
|
>> C7Decrypt::Type7.decrypt("060506324F41")
|
|
51
51
|
=> "cisco"
|
|
52
52
|
```
|
|
53
|
-
Encrypt
|
|
53
|
+
Encrypt Cisco Type-7 Password
|
|
54
54
|
|
|
55
55
|
```ruby
|
|
56
56
|
>> C7Decrypt::Type7.encrypt("cisco")
|
|
57
57
|
=> "02050D480809"
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
Encrypt
|
|
60
|
+
Encrypt Cisco Type-5 Password
|
|
61
61
|
|
|
62
62
|
```ruby
|
|
63
63
|
>> C7Decrypt::Type5.encrypt("cisco")
|
|
@@ -88,6 +88,7 @@ If you are interested in contributing to this project, please see [CONTRIBUTING.
|
|
|
88
88
|
|
|
89
89
|
- [**Daren Matthew**](http://mccltd.net/blog/?p=1034) - For his blog post on the subject aggregating tools and sources that perform the decryption/decoding logic.
|
|
90
90
|
- [**m00nie**](http://www.m00nie.com/2011/09/cisco-type-7-password-decryption-and-encryption-with-perl/) - For the blog post on the subject, the source code of type7tool.pl and it's encryption techniques.
|
|
91
|
+
- [**Roger Nesbitt (mogest)**](https://github.com/mogest/unix-crypt) - For the unix-crypt Ruby library that demonstrates Unix MD5 hashing schemes.
|
|
91
92
|
|
|
92
93
|
**Application(s) that use C7Decrypt**
|
|
93
94
|
|
data/c7decrypt.gemspec
CHANGED
|
@@ -9,7 +9,6 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
s.email = 'claudijd@yahoo.com'
|
|
10
10
|
s.platform = Gem::Platform::RUBY
|
|
11
11
|
s.files = Dir.glob("lib/**/*") +
|
|
12
|
-
Dir.glob("spec/**/*") +
|
|
13
12
|
Dir.glob("bin/**/*") +
|
|
14
13
|
[".gitignore",
|
|
15
14
|
".rspec",
|
|
@@ -22,9 +21,11 @@ Gem::Specification.new do |s|
|
|
|
22
21
|
"c7decrypt.gemspec"]
|
|
23
22
|
s.require_paths = ["lib"]
|
|
24
23
|
s.executables = s.files.grep(%r{^bin/[^\/]+$}) { |f| File.basename(f) }
|
|
25
|
-
s.summary = 'Ruby based Cisco
|
|
26
|
-
s.description = 'A library for
|
|
24
|
+
s.summary = 'Ruby based Cisco Password Encryptor/Decryptor'
|
|
25
|
+
s.description = 'A library for encrypting/decrypting Cisco passwords'
|
|
27
26
|
s.homepage = 'http://rubygems.org/gems/c7decrypt'
|
|
27
|
+
s.cert_chain = ['certs/claudijd.pem']
|
|
28
|
+
s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
|
|
28
29
|
|
|
29
30
|
s.add_development_dependency('fuzzbert')
|
|
30
31
|
s.add_development_dependency('rspec', '~> 3.0.0')
|
data/lib/c7decrypt/version.rb
CHANGED
data.tar.gz.sig
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1����33���8���Vg�o;�\�2t��'�EC9�,!�ot�H������F��I,�q5��(�[�<<>d\P�\���0I,������s�bu�I���k������V4\��9���!arF���f��SF�BBD��\�s�fu`0&�v)�L�RL�3�A�
|
metadata
CHANGED
|
@@ -1,14 +1,36 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: c7decrypt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Claudius
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
|
-
cert_chain:
|
|
11
|
-
|
|
10
|
+
cert_chain:
|
|
11
|
+
- |
|
|
12
|
+
-----BEGIN CERTIFICATE-----
|
|
13
|
+
MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhjbGF1
|
|
14
|
+
ZGlqZDEVMBMGCgmSJomT8ixkARkWBXlhaG9vMRMwEQYKCZImiZPyLGQBGRYDY29t
|
|
15
|
+
MB4XDTE0MTIxOTE4MzkxOVoXDTE1MTIxOTE4MzkxOVowPzERMA8GA1UEAwwIY2xh
|
|
16
|
+
dWRpamQxFTATBgoJkiaJk/IsZAEZFgV5YWhvbzETMBEGCgmSJomT8ixkARkWA2Nv
|
|
17
|
+
bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPJYhex3xS5rsgKZnXNK
|
|
18
|
+
Bo3/++yub5QJ6e7cNrEpypqL/kh4aKX99779Uiw2vJAQ6E9LH+t53Cip+t6nDWkg
|
|
19
|
+
47FzbH4M7k1ZLKSSKxpWC2qk5mWMAVvyVGvWojM9QGPCIk86pfUGfO2nsOq3whXD
|
|
20
|
+
q0FhBF40ZZnYTuIUbiXTkdQnsOor1WMcagLXS8PFVtOrZ/tCghvSy2dIQFiyTBnb
|
|
21
|
+
3cz/hEf/Xq6Cx4IBGPWyqGnvD+3RGvmTK1V4ze4MCLBfyc4gWu6mJVAEN0lleJck
|
|
22
|
+
BuiLNW8hs72474B6VKtJaaDA8B/9kTQnoZ7Fa5YJo/GbaYUqItcy6jHSCT0rWJXA
|
|
23
|
+
LP8CAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFFZi
|
|
24
|
+
drho+yUOaenpeDftNILNdfGJMB0GA1UdEQQWMBSBEmNsYXVkaWpkQHlhaG9vLmNv
|
|
25
|
+
bTAdBgNVHRIEFjAUgRJjbGF1ZGlqZEB5YWhvby5jb20wDQYJKoZIhvcNAQEFBQAD
|
|
26
|
+
ggEBAGPQew4aW3rpPNzen7yJCng88CXjrBHcCZ6NgwV4sFKqGzKMwuP+RiDeSdx7
|
|
27
|
+
wdjM9wRtYcgKusVifjUhzmSWNd2O1s/osZY9UWXFKRwhMuk7jtepzx3G+6ptGoFF
|
|
28
|
+
9deFhOXTJ1y6/JEDQDt7ndqcqoEkE4iPVEUlMxuNx5XxnXtaOMMiQDm21l72K+ZQ
|
|
29
|
+
jQuNssCu6elWT8ctrme4nmVn2CK74aTVxCsNgtfDMd/1gwHGfnkdWY5Fq+U81uWt
|
|
30
|
+
2Gsrg58uhzB8auXnyQj1csrXR4q84eYMXQFdhGUr/grHSy2kBkyWkzS0iYqwsTzv
|
|
31
|
+
ho7/RMjGipku8I9m88xT0YfDq5E=
|
|
32
|
+
-----END CERTIFICATE-----
|
|
33
|
+
date: 2014-12-19 00:00:00.000000000 Z
|
|
12
34
|
dependencies:
|
|
13
35
|
- !ruby/object:Gem::Dependency
|
|
14
36
|
name: fuzzbert
|
|
@@ -66,7 +88,7 @@ dependencies:
|
|
|
66
88
|
- - ">="
|
|
67
89
|
- !ruby/object:Gem::Version
|
|
68
90
|
version: '0'
|
|
69
|
-
description: A library for
|
|
91
|
+
description: A library for encrypting/decrypting Cisco passwords
|
|
70
92
|
email: claudijd@yahoo.com
|
|
71
93
|
executables:
|
|
72
94
|
- c7decrypt
|
|
@@ -87,11 +109,6 @@ files:
|
|
|
87
109
|
- lib/c7decrypt/type5.rb
|
|
88
110
|
- lib/c7decrypt/type7.rb
|
|
89
111
|
- lib/c7decrypt/version.rb
|
|
90
|
-
- spec/example_configs/bad_canned_example.txt
|
|
91
|
-
- spec/example_configs/empty_example.txt
|
|
92
|
-
- spec/example_configs/simple_canned_example.txt
|
|
93
|
-
- spec/type5_spec.rb
|
|
94
|
-
- spec/type7_spec.rb
|
|
95
112
|
homepage: http://rubygems.org/gems/c7decrypt
|
|
96
113
|
licenses: []
|
|
97
114
|
metadata: {}
|
|
@@ -114,5 +131,5 @@ rubyforge_project:
|
|
|
114
131
|
rubygems_version: 2.2.2
|
|
115
132
|
signing_key:
|
|
116
133
|
specification_version: 4
|
|
117
|
-
summary: Ruby based Cisco
|
|
134
|
+
summary: Ruby based Cisco Password Encryptor/Decryptor
|
|
118
135
|
test_files: []
|
metadata.gz.sig
ADDED
|
Binary file
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# Removed "7"
|
|
2
|
-
username password 0822455D0A16
|
|
3
|
-
# Removed password
|
|
4
|
-
username password 7
|
|
5
|
-
# changed password to pword
|
|
6
|
-
enable pword 7 060506324F41
|
|
7
|
-
# changed hash to something weird, but still expect this to "hit"
|
|
8
|
-
enable password 7 abc123
|
|
9
|
-
R3(config)#do show run | sec vty
|
|
10
|
-
line vty 0 4
|
|
11
|
-
# again changed hash to something weird, expect this to "hit" but it doesn't ...
|
|
12
|
-
password 7 /etc/passwd
|
|
13
|
-
login
|
|
File without changes
|
data/spec/type5_spec.rb
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require 'c7decrypt'
|
|
2
|
-
require 'rspec/its'
|
|
3
|
-
|
|
4
|
-
describe C7Decrypt::Type5 do
|
|
5
|
-
|
|
6
|
-
context "when encrypting single Cisco Type-5 hash" do
|
|
7
|
-
before(:each) do
|
|
8
|
-
@password = "SECRETPASSWORD"
|
|
9
|
-
@salt = "TMnL"
|
|
10
|
-
@hash = C7Decrypt::Type5.encrypt(@password, @salt)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
subject{@hash}
|
|
14
|
-
its(:class) {should == ::String}
|
|
15
|
-
it {should == "$1$#{@salt}$iAFs16ZXx7x18vR1DeIp6/"}
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when encrypting single Cisco Type-5 hash" do
|
|
19
|
-
before(:each) do
|
|
20
|
-
@password = "Password123"
|
|
21
|
-
@salt = "VkQd"
|
|
22
|
-
@hash = C7Decrypt::Type5.encrypt(@password, @salt)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
subject{@hash}
|
|
26
|
-
its(:class) {should == ::String}
|
|
27
|
-
it {should == "$1$#{@salt}$Vma3sR7B1LL.v5lgy1NYc/"}
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
end
|
data/spec/type7_spec.rb
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
require 'c7decrypt'
|
|
2
|
-
require 'rspec/its'
|
|
3
|
-
|
|
4
|
-
describe C7Decrypt::Type7 do
|
|
5
|
-
|
|
6
|
-
before(:each) do
|
|
7
|
-
@known_values = [
|
|
8
|
-
{:pt => "cisco", :seed => 2, :ph => "02050D480809"},
|
|
9
|
-
{:pt => "cisco", :seed => 3, :ph => "030752180500"},
|
|
10
|
-
{:pt => "cisco", :seed => 4, :ph => "045802150C2E"},
|
|
11
|
-
{:pt => "cisco", :seed => 5, :ph => "05080F1C2243"},
|
|
12
|
-
{:pt => "cisco", :seed => 6, :ph => "060506324F41"},
|
|
13
|
-
{:pt => "cisco", :seed => 7, :ph => "070C285F4D06"},
|
|
14
|
-
{:pt => "cisco", :seed => 8, :ph => "0822455D0A16"},
|
|
15
|
-
{:pt => "cisco", :seed => 9, :ph => "094F471A1A0A"},
|
|
16
|
-
{:pt => "password", :seed => 9, :ph => "095C4F1A0A1218000F"},
|
|
17
|
-
{:pt => "password", :seed => 4, :ph => "044B0A151C36435C0D"}
|
|
18
|
-
]
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
context "when decrypting single Cisco Type-7 hash using longhand" do
|
|
22
|
-
before(:each) do
|
|
23
|
-
@encrypted_hash = "060506324F41"
|
|
24
|
-
@decrypted_hash = C7Decrypt::Type7.decrypt(@encrypted_hash)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
subject{@decrypted_hash}
|
|
28
|
-
its(:class) {should == ::String}
|
|
29
|
-
it {should == "cisco"}
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context "when decrypting an array of Cisco Type-7 hashes" do
|
|
33
|
-
before(:each) do
|
|
34
|
-
@encrypted_hashes = [
|
|
35
|
-
"060506324F41",
|
|
36
|
-
"0822455D0A16"
|
|
37
|
-
]
|
|
38
|
-
@decrypted_hashes = C7Decrypt::Type7.decrypt_array(@encrypted_hashes)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
subject{@decrypted_hashes}
|
|
42
|
-
its(:class) {should == ::Array}
|
|
43
|
-
its(:first) {should == "cisco"}
|
|
44
|
-
its(:last) {should == "cisco"}
|
|
45
|
-
its(:size) {should == 2}
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context "when decrypting Cisco Type-7 hashes from a config" do
|
|
49
|
-
before(:each) do
|
|
50
|
-
@config_file = "./spec/example_configs/simple_canned_example.txt"
|
|
51
|
-
@decrypted_hashes = C7Decrypt::Type7.decrypt_config(@config_file)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
subject{@decrypted_hashes}
|
|
55
|
-
its(:class) {should == ::Array}
|
|
56
|
-
its(:size) {should == 5}
|
|
57
|
-
it {should == [
|
|
58
|
-
"cisco",
|
|
59
|
-
"cisco",
|
|
60
|
-
"cisco",
|
|
61
|
-
"cisco",
|
|
62
|
-
"cisco"
|
|
63
|
-
]}
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
context "when decrypting known Cisco Type-7 known value matches" do
|
|
67
|
-
before(:each) do
|
|
68
|
-
@decrypted_hashes = C7Decrypt::Type7.decrypt_array(
|
|
69
|
-
@known_values.map {|known_value| known_value[:ph]}
|
|
70
|
-
)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
subject{@decrypted_hashes}
|
|
74
|
-
its(:class) {should == ::Array}
|
|
75
|
-
its(:size) {should == @known_values.size}
|
|
76
|
-
it {should == @known_values.map {|known_value| known_value[:pt]}}
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
context "when decrypting Cisco Type-7 with a seed greater than 9" do
|
|
80
|
-
before(:each) do
|
|
81
|
-
@decrypt_hash = C7Decrypt::Type7.decrypt("15000E010723382727")
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
subject{@decrypt_hash}
|
|
85
|
-
its(:class) {should == ::String}
|
|
86
|
-
it {should == "remcisco"}
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
context "when matchings known Cisco Type-7 known config line matches" do
|
|
90
|
-
before(:each) do
|
|
91
|
-
@encrypted_hashes = []
|
|
92
|
-
@known_config_lines = {
|
|
93
|
-
"username test password 7 0822455D0A16" => "0822455D0A16",
|
|
94
|
-
"enable password 7 060506324F41" => "060506324F41",
|
|
95
|
-
"password 7 02050D480809" => "02050D480809"
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
@known_config_lines.keys.each do |k,v|
|
|
99
|
-
@encrypted_hashes << C7Decrypt::Type7.type_7_matches(k)
|
|
100
|
-
end
|
|
101
|
-
@encrypted_hashes.flatten!
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
subject{@encrypted_hashes}
|
|
105
|
-
its(:class) {should == ::Array}
|
|
106
|
-
its(:size) {should == @known_config_lines.size}
|
|
107
|
-
it {should == @known_config_lines.values}
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
context "when encrypting single Cisco Type-7 hash" do
|
|
111
|
-
before(:each) do
|
|
112
|
-
@plaintext_hash = "cisco"
|
|
113
|
-
@encrypted_hash = C7Decrypt::Type7.encrypt(@plaintext_hash)
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
subject{@encrypted_hash}
|
|
117
|
-
its(:class) {should == ::String}
|
|
118
|
-
it {should == "02050D480809"}
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
context "when encrypting single Cisco Type-7 hash with an alternate seed value" do
|
|
122
|
-
before(:each) do
|
|
123
|
-
@plaintext_hash = "cisco"
|
|
124
|
-
@seed = 3
|
|
125
|
-
@encrypted_hash = C7Decrypt::Type7.encrypt(@plaintext_hash, @seed)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
subject{@encrypted_hash}
|
|
129
|
-
its(:class) {should == ::String}
|
|
130
|
-
it {should == "030752180500"}
|
|
131
|
-
|
|
132
|
-
it "should decrypt back to the original plaintext hash" do
|
|
133
|
-
C7Decrypt::Type7.decrypt(@encrypted_hash).should == @plaintext_hash
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
context "when encrypting multiple plaintext passwords with alternate seed values" do
|
|
138
|
-
before(:each) do
|
|
139
|
-
@plaintext_hash = "cisco"
|
|
140
|
-
@seeds = 0..15
|
|
141
|
-
@encrypted_hashes = @seeds.map {|seed| C7Decrypt::Type7.encrypt(@plaintext_hash, seed)}
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
subject{@encrypted_hashes}
|
|
145
|
-
its(:class) {should == ::Array}
|
|
146
|
-
|
|
147
|
-
it "should decrypt back to the original plaintext hashes" do
|
|
148
|
-
@encrypted_hashes.each do |encrypted_hash|
|
|
149
|
-
C7Decrypt::Type7.decrypt(encrypted_hash).should == @plaintext_hash
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
context "when encrypting known value matches individually" do
|
|
155
|
-
before(:each) do
|
|
156
|
-
@encrypted_hashes = []
|
|
157
|
-
@known_values.each do |known_value|
|
|
158
|
-
@encrypted_hashes << C7Decrypt::Type7.encrypt(known_value[:pt], known_value[:seed])
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
subject{@encrypted_hashes}
|
|
163
|
-
its(:class) {should == ::Array}
|
|
164
|
-
its(:size) {should == @known_values.size}
|
|
165
|
-
it {should == @known_values.map {|known_value| known_value[:ph]}}
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
context "when encrypting known value matches individually as an array" do
|
|
169
|
-
before(:each) do
|
|
170
|
-
@plaintext_passwords = @known_values.map {|known_value| known_value[:pt]}.uniq
|
|
171
|
-
@encrypted_passwords = C7Decrypt::Type7.encrypt_array(@plaintext_passwords)
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
subject{@encrypted_passwords}
|
|
175
|
-
its(:class) {should == ::Array}
|
|
176
|
-
its(:size) {should == @plaintext_passwords.size}
|
|
177
|
-
it {should == @plaintext_passwords.map {|plaintext_password| C7Decrypt::Type7.encrypt(plaintext_password)}}
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
context "when encrypting Cisco Type-7" do
|
|
181
|
-
before(:each) do
|
|
182
|
-
@plaintext_hash = "remcisco"
|
|
183
|
-
@encrypted_hash = C7Decrypt::Type7.encrypt(@plaintext_hash)
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
subject{@encrypted_hash}
|
|
187
|
-
its(:class) {should == ::String}
|
|
188
|
-
it {should == "02140156080F1C2243"}
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
context "when encrypting Cisco Type-7 with a seed of 15" do
|
|
192
|
-
before(:each) do
|
|
193
|
-
@plaintext_hash = "remcisco"
|
|
194
|
-
@seed = 15
|
|
195
|
-
@encrypted_hash = C7Decrypt::Type7.encrypt(@plaintext_hash, @seed)
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
subject{@encrypted_hash}
|
|
199
|
-
its(:class) {should == ::String}
|
|
200
|
-
it {should == "15000E010723382727"}
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
context "when trying to decrypt a hash with an invalid first character" do
|
|
204
|
-
it "should raise an InvalidFirstCharacter Exception" do
|
|
205
|
-
expect {
|
|
206
|
-
C7Decrypt::Type7.decrypt("AA000E010723382727")
|
|
207
|
-
}.to raise_error(C7Decrypt::Type7::InvalidFirstCharacter)
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
context "when trying to decrypt a hash with an invalid character" do
|
|
212
|
-
it "should raise an InvalidFirstCharacter Exception" do
|
|
213
|
-
expect {
|
|
214
|
-
C7Decrypt::Type7.decrypt("06000**E010723382727")
|
|
215
|
-
}.to raise_error(C7Decrypt::Type7::InvalidCharacter)
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
context "when trying to decrypt a hash with an odd number of characters" do
|
|
220
|
-
it "should raise an InvalidFirstCharacter Exception" do
|
|
221
|
-
expect {
|
|
222
|
-
C7Decrypt::Type7.decrypt("06000E01723382727")
|
|
223
|
-
}.to raise_error(C7Decrypt::Type7::OddNumberOfCharacters)
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
context "when trying to encrypt a hash with an invalid high encryption seed" do
|
|
228
|
-
it "should raise an InvalidFirstCharacter Exception" do
|
|
229
|
-
expect {
|
|
230
|
-
C7Decrypt::Type7.encrypt("bananas", 16)
|
|
231
|
-
}.to raise_error(C7Decrypt::Type7::InvalidEncryptionSeed)
|
|
232
|
-
end
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
context "when trying to encrypt a hash with an invalid low encryption seed" do
|
|
236
|
-
it "should raise an InvalidFirstCharacter Exception" do
|
|
237
|
-
expect {
|
|
238
|
-
C7Decrypt::Type7.encrypt("bananas", -1)
|
|
239
|
-
}.to raise_error(C7Decrypt::Type7::InvalidEncryptionSeed)
|
|
240
|
-
end
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
end
|