nist_randomness_beacon 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/.gitignore +1 -0
- data/.rspec +3 -0
- data/CONTRIBUTING.md +8 -0
- data/README.md +6 -1
- data/lib/nist_randomness_beacon/client.rb +62 -0
- data/lib/nist_randomness_beacon/record.rb +13 -0
- data/lib/nist_randomness_beacon/service_error.rb +10 -0
- data/lib/nist_randomness_beacon/underscore.rb +12 -0
- data/lib/nist_randomness_beacon/version.rb +1 -1
- data/nist_randomness_beacon.gemspec +5 -2
- data/spec/cassettes/current.yml +38 -0
- data/spec/cassettes/last.yml +38 -0
- data/spec/cassettes/next.yml +38 -0
- data/spec/cassettes/previous.yml +38 -0
- data/spec/cassettes/start_chain.yml +38 -0
- data/spec/client_spec.rb +72 -0
- data/spec/spec_helper.rb +102 -0
- metadata +28 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d2238e7bc6236232cc206d71f6244d20dc391286
|
|
4
|
+
data.tar.gz: a5045f49d245828c1b8e00d3f811ffbc1a674219
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d856cefac19391e70726c59e5aa166bd12e2a04f79202d308964d087cf5bc2fb9e732762476bd347a8286373fb93d37e13ff544536a15cc2379c803cc8b5a365
|
|
7
|
+
data.tar.gz: 0850df25671845a6daf8674e950e07ac5e8470acc532d31eca5f2d335c542b54e861c4c47b7d7af5cab0e92a63a807cc89ffc564aeeab3df5302533dc4a8ba19
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
1. Fork it ( https://github.com/[my-github-username]/nist_randomness_beacon/fork )
|
|
4
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
|
5
|
+
1. Please follow the [style guide](http://learning-things.cirrusmio.com/style-guides/ruby.html) as you do.
|
|
6
|
+
1. Commit your changes (`git commit -am 'Add some feature'`)
|
|
7
|
+
1. Push to the branch (`git push origin my-new-feature`)
|
|
8
|
+
1. Create a new Pull Request
|
data/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# NIST Randomness Beacon
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A wrapper for the NIST Randomness Beacon 'cause sometimes you need to get
|
|
4
|
+
a 512-bit full-entropy bit-string programmaticlly. You never know.
|
|
4
5
|
|
|
5
6
|
Inspiration: http://hackaday.com/2014/12/19/nist-randomness-beacon/
|
|
7
|
+
|
|
8
|
+
NIST project description: http://www.nist.gov/itl/csd/ct/nist_beacon.cfm
|
|
9
|
+
|
|
6
10
|
API Description: https://beacon.nist.gov/home
|
|
7
11
|
|
|
8
12
|
## Installation
|
|
@@ -31,6 +35,7 @@ record.output_value
|
|
|
31
35
|
# => "4838827EDEE67CD5F58139933709764D1C51B4FC362DCAAB06B1572AC533F15F648F5EA98C5276187EBB87148852AEE291DB735F821CDC04E53DD7331AB1D3B6"
|
|
32
36
|
```
|
|
33
37
|
|
|
38
|
+
WARNING: DO NOT USE BEACON GENERATED VALUES AS SECRET CRYPTOGRAPHIC KEYS.
|
|
34
39
|
|
|
35
40
|
## Contributing
|
|
36
41
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
module NISTRandomnessBeacon
|
|
5
|
+
# Client to the Randomness Beacon API
|
|
6
|
+
class Client
|
|
7
|
+
include HTTParty
|
|
8
|
+
|
|
9
|
+
attr_accessor :timestamp
|
|
10
|
+
|
|
11
|
+
URI = 'https://beacon.nist.gov/rest/record'.freeze
|
|
12
|
+
|
|
13
|
+
def initialize timestamp=Time.now.to_i
|
|
14
|
+
@timestamp = timestamp
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Returns the Current Record (or next closest)
|
|
18
|
+
# https://beacon.nist.gov/rest/record/<timestamp>
|
|
19
|
+
#
|
|
20
|
+
def current
|
|
21
|
+
response = self.class.get("#{URI}/#{@timestamp}")
|
|
22
|
+
raise ServiceError, response.body unless response.code.eql? 200
|
|
23
|
+
NISTRandomnessBeacon::Record.new(response.parsed_response['record'])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Returns the Previous Record
|
|
27
|
+
# https://beacon.nist.gov/rest/record/previous/<timestamp>
|
|
28
|
+
#
|
|
29
|
+
def previous
|
|
30
|
+
response = self.class.get("#{URI}/previous/#{@timestamp}")
|
|
31
|
+
raise ServiceError, response.body unless response.code.eql? 200
|
|
32
|
+
NISTRandomnessBeacon::Record.new(response.parsed_response['record'])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Returns the Next Record
|
|
36
|
+
# https://beacon.nist.gov/rest/record/next/<timestamp>
|
|
37
|
+
#
|
|
38
|
+
def next
|
|
39
|
+
response = self.class.get("#{URI}/next/#{@timestamp}")
|
|
40
|
+
raise ServiceError, response.body unless response.code.eql? 200
|
|
41
|
+
NISTRandomnessBeacon::Record.new(response.parsed_response['record'])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Returns the Last Record
|
|
45
|
+
# https://beacon.nist.gov/rest/record/last
|
|
46
|
+
#
|
|
47
|
+
def last
|
|
48
|
+
response = self.class.get("#{URI}/last")
|
|
49
|
+
raise ServiceError, response.body unless response.code.eql? 200
|
|
50
|
+
NISTRandomnessBeacon::Record.new(response.parsed_response['record'])
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Returns the Start Chain Record
|
|
54
|
+
# https://beacon.nist.gov/rest/record/start-chain/<timestamp>
|
|
55
|
+
#
|
|
56
|
+
def start_chain
|
|
57
|
+
response = self.class.get("#{URI}/start-chain/#{@timestamp}")
|
|
58
|
+
raise ServiceError, response.body unless response.code.eql? 200
|
|
59
|
+
NISTRandomnessBeacon::Record.new(response.parsed_response['record'])
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module NISTRandomnessBeacon
|
|
2
|
+
class Record
|
|
3
|
+
attr_reader :version, :frequency, :timestamp, :seed_value,
|
|
4
|
+
:previous_output_value, :signature_value, :output_value,
|
|
5
|
+
:status_code
|
|
6
|
+
|
|
7
|
+
def initialize args={}
|
|
8
|
+
args.each do |k, v|
|
|
9
|
+
instance_variable_set("@#{k}".underscore, v) unless v.nil?
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Add underscore string transformation like rails does.
|
|
2
|
+
# http://stackoverflow.com/a/1509939/281699
|
|
3
|
+
#
|
|
4
|
+
class String
|
|
5
|
+
def underscore
|
|
6
|
+
self.gsub(/::/, '/').
|
|
7
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
|
8
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
|
9
|
+
tr("-", "_").
|
|
10
|
+
downcase
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -9,8 +9,11 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.authors = ["Chase Southard"]
|
|
10
10
|
spec.email = ["chase.southard@gmail.com"]
|
|
11
11
|
spec.summary = %q{A wrapper for NIST Randomness Beacon}
|
|
12
|
-
spec.description = %q{A wrapper for NIST Randomness Beacon
|
|
13
|
-
|
|
12
|
+
spec.description = %q{A wrapper for the NIST Randomness Beacon
|
|
13
|
+
'cause sometimes you need to get
|
|
14
|
+
a 512-bit full-entropy bit-string programmaticlly.
|
|
15
|
+
You never know.}
|
|
16
|
+
spec.homepage = "https://github.com/chaserx/nist_randomness_beacon"
|
|
14
17
|
spec.license = "MIT"
|
|
15
18
|
|
|
16
19
|
spec.files = `git ls-files -z`.split("\x0")
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://beacon.nist.gov/rest/record/1388552400
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Content-Length:
|
|
22
|
+
- '1208'
|
|
23
|
+
Content-Type:
|
|
24
|
+
- text/xml
|
|
25
|
+
Server:
|
|
26
|
+
- Microsoft-IIS/7.5
|
|
27
|
+
X-Powered-By:
|
|
28
|
+
- ARR/2.5
|
|
29
|
+
- ASP.NET
|
|
30
|
+
Date:
|
|
31
|
+
- Wed, 31 Dec 2014 03:23:22 GMT
|
|
32
|
+
body:
|
|
33
|
+
encoding: UTF-8
|
|
34
|
+
string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><record><version>Version
|
|
35
|
+
1.0</version><frequency>60</frequency><timeStamp>1388552400</timeStamp><seedValue>99149759C361F19D3B1BBA4B4F43BA933EBD739C06D8FC84BEF45D1D02BB2B717AD257138141437BF53183CA14D9C2273D6B51CE4269D89200DEA580A6C8FFBF</seedValue><previousOutputValue>19897B9BFCDC32E9D57709EF261C13A770F859CDFDF89665C48C18AD940F1D29C66580F2B488895843F9635BF84475644414747C36A5EFF55867077E01791B27</previousOutputValue><signatureValue>F184E6C6B0F7EEA5183E5A1C828035F956833799A94B1AE38CAD15FE278D7AE77F83B16C0B9C050A2EEDB7AD1EC131204329D70D44005EE937D64711CB98ADCF8A63080E47B8471D11AE01CF31A9A0F61023CFE1BE98F3D04DE62D3F7B08F0D72E122519180B09934B64C987F9C730E8A1340B6C9C240C4814CC51323E7757328D4F8D8D61AAE952F3AA8E7287C814A65BCDD26A0F42F1F9A0E6933964E0A25E689B4688ABCF46EEF10C9591256DD0ACECD45C76732F0273BC61B94573D92A99101D2C2A256B07A02364C879926AF6361D5AC1AAE53986388997BA3AAFE91156164223FE9A300828F94A12966FCB89E08F7A510C99C9F494EFAF9412C1B7BB32</signatureValue><outputValue>26071FBF7858244DD1FF2C4E0C4E1D1EA0FF58A9A35F50A2E62ACED01A9BF0DDE71E0D51DDC488ECD97DB035C5FB23C0D868E4BD45CFDA9F5BF6414DBE31D940</outputValue><statusCode>0</statusCode></record>
|
|
36
|
+
http_version:
|
|
37
|
+
recorded_at: Wed, 01 Jan 2014 05:00:00 GMT
|
|
38
|
+
recorded_with: VCR 2.9.3
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://beacon.nist.gov/rest/record/last
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Content-Length:
|
|
22
|
+
- '1208'
|
|
23
|
+
Content-Type:
|
|
24
|
+
- text/xml
|
|
25
|
+
Server:
|
|
26
|
+
- Microsoft-IIS/7.5
|
|
27
|
+
X-Powered-By:
|
|
28
|
+
- ARR/2.5
|
|
29
|
+
- ASP.NET
|
|
30
|
+
Date:
|
|
31
|
+
- Wed, 31 Dec 2014 03:23:22 GMT
|
|
32
|
+
body:
|
|
33
|
+
encoding: UTF-8
|
|
34
|
+
string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><record><version>Version
|
|
35
|
+
1.0</version><frequency>60</frequency><timeStamp>1419996180</timeStamp><seedValue>D841FF661825248DE94C2254AE0BCD9B565A2EA6B93FD3EE01205D59D868B71ABCBFDE5B785A0C7471FC0160CD6A0243FFBEFC884E34EE4DEBD8EC968BF844CA</seedValue><previousOutputValue>1C8DACC558A8C97B8099EFC069CDEDC9BA72F46C2F213A335970F761E440603E1826D1BD0521D738FDBD28B35338DC27FE51CC06FFF3F4C3019C12128390DE20</previousOutputValue><signatureValue>5F11064F6A41FAFA76A99A2F3CA8C2842D7BD49F37C86FFA7FC1EC002EA627CD5049C4EED11B7EB5C4E1CE88C200BC5D6C935A8D39E8AB2B0FC4116BE3C72711975C33765382411A9BEB57BF420D3E885D80C287CF9EF62E3DEE6DAD8998B45DF227B25712B5A374F5253494FB471262472EC668A6E224CEBEB9F7575FF499B231645895BFD2B9F78061DDB15919751F23ED2351954530B6B00247454B29AF92E97B28BC0431D1F17BE963B070B2B2C9BA6AB933F8B2B3495D00F3AAEA38B9075E3BDE8824E6F7164FD58240C02B76C7747A5C2E67DD034ABF18B8446491CC2DAB7B05BAC8F2748973D534D335C5CCB0315F440206958B99C0B1ED04097CC13B</signatureValue><outputValue>8E7ECAE502E68A90F9C3284460B43383685FDED5C021F761CED640968C479F4238FDBA17D07C94B4520F6440384913DAE0DD2DAEF03A9988CE295473773B939B</outputValue><statusCode>0</statusCode></record>
|
|
36
|
+
http_version:
|
|
37
|
+
recorded_at: Wed, 01 Jan 2014 05:00:00 GMT
|
|
38
|
+
recorded_with: VCR 2.9.3
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://beacon.nist.gov/rest/record/next/1388552400
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Content-Length:
|
|
22
|
+
- '1208'
|
|
23
|
+
Content-Type:
|
|
24
|
+
- text/xml
|
|
25
|
+
Server:
|
|
26
|
+
- Microsoft-IIS/7.5
|
|
27
|
+
X-Powered-By:
|
|
28
|
+
- ARR/2.5
|
|
29
|
+
- ASP.NET
|
|
30
|
+
Date:
|
|
31
|
+
- Wed, 31 Dec 2014 03:23:24 GMT
|
|
32
|
+
body:
|
|
33
|
+
encoding: UTF-8
|
|
34
|
+
string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><record><version>Version
|
|
35
|
+
1.0</version><frequency>60</frequency><timeStamp>1388552460</timeStamp><seedValue>78646721C71A528C5F6E597B955094722A75BCFBD3C8C4B330F2BCE7C42911BE4A2C99B0EA8DCE6133ACEE26E6E26171ACB6C7D541CB68820EF22FCE5983F6BF</seedValue><previousOutputValue>26071FBF7858244DD1FF2C4E0C4E1D1EA0FF58A9A35F50A2E62ACED01A9BF0DDE71E0D51DDC488ECD97DB035C5FB23C0D868E4BD45CFDA9F5BF6414DBE31D940</previousOutputValue><signatureValue>DF7E200927197AD10C1DB7987142D818F9B2F701DA1C8AC35393B3C6B3DE2B3FB8A473BB3F7010BC942F084D7D9BD16C05746831ACF0076238FB540A70B51E7BA5AFD1D959B465A7EBBE179E6C7BE01F2BCBFF6E74FD0997CEBCCB49E9EEDAE8662D9716BEDF5775AE1678193A434C8145B53A003118F18AFFB45A464115888AC9F67CFC0D47DB696C81C4438AE154405E9F9F86B2A4FAB621F272B8962D37358960AE8C1A850232BDFFA9D57873619CDD5F1A1D97EFA19A293F189CD236CB4700CE4B9C5823DDFA20F984108F0CB24F8A47743C27E54446183EFBABECA1740A3383D3BC806DD0EC06DA302710D04A89910E12840C54DC13D24E8BFA9762A51A</signatureValue><outputValue>542B7881E44FCB88E04831285C9C0EEF4DCB087A9C296AF3FEE42C1613E5229E742B24C3F3A8A3C6A06DE30EB115BE78541357D6EAD26240EC30F70000A2F0EE</outputValue><statusCode>0</statusCode></record>
|
|
36
|
+
http_version:
|
|
37
|
+
recorded_at: Wed, 01 Jan 2014 05:00:00 GMT
|
|
38
|
+
recorded_with: VCR 2.9.3
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://beacon.nist.gov/rest/record/previous/1388552400
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Content-Length:
|
|
22
|
+
- '1208'
|
|
23
|
+
Content-Type:
|
|
24
|
+
- text/xml
|
|
25
|
+
Server:
|
|
26
|
+
- Microsoft-IIS/7.5
|
|
27
|
+
X-Powered-By:
|
|
28
|
+
- ARR/2.5
|
|
29
|
+
- ASP.NET
|
|
30
|
+
Date:
|
|
31
|
+
- Wed, 31 Dec 2014 03:23:24 GMT
|
|
32
|
+
body:
|
|
33
|
+
encoding: UTF-8
|
|
34
|
+
string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><record><version>Version
|
|
35
|
+
1.0</version><frequency>60</frequency><timeStamp>1388552340</timeStamp><seedValue>D2447EAB04865C191D2969BE50909E8E4E2E83763745D2DD53159BA1D51CDEBF8B764561D619AA807FAFBDE330B047AD987BBBA19B2253A04AD5EC61D863E220</seedValue><previousOutputValue>B22A55266D370DA102733D5EA7D4B4325D5FB57AD49EF7D439543F5CCB46828B1541AD2E563E7C7E6564CDA17F9CDC7542D38453C6F7F5A6122AF39CEC7F5AD2</previousOutputValue><signatureValue>FB3722B4F8752ABFDAA1FCB071918619D7620EE7F4FD9F28CBDB5A7BABB5CBD054CAF7D62C2FA103BEAF381C94108A752E3917F6B5EFBEC964577F30F694D9045BFE8E4A25D424EEFBC28959C80512EBABE038C46EBEC77C22FAD7F94D9681CDB989DECA9EB50314B43CCD549A5C6BFB6C2C69567AC0946531936F60835DB4210ED4546A672C848467FB85375883CBF06C4286878D05062A32AE74C3C17C721890D78BEE14FFC6942441A3CD20BEC277FADF83537F8C56EAD7F075114D6FE29E98C11417945BDB1F80FC7107F6EED14786193782732B6EB3C048A46E5F53ABFC3EBB6539772B7B3133E86F13DEDB96B4E7033618B356E3620408739E0861E420</signatureValue><outputValue>19897B9BFCDC32E9D57709EF261C13A770F859CDFDF89665C48C18AD940F1D29C66580F2B488895843F9635BF84475644414747C36A5EFF55867077E01791B27</outputValue><statusCode>0</statusCode></record>
|
|
36
|
+
http_version:
|
|
37
|
+
recorded_at: Wed, 01 Jan 2014 05:00:00 GMT
|
|
38
|
+
recorded_with: VCR 2.9.3
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://beacon.nist.gov/rest/record/start-chain/1388552400
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Content-Length:
|
|
22
|
+
- '1208'
|
|
23
|
+
Content-Type:
|
|
24
|
+
- text/xml
|
|
25
|
+
Server:
|
|
26
|
+
- Microsoft-IIS/7.5
|
|
27
|
+
X-Powered-By:
|
|
28
|
+
- ARR/2.5
|
|
29
|
+
- ASP.NET
|
|
30
|
+
Date:
|
|
31
|
+
- Wed, 31 Dec 2014 03:24:53 GMT
|
|
32
|
+
body:
|
|
33
|
+
encoding: UTF-8
|
|
34
|
+
string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><record><version>Version
|
|
35
|
+
1.0</version><frequency>60</frequency><timeStamp>1378395540</timeStamp><seedValue>87F49DB997D2EED0B4FDD93BAA4CDFCA49095AF98E54B81F2C39B5C4002EC04B8C9E31FA537E64AC35FA2F038AA80730B054CFCF371AB5584CFB4EFD293280EE</seedValue><previousOutputValue>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</previousOutputValue><signatureValue>F93BBE5714944F31983AE8187D5D94F87FFEC2F98185F9EB4FE5DB61A9E5119FB0756E9AF4B7112DEBF541E9E53D05346B7358C12FA43A8E0D695BFFAF193B1C3FFC4AE7BCF6651812B6D60190DB8FF23C9364374737F45F1A89F22E1E492B0F373E4DB523274E9D31C86987C64A26F507008828A358B0E166A197D433597480895E9298C60D079673879C3C1AEDA6306C3201991D0A6778B21462BDEBB8D3776CD3D0FA0325AFE99B2D88A7C357E62170320EFB51F9749B5C7B9E7347178AB051BDD097B226664A2D64AF1557BB31540601849F0BE3AAF31D7A25E2B358EEF5A346937ADE34A110722DA8C037F973350B3846DCAB16C9AA125F2027C246FDB3</signatureValue><outputValue>17070B49DBF3BA12BEA427CB6651ECF7860FDC3792268031B77711D63A8610F4CDA551B7FB331103889A62E2CB23C0F85362BBA49B9E0086D1DA0830E4389AB1</outputValue><statusCode>1</statusCode></record>
|
|
36
|
+
http_version:
|
|
37
|
+
recorded_at: Wed, 01 Jan 2014 05:00:00 GMT
|
|
38
|
+
recorded_with: VCR 2.9.3
|
data/spec/client_spec.rb
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require_relative '../lib/nist_randomness_beacon.rb'
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe NISTRandomnessBeacon::Client do
|
|
5
|
+
before do
|
|
6
|
+
Timecop.freeze(Time.local(2014))
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
after do
|
|
10
|
+
Timecop.return
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe 'current' do
|
|
14
|
+
subject {
|
|
15
|
+
VCR.use_cassette('current') do
|
|
16
|
+
NISTRandomnessBeacon::Client.new.current
|
|
17
|
+
end
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
it 'returns a record object' do
|
|
21
|
+
expect(subject).to be_an_instance_of(NISTRandomnessBeacon::Record)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe 'previous' do
|
|
26
|
+
subject {
|
|
27
|
+
VCR.use_cassette('previous') do
|
|
28
|
+
NISTRandomnessBeacon::Client.new.previous
|
|
29
|
+
end
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
it 'returns a record object' do
|
|
33
|
+
expect(subject).to be_an_instance_of(NISTRandomnessBeacon::Record)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe 'next' do
|
|
38
|
+
subject {
|
|
39
|
+
VCR.use_cassette('next') do
|
|
40
|
+
NISTRandomnessBeacon::Client.new.next
|
|
41
|
+
end
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
it 'returns a record object' do
|
|
45
|
+
expect(subject).to be_an_instance_of(NISTRandomnessBeacon::Record)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe 'last' do
|
|
50
|
+
subject {
|
|
51
|
+
VCR.use_cassette('last') do
|
|
52
|
+
NISTRandomnessBeacon::Client.new.last
|
|
53
|
+
end
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
it 'returns a record object' do
|
|
57
|
+
expect(subject).to be_an_instance_of(NISTRandomnessBeacon::Record)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe 'start chain' do
|
|
62
|
+
subject {
|
|
63
|
+
VCR.use_cassette('start_chain') do
|
|
64
|
+
NISTRandomnessBeacon::Client.new.start_chain
|
|
65
|
+
end
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
it 'returns a record object' do
|
|
69
|
+
expect(subject).to be_an_instance_of(NISTRandomnessBeacon::Record)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
require 'rspec'
|
|
2
|
+
require 'webmock/rspec'
|
|
3
|
+
require 'vcr'
|
|
4
|
+
require 'simplecov'
|
|
5
|
+
require 'timecop'
|
|
6
|
+
|
|
7
|
+
SimpleCov.start
|
|
8
|
+
|
|
9
|
+
VCR.configure do |c|
|
|
10
|
+
c.cassette_library_dir = 'spec/cassettes'
|
|
11
|
+
c.hook_into :webmock
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
15
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
16
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
|
17
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
|
18
|
+
#
|
|
19
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
|
20
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
21
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
22
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
|
23
|
+
# a separate helper file that requires the additional dependencies and performs
|
|
24
|
+
# the additional setup, and require it from the spec files that actually need it.
|
|
25
|
+
#
|
|
26
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
|
27
|
+
# users commonly want.
|
|
28
|
+
#
|
|
29
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
30
|
+
RSpec.configure do |config|
|
|
31
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
32
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
33
|
+
# assertions if you prefer.
|
|
34
|
+
config.expect_with :rspec do |expectations|
|
|
35
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
36
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
37
|
+
# defined using `chain`, e.g.:
|
|
38
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
39
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
40
|
+
# ...rather than:
|
|
41
|
+
# # => "be bigger than 2"
|
|
42
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
46
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
47
|
+
config.mock_with :rspec do |mocks|
|
|
48
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
49
|
+
# a real object. This is generally recommended, and will default to
|
|
50
|
+
# `true` in RSpec 4.
|
|
51
|
+
mocks.verify_partial_doubles = true
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# The settings below are suggested to provide a good initial experience
|
|
55
|
+
# with RSpec, but feel free to customize to your heart's content.
|
|
56
|
+
#=begin
|
|
57
|
+
# These two settings work together to allow you to limit a spec run
|
|
58
|
+
# to individual examples or groups you care about by tagging them with
|
|
59
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
|
60
|
+
# get run.
|
|
61
|
+
# config.filter_run :focus
|
|
62
|
+
# config.run_all_when_everything_filtered = true
|
|
63
|
+
|
|
64
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
|
65
|
+
# For more details, see:
|
|
66
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
|
67
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
|
68
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
|
69
|
+
# config.disable_monkey_patching!
|
|
70
|
+
|
|
71
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
|
72
|
+
# be too noisy due to issues in dependencies.
|
|
73
|
+
# config.warnings = true
|
|
74
|
+
|
|
75
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
76
|
+
# file, and it's useful to allow more verbose output when running an
|
|
77
|
+
# individual spec file.
|
|
78
|
+
if config.files_to_run.one?
|
|
79
|
+
# Use the documentation formatter for detailed output,
|
|
80
|
+
# unless a formatter has already been configured
|
|
81
|
+
# (e.g. via a command-line flag).
|
|
82
|
+
config.default_formatter = 'doc'
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Print the 10 slowest examples and example groups at the
|
|
86
|
+
# end of the spec run, to help surface which specs are running
|
|
87
|
+
# particularly slow.
|
|
88
|
+
# config.profile_examples = 10
|
|
89
|
+
|
|
90
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
91
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
92
|
+
# the seed, which is printed after each run.
|
|
93
|
+
# --seed 1234
|
|
94
|
+
config.order = :random
|
|
95
|
+
|
|
96
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
97
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
98
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
99
|
+
# as the one that triggered the failure.
|
|
100
|
+
Kernel.srand config.seed
|
|
101
|
+
#=end
|
|
102
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nist_randomness_beacon
|
|
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
|
- Chase Southard
|
|
@@ -164,7 +164,11 @@ dependencies:
|
|
|
164
164
|
- - '='
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
166
|
version: 1.8.1
|
|
167
|
-
description:
|
|
167
|
+
description: |-
|
|
168
|
+
A wrapper for the NIST Randomness Beacon
|
|
169
|
+
'cause sometimes you need to get
|
|
170
|
+
a 512-bit full-entropy bit-string programmaticlly.
|
|
171
|
+
You never know.
|
|
168
172
|
email:
|
|
169
173
|
- chase.southard@gmail.com
|
|
170
174
|
executables: []
|
|
@@ -172,14 +176,27 @@ extensions: []
|
|
|
172
176
|
extra_rdoc_files: []
|
|
173
177
|
files:
|
|
174
178
|
- ".gitignore"
|
|
179
|
+
- ".rspec"
|
|
180
|
+
- CONTRIBUTING.md
|
|
175
181
|
- Gemfile
|
|
176
182
|
- LICENSE.txt
|
|
177
183
|
- README.md
|
|
178
184
|
- Rakefile
|
|
179
185
|
- lib/nist_randomness_beacon.rb
|
|
186
|
+
- lib/nist_randomness_beacon/client.rb
|
|
187
|
+
- lib/nist_randomness_beacon/record.rb
|
|
188
|
+
- lib/nist_randomness_beacon/service_error.rb
|
|
189
|
+
- lib/nist_randomness_beacon/underscore.rb
|
|
180
190
|
- lib/nist_randomness_beacon/version.rb
|
|
181
191
|
- nist_randomness_beacon.gemspec
|
|
182
|
-
|
|
192
|
+
- spec/cassettes/current.yml
|
|
193
|
+
- spec/cassettes/last.yml
|
|
194
|
+
- spec/cassettes/next.yml
|
|
195
|
+
- spec/cassettes/previous.yml
|
|
196
|
+
- spec/cassettes/start_chain.yml
|
|
197
|
+
- spec/client_spec.rb
|
|
198
|
+
- spec/spec_helper.rb
|
|
199
|
+
homepage: https://github.com/chaserx/nist_randomness_beacon
|
|
183
200
|
licenses:
|
|
184
201
|
- MIT
|
|
185
202
|
metadata: {}
|
|
@@ -203,5 +220,12 @@ rubygems_version: 2.2.2
|
|
|
203
220
|
signing_key:
|
|
204
221
|
specification_version: 4
|
|
205
222
|
summary: A wrapper for NIST Randomness Beacon
|
|
206
|
-
test_files:
|
|
223
|
+
test_files:
|
|
224
|
+
- spec/cassettes/current.yml
|
|
225
|
+
- spec/cassettes/last.yml
|
|
226
|
+
- spec/cassettes/next.yml
|
|
227
|
+
- spec/cassettes/previous.yml
|
|
228
|
+
- spec/cassettes/start_chain.yml
|
|
229
|
+
- spec/client_spec.rb
|
|
230
|
+
- spec/spec_helper.rb
|
|
207
231
|
has_rdoc:
|