rassphrase 0.0.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.
- data/.gitignore +7 -0
- data/Gemfile +3 -0
- data/README.md +5 -0
- data/Rakefile +1 -0
- data/bin/rassphrase +38 -0
- data/features/diceware.feature +28 -0
- data/features/generate_passphrase.feature +19 -0
- data/features/roll_dice.feature +14 -0
- data/features/step_definitions/diceware_steps.rb +33 -0
- data/features/step_definitions/generate_passphrase_steps.rb +22 -0
- data/features/step_definitions/roll_dice.rb +24 -0
- data/features/support/env.rb +2 -0
- data/lib/beale.wordlist +7776 -0
- data/lib/diceware.wordlist +7776 -0
- data/lib/rassphrase/dice.rb +17 -0
- data/lib/rassphrase/rassphrase.rb +67 -0
- data/lib/rassphrase/version.rb +3 -0
- data/lib/rassphrase/wordlist_parser.rb +19 -0
- data/lib/rassphrase.rb +4 -0
- data/rassphrase.gemspec +23 -0
- data/spec/rassphrase/dice_spec.rb +27 -0
- data/spec/rassphrase/rassphrase_spec.rb +154 -0
- data/spec/rassphrase/wordlist_parser_spec.rb +18 -0
- data/spec/spec_helper.rb +6 -0
- metadata +104 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/rassphrase
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
path_to_lib = "../../lib/"
|
4
|
+
$LOAD_PATH << File.expand_path(path_to_lib, __FILE__)
|
5
|
+
|
6
|
+
require "optparse"
|
7
|
+
require 'rassphrase'
|
8
|
+
|
9
|
+
@options = {
|
10
|
+
:number => 1,
|
11
|
+
:size => 5,
|
12
|
+
:wordlist_path => File.expand_path("#{path_to_lib}diceware.wordlist", __FILE__)
|
13
|
+
}
|
14
|
+
optparse = OptionParser.new do |opts|
|
15
|
+
opts.banner = "Usage: rassphrase [options]"
|
16
|
+
|
17
|
+
opts.on("-s SIZE", Integer, "Specifies the number of words for the passphrase") do |s|
|
18
|
+
@options[:size] = s
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("-c", "Capitalizes the words in the passphrase") do
|
22
|
+
@options[:capitalize] = true
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("-b", "Uses the Beale wordlist dictionary.") do |w|
|
26
|
+
@options[:wordlist_path] = File.expand_path("#{path_to_lib}beale.wordlist", __FILE__)
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("-n NUMBER", Integer, "The number of passphrases to generate") do |n|
|
30
|
+
@options[:number] = n.to_i
|
31
|
+
end
|
32
|
+
end
|
33
|
+
optparse.parse!
|
34
|
+
|
35
|
+
rassphrase = Rassphrase::Rassphrase.new(@options)
|
36
|
+
@options[:number].times do
|
37
|
+
puts rassphrase.generate
|
38
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Feature: Usage Diceware method
|
2
|
+
|
3
|
+
To protect my information, as a security aware user
|
4
|
+
I want to generate a secure passphrase using the diceware method
|
5
|
+
|
6
|
+
Scenario: Get a diceware code
|
7
|
+
Given I have a rassphrase
|
8
|
+
When I ask for a diceware code
|
9
|
+
Then the dice should roll 5 times
|
10
|
+
|
11
|
+
Scenario: Diceware code digits
|
12
|
+
Given I have a rassphrase
|
13
|
+
When I ask for a diceware code
|
14
|
+
Then I should get a code with digits from 1 to 6
|
15
|
+
|
16
|
+
Scenario Outline: Usage of diceware word list
|
17
|
+
Given I have a rassphrase with the Diceware wordlist
|
18
|
+
When I ask for the word with the code "<code>"
|
19
|
+
Then I should get the word "<word>"
|
20
|
+
|
21
|
+
Examples:
|
22
|
+
| code | word |
|
23
|
+
| 21111 | cliche |
|
24
|
+
| 16655 | clause |
|
25
|
+
| 15144 | brassy |
|
26
|
+
| 11164 | above |
|
27
|
+
| 36223 | lead |
|
28
|
+
| 52422 | rumen |
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Generates a passphrase
|
2
|
+
|
3
|
+
To protect my information, as a security aware user
|
4
|
+
I want to generate a random passphrase
|
5
|
+
|
6
|
+
Scenario: Random passphrase
|
7
|
+
Given I have a rassphrase
|
8
|
+
When I generate a passphrase
|
9
|
+
Then I get a passphrase with concatenated words
|
10
|
+
|
11
|
+
Scenario: Different words
|
12
|
+
Given I have a rassphrase
|
13
|
+
When I generate a passphrase
|
14
|
+
Then all the words are different
|
15
|
+
|
16
|
+
Scenario: Specific word size
|
17
|
+
Given I have a rassphrase
|
18
|
+
When I generate a passphrase with 9 words
|
19
|
+
Then I get a passphrase with 9 words
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: Dice simulation
|
2
|
+
|
3
|
+
In real life a dice is used to generate a random number. To replicate
|
4
|
+
this randomness in software, I want to roll a virtual dice.
|
5
|
+
|
6
|
+
Scenario: Dice numbers range
|
7
|
+
Given that a dice has 6 sides
|
8
|
+
When I roll the dice 20 times
|
9
|
+
Then I should get 20 numbers between 1 and 6
|
10
|
+
|
11
|
+
Scenario: Numbers randomness
|
12
|
+
Given that a dice has 6 sides
|
13
|
+
When I roll the dice 20 times
|
14
|
+
Then I should get at least 4 different numbers
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Given /^I have a rassphrase$/ do
|
2
|
+
@dice = Rassphrase::Dice.new
|
3
|
+
@rassphrase = Rassphrase::Rassphrase.new(:dice => @dice)
|
4
|
+
end
|
5
|
+
|
6
|
+
Given /^I have a rassphrase with the Diceware wordlist$/ do
|
7
|
+
wordlist_path = File.expand_path("../../../lib/diceware.wordlist", __FILE__)
|
8
|
+
@rassphrase = Rassphrase::Rassphrase.new(:wordlist_path => wordlist_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
When /^I ask for a diceware code$/ do
|
12
|
+
@dice_rolls_before_code = @dice.roll_count
|
13
|
+
@code = @rassphrase.generate_code
|
14
|
+
end
|
15
|
+
|
16
|
+
Then /^the dice should roll (\d+) times$/ do |times|
|
17
|
+
@dice.roll_count.should == @dice_rolls_before_code + times.to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
Then /^I should get a code with digits from (\d+) to (\d+)$/ do |min, max|
|
21
|
+
@code.split('').each do |n|
|
22
|
+
n.to_i.should be >= min.to_i
|
23
|
+
n.to_i.should be <= max.to_i
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
When /^I ask for the word with the code "([^"]*)"$/ do |code|
|
28
|
+
@word = @rassphrase.word(code)
|
29
|
+
end
|
30
|
+
|
31
|
+
Then /^I should get the word "([^"]*)"$/ do |word|
|
32
|
+
word.should == @word
|
33
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
When /^I generate a passphrase$/ do
|
2
|
+
@passphrase = @rassphrase.generate
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^I generate a passphrase with (\d+) words$/ do |word_count|
|
6
|
+
@passphrase = @rassphrase.generate(word_count.to_i)
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^I get a passphrase with concatenated words$/ do
|
10
|
+
@passphrase.should == @rassphrase.words.join
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^all the words are different$/ do
|
14
|
+
words = @rassphrase.words
|
15
|
+
words.each do |w|
|
16
|
+
words.count(w).should be 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Then /^I get a passphrase with (\d+) words$/ do |word_count|
|
21
|
+
@rassphrase.should have(word_count.to_i).words
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Given /^that a dice has (\d+) sides$/ do |number_sides|
|
2
|
+
end
|
3
|
+
|
4
|
+
When /^I roll the dice (\d+) times$/ do |times|
|
5
|
+
@results = []
|
6
|
+
dice = Rassphrase::Dice.new
|
7
|
+
times.to_i.times do |n|
|
8
|
+
@results << dice.roll
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Then /^I should get (\d+) numbers between (\d+) and (\d+)$/ do |count, minimum, maximum|
|
13
|
+
count.to_i.should == @results.size
|
14
|
+
@results.each do |n|
|
15
|
+
n.should be >= minimum.to_i
|
16
|
+
n.should be <= maximum.to_i
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Then /^I should get at least (\d+) different numbers$/ do |count|
|
21
|
+
different = []
|
22
|
+
@results.each { |n| different << n unless different.index(n) }
|
23
|
+
different.size.should be >= count.to_i
|
24
|
+
end
|