sirp 2.0.0.pre
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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -0
- data/.coco.yml +7 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +32 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +24 -0
- data/README.md +231 -0
- data/RELEASE.md +101 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/certs/gem-public_cert_grempe.pem +21 -0
- data/docs/rfc2945.txt +406 -0
- data/docs/rfc5054.txt +1347 -0
- data/examples/Gemfile +6 -0
- data/examples/README.md +34 -0
- data/examples/clients/javascript/.gitignore +1 -0
- data/examples/clients/javascript/app.js +59 -0
- data/examples/clients/javascript/index.html +23 -0
- data/examples/clients/javascript/package.json +15 -0
- data/examples/clients/ruby/client.rb +48 -0
- data/examples/server.rb +88 -0
- data/lib/sirp.rb +8 -0
- data/lib/sirp/client.rb +50 -0
- data/lib/sirp/sirp.rb +283 -0
- data/lib/sirp/verifier.rb +72 -0
- data/lib/sirp/version.rb +3 -0
- data/sirp.gemspec +48 -0
- metadata +226 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 09ad55f348720fdef0cd77d90bc9f166db80cc59
|
4
|
+
data.tar.gz: 0b664333742d32311c3e6a8b3269cdd482fa395f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d89cecbbf3761e596eba3953adcb22af3ca25507068d0186728a6febb3fc72e6549885b04fa202d25eef736eab066eed22cdc59b4f2dfc59193bbd4a29a513c4
|
7
|
+
data.tar.gz: 9e0b5e09f86ec07eb5db4ad2c61509749ae7e38c36645b39101fa21ce2dd0ddb6692a984e9a6896ba61e6cbe376172ba0a14beaa698b7c268954d7e82e13c1b4
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
AL��[�o��k��N���V���7"��a*R}*ʶ�5�a�*�̞S���l��,k���È���"6:��v�H��1ۂ<�QC�����ifo�j�7(�A��#�����J�� ~ӂb?��p�B��\r�e� d���yq���)�N��jyMj���c�7#�Ʃ��� 4�a'���n���{>"!g�h������D�[//�I�O�3��~ϋ�����.)#gRr
|
data/.coco.yml
ADDED
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
AllCops:
|
2
|
+
# Exclude:
|
3
|
+
# - 'spec/**/*'
|
4
|
+
UseCache: false
|
5
|
+
|
6
|
+
Style/VariableName:
|
7
|
+
Description: 'Use the configured style when naming variables.'
|
8
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars'
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Metrics/ModuleLength:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Metrics/ParameterLists:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Metrics/LineLength:
|
18
|
+
Description: 'Limit lines to 80 characters.'
|
19
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/Documentation:
|
23
|
+
Description: 'Document classes and non-namespace modules.'
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Style/FormatString:
|
27
|
+
Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
|
28
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/MethodName:
|
32
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2016, Glenn Rempe, Mikael Lammentausta
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
* Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
* Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
* Neither the name of the <organization> nor the
|
12
|
+
names of its contributors may be used to endorse or promote products
|
13
|
+
derived from this software without specific prior written permission.
|
14
|
+
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
16
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL Glenn Rempe or Mikael Lammentausta BE LIABLE FOR ANY
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,231 @@
|
|
1
|
+
# SiRP : Secure (interoperable) Remote Password Authentication
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/sirp)
|
4
|
+
[](https://gemnasium.com/github.com/grempe/sirp)
|
5
|
+
[](https://travis-ci.org/grempe/sirp)
|
6
|
+
[](https://coveralls.io/github/grempe/sirp?branch=master)
|
7
|
+
[](https://codeclimate.com/github/grempe/sirp)
|
8
|
+
[](http://inch-ci.org/github/grempe/sirp)
|
9
|
+
|
10
|
+
Ruby Docs : [http://www.rubydoc.info/gems/sirp](http://www.rubydoc.info/gems/sirp)
|
11
|
+
|
12
|
+
|
13
|
+
This is a pure Ruby implementation of the
|
14
|
+
[Secure Remote Password](http://srp.stanford.edu/) protocol (SRP-6a),
|
15
|
+
which is a 'zero-knowledge' mutual authentication system.
|
16
|
+
|
17
|
+
SiRP is an authentication method that allows the use of user names and passwords
|
18
|
+
over an insecure network connection without revealing the password. If either the
|
19
|
+
client lacks the user's password or the server lacks the proper verification
|
20
|
+
key, the authentication will fail. This approach is much more secure than the
|
21
|
+
vast majority of authentication systems in daily use since the password is
|
22
|
+
***never*** sent over the wire, and is therefore impossible to intercept, and
|
23
|
+
impossible to be revealed in a breach unless the verifier can be reversed. This
|
24
|
+
attack would be of similar difficulty as deriving a private encryption key from
|
25
|
+
its public key.
|
26
|
+
|
27
|
+
Unlike other common challenge-response authentication protocols, such as
|
28
|
+
Kerberos and SSL, SiRP does not rely on an external infrastructure of trusted
|
29
|
+
key servers or complex certificate management.
|
30
|
+
|
31
|
+
## Documentation
|
32
|
+
|
33
|
+
There is pretty extensive inline documentation. You can view the latest
|
34
|
+
auto-generated docs at [http://www.rubydoc.info/gems/sirp](http://www.rubydoc.info/gems/sirp)
|
35
|
+
|
36
|
+
You can check my documentation quality score at
|
37
|
+
[http://inch-ci.org/github/grempe/sirp](http://inch-ci.org/github/grempe/sirp?branch=master)
|
38
|
+
|
39
|
+
## Supported Platforms
|
40
|
+
|
41
|
+
SiRP is continuously integration tested on the following Ruby VMs:
|
42
|
+
|
43
|
+
* MRI 2.1, 2.2, 2.3
|
44
|
+
|
45
|
+
It may work on others as well.
|
46
|
+
|
47
|
+
## Installation
|
48
|
+
|
49
|
+
Add this line to your application's `Gemfile`:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
gem 'sirp', '~> 2.0'
|
53
|
+
```
|
54
|
+
|
55
|
+
And then execute:
|
56
|
+
```sh
|
57
|
+
$ bundle
|
58
|
+
```
|
59
|
+
|
60
|
+
Or install it yourself as:
|
61
|
+
|
62
|
+
```sh
|
63
|
+
$ gem install sirp
|
64
|
+
```
|
65
|
+
|
66
|
+
### Installation Security : Signed Ruby Gem
|
67
|
+
|
68
|
+
The SiRP gem is cryptographically signed. To be sure the gem you install hasn’t
|
69
|
+
been tampered with you can install it using the following method:
|
70
|
+
|
71
|
+
Add my public key (if you haven’t already) as a trusted certificate
|
72
|
+
|
73
|
+
```
|
74
|
+
# Caveat: Gem certificates are trusted globally, such that adding a
|
75
|
+
# cert.pem for one gem automatically trusts all gems signed by that cert.
|
76
|
+
gem cert --add <(curl -Ls https://raw.github.com/grempe/sirp/master/certs/gem-public_cert_grempe.pem)
|
77
|
+
```
|
78
|
+
|
79
|
+
To install, it is possible to specify either `HighSecurity` or `MediumSecurity`
|
80
|
+
mode. Since the `sirp` gem depends on one or more gems that are not cryptographically
|
81
|
+
signed you will likely need to use `MediumSecurity`. You should receive a warning
|
82
|
+
if any signed gem does not match its signature.
|
83
|
+
|
84
|
+
```
|
85
|
+
# All dependent gems must be signed and verified.
|
86
|
+
gem install sirp -P HighSecurity
|
87
|
+
```
|
88
|
+
|
89
|
+
```
|
90
|
+
# All signed dependent gems must be verified.
|
91
|
+
gem install sirp -P MediumSecurity
|
92
|
+
```
|
93
|
+
|
94
|
+
```
|
95
|
+
# Same as above, except Bundler only recognizes
|
96
|
+
# the long --trust-policy flag, not the short -P
|
97
|
+
bundle --trust-policy MediumSecurity
|
98
|
+
```
|
99
|
+
|
100
|
+
You can [learn more about security and signed Ruby Gems](http://guides.rubygems.org/security/).
|
101
|
+
|
102
|
+
### Installation Security : Signed Git Commits
|
103
|
+
|
104
|
+
Most, if not all, of the commits and tags to the repository for this code are
|
105
|
+
signed with my PGP/GPG code signing key. I have uploaded my code signing public
|
106
|
+
keys to GitHub and you can now verify those signatures with the GitHub UI.
|
107
|
+
See [this list of commits](https://github.com/grempe/sirp/commits/master)
|
108
|
+
and look for the `Verified` tag next to each commit. You can click on that tag
|
109
|
+
for additional information.
|
110
|
+
|
111
|
+
You can also clone the repository and verify the signatures locally using your
|
112
|
+
own GnuPG installation. You can find my certificates and read about how to conduct
|
113
|
+
this verification at [https://www.rempe.us/keys/](https://www.rempe.us/keys/).
|
114
|
+
|
115
|
+
## Compatibility
|
116
|
+
|
117
|
+
This implementation has been tested for compatibility with the following SRP-6a
|
118
|
+
compliant third-party libraries:
|
119
|
+
|
120
|
+
[JSRP / JavaScript](https://github.com/alax/jsrp)
|
121
|
+
|
122
|
+
## Usage Example
|
123
|
+
|
124
|
+
In this example the client and server steps are interleaved for demonstration
|
125
|
+
purposes. See the `examples` dir for simple working client and server
|
126
|
+
implementations.
|
127
|
+
|
128
|
+
``` ruby
|
129
|
+
require 'sirp'
|
130
|
+
|
131
|
+
username = 'user'
|
132
|
+
password = 'password'
|
133
|
+
prime_length = 2048
|
134
|
+
|
135
|
+
# The salt and verifier should be stored on the server database.
|
136
|
+
@auth = SIRP::Verifier.new(prime_length).generate_userauth(username, password)
|
137
|
+
# @auth is a hash containing :username, :verifier and :salt
|
138
|
+
|
139
|
+
# ~~~ Begin Authentication ~~~
|
140
|
+
|
141
|
+
client = SIRP::Client.new(prime_length)
|
142
|
+
A = client.start_authentication
|
143
|
+
|
144
|
+
# Client => Server: username, A
|
145
|
+
|
146
|
+
# Server retrieves user's verifier and salt from the database.
|
147
|
+
v = @auth[:verifier]
|
148
|
+
salt = @auth[:salt]
|
149
|
+
|
150
|
+
# Server generates challenge for the client.
|
151
|
+
verifier = SIRP::Verifier.new(prime_length)
|
152
|
+
session = verifier.get_challenge_and_proof(username, v, salt, A)
|
153
|
+
|
154
|
+
# Server has to persist proof to authenticate the client response later.
|
155
|
+
@proof = session[:proof]
|
156
|
+
|
157
|
+
# Server sends the challenge containing salt and B to client.
|
158
|
+
response = session[:challenge]
|
159
|
+
|
160
|
+
# Server => Client: salt, B
|
161
|
+
|
162
|
+
# Client calculates M as a response to the challenge.
|
163
|
+
client_M = client.process_challenge(username, password, salt, B)
|
164
|
+
|
165
|
+
# Client => Server: username, M
|
166
|
+
|
167
|
+
# Instantiate a new verifier on the server.
|
168
|
+
verifier = SIRP::Verifier.new(prime_length)
|
169
|
+
|
170
|
+
# Verify challenge response M.
|
171
|
+
# The Verifier state is passed in @proof.
|
172
|
+
server_H_AMK = verifier.verify_session(@proof, client_M)
|
173
|
+
# Is false if authentication failed.
|
174
|
+
|
175
|
+
# At this point, the client and server should have a common session key
|
176
|
+
# that is secure (i.e. not known to an outside party). To finish
|
177
|
+
# authentication, they must prove to each other that their keys are
|
178
|
+
# identical.
|
179
|
+
|
180
|
+
# Server => Client: H(AMK)
|
181
|
+
|
182
|
+
client.verify(server_H_AMK) == true
|
183
|
+
|
184
|
+
```
|
185
|
+
|
186
|
+
## History
|
187
|
+
|
188
|
+
This gem is a fork of the [lamikae/srp-rb](https://github.com/lamikae/srp-rb)
|
189
|
+
repository created by Mikael Lammentausta [@lamikae](https://github.com/lamikae).
|
190
|
+
Significant changes were needed for my use-case which demanded breaking changes
|
191
|
+
for the sake of greater interoperability. With these factors in mind, a hard
|
192
|
+
fork seemed the most appropriate path to take. Much credit is due to Mikael for
|
193
|
+
his original implementation.
|
194
|
+
|
195
|
+
## Development
|
196
|
+
|
197
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
198
|
+
run `bundle exec rake test` to run the tests. You can also run `bin/console` for an
|
199
|
+
interactive prompt that will allow you to experiment.
|
200
|
+
|
201
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
202
|
+
|
203
|
+
### Contributing
|
204
|
+
|
205
|
+
Bug reports and pull requests are welcome on GitHub
|
206
|
+
at [https://github.com/grempe/sirp](https://github.com/grempe/sirp). This
|
207
|
+
project is intended to be a safe, welcoming space for collaboration, and
|
208
|
+
contributors are expected to adhere to the
|
209
|
+
[Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
210
|
+
|
211
|
+
## Legal
|
212
|
+
|
213
|
+
### Copyright
|
214
|
+
|
215
|
+
(c) 2016 Glenn Rempe <[glenn@rempe.us](mailto:glenn@rempe.us)> ([https://www.rempe.us/](https://www.rempe.us/))
|
216
|
+
|
217
|
+
(c) 2012 Mikael Lammentausta
|
218
|
+
|
219
|
+
### License
|
220
|
+
|
221
|
+
The gem is available as open source under the terms of
|
222
|
+
the [BSD 3-clause "New" or "Revised" License](https://spdx.org/licenses/BSD-3-Clause.html).
|
223
|
+
|
224
|
+
### Warranty
|
225
|
+
|
226
|
+
Unless required by applicable law or agreed to in writing,
|
227
|
+
software distributed under the License is distributed on an
|
228
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
229
|
+
either express or implied. See the LICENSE.txt file for the
|
230
|
+
specific language governing permissions and limitations under
|
231
|
+
the License.
|
data/RELEASE.md
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
# Gem Release Process
|
2
|
+
|
3
|
+
Don't use the `bundle exec rake release` task. It is more convenient,
|
4
|
+
but it skips the process of signing the version release task.
|
5
|
+
|
6
|
+
## Run Tests
|
7
|
+
|
8
|
+
```sh
|
9
|
+
$ bundle exec rake test
|
10
|
+
$ bundle exec rake wwtd
|
11
|
+
```
|
12
|
+
|
13
|
+
## Git Push
|
14
|
+
|
15
|
+
```sh
|
16
|
+
$ git push
|
17
|
+
```
|
18
|
+
|
19
|
+
Check for regressions in automated tests covered by the README badges.
|
20
|
+
|
21
|
+
## Bump Version Number and edit CHANGELOG.md
|
22
|
+
|
23
|
+
```sh
|
24
|
+
$ vi lib/sirp/version.rb
|
25
|
+
$ git add lib/sirp/version.rb
|
26
|
+
$ vi CHANGELOG.md
|
27
|
+
$ git add CHANGELOG.md
|
28
|
+
```
|
29
|
+
|
30
|
+
## Local Build and Install w/ Signed Gem
|
31
|
+
|
32
|
+
The `build` step should ask for PEM passphrase to sign gem. If it does
|
33
|
+
not ask it means that the signing cert is not present.
|
34
|
+
|
35
|
+
Build:
|
36
|
+
|
37
|
+
```sh
|
38
|
+
$ rake build
|
39
|
+
Enter PEM pass phrase:
|
40
|
+
sirp x.x.x built to pkg/sirp-x.x.x.gem
|
41
|
+
```
|
42
|
+
|
43
|
+
Install locally w/ Cert:
|
44
|
+
|
45
|
+
```sh
|
46
|
+
$ gem uninstall sirp
|
47
|
+
$ rbenv rehash
|
48
|
+
$ gem install pkg/tss-x.x.x.gem -P MediumSecurity
|
49
|
+
Successfully installed sirp-x.x.x
|
50
|
+
1 gem installed
|
51
|
+
```
|
52
|
+
|
53
|
+
## Git Commit Version and CHANGELOG Changes, Tag and push to Github
|
54
|
+
|
55
|
+
```sh
|
56
|
+
$ git add lib/tss/version.rb
|
57
|
+
$ git add CHANGELOG.md
|
58
|
+
$ git commit -m 'Bump version v2.0.0'
|
59
|
+
$ git tag -s v2.0.0 -m "v2.0.0" SHA1_OF_COMMIT
|
60
|
+
```
|
61
|
+
|
62
|
+
Verify last commit and last tag are GPG signed:
|
63
|
+
|
64
|
+
```
|
65
|
+
$ git tag -v v2.0.0
|
66
|
+
...
|
67
|
+
gpg: Good signature from "Glenn Rempe (Code Signing Key) <glenn@rempe.us>" [ultimate]
|
68
|
+
...
|
69
|
+
```
|
70
|
+
|
71
|
+
```
|
72
|
+
$ git log --show-signature
|
73
|
+
...
|
74
|
+
gpg: Good signature from "Glenn Rempe (Code Signing Key) <glenn@rempe.us>" [ultimate]
|
75
|
+
...
|
76
|
+
```
|
77
|
+
|
78
|
+
Push code and tags to GitHub:
|
79
|
+
|
80
|
+
```
|
81
|
+
$ git push
|
82
|
+
$ git push --tags
|
83
|
+
```
|
84
|
+
|
85
|
+
## Push gem to Rubygems.org
|
86
|
+
|
87
|
+
```sh
|
88
|
+
$ gem push pkg/sirp-2.0.0.gem
|
89
|
+
```
|
90
|
+
|
91
|
+
Verify Gem Push at [https://rubygems.org/gems/sirp](https://rubygems.org/gems/sirp)
|
92
|
+
|
93
|
+
## Create a GitHub Release
|
94
|
+
|
95
|
+
Specify the tag we just pushed to attach release to. Copy notes from CHANGELOG.md
|
96
|
+
|
97
|
+
[https://github.com/grempe/sirp/releases](https://github.com/grempe/sirp/releases)
|
98
|
+
|
99
|
+
## Announce Release on Twitter
|
100
|
+
|
101
|
+
The normal blah, blah, blah.
|